KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > elements > schedule > ScheduleFactory


1 /*
2  * (c) Rob Gordon 2005.
3  */

4 package org.oddjob.designer.elements.schedule;
5
6 import org.apache.log4j.Logger;
7 import org.oddjob.arooa.ArooaException;
8 import org.oddjob.arooa.ObjectFactory;
9 import org.oddjob.designer.factory.DesignFactoryBean;
10 import org.oddjob.designer.factory.SimpleHierarchy;
11 import org.oddjob.designer.model.DesignComponent;
12 import org.oddjob.designer.model.DesignElementType;
13
14 /**
15  * A factory which can create DesignComponents and DesignElements.
16  */

17 public class ScheduleFactory {
18     public static Logger logger = Logger.getLogger(ScheduleFactory.class);
19     
20     private static DesignFactoryBean instance;
21     
22     private static DesignFactoryBean getInstance() {
23         if (instance == null) {
24             instance = new DesignFactoryBean(
25                     ScheduleFactory.class.getResourceAsStream("schedules.xml"));
26         }
27         return instance;
28     }
29     
30     /**
31      * Returns a hierarchy of ComponentAction objects which can be used in a
32      * hierarchical menu structure for creating and adding components.
33      *
34      * @param subject The object the new component will be added to.
35      * @param element The element name the child appears under.
36      *
37      * @return A SimpleHierarchy of ComponentAction objects.
38      */

39     public static SimpleHierarchy childActions(final Object JavaDoc subject, final String JavaDoc element) {
40         return getInstance().childActions(subject, element);
41     }
42     
43     /**
44      * Create a component for the given name.
45      *
46      * @param name The name of the tag identifiying the component.
47      * @return A created component. Never null.
48      *
49      * @throws ArooaException If the component can't be created.
50      */

51     public static DesignComponent createComponent(String JavaDoc name) throws ArooaException {
52         return getInstance().createComponent(name);
53     }
54     
55     /**
56      * Creates a ObjectFactory which creates components.
57      *
58      * @return An ObjectFactory.
59      */

60     public static ObjectFactory componentFactory() {
61         return getInstance().componentFactory();
62     }
63
64     /**
65      * Return supported child type for a given type.
66      *
67      * @param type The type.
68      * @return A list of supported types.
69      */

70     public static String JavaDoc[] supportedTypes(Class JavaDoc type) {
71         return getInstance().supportedTypes(type);
72     }
73     
74     public static String JavaDoc[] allTypes() {
75         return getInstance().allTypes();
76         
77     }
78     
79     
80     /**
81      * Creat a type for the given type name.
82      *
83      * @param name The type name.
84      * @return The created type.
85      *
86      * @throws ArooaException If the type can't be created.
87      */

88     public static DesignElementType createType(String JavaDoc name) throws ArooaException {
89         return getInstance().createType(name);
90     }
91     
92     public static ObjectFactory valueFactory() {
93         return getInstance().valueFactory();
94     }
95
96 }
97
Popular Tags