1 19 package org.netbeans.modules.j2ee.websphere6.dd.beans; 20 21 import org.w3c.dom.*; 22 import org.netbeans.modules.schema2beans.*; 23 import java.beans.*; 24 import java.util.*; 25 import java.io.*; 26 27 31 public class WSEjbBnd extends DDXmi{ 32 private static final String ROOT=TYPE_EJB_BND_ID; 33 34 private static final String ROOT_NAME="EjbJarBnd"; 35 36 37 public WSEjbBnd() { 38 this(null, Common.USE_DEFAULT_VALUES); 39 } 40 public WSEjbBnd(org.w3c.dom.Node doc, int options) { 41 this(Common.NO_DEFAULT_VALUES); 42 try { 43 initFromNode(doc, options); 44 } catch (Schema2BeansException e) { 45 throw new RuntimeException (e); 46 } 47 } 48 public WSEjbBnd(int options) { 49 super(options,ROOT); 50 } 52 53 public WSEjbBnd(File f,boolean validate) throws IOException{ 54 this(GraphManager.createXmlDocument(new FileInputStream(f), validate), Common.NO_DEFAULT_VALUES); 55 } 56 57 public WSEjbBnd(InputStream in, boolean validate) { 58 this(GraphManager.createXmlDocument(in, validate), Common.NO_DEFAULT_VALUES); 59 } 60 61 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException { 62 if (doc == null) { 63 doc = GraphManager.createRootElementNode(ROOT); if (doc == null) 65 throw new Schema2BeansException(Common.getMessage( 66 "CantCreateDOMRoot_msg", ROOT)); 67 } 68 Node n = GraphManager.getElementNode(ROOT, doc); if (n == null) { 70 throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName())); 71 } 72 this.graphManager.setXmlDocument(doc); 73 this.createBean(n, this.graphManager()); 74 this.initialize(options); 75 }; 76 77 public void initialize(int options) { 78 79 } 80 81 public void setDefaults() { 82 setXmiVersion(); 83 setNsXmi(); 84 setNsEjb(); 85 setNsEjbBnd(); 86 setNsCommon(); 87 setNsCommonBnd(); 88 setXmiId("EJBJarBinding"); 89 setEjbJar(""); 90 setEjbJarHref("ID_ejb_jar"); 91 101 } 102 103 protected void initOptions(int options) { 104 this.graphManager = new GraphManager(this); 105 this.createRoot(ROOT, ROOT_NAME, Common.TYPE_1 | Common.TYPE_BEAN, WSEjbBnd.class); 107 this.createAttribute(XMI_ID_ID, XMI_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 108 this.createAttribute(NS_EJB_ID, NS_EJB, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 109 this.createAttribute(NS_EJB_BND_ID, NS_EJB_BND, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 110 this.createAttribute(NS_XMI_ID, NS_XMI, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 111 this.createAttribute(XMI_VERSION_ID, XMI_VERSION, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 112 this.createAttribute(NS_COMMON_ID, NS_COMMON, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 113 this.createAttribute(NS_COMMON_BND_ID, NS_COMMON_BND, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 114 this.createAttribute(CURRENT_BACKEND_ID_ID, CURRENT_BACKEND_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 115 initPropertyTables(3); 116 117 this.createProperty(EJB_BINDINGS_ID, EJB_BINDINGS, 119 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 120 EjbBindingsType.class); 121 122 this.createAttribute(EJB_BINDINGS,XMI_ID_ID , EJB_BINDINGS_XMI_ID , AttrProp.CDATA | AttrProp.IMPLIED,null, null); 123 this.createAttribute(EJB_BINDINGS,JNDI_NAME_ID , EJB_BINDINGS_JNDI_NAME , AttrProp.CDATA | AttrProp.IMPLIED,null, null); 124 125 this.createProperty(EJB_JAR_ID, EJB_JAR, 127 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 128 java.lang.String .class); 129 this.createAttribute(EJB_JAR,HREF_ID,EJB_JAR_HREF,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 130 131 132 this.createProperty(DEFAULT_CMP_CONNECTION_FACTORY_ID, 133 CMP_CONNECTION_FACTORY, 134 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 135 java.lang.String .class); 136 this.createAttribute(CMP_CONNECTION_FACTORY,XMI_ID_ID,CMP_CONNECTION_FACTORY_XMI_ID,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 137 this.createAttribute(CMP_CONNECTION_FACTORY,JNDI_NAME_ID,CMP_CONNECTION_FACTORY_JNDI_NAME,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 138 this.createAttribute(CMP_CONNECTION_FACTORY,RES_AUTH_ID,CMP_CONNECTION_FACTORY_RES_AUTH,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 139 140 141 this.initialize(options); 142 } 143 144 public void setEjbBindings(int index,EjbBindingsType value) { 145 this.setValue(EJB_BINDINGS, index,value); 146 } 147 148 public void setEjbBindings(EjbBindingsType[]value) { 149 this.setValue(EJB_BINDINGS, value); 150 } 151 public EjbBindingsType[] getEjbBindings() { 153 return (EjbBindingsType[])this.getValues(EJB_BINDINGS); 154 } 155 public EjbBindingsType getEjbBindings(int index) { 156 return (EjbBindingsType)this.getValue(EJB_BINDINGS,index); 157 } 158 public int sizeEjbBindings() { 159 return this.size(EJB_BINDINGS); 160 } 161 public int addEjbBindings(EjbBindingsType value) { 162 int positionOfNewItem = this.addValue(EJB_BINDINGS, value); 163 return positionOfNewItem; 164 } 165 166 public int removeEjbBindings(EjbBindingsType value) { 171 return this.removeValue(EJB_BINDINGS, value); 172 } 173 174 175 public void setEjbBindingsId(String value,int index) { 176 setAttributeValue(EJB_BINDINGS,index,XMI_ID,value); 177 } 178 179 public String getEjbBindingsId(int index){ 180 return (String )getAttributeValue(EJB_BINDINGS,index,EJB_BINDINGS_XMI_ID); 181 } 182 183 184 185 public void setEjbBindingsJndiName(String value,int index) { 186 setAttributeValue(EJB_BINDINGS,index,EJB_BINDINGS_JNDI_NAME,value); 187 } 188 189 public String getEjbBindingsJndiName(int index){ 190 return (String )getAttributeValue(EJB_BINDINGS,index,EJB_BINDINGS_JNDI_NAME); 191 } 192 public void setCurrentBackendId(String value) { 193 setAttributeValue(CURRENT_BACKEND_ID,value); 194 } 195 public String getCurrentBackendId() { 196 return (String )this.getAttributeValue(CURRENT_BACKEND_ID); 197 } 198 199 200 public void setCmpConnectionFactory(String value) { 201 this.setValue(CMP_CONNECTION_FACTORY,value); 202 } 203 public String getCmpConnectionFactory() { 204 return (String )this.getValue(CMP_CONNECTION_FACTORY); 205 } 206 public void setCmpConnectionFactoryXmiId(String value) { 207 if(size(CMP_CONNECTION_FACTORY)==0) { 208 setCmpConnectionFactory(""); 209 } 210 this.setAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_XMI_ID,value); 211 } 212 public String getCmpConnectionFactoryXmiId() { 213 if(size(CMP_CONNECTION_FACTORY)==0) { 214 return null; 215 } 216 return (String ) this.getAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_XMI_ID); 217 } 218 public void setCmpConnectionFactoryJndiName(String value) { 219 if(size(CMP_CONNECTION_FACTORY)==0) { 220 setCmpConnectionFactory(""); 221 } 222 this.setAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_JNDI_NAME,value); 223 } 224 public String getCmpConnectionFactoryJndiName() { 225 if(size(CMP_CONNECTION_FACTORY)==0) { 226 return null; 227 } 228 return (String ) this.getAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_JNDI_NAME); 229 } 230 public void setCmpConnectionFactoryResAuth(String value) { 231 if(size(CMP_CONNECTION_FACTORY)==0) { 232 setCmpConnectionFactory(""); 233 } 234 this.setAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_RES_AUTH,value); 235 } 236 public String getCmpConnectionFactoryResAuth() { 237 if(size(CMP_CONNECTION_FACTORY)==0) { 238 return null; 239 } 240 return (String ) this.getAttributeValue(CMP_CONNECTION_FACTORY,CMP_CONNECTION_FACTORY_RES_AUTH); 241 } 242 243 244 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 245 246 if (getEjbBindings()!= null) { 247 for (int _index = 0; _index < sizeEjbBindings(); ++_index) { 249 EjbBindingsType element = getEjbBindings(_index); 250 if (element != null) { 251 element.validate(); 252 } 253 if(getEjbBindingsId(_index)==null) { 254 throw new org.netbeans.modules.schema2beans.ValidateException("getEjbBindingsId["+_index+"] == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, EJB_BINDINGS, this); } 256 if(getEjbBindingsJndiName(_index)==null) { 257 throw new org.netbeans.modules.schema2beans.ValidateException("getEjbBindingsName["+_index+"] == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, EJB_BINDINGS, this); } 259 } 260 } 261 if (getEjbJar()== null) { 262 throw new org.netbeans.modules.schema2beans.ValidateException("getEjbJar() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, EJB_JAR, this); } 264 if (getEjbJarHref()==null) { 265 throw new org.netbeans.modules.schema2beans.ValidateException("getEjbJarHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, EJB_JAR, this); } 267 if (getNsEjb()==null) { 268 throw new org.netbeans.modules.schema2beans.ValidateException("getNsEjb() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 270 if (getNsEjbBnd()==null) { 271 throw new org.netbeans.modules.schema2beans.ValidateException("getNsEjbBnd() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 273 if (getNsXmi()==null) { 274 throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 276 if(getXmiId()==null) { 277 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 279 if(getXmiVersion()==null) { 280 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 282 283 } 284 285 public void dump(StringBuffer str, String indent){ 286 String s; 287 Object o; 288 BaseBean n; 289 290 str.append(indent); 291 str.append(EJB_JAR); str.append(indent+"\t"); str.append("<"); o = this.getApplication(); 295 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(EJB_JAR, 0, str, indent); 298 299 str.append(indent); 300 str.append(EJB_BINDINGS+"["+this.sizeEjbBindings()+"]"); for(int i=0; i<this.sizeEjbBindings(); i++) { 302 str.append(indent+"\t"); 303 str.append("#"+i+":"); 304 n = (BaseBean) this.getEjbBindings(i); 305 if (n != null) 306 n.dump(str, indent + "\t"); else 308 str.append(indent+"\tnull"); this.dumpAttributes(EJB_BINDINGS, i, str, indent); 310 } 311 312 } 313 public String dumpBeanNode(){ 314 StringBuffer str = new StringBuffer (); 315 str.append(getClass().getName()); this.dump(str, "\n "); return str.toString(); 318 } 319 } 320 | Popular Tags |