package at.gv.egovernment.moa.id.protocols.stork2; import java.util.ArrayList; import java.util.List; import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin; /** * A factory for creating AttributeProvider objects. */ public class AttributeProviderFactory { /** * Gets the available plugins. * * @return the available plugins */ public static List getAvailablePlugins() { List result = new ArrayList(); result.add("StorkAttributeRequestProvider"); result.add("EHvdAttributeProvider"); return result; } /** * Creates an AttributeProvider object for the given shortname. Returns * {@code null} if there is no such provider available. * * @param shortname * the simpleName for the providers class * @return the attribute provider */ public static AttributeProvider create(String shortname, String url) { if (shortname.equals("StorkAttributeRequestProvider")) { return new StorkAttributeRequestProvider(url); } else if(shortname.equals("EHvdAttributeProvider")) { return new EHvdAttributeProviderPlugin(url); } else { return null; } } /** * Gets fresh instances of the configured plugins. * * @param configuredAPs the configured a ps * @return the configured plugins */ public static List getConfiguredPlugins( List configuredAPs) { List result = new ArrayList(); for(AttributeProviderPlugin current : configuredAPs) result.add(create(current.getName(), current.getUrl())); return result; } }