1 23 24 58 59 package com.sun.enterprise.tools.common.dd.connector; 60 61 import org.w3c.dom.*; 62 import org.netbeans.modules.schema2beans.*; 63 import java.beans.*; 64 import java.util.*; 65 import java.io.*; 66 67 69 public class SunConnector extends com.sun.enterprise.tools.common.dd.SunBaseBean 70 { 71 72 static Vector comparators = new Vector(); 73 74 static public final String RESOURCE_ADAPTER = "ResourceAdapter"; static public final String ROLE_MAP = "RoleMap"; 77 public SunConnector() throws org.netbeans.modules.schema2beans.Schema2BeansException { 78 this(null, Common.USE_DEFAULT_VALUES); 79 } 80 81 public SunConnector(org.w3c.dom.Node doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException { 82 this(Common.NO_DEFAULT_VALUES); 83 initFromNode(doc, options); 84 } 85 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException 86 { 87 if (doc == null) 88 { 89 doc = GraphManager.createRootElementNode("sun-connector"); if (doc == null) 91 throw new Schema2BeansException(Common.getMessage( 92 "CantCreateDOMRoot_msg", "sun-connector")); 93 } 94 Node n = GraphManager.getElementNode("sun-connector", doc); if (n == null) 96 throw new Schema2BeansException(Common.getMessage( 97 "DocRootNotInDOMGraph_msg", "sun-connector", doc.getFirstChild().getNodeName())); 98 99 this.graphManager.setXmlDocument(doc); 100 101 this.createBean(n, this.graphManager()); 103 this.initialize(options); 104 } 105 public SunConnector(int options) 106 { 107 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 108 initOptions(options); 109 } 110 protected void initOptions(int options) 111 { 112 this.graphManager = new GraphManager(this); 114 this.createRoot("sun-connector", "SunConnector", Common.TYPE_1 | Common.TYPE_BEAN, SunConnector.class); 116 117 this.createProperty("resource-adapter", RESOURCE_ADAPTER, 120 Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 121 ResourceAdapter.class); 122 this.createAttribute(RESOURCE_ADAPTER, "jndi-name", "JndiName", 123 AttrProp.CDATA | AttrProp.REQUIRED, 124 null, null); 125 this.createAttribute(RESOURCE_ADAPTER, "max-pool-size", "MaxPoolSize", 126 AttrProp.CDATA, 127 null, "32"); 128 this.createAttribute(RESOURCE_ADAPTER, "steady-pool-size", "SteadyPoolSize", 129 AttrProp.CDATA, 130 null, "4"); 131 this.createAttribute(RESOURCE_ADAPTER, "max-wait-time-in-millis", "MaxWaitTimeInMillis", 132 AttrProp.CDATA, 133 null, "10000"); 134 this.createAttribute(RESOURCE_ADAPTER, "idle-timeout-in-seconds", "IdleTimeoutInSeconds", 135 AttrProp.CDATA, 136 null, "1000"); 137 this.createProperty("role-map", ROLE_MAP, 139 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 140 RoleMap.class); 141 this.createAttribute(ROLE_MAP, "map-id", "MapId", 142 AttrProp.CDATA | AttrProp.REQUIRED, 143 null, null); 144 this.initialize(options); 145 } 146 147 void initialize(int options) 149 { 150 151 } 152 153 public void setResourceAdapter(ResourceAdapter value) { 155 this.setValue(RESOURCE_ADAPTER, value); 156 } 157 158 public ResourceAdapter getResourceAdapter() { 160 return (ResourceAdapter)this.getValue(RESOURCE_ADAPTER); 161 } 162 163 public void setRoleMap(RoleMap value) { 165 this.setValue(ROLE_MAP, value); 166 } 167 168 public RoleMap getRoleMap() { 170 return (RoleMap)this.getValue(ROLE_MAP); 171 } 172 173 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 175 comparators.add(c); 176 } 177 178 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 180 comparators.remove(c); 181 } 182 public static SunConnector createGraph(org.w3c.dom.Node doc) throws org.netbeans.modules.schema2beans.Schema2BeansException { 187 return new SunConnector(doc, Common.NO_DEFAULT_VALUES); 188 } 189 190 public static SunConnector createGraph(java.io.InputStream in) throws org.netbeans.modules.schema2beans.Schema2BeansException { 191 return createGraph(in, false); 192 } 193 194 public static SunConnector createGraph(java.io.InputStream in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException { 195 Document doc = GraphManager.createXmlDocument(in, validate); 196 return createGraph(doc); 197 } 198 199 public static SunConnector createGraph() { 203 try { 204 return new SunConnector(); 205 } 206 catch (Schema2BeansException e) { 207 throw new RuntimeException (e.getMessage()); 208 } 209 } 210 211 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 212 boolean restrictionFailure = false; 213 if (getResourceAdapter() == null) { 215 throw new org.netbeans.modules.schema2beans.ValidateException("getResourceAdapter() == null", "resourceAdapter", this); } 217 getResourceAdapter().validate(); 218 if (getRoleMap() != null) { 220 getRoleMap().validate(); 221 } 222 } 223 224 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { 226 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 227 write(baos); 228 String str = baos.toString();; 229 out.writeUTF(str); 231 } 232 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException , ClassNotFoundException { 234 try{ 235 init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 236 String strDocument = in.readUTF(); 237 ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes()); 239 Document doc = GraphManager.createXmlDocument(bais, false); 240 initOptions(Common.NO_DEFAULT_VALUES); 241 initFromNode(doc, Common.NO_DEFAULT_VALUES); 242 } 243 catch (Schema2BeansException e) { 244 e.printStackTrace(); 245 throw new RuntimeException (e.getMessage()); 246 } 247 } 248 249 public void dump(StringBuffer str, String indent){ 251 String s; 252 Object o; 253 org.netbeans.modules.schema2beans.BaseBean n; 254 str.append(indent); 255 str.append("ResourceAdapter"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getResourceAdapter(); 257 if (n != null) 258 n.dump(str, indent + "\t"); else 260 str.append(indent+"\tnull"); this.dumpAttributes(RESOURCE_ADAPTER, 0, str, indent); 262 263 str.append(indent); 264 str.append("RoleMap"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getRoleMap(); 266 if (n != null) 267 n.dump(str, indent + "\t"); else 269 str.append(indent+"\tnull"); this.dumpAttributes(ROLE_MAP, 0, str, indent); 271 272 } 273 public String dumpBeanNode(){ 274 StringBuffer str = new StringBuffer (); 275 str.append("SunConnector\n"); this.dump(str, "\n "); return str.toString(); 278 }} 279 280 282 283 354 | Popular Tags |