1 23 package com.sun.enterprise.tools.jsfext.layout.descriptor; 24 25 import com.sun.enterprise.tools.jsfext.component.factory.ComponentFactory; 26 27 28 37 public class ComponentType implements java.io.Serializable { 38 39 42 public ComponentType(String id, String factoryClass) { 43 if (id == null) { 44 throw new NullPointerException ("'id' cannot be null!"); 45 } 46 if (factoryClass == null) { 47 throw new NullPointerException ("'factoryClass' cannot be null!"); 48 } 49 _id = id; 50 _factoryClass = factoryClass; 51 _factory = createFactory(); 52 } 53 54 55 public String getId() { 56 return _id; 57 } 58 59 60 65 public ComponentFactory getFactory() { 66 if (_factory == null) { 67 _factory = createFactory(); 68 } 69 return _factory; 70 } 71 72 73 78 protected ComponentFactory createFactory() { 79 try { 80 Class cls = Class.forName(_factoryClass); 81 return (ComponentFactory) cls.newInstance(); 82 } catch (ClassNotFoundException ex) { 83 throw new RuntimeException (ex); 84 } catch (InstantiationException ex) { 85 throw new RuntimeException (ex); 86 } catch (IllegalAccessException ex) { 87 throw new RuntimeException (ex); 88 } 89 } 90 91 92 95 private String _id = null; 96 97 98 101 private String _factoryClass = null; 102 103 104 108 private transient ComponentFactory _factory = null; 109 } 110 | Popular Tags |