#136868 Do not pass disableInBC endpoint extension to runtime. Endpoints with disableInBC=true should be removed from BC SU's jbi.xml.
1.1 --- a/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/BCSUDescriptorBuilder.java Fri Apr 25 08:24:55 2008 -0700
1.2 +++ b/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/BCSUDescriptorBuilder.java Fri Jun 13 14:38:34 2008 +0200
1.3 @@ -54,11 +54,8 @@
1.4 import java.util.*;
1.5 import java.io.File;
1.6 import java.io.Serializable;
1.7 -import org.w3c.dom.Node;
1.8 -import org.w3c.dom.NodeList;
1.9
1.10 import static org.netbeans.modules.compapp.projects.jbi.JbiConstants.*;
1.11 -import static org.netbeans.modules.compapp.projects.jbi.CasaConstants.*;
1.12
1.13 /**
1.14 * Creates a Binding Component Service Unit's deployment descriptor (jbi.xml).
1.15 @@ -157,68 +154,8 @@
1.16 * Decorates consumes/provides endpoint using extension elements in CASA.
1.17 */
1.18 public void decorateEndpoints(Document casaDocument) {
1.19 - NodeList consumesNodeList = document.getElementsByTagName(JBI_CONSUMES_ELEM_NAME);
1.20 - for (int i = 0; i < consumesNodeList.getLength(); i++) {
1.21 - Element consumes = (Element) consumesNodeList.item(i);
1.22 - decorateEndpointElement(consumes, casaDocument);
1.23 - }
1.24 -
1.25 - NodeList providesNodeList = document.getElementsByTagName(JBI_PROVIDES_ELEM_NAME);
1.26 - for (int i = 0; i < providesNodeList.getLength(); i++) {
1.27 - Element provides = (Element) providesNodeList.item(i);
1.28 - decorateEndpointElement(provides, casaDocument);
1.29 - }
1.30 - }
1.31 -
1.32 - /**
1.33 - * Adds CASA extension elements to a Consumes/Provides endpoint into JBI.
1.34 - *
1.35 - * @param jbiEndpointElement a JBI consumes/provides element
1.36 - * @param casaDocument CASA document
1.37 - */
1.38 - private void decorateEndpointElement(Element jbiEndpointElement,
1.39 - Document casaDocument) {
1.40 - if (casaDocument == null) {
1.41 - return;
1.42 - }
1.43 -
1.44 - boolean isConsumes =
1.45 - jbiEndpointElement.getNodeName().equals(JBI_CONSUMES_ELEM_NAME);
1.46 -
1.47 - // 1. Find corresponding CASA consumes/provides element
1.48 -
1.49 - Endpoint endpoint = getEndpointInJBI(jbiEndpointElement);
1.50 -
1.51 - Element casaEndpointRefElement = CasaBuilder.getEndpointRefElement(
1.52 - casaDocument, endpoint, false, isConsumes);
1.53 -
1.54 - // 2. Copy child extension elements over from CASA to JBI
1.55 - if (casaEndpointRefElement != null) {
1.56 - NodeList casaEndpointChildren = casaEndpointRefElement.getChildNodes();
1.57 - for (int k = 0; k < casaEndpointChildren.getLength(); k++) {
1.58 - Node casaEndpointChild = casaEndpointChildren.item(k);
1.59 - if (casaEndpointChild instanceof Element) {
1.60 - Node clonedNode = CasaBuilder.deepCloneCasaNode(
1.61 - casaEndpointChild, document);
1.62 - jbiEndpointElement.appendChild(clonedNode);
1.63 - }
1.64 - }
1.65 - }
1.66 - }
1.67 -
1.68 - /**
1.69 - * Gets an Endpoint object from an endpoint element in JBI DOM.
1.70 - */
1.71 - static Endpoint getEndpointInJBI(Element jbiEndpointElement) {
1.72 - String endpointName =
1.73 - jbiEndpointElement.getAttribute(JBI_ENDPOINT_NAME_ATTR_NAME);
1.74 - QName serviceQName = XmlUtil.getAttributeNSName(
1.75 - jbiEndpointElement, JBI_SERVICE_NAME_ATTR_NAME);
1.76 - QName interfaceQName = XmlUtil.getAttributeNSName(
1.77 - jbiEndpointElement, JBI_INTERFACE_NAME_ATTR_NAME);
1.78 -
1.79 - return new Endpoint(endpointName, serviceQName, interfaceQName);
1.80 - }
1.81 + ServiceUnitDescriptorEnhancer.decorateEndpoints(document, casaDocument);
1.82 + }
1.83
1.84 private void setEndpointElementAttributes(Element endpointElement,
1.85 Endpoint endpoint,
2.1 --- a/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/BuildServiceAssembly.java Fri Apr 25 08:24:55 2008 -0700
2.2 +++ b/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/BuildServiceAssembly.java Fri Jun 13 14:38:34 2008 +0200
2.3 @@ -242,9 +242,13 @@
2.4
2.5 String asiFileLoc = confDirLoc + JbiProject.ASSEMBLY_INFO_FILE_NAME;
2.6 loadAssemblyInfo(asiFileLoc);
2.7 +
2.8 + CasaBuilder casaBuilder = new CasaBuilder(project, mRepo, this);
2.9 + final Document oldCasaDocument = casaBuilder.getOldCasaDocument();
2.10
2.11 - // generate the SE jar file list
2.12 - // loop thru SE suprojects and copying SE deployment jars
2.13 + // Generate the SE jar file list
2.14 + // Loop thru SE suprojects and copying/updating SE deployment jars
2.15 + log("Generating Service Engine Service Units...");
2.16 List<String> srcJarPaths = getJarList(jars);
2.17 List<String> javaEEJarPaths = getJarList(javaeeJars);
2.18 List<String> saEEJarPaths = new ArrayList<String>();
2.19 @@ -270,13 +274,11 @@
2.20 } else {
2.21 String destJarPath = buildDir + File.separator + jarName;
2.22 //log(" copying Sub-Assembly: " + destJarPath);
2.23 - copyJarFile(srcJarPath, destJarPath);
2.24 + copyJarFileWithEndpointDecoration(srcJarPath, destJarPath,
2.25 + oldCasaDocument);
2.26 }
2.27 }
2.28
2.29 - CasaBuilder casaBuilder = new CasaBuilder(project, mRepo, this);
2.30 - final Document oldCasaDocument = casaBuilder.getOldCasaDocument();
2.31 -
2.32 // Resolve connections
2.33 log("Resolving connections...");
2.34 ConnectionResolver connectionResolver =
2.35 @@ -354,8 +356,49 @@
2.36 // IZ#126214, soap bc wist callback handler...
2.37 createBCJar(bcJarMap.get(bcName), genericBCJar,
2.38 /*isCompAppWSDLNeeded,*/ bcsuDescriptorBuilder, bcName);
2.39 + }
2.40 +
2.41 + /*
2.42 + // Generate the SE jar file list
2.43 + // Loop thru SE suprojects and copying/updating SE deployment jars
2.44 + log("Generating Service Engine Service Units...");
2.45 + List<String> srcJarPaths = getJarList(jars);
2.46 + List<String> javaEEJarPaths = getJarList(javaeeJars);
2.47 + List<String> saEEJarPaths = new ArrayList<String>();
2.48 +
2.49 + for (String srcJarPath : srcJarPaths) {
2.50 + if ((javaEEJarPaths != null) && (javaEEJarPaths.contains(srcJarPath))){
2.51 + srcJarPath = getLocalJavaEEJarPath(buildDir, srcJarPath);
2.52 + saEEJarPaths.add(srcJarPath);
2.53 + createEndpointsFrom(srcJarPath);
2.54 + continue;
2.55 + }
2.56 +
2.57 + if ((srcJarPath.indexOf(':') < 0) && (!srcJarPath.startsWith("/"))) { // i.e., relative path
2.58 + srcJarPath = projDirLoc + srcJarPath;
2.59 + }
2.60 + File srcJarFile = new File(srcJarPath);
2.61 +
2.62 + String jarName = getShortName(srcJarPath); // e.x.: SynchronousSample.jar
2.63 + if (!srcJarFile.exists()) {
2.64 + log(" Error: Missing project Sub-Assembly: " + srcJarPath);
2.65 + } else if (! suJarNames.contains(jarName)) {
2.66 + log(" Error: Cannot locate service unit for " + jarName);
2.67 + } else {
2.68 + String destJarPath = buildDir + File.separator + jarName;
2.69 + //log(" copying Sub-Assembly: " + destJarPath);
2.70 + copyJarFileWithEndpointDecoration(srcJarPath, destJarPath,
2.71 + newCasaDocument);
2.72 + }
2.73 }
2.74 -
2.75 + */
2.76 + // )4/03/08, generated OSGi supported manifest.mf (minimum entries)
2.77 + String osgisupport = p.getProperty(JbiProjectProperties.OSGI_SUPPORT);
2.78 + String projName = p.getProperty(JbiProjectProperties.SERVICE_ASSEMBLY_ID);
2.79 + if ((osgisupport != null) && osgisupport.equalsIgnoreCase("true")) {
2.80 + generateOSGiManifest(buildMetaInfDir, projName);
2.81 + }
2.82 +
2.83 // 9/12/07, filter out unconnected JavaEE endpoints
2.84 log("Filtering Java EE Endpoints...");
2.85
2.86 @@ -376,6 +419,36 @@
2.87 }
2.88 }
2.89
2.90 + private void generateOSGiManifest(File buildDir, String projName) {
2.91 + if (buildDir == null) {
2.92 + return;
2.93 + }
2.94 +
2.95 + if (projName == null) {
2.96 + projName = "UnKnownApp"; // NOI18N
2.97 + }
2.98 + try {
2.99 + String manText = "Bundle-Name: " + projName + "\n" + // NOI18N
2.100 + "Bundle-SymbolicName: " + projName + "\n" + // NOI18N
2.101 + "Bundle-ManifestVersion: 2\n" + // NOI18N
2.102 + "Bundle-Version: 1.0.0"; // NOI18N
2.103 +
2.104 + File file = new File(buildDir, "MANIFEST.MF"); // NOI18N
2.105 + boolean success = file.createNewFile();
2.106 + if (success) {
2.107 + BufferedWriter out = new BufferedWriter(new FileWriter(file));
2.108 + out.write(manText);
2.109 + out.close();
2.110 + } else {
2.111 + // File already exists
2.112 + }
2.113 + } catch (IOException ex) {
2.114 + log("Exception: A processing error occurred; " + ex); // NOI18N
2.115 + }
2.116 +
2.117 +
2.118 + }
2.119 +
2.120 private List<String> getJarList(String commaSeparatedList){
2.121 List<String> ret = new ArrayList<String>();
2.122 if (commaSeparatedList != null) {
2.123 @@ -790,8 +863,9 @@
2.124
2.125 }
2.126
2.127 - private void copyJarFile(String inFile, String outFile)
2.128 - throws Exception {
2.129 + private void copyJarFileWithEndpointDecoration(String inFile, String outFile,
2.130 + Document casaDocument)
2.131 + throws Exception {
2.132 byte[] buffer = new byte[1024];
2.133 int bytesRead;
2.134
2.135 @@ -812,23 +886,32 @@
2.136 String fileName = entry.getName().toLowerCase();
2.137 InputStream is = jar.getInputStream(entry);
2.138 copyJbiXml = false;
2.139 - newJar.putNextEntry(entry);
2.140
2.141 if (fileName.equalsIgnoreCase(SU_JBIXML_PATH)) {
2.142 // found existing jbi.xml
2.143 hasJbiXml = true;
2.144 copyJbiXml = true;
2.145 + newJar.putNextEntry(new JarEntry(entry.getName()));
2.146 + } else {
2.147 + newJar.putNextEntry(entry);
2.148 }
2.149
2.150 while ((bytesRead = is.read(buffer)) != -1) {
2.151 - newJar.write(buffer, 0, bytesRead);
2.152 if (copyJbiXml) {
2.153 jbiXml += new String(buffer, 0, bytesRead, "UTF-8");
2.154 + } else {
2.155 + newJar.write(buffer, 0, bytesRead);
2.156 }
2.157 }
2.158
2.159 is.close();
2.160 is = null;
2.161 +
2.162 + if (copyJbiXml) {
2.163 + Document jbiDoc = XmlUtil.createDocumentFromXML(true, jbiXml);
2.164 + ServiceUnitDescriptorEnhancer.decorateEndpoints(jbiDoc, casaDocument);
2.165 + newJar.write(XmlUtil.writeToBytes(jbiDoc));
2.166 + }
2.167 }
2.168
2.169 // create a temp jbi.xml
3.1 --- a/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/CasaBuilder.java Fri Apr 25 08:24:55 2008 -0700
3.2 +++ b/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/CasaBuilder.java Fri Jun 13 14:38:34 2008 +0200
3.3 @@ -225,8 +225,8 @@
3.4 mergeLocations();
3.5
3.6 // Merge endpoint extension elements from old casa
3.7 - mergeBCEndpointExtensions(true);
3.8 - mergeBCEndpointExtensions(false);
3.9 + mergeEndpointExtensions(true);
3.10 + mergeEndpointExtensions(false);
3.11
3.12 // Merge connection extension elements from old casa
3.13 mergeConnectionExtensions();
3.14 @@ -390,33 +390,24 @@
3.15 }
3.16
3.17 /**
3.18 - * Merge binding component endpoint extension elements from the
3.19 - * old CASA document.
3.20 - *
3.21 - * @param isConsumes is consumes endpoint or provides endpoint
3.22 + * Merge endpoint extension elements from the old CASA document.
3.23 */
3.24 - private void mergeBCEndpointExtensions(boolean isConsumes) {
3.25 + private void mergeEndpointExtensions(boolean isConsumes) {
3.26 if (oldCasaDocument == null) {
3.27 return;
3.28 }
3.29
3.30 - NodeList oldBCSUs = oldCasaDocument.getElementsByTagName(
3.31 - CASA_BINDING_COMPONENT_SERVICE_UNIT_ELEM_NAME);
3.32 + NodeList oldEndpointRefs = oldCasaDocument.getElementsByTagName(
3.33 + isConsumes ? CASA_CONSUMES_ELEM_NAME : CASA_PROVIDES_ELEM_NAME);
3.34
3.35 - for (int i = 0; i < oldBCSUs.getLength(); i++) {
3.36 - Element oldBCSU = (Element) oldBCSUs.item(i);
3.37 - NodeList oldEndpointRefs = oldBCSU.getElementsByTagName(
3.38 - isConsumes ? CASA_CONSUMES_ELEM_NAME : CASA_PROVIDES_ELEM_NAME);
3.39 + for (int j = 0; j < oldEndpointRefs.getLength(); j++) {
3.40 + Element oldEndpointRef = (Element) oldEndpointRefs.item(j);
3.41 + Element newEndpointRef = findEndpointRef(oldCasaDocument,
3.42 + oldEndpointRef, newCasaDocument, isConsumes);
3.43
3.44 - for (int j = 0; j < oldEndpointRefs.getLength(); j++) {
3.45 - Element oldEndpointRef = (Element) oldEndpointRefs.item(j);
3.46 - Element newEndpointRef = findEndpointRef(oldCasaDocument,
3.47 - oldEndpointRef, newCasaDocument, isConsumes);
3.48 -
3.49 - // Copy child extension elements over from old CASA to new CASA
3.50 - if (newEndpointRef != null) {
3.51 - deepCloneChildren(oldEndpointRef, newEndpointRef);
3.52 - }
3.53 + // Copy child extension elements over from old CASA to new CASA
3.54 + if (newEndpointRef != null) {
3.55 + deepCloneChildren(oldEndpointRef, newEndpointRef);
3.56 }
3.57 }
3.58 }
3.59 @@ -431,7 +422,7 @@
3.60
3.61 if (newEndpointID != null) {
3.62 newEndpointRef = getEndpointRefElement(
3.63 - newCasaDocument, newEndpointID, false, isConsumes);
3.64 + newCasaDocument, newEndpointID, isConsumes);
3.65 }
3.66
3.67 return newEndpointRef;
3.68 @@ -458,20 +449,16 @@
3.69 *
3.70 * @param casaDocument CASA document
3.71 * @param endpoint an endpoint object
3.72 - * @param isSESU if <code>true</code>, the endpoint belongs to a
3.73 - * service engine service unit;
3.74 - * if <code>false</code>, the endpoint belongs to a
3.75 - * binging component service unit
3.76 * @param isConsumes if <code>true</code>, the endpoint is a consumes,
3.77 * if <code>false</code>, the endpoint is a provides.
3.78 *
3.79 * @return the consumes/provides element with the given ID.
3.80 */
3.81 static Element getEndpointRefElement(Document casaDocument,
3.82 - Endpoint endpoint, boolean isSESU, boolean isConsumes) {
3.83 + Endpoint endpoint, boolean isConsumes) {
3.84
3.85 String endpointID = getEndpointID(casaDocument, endpoint);
3.86 - return getEndpointRefElement(casaDocument, endpointID, isSESU, isConsumes);
3.87 + return getEndpointRefElement(casaDocument, endpointID, isConsumes);
3.88 }
3.89
3.90 /**
3.91 @@ -480,34 +467,22 @@
3.92 *
3.93 * @param casaDocument CASA document
3.94 * @param endpointID ID of an endpoint
3.95 - * @param isSESU if <code>true</code>, the endpoint belongs to a
3.96 - * service engine service unit;
3.97 - * if <code>false</code>, the endpoint belongs to a
3.98 - * binging component service unit
3.99 * @param isConsumes if <code>true</code>, the endpoint is a consumes,
3.100 * if <code>false</code>, the endpoint is a provides.
3.101 *
3.102 * @return the consumes/provides element with the given ID.
3.103 */
3.104 private static Element getEndpointRefElement(Document casaDocument,
3.105 - String endpointID, boolean isSESU, boolean isConsumes) {
3.106 + String endpointID, boolean isConsumes) {
3.107
3.108 - NodeList sus = casaDocument.getElementsByTagName(
3.109 - isSESU ? CASA_SERVICE_ENGINE_SERVICE_UNIT_ELEM_NAME : CASA_BINDING_COMPONENT_SERVICE_UNIT_ELEM_NAME);
3.110 + NodeList endpointRefs = casaDocument.getElementsByTagName(
3.111 + isConsumes ? CASA_CONSUMES_ELEM_NAME : CASA_PROVIDES_ELEM_NAME);
3.112
3.113 - for (int i = 0; i < sus.getLength(); i++) {
3.114 -
3.115 - Element su = (Element) sus.item(i);
3.116 -
3.117 - NodeList endpointRefs = su.getElementsByTagName(
3.118 - isConsumes ? CASA_CONSUMES_ELEM_NAME : CASA_PROVIDES_ELEM_NAME);
3.119 -
3.120 - for (int j = 0; j < endpointRefs.getLength(); j++) {
3.121 - Element endpointRef = (Element) endpointRefs.item(j);
3.122 - if (endpointRef.getAttribute(CASA_ENDPOINT_ATTR_NAME).
3.123 - equals(endpointID)) {
3.124 - return endpointRef;
3.125 - }
3.126 + for (int j = 0; j < endpointRefs.getLength(); j++) {
3.127 + Element endpointRef = (Element) endpointRefs.item(j);
3.128 + if (endpointRef.getAttribute(CASA_ENDPOINT_ATTR_NAME).
3.129 + equals(endpointID)) {
3.130 + return endpointRef;
3.131 }
3.132 }
3.133
4.1 --- a/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/DeployServiceAssembly.java Fri Apr 25 08:24:55 2008 -0700
4.2 +++ b/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/DeployServiceAssembly.java Fri Jun 13 14:38:34 2008 +0200
4.3 @@ -44,9 +44,13 @@
4.4 import com.sun.esb.management.api.deployment.DeploymentService;
4.5 import com.sun.esb.management.common.ManagementRemoteException;
4.6 import com.sun.jbi.ui.common.ServiceAssemblyInfo;
4.7 +import java.io.File;
4.8 +import java.io.FileInputStream;
4.9 +import java.io.FileOutputStream;
4.10 +import java.io.IOException;
4.11 import java.io.StringReader;
4.12
4.13 -import java.util.List;
4.14 +import java.nio.channels.FileChannel;
4.15 import javax.xml.parsers.DocumentBuilder;
4.16 import javax.xml.parsers.DocumentBuilderFactory;
4.17
4.18 @@ -55,6 +59,7 @@
4.19 import org.apache.tools.ant.Task;
4.20 import org.netbeans.modules.compapp.jbiserver.JbiManager;
4.21 import org.netbeans.modules.compapp.projects.jbi.AdministrationServiceHelper;
4.22 +import org.netbeans.modules.compapp.projects.jbi.ui.customizer.JbiProjectProperties;
4.23 import org.openide.util.Exceptions;
4.24 import org.w3c.dom.Document;
4.25 import org.xml.sax.InputSource;
4.26 @@ -217,14 +222,51 @@
4.27 public String getJ2eeServerInstance() {
4.28 return j2eeServerInstance;
4.29 }
4.30 -
4.31 +
4.32 /**
4.33 * DOCUMENT ME!
4.34 *
4.35 * @throws BuildException
4.36 * DOCUMENT ME!
4.37 */
4.38 + @Override
4.39 public void execute() throws BuildException {
4.40 +
4.41 + // 4/11/08, copy SA over to autodeploy directory if OSGi is enabled
4.42 + Project p = this.getProject();
4.43 + String osgisupport = p.getProperty(JbiProjectProperties.OSGI_SUPPORT);
4.44 + if ((osgisupport != null) && osgisupport.equalsIgnoreCase("true")) {
4.45 +
4.46 + String osgiDirPath =
4.47 + p.getProperty(JbiProjectProperties.OSGI_CONTAINER_DIR);
4.48 + if (osgiDirPath == null || osgiDirPath.trim().length() == 0) {
4.49 + throw new BuildException("OSGi container directory is not specified.");
4.50 + }
4.51 +
4.52 + File osgiDir = new File(osgiDirPath);
4.53 + if (!osgiDir.exists() || osgiDir.isFile()) {
4.54 + throw new BuildException("Invalid OSGi container directory: " + osgiDirPath);
4.55 + }
4.56 +
4.57 + File autoDeployDir = new File(osgiDirPath + "/jbi/autodeploy/");
4.58 + File srcFile = new File(serviceAssemblyLocation);
4.59 + File targetFile = new File(autoDeployDir, srcFile.getName());
4.60 +
4.61 + if (undeployServiceAssembly.equalsIgnoreCase("true")) { // NOI18N
4.62 + log(" remove " + targetFile.getAbsolutePath());
4.63 + targetFile.delete();
4.64 + } else {
4.65 + try {
4.66 + log(" copy " + srcFile.getAbsolutePath() + " to " +
4.67 + autoDeployDir.getAbsolutePath());
4.68 + copyFile(srcFile, targetFile);
4.69 + } catch (IOException ex) {
4.70 + throw new BuildException(ex.getMessage());
4.71 + }
4.72 + }
4.73 + return;
4.74 + }
4.75 +
4.76 if (serviceAssemblyID != null &&
4.77 serviceAssemblyID.equals("${org.netbeans.modules.compapp.projects.jbi.descriptor.uuid.assembly-unit}")) {
4.78 String msg = "Unknown Service Assembly ID: " + serviceAssemblyID +
4.79 @@ -301,7 +343,7 @@
4.80 try {
4.81 deployServiceAssembly(deploymentService);
4.82 } catch (BuildException e) {
4.83 -
4.84 +
4.85 Object[] processResult = JBIMBeanTaskResultHandler.getProcessResult(
4.86 GenericConstants.DEPLOY_SERVICE_ASSEMBLY_OPERATION_NAME,
4.87 serviceAssemblyID, e.getMessage(), false);
4.88 @@ -494,6 +536,24 @@
4.89 return null;
4.90 }
4.91 }
4.92 +
4.93 + private static void copyFile(File src, File target)
4.94 + throws IOException {
4.95 + FileChannel inChannel = new FileInputStream(src).getChannel();
4.96 + FileChannel outChannel = new FileOutputStream(target).getChannel();
4.97 + try {
4.98 + inChannel.transferTo(0, inChannel.size(), outChannel);
4.99 + } catch (IOException e) {
4.100 + throw e;
4.101 + } finally {
4.102 + if (inChannel != null) {
4.103 + inChannel.close();
4.104 + }
4.105 + if (outChannel != null) {
4.106 + outChannel.close();
4.107 + }
4.108 + }
4.109 + }
4.110
4.111 /**
4.112 * DOCUMENT ME!
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/compapp.projects.jbi/antsrc/org/netbeans/modules/compapp/projects/jbi/anttasks/ServiceUnitDescriptorEnhancer.java Fri Jun 13 14:38:34 2008 +0200
5.3 @@ -0,0 +1,157 @@
5.4 +/*
5.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5.6 + *
5.7 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5.8 + *
5.9 + * The contents of this file are subject to the terms of either the GNU
5.10 + * General Public License Version 2 only ("GPL") or the Common
5.11 + * Development and Distribution License("CDDL") (collectively, the
5.12 + * "License"). You may not use this file except in compliance with the
5.13 + * License. You can obtain a copy of the License at
5.14 + * http://www.netbeans.org/cddl-gplv2.html
5.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
5.16 + * specific language governing permissions and limitations under the
5.17 + * License. When distributing the software, include this License Header
5.18 + * Notice in each file and include the License file at
5.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
5.20 + * particular file as subject to the "Classpath" exception as provided
5.21 + * by Sun in the GPL Version 2 section of the License file that
5.22 + * accompanied this code. If applicable, add the following below the
5.23 + * License Header, with the fields enclosed by brackets [] replaced by
5.24 + * your own identifying information:
5.25 + * "Portions Copyrighted [year] [name of copyright owner]"
5.26 + *
5.27 + * If you wish your version of this file to be governed by only the CDDL
5.28 + * or only the GPL Version 2, indicate your decision by adding
5.29 + * "[Contributor] elects to include this software in this distribution
5.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
5.31 + * single choice of license, a recipient has the option to distribute
5.32 + * your version of this file under either the CDDL, the GPL Version 2 or
5.33 + * to extend the choice of license to its licensees as provided above.
5.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
5.35 + * Version 2 license, then the option applies only if the new code is
5.36 + * made subject to such option by the copyright holder.
5.37 + *
5.38 + * Contributor(s):
5.39 + *
5.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
5.41 + */
5.42 +
5.43 +package org.netbeans.modules.compapp.projects.jbi.anttasks;
5.44 +
5.45 +import javax.xml.namespace.QName;
5.46 +import org.netbeans.modules.compapp.projects.jbi.descriptor.XmlUtil;
5.47 +import org.netbeans.modules.compapp.projects.jbi.descriptor.endpoints.model.Endpoint;
5.48 +import org.w3c.dom.Document;
5.49 +import org.w3c.dom.Element;
5.50 +import org.w3c.dom.Node;
5.51 +import org.w3c.dom.NodeList;
5.52 +
5.53 +import static org.netbeans.modules.compapp.projects.jbi.JbiConstants.*;
5.54 +
5.55 +/**
5.56 + * Helper class to enhance endpoints in SE/BC SU descriptor with various
5.57 + * extensions.
5.58 + *
5.59 + * @author jqian
5.60 + */
5.61 +public class ServiceUnitDescriptorEnhancer {
5.62 +
5.63 + // See config extension module
5.64 + private static final String DISABLE_IN_BC = "disableInBC";
5.65 + private static final String CODEGEN = "codegen";
5.66 + private static final String ENDPOINT_CONFIG_NS = "http://www.sun.com/jbi/descriptor/config-endpoint";
5.67 +
5.68 + /**
5.69 + * Decorates consumes/provides endpoints using extension elements in CASA.
5.70 + *
5.71 + * @param jbiDocument plain SU JBI document
5.72 + * @param casaDocument CASA document
5.73 + */
5.74 + public static void decorateEndpoints(Document jbiDocument, Document casaDocument) {
5.75 + NodeList consumesNodeList =
5.76 + jbiDocument.getElementsByTagName(JBI_CONSUMES_ELEM_NAME);
5.77 + for (int i = 0; i < consumesNodeList.getLength(); i++) {
5.78 + Element consumes = (Element) consumesNodeList.item(i);
5.79 + decorateEndpointElement(jbiDocument, consumes, casaDocument);
5.80 + }
5.81 +
5.82 + NodeList providesNodeList =
5.83 + jbiDocument.getElementsByTagName(JBI_PROVIDES_ELEM_NAME);
5.84 + for (int i = 0; i < providesNodeList.getLength(); i++) {
5.85 + Element provides = (Element) providesNodeList.item(i);
5.86 + decorateEndpointElement(jbiDocument, provides, casaDocument);
5.87 + }
5.88 + }
5.89 +
5.90 + /**
5.91 + * Adds CASA extension elements to a consumes/provides endpoint into the
5.92 + * JBI document.
5.93 + *
5.94 + * @param jbiDocument plain SU JBI document
5.95 + * @param jbiEndpointElement a JBI consumes/provides element
5.96 + * @param casaDocument CASA document
5.97 + */
5.98 + private static void decorateEndpointElement(Document jbiDocument,
5.99 + Element jbiEndpointElement,
5.100 + Document casaDocument) {
5.101 +
5.102 + if (casaDocument == null) {
5.103 + return;
5.104 + }
5.105 +
5.106 + boolean isConsumes =
5.107 + jbiEndpointElement.getNodeName().equals(JBI_CONSUMES_ELEM_NAME);
5.108 +
5.109 + // 1. Find corresponding CASA consumes/provides element
5.110 +
5.111 + Endpoint endpoint = getEndpointInJBI(jbiEndpointElement);
5.112 +
5.113 + Element casaEndpointRefElement = CasaBuilder.getEndpointRefElement(
5.114 + casaDocument, endpoint, isConsumes);
5.115 +
5.116 + // 2. Copy child extension elements over from CASA to JBI
5.117 + if (casaEndpointRefElement != null) {
5.118 + NodeList casaEndpointChildren = casaEndpointRefElement.getChildNodes();
5.119 + for (int k = 0; k < casaEndpointChildren.getLength(); k++) {
5.120 + Node casaEndpointChild = casaEndpointChildren.item(k);
5.121 + if (casaEndpointChild instanceof Element) {
5.122 +
5.123 + // #136868 Remove disabled BC endpoint when applicable,
5.124 + // or skip cloning of this type of endpoint extension
5.125 + // 'cause runtime doesn't understand it.
5.126 + Element casaEndpointExtension = (Element) casaEndpointChild;
5.127 + String extName = casaEndpointExtension.getNodeName();
5.128 + String nsValue = casaEndpointExtension.getAttribute("xmlns");
5.129 + // The cloned extension elements in the new CASA document
5.130 + // are not namespace aware.
5.131 + if (CODEGEN.equals(extName) && ENDPOINT_CONFIG_NS.equals(nsValue)) {
5.132 + String disableInBCValue = casaEndpointExtension.getAttribute(DISABLE_IN_BC);
5.133 + if ("true".equalsIgnoreCase(disableInBCValue)) {
5.134 + jbiEndpointElement.getParentNode().removeChild(jbiEndpointElement);
5.135 + }
5.136 + continue;
5.137 + }
5.138 +
5.139 + Node clonedNode = CasaBuilder.deepCloneCasaNode(
5.140 + casaEndpointChild, jbiDocument);
5.141 + jbiEndpointElement.appendChild(clonedNode);
5.142 + }
5.143 + }
5.144 + }
5.145 + }
5.146 +
5.147 + /**
5.148 + * Gets an Endpoint object from an endpoint element in JBI DOM.
5.149 + */
5.150 + private static Endpoint getEndpointInJBI(Element jbiEndpointElement) {
5.151 + String endpointName =
5.152 + jbiEndpointElement.getAttribute(JBI_ENDPOINT_NAME_ATTR_NAME);
5.153 + QName serviceQName = XmlUtil.getAttributeNSName(
5.154 + jbiEndpointElement, JBI_SERVICE_NAME_ATTR_NAME);
5.155 + QName interfaceQName = XmlUtil.getAttributeNSName(
5.156 + jbiEndpointElement, JBI_INTERFACE_NAME_ATTR_NAME);
5.157 +
5.158 + return new Endpoint(endpointName, serviceQName, interfaceQName);
5.159 + }
5.160 +}
6.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/projects/jbi/ui/customizer/JbiProjectProperties.java Fri Apr 25 08:24:55 2008 -0700
6.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/projects/jbi/ui/customizer/JbiProjectProperties.java Fri Jun 13 14:38:34 2008 +0200
6.3 @@ -338,6 +338,9 @@
6.4
6.5 public static final String SOURCE_ENCODING = "source.encoding"; // NOI18N
6.6
6.7 + public static final String OSGI_SUPPORT = "osgi.support"; // NOI18N
6.8 + public static final String OSGI_CONTAINER_DIR = "osgi.container.dir"; // NOI18N
6.9 +
6.10 //================== Start of JBI =====================================//
6.11
6.12 /**
6.13 @@ -536,7 +539,9 @@
6.14 new PropertyDescriptor(JAVADOC_ENCODING, PROJECT, STRING_PARSER),
6.15 new PropertyDescriptor(JAVADOC_PREVIEW, PROJECT, BOOLEAN_PARSER),
6.16 new PropertyDescriptor(SOURCE_ENCODING, PROJECT, CHARSET_PARSER),
6.17 -
6.18 + new PropertyDescriptor(OSGI_SUPPORT, PROJECT, BOOLEAN_PARSER),
6.19 + new PropertyDescriptor(OSGI_CONTAINER_DIR, PROJECT, STRING_PARSER),
6.20 +
6.21 // This should be OS-agnostic
6.22 new PropertyDescriptor(JBI_CONTENT_ADDITIONAL, PROJECT, SEMICOLON_PATH_PARSER),
6.23 new PropertyDescriptor(JBI_JAVAEE_JARS, PROJECT, SEMICOLON_PATH_PARSER),