View Javadoc

1   /*
2    * $Id: ComponentsFactory.java,v 1.18 2011/06/16 09:29:40 jbmeslin Exp $
3    */
4   package org.rcfaces.core.internal.component;
5   
6   import java.util.ArrayList;
7   import java.util.HashMap;
8   import java.util.List;
9   import java.util.Map;
10  
11  import javax.faces.FacesException;
12  import javax.faces.context.FacesContext;
13  
14  import org.rcfaces.core.internal.capability.IComponentEngine;
15  
16  /**
17   * @author Olivier Oeuillot (latest modification by $Author: jbmeslin $)
18   * @version $Revision: 1.18 $ $Date: 2011/06/16 09:29:40 $
19   */
20  public class ComponentsFactory implements IFactory {
21      private static final String REVISION = "$Revision: 1.18 $";
22  
23      private static final ComponentsFactory SINGLETON = new ComponentsFactory();
24  
25      private ComponentsFactory() {
26      }
27  
28      public String getName() {
29          return "Camelia basic components factory";
30      }
31  
32      public static final ComponentsFactory getCameliaFactory(
33              FacesContext facesContext) {
34          return SINGLETON;
35      }
36  
37      public List createList(int size) {
38          return new ArrayList(size);
39      }
40  
41      /*
42       * (non-Javadoc)
43       * 
44       * @see org.rcfaces.core.internal.util.IContainerStrategies#createMap(int)
45       */
46      public Map createMap(int size) {
47          return new HashMap(size);
48      }
49  
50      public Object allocateObject(Class claz) {
51          try {
52              return claz.newInstance();
53  
54          } catch (Throwable th) {
55              throw new FacesException("Can not allocate object from class '"
56                      + claz + "'.", th);
57          }
58      }
59  
60      public IComponentEngine createComponentEngine() {
61          return new BasicComponentEngine(this);
62      }
63  
64      public IPropertiesManager createPropertiesManager(IComponentEngine engine) {
65  
66          BasicPropertiesManager pa = (BasicPropertiesManager) allocateObject(BasicPropertiesManager.class);
67  
68          pa.setCameliaFactory(this);
69  
70          return pa;
71      }
72  
73      public IInitializationState createInitializationState() {
74          return new BasicInitializationState();
75      }
76  
77  }