1 23 package com.sun.enterprise.tools.jsfext.layout.descriptor; 24 25 import com.sun.enterprise.tools.jsfext.resource.ResourceFactory; 26 27 28 38 public class Resource implements java.io.Serializable { 39 40 43 private String _id = null; 44 45 49 private String _extraInfo = null; 50 51 52 55 private String _factoryClass = null; 56 57 58 61 private transient ResourceFactory _factory = null; 62 63 64 67 public Resource(String id, String extraInfo, String factoryClass) { 68 if (id == null) { 69 throw new NullPointerException ("'id' cannot be null!"); 70 } 71 if (factoryClass == null) { 72 throw new NullPointerException ("'factoryClass' cannot be null!"); 73 } 74 _id = id; 75 _extraInfo = extraInfo; 76 _factoryClass = factoryClass; 77 _factory = createFactory(); 78 } 79 80 81 85 public String getId() { 86 return _id; 87 } 88 89 93 public String getExtraInfo() { 94 return _extraInfo; 95 } 96 97 98 103 public ResourceFactory getFactory() { 104 if (_factory == null) { 105 _factory = createFactory(); 106 } 107 return _factory; 108 } 109 110 115 protected ResourceFactory createFactory() { 116 try { 117 Class cls = Class.forName(_factoryClass); 118 return (ResourceFactory) cls.newInstance(); 119 } catch (ClassNotFoundException ex) { 120 throw new RuntimeException (ex); 121 } catch (InstantiationException ex) { 122 throw new RuntimeException (ex); 123 } catch (IllegalAccessException ex) { 124 throw new RuntimeException (ex); 125 } 126 } 127 } 128 | Popular Tags |