1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans; 26 27 import java.util.Vector ; 28 29 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair; 30 import org.netbeans.modules.j2ee.sun.share.serverresources.PersistenceManagerResource; 31 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider; 32 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.*; 33 34 38 public class PersistenceManagerBean extends PersistenceManagerResource implements java.io.Serializable { 39 40 41 public PersistenceManagerBean() { 42 } 43 44 public String getName() { 45 return super.getName(); 46 } 47 48 public String getJndiName(){ 49 return super.getJndiName(); 50 } 51 52 public static PersistenceManagerBean createBean(PersistenceManagerFactoryResource pmfresource) { 53 PersistenceManagerBean bean = new PersistenceManagerBean(); 54 bean.setName(pmfresource.getJndiName()); 57 bean.setDescription(pmfresource.getDescription()); 58 bean.setJndiName(pmfresource.getJndiName()); 59 bean.setFactoryClass(pmfresource.getFactoryClass()); 60 bean.setDatasourceJndiName(pmfresource.getJdbcResourceJndiName()); 61 bean.setIsEnabled(pmfresource.getEnabled()); 62 63 PropertyElement[] extraProperties = pmfresource.getPropertyElement(); 64 Vector vec = new Vector (); 65 for (int i = 0; i < extraProperties.length; i++) { 66 NameValuePair pair = new NameValuePair(); 67 pair.setParamName(extraProperties[i].getName()); 68 pair.setParamValue(extraProperties[i].getValue()); 69 vec.add(pair); 70 } 71 72 if (vec != null && vec.size() > 0) { 73 NameValuePair[] props = new NameValuePair[vec.size()]; 74 bean.setExtraParams((NameValuePair[])vec.toArray(props)); 75 } 76 77 return bean; 78 } 79 80 public Resources getGraph(){ 81 Resources res = getResourceGraph(); 82 PersistenceManagerFactoryResource pmfresource = res.newPersistenceManagerFactoryResource(); 83 pmfresource.setDescription(getDescription()); 84 pmfresource.setJndiName(getJndiName()); 85 pmfresource.setFactoryClass(getFactoryClass()); 86 pmfresource.setJdbcResourceJndiName(getDatasourceJndiName()); 87 pmfresource.setEnabled(getIsEnabled()); 88 89 NameValuePair[] params = getExtraParams(); 91 if (params != null && params.length > 0) { 92 for (int i = 0; i < params.length; i++) { 93 NameValuePair pair = params[i]; 94 PropertyElement prop = pmfresource.newPropertyElement(); 95 prop = populatePropertyElement(prop, pair); 96 pmfresource.addPropertyElement(prop); 97 } 98 } 99 100 res.addPersistenceManagerFactoryResource(pmfresource); 101 return res; 102 } 103 104 } 105 | Popular Tags |