| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package javax.faces; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.HashMap; |
| 20 | |
import java.util.List; |
| 21 | |
import java.util.Map; |
| 22 | |
|
| 23 | |
import javax.faces.internal.FactoryFinderUtil; |
| 24 | |
|
| 25 | |
import org.seasar.framework.util.AssertionUtil; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | 0 | public final class FactoryFinder { |
| 32 | |
|
| 33 | |
public static final String APPLICATION_FACTORY = "javax.faces.application.ApplicationFactory"; |
| 34 | |
|
| 35 | |
public static final String FACES_CONTEXT_FACTORY = "javax.faces.context.FacesContextFactory"; |
| 36 | |
|
| 37 | |
public static final String LIFECYCLE_FACTORY = "javax.faces.lifecycle.LifecycleFactory"; |
| 38 | |
|
| 39 | |
public static final String RENDER_KIT_FACTORY = "javax.faces.render.RenderKitFactory"; |
| 40 | |
|
| 41 | 1 | private static final Map factories = new HashMap(); |
| 42 | |
|
| 43 | 1 | private static final Map factoryClassNames = new HashMap(); |
| 44 | |
|
| 45 | |
public static Object getFactory(String factoryName) throws FacesException { |
| 46 | 6009 | AssertionUtil.assertNotNull("factoryName", factoryName); |
| 47 | 6008 | if (!factoryClassNames.containsKey(factoryName)) { |
| 48 | 1 | throw new IllegalStateException("no factory " + factoryName |
| 49 | |
+ " configured for this application"); |
| 50 | |
} |
| 51 | 6007 | Object factory = factories.get(factoryName); |
| 52 | 6007 | if (factory == null) { |
| 53 | 5368 | List classNames = (List) factoryClassNames.get(factoryName); |
| 54 | 5368 | factory = FactoryFinderUtil.createFactoryInstance(factoryName, |
| 55 | |
classNames); |
| 56 | 5368 | factories.put(factoryName, factory); |
| 57 | 5368 | return factory; |
| 58 | |
} else { |
| 59 | 639 | return factory; |
| 60 | |
} |
| 61 | |
} |
| 62 | |
|
| 63 | |
public static void setFactory(String factoryName, String implName) { |
| 64 | 5385 | AssertionUtil.assertNotNull("factoryName", factoryName); |
| 65 | 5384 | FactoryFinderUtil.checkValidFactoryNames(factoryName); |
| 66 | 5383 | List classNameList = (List) factoryClassNames.get(factoryName); |
| 67 | 5383 | if (classNameList == null) { |
| 68 | 5368 | classNameList = new ArrayList(); |
| 69 | 5368 | factoryClassNames.put(factoryName, classNameList); |
| 70 | |
} |
| 71 | 5383 | if (classNameList.contains(implName)) { |
| 72 | 14 | return; |
| 73 | |
} |
| 74 | 5369 | classNameList.add(implName); |
| 75 | 5369 | } |
| 76 | |
|
| 77 | |
public static void releaseFactories() throws FacesException { |
| 78 | 1369 | factories.clear(); |
| 79 | 1369 | factoryClassNames.clear(); |
| 80 | 1369 | } |
| 81 | |
|
| 82 | |
} |