1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean; 26 27 import javax.enterprise.deploy.model.DDBean ; 28 import javax.enterprise.deploy.model.DDBeanRoot ; 29 import javax.enterprise.deploy.model.DeployableObject ; 30 import javax.enterprise.deploy.model.J2eeApplicationObject ; 31 import javax.enterprise.deploy.spi.DConfigBean ; 32 import javax.enterprise.deploy.spi.DeploymentConfiguration ; 33 import javax.enterprise.deploy.spi.exceptions.ConfigurationException ; 34 35 36 40 abstract public class BaseModuleRef extends Base { 41 42 45 46 48 public BaseModuleRef() { 49 setDescriptorElement(bundle.getString("BDN_BaseModuleRef")); } 51 52 57 protected void init(DDBean dDBean, Base parent) throws ConfigurationException { 58 super.init(dDBean, parent); 59 60 initModuleUri(dDBean); 66 67 findRootDCB(moduleUri); 69 } 70 71 76 protected void initModuleUri(DDBean dDBean) { 77 setModuleUri(dDBean); 78 } 79 80 83 84 85 private DDBean moduleUri; 86 87 90 public String getDisplayName() { 91 StringBuffer buf = new StringBuffer (64); 92 93 if(moduleUri != null) { 96 buf.append(getModuleUri()); 97 } 98 buf.append(" ["); 99 buf.append(getDescriptorElement()); 100 buf.append("]"); 101 102 return buf.toString(); 103 } 104 105 109 public String getTitleFragment() { 110 return (J2EEVersion.J2EE_1_4.compareSpecification(getJ2EEModuleVersion()) >= 0) ? 111 bundle.getString("LBL_J2EETitleFragment") : bundle.getString("LBL_JavaEETitleFragment"); } 114 115 119 public String getModuleUri() { 120 String moduleUriText = null; 121 122 if(moduleUri != null) { 123 moduleUriText = moduleUri.getText(); 124 } 125 126 if(moduleUriText == null) { 127 moduleUriText = "(null)"; } 129 130 return moduleUriText; 131 } 132 133 protected void setModuleUri(DDBean uriBean) { 134 moduleUri = uriBean; 135 } 136 137 141 public String getRefIdentity() { 142 String result = "(null)"; if(getReference() != null) { 144 result = getReference().getIdentity(); 145 } 146 147 return result; 148 } 149 150 153 private BaseRoot referencedDCB = null; 154 155 protected BaseRoot getReference() { 156 return referencedDCB; 157 } 158 159 protected void setReference(BaseRoot ref) { 160 referencedDCB = ref; 161 } 162 163 protected void findRootDCB(DDBean ddBean) { 164 SunONEDeploymentConfiguration dc = getConfig(); 166 DDBeanRoot ddbRoot = getDDBeanRoot(ddBean, dc.getDeployableObject()); 167 168 if(ddbRoot != null) { 170 Base dcb = getDCBInstance(ddbRoot); 171 if(dcb != null && dcb instanceof BaseRoot) { 172 BaseRoot rootDCB = (BaseRoot) dcb; 173 174 if(rootDCB.getReference() == null) { 175 setReference(rootDCB); 178 rootDCB.setReference(this); 179 } else { 180 jsr88Logger.finer("ReferencePatcher: " + rootDCB + " already has reference " + rootDCB.getReference()); 181 } 182 } 183 184 if(getReference() == null) { 185 dc.getPatchList().put(ddbRoot, this); 190 } 191 } 192 } 193 194 private DDBeanRoot getDDBeanRoot(DDBean dDBean, DeployableObject dplObj) { 195 DDBeanRoot innerDDBeanRoot = null; 196 197 if(dplObj != null && dplObj instanceof J2eeApplicationObject ) { 198 J2eeApplicationObject dplObjRoot = (J2eeApplicationObject ) dplObj; 199 200 String uri = dDBean.getText(); 204 205 if(uri != null) { DeployableObject innerDObj = dplObjRoot.getDeployableObject(uri); 207 if(innerDObj != null) { 208 innerDDBeanRoot = innerDObj.getDDBeanRoot(); 209 } else { 210 jsr88Logger.finer("ReferencePatcher: no deployable object found for URI='" + uri + "'"); 211 } 212 } else { 213 jsr88Logger.finer("ReferencePatcher: no URI found for XPath='" + dDBean.getXpath() + "'"); 214 } 215 } 216 217 return innerDDBeanRoot; 218 } 219 220 } 221 | Popular Tags |