geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shiv...@apache.org
Subject svn commit: r594759 - in /geronimo/server/trunk/plugins: j2ee/geronimo-test-ddbean/src/main/java/org/apache/geronimo/deployment/tools/loader/ j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/ plancreator/plancreator-portle...
Date Wed, 14 Nov 2007 04:32:36 GMT
Author: shivahr
Date: Tue Nov 13 20:32:35 2007
New Revision: 594759

URL: http://svn.apache.org/viewvc?rev=594759&view=rev
Log:
GERONIMO-3430 Enhance 'Create Plan' portlet to auto handle Web Service references in a web-app

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-test-ddbean/src/main/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/AbstractHandler.java
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/view/configcreator/references.jsp

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-test-ddbean/src/main/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-test-ddbean/src/main/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java?rev=594759&r1=594758&r2=594759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-test-ddbean/src/main/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-test-ddbean/src/main/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java
Tue Nov 13 20:32:35 2007
@@ -43,7 +43,10 @@
         super(ModuleType.WAR, moduleURL, "WEB-INF/web.xml");
         ClassLoader parent = super.getModuleLoader();
         List path = new ArrayList();
-        path.add(parent.getResource("WEB-INF/classes/"));
+        URL url = parent.getResource("WEB-INF/classes/");
+        if (url != null) {
+            path.add(url);
+        }
         Enumeration e = entries();
         while (e.hasMoreElements()) {
             String entry = (String) e.nextElement();

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java?rev=594759&r1=594758&r2=594759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java
Tue Nov 13 20:32:35 2007
@@ -40,6 +40,7 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
 import org.apache.xmlbeans.SchemaTypeLoader;
 
@@ -299,14 +300,26 @@
         getWebApp().setSecurityRealmName(securityRealmName);
     }
 
+    //TODO Method to be updated once DConfigBean for "security" is available
     public GerAbstractSecurityType getSecurity() {
         return getWebApp().getSecurity();
     }
 
+    //TODO Method to be updated once DConfigBean for "security" is available
     public void setSecurity(GerAbstractSecurityType security) {
         pcs.firePropertyChange("security", getSecurity(), security);
         getWebApp().setSecurity(security);
     }
 
+    //TODO Method to be updated once DConfigBean for "service-ref" is available
+    public GerServiceRefType[] getServiceRefs() {
+        return getWebApp().getServiceRefArray();
+    }
+
+    //TODO Method to be updated once DConfigBean for "service-ref" is available
+    public void setServiceRefs(GerServiceRefType[] serviceRefArray){
+        pcs.firePropertyChange("service-ref", getServiceRefs(), serviceRefArray);
+        getWebApp().setServiceRefArray(serviceRefArray);
+    }
     // ----------------------- End of JavaBean Properties ----------------------
 }

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/AbstractHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/AbstractHandler.java?rev=594759&r1=594758&r2=594759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/AbstractHandler.java
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/AbstractHandler.java
Tue Nov 13 20:32:35 2007
@@ -29,6 +29,8 @@
 import org.apache.geronimo.console.MultiPageAbstractHandler;
 import org.apache.geronimo.console.MultiPageModel;
 import org.apache.geronimo.deployment.xbeans.PatternType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPortType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.geronimo.xbeans.geronimo.security.GerDistinguishedNameType;
 import org.apache.geronimo.xbeans.geronimo.security.GerLoginDomainPrincipalType;
 import org.apache.geronimo.xbeans.geronimo.security.GerPrincipalType;
@@ -187,6 +189,8 @@
 
         private List javaMailSessionRefs = new ArrayList();
 
+        private List<GerServiceRefType> webServiceRefs = new ArrayList<GerServiceRefType>();
+
         private List dependencies = new ArrayList();
 
         private boolean referenceNotResolved;
@@ -218,6 +222,7 @@
             readParameters(MESSAGE_DESTINATION_PREFIX, messageDestinations, request);
             readParameters(JDBC_POOL_REF_PREFIX, jdbcPoolRefs, request);
             readParameters(JAVAMAIL_SESSION_REF_PREFIX, javaMailSessionRefs, request);
+            readWebServiceRefsData(request);
         }
 
         private void readParameters(String prefix1, List list, PortletRequest request) {
@@ -235,6 +240,50 @@
             }
         }
 
+        public void readWebServiceRefsData(PortletRequest request) {
+            Map map = request.getParameterMap();
+            for (int i = 0; i < getWebServiceRefs().size(); i++) {
+                GerServiceRefType serviceRef = getWebServiceRefs().get(i);
+                for (int j = serviceRef.getPortArray().length - 1; j >= 0; j--) {
+                    serviceRef.removePort(j);
+                }
+                String prefix1 = "serviceRef" + "." + i + "." + "port" + ".";
+                int lastIndex = Integer.parseInt(request.getParameter(prefix1 + "lastIndex"));
+                for (int j = 0; j < lastIndex; j++) {
+                    String prefix2 = prefix1 + j + ".";
+                    if (!map.containsKey(prefix2 + "portName")) {
+                        continue;
+                    }
+                    GerPortType port = serviceRef.addNewPort();
+                    String value = request.getParameter(prefix2 + "portName");
+                    if (!isEmpty(value)) {
+                        port.setPortName(value);
+                    }
+                    value = request.getParameter(prefix2 + "protocol");
+                    if (!isEmpty(value)) {
+                        port.setProtocol(value);
+                    }
+                    value = request.getParameter(prefix2 + "host");
+                    if (!isEmpty(value)) {
+                        port.setHost(value);
+                    }
+                    value = request.getParameter(prefix2 + "port");
+                    if (!isEmpty(value)) {
+                        int portValue = Integer.parseInt(value);
+                        port.setPort(portValue);
+                    }
+                    value = request.getParameter(prefix2 + "uri");
+                    if (!isEmpty(value)) {
+                        port.setUri(value);
+                    }
+                    value = request.getParameter(prefix2 + "credentialsName");
+                    if (!isEmpty(value)) {
+                        port.setCredentialsName(value);
+                    }
+                }
+            }
+        }
+
         public void readSecurityData(PortletRequest request) {
             securityRealmName = request.getParameter("securityRealmName");
             readSecurityParameters(request);
@@ -463,6 +512,10 @@
 
         public List getJavaMailSessionRefs() {
             return javaMailSessionRefs;
+        }
+
+        public List<GerServiceRefType> getWebServiceRefs() {
+            return webServiceRefs;
         }
 
         public boolean isReferenceNotResolved() {

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java?rev=594759&r1=594758&r2=594759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java
Tue Nov 13 20:32:35 2007
@@ -74,6 +74,7 @@
 import org.apache.geronimo.web.deployment.WebAppDConfigBean;
 import org.apache.geronimo.web.deployment.WebAppDConfigRoot;
 import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
+import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.geronimo.xbeans.geronimo.security.GerRoleType;
 import org.apache.geronimo.xbeans.geronimo.security.GerSecurityType;
 import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
@@ -82,6 +83,7 @@
 import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
 import org.apache.geronimo.xbeans.javaee.ResourceRefType;
 import org.apache.geronimo.xbeans.javaee.SecurityRoleType;
+import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.xbean.finder.ClassFinder;
 
@@ -211,6 +213,14 @@
             }
         }*/
 
+        ServiceRefType[] serviceRefs = annotatedApp.getServiceRefArray();
+        for(int i = 0; i < serviceRefs.length; i++) {
+            String refName = serviceRefs[i].getServiceRefName().getStringValue();
+            GerServiceRefType serviceRef = GerServiceRefType.Factory.newInstance();
+            serviceRef.setServiceRefName(refName);
+            data.getWebServiceRefs().add(serviceRef);
+        }
+
         ResourceEnvRefType[] resourceEnvRefs = annotatedApp.getResourceEnvRefArray();
         for(int i = 0; i < resourceEnvRefs.length; i++) {
             String refName = resourceEnvRefs[i].getResourceEnvRefName().getStringValue();
@@ -423,6 +433,11 @@
                 resourceEnvRef.setPattern(createPattern(referenceData.getRefLink()));
                 // resourceEnvRef.setAdminObjectLink(createPattern(referenceData.getRefLink()).getName());
             }
+        }
+
+        int numWebServiceRefs = data.getWebServiceRefs().size();
+        if (numWebServiceRefs > 0) {
+            webApp.setServiceRefs(data.getWebServiceRefs().toArray(new GerServiceRefType[numWebServiceRefs]));
         }
 
         if (data.getSecurity() != null) {

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/view/configcreator/references.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/view/configcreator/references.jsp?rev=594759&r1=594758&r2=594759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/view/configcreator/references.jsp
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/view/configcreator/references.jsp
Tue Nov 13 20:32:35 2007
@@ -22,8 +22,105 @@
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <portlet:defineObjects />
 
-<p><b>WAR - References</b> -- Resolve EJB, EJB Local, JDBC Connection Pool,
JavaMail Session, JMS Connection Factory and 
-JMS Destination references</p>
+<script>
+function <portlet:namespace/>showElement(id) {
+  var element = document.getElementById("<portlet:namespace/>"+id);
+  if (element.style.display != 'inline') {
+    element.style.display = 'inline';
+  }
+}
+
+function <portlet:namespace/>hideElement(id) {
+  var element = document.getElementById("<portlet:namespace/>"+id);
+  if (element.style.display != 'none') {
+    element.style.display = 'none';
+  }
+}
+
+function <portlet:namespace/>addPort(serviceRefId)
+{
+  var prefix = "<portlet:namespace/>" + serviceRefId;
+  if (document.getElementById(prefix + ".newPort.portName").value == "") {
+    alert("Port Name field is empty!");
+    return;
+  }
+
+  var lastIndex = document.getElementById(prefix + ".port.lastIndex");
+  var elementId = serviceRefId + ".port." + lastIndex.value;
+  lastIndex.value = (lastIndex.value - 1) + 2;
+  //lastIndex.value is a string, and using lastIndex.value += 1 might imply string concat
+  var newTRId = "<portlet:namespace/>" + elementId + ".tr";
+  var newTR = document.createElement("tr");
+  newTR.setAttribute("id", newTRId);
+
+  var portNameField = document.getElementById(prefix + ".newPort.portName");
+  var portName = portNameField.value;
+  portNameField.value="";
+  var newTD = document.createElement("td");
+  newTD.innerHTML = name + 
+    "<input type=\"hidden\" name=\"" + elementId + ".portName\" value=\"" + portName +
"\" /> ";
+  newTR.appendChild(newTD);
+
+  var url = "";
+  var innerHTML = "";
+  var protocolField = document.getElementById(prefix + ".newPort.protocol");
+  var protocol = protocolField.value;
+  if (protocol != "") {
+    url += protocol + "://";
+    innerHTML += "<input type=\"hidden\" name=\"" + elementId + ".protocol\" value=\""
+ protocol + "\" /> ";
+  }
+  var hostField = document.getElementById(prefix + ".newPort.host");
+  var host = hostField.value;
+  if (host != "") {
+    url += host;
+    innerHTML += "<input type=\"hidden\" name=\"" + elementId + ".host\" value=\"" + host
+ "\" /> ";
+  }
+  var portField = document.getElementById(prefix + ".newPort.port");
+  var port = portField.value;
+  if (port != "") {
+    url += ":" + port;
+    innerHTML += "<input type=\"hidden\" name=\"" + elementId + ".port\" value=\"" + port
+ "\" /> ";
+  }
+  var uriField = document.getElementById(prefix + ".newPort.uri");
+  var uri = uriField.value;
+  if (uri != "") {
+    url += "/" + uri;
+    innerHTML += "<input type=\"hidden\" name=\"" + elementId + ".uri\" value=\"" + uri
+ "\" /> ";
+  }
+  newTD = document.createElement("td");
+  newTD.innerHTML = url + innerHTML;
+  newTR.appendChild(newTD);
+
+  var credentialsNameField = document.getElementById(prefix + ".newPort.credentialsName");
+  var credentialsName = credentialsNameField.value;
+  newTD = document.createElement("td");
+  if(credentialsName != "") {
+    newTD.innerHTML = credentialsName + 
+      "<input type=\"hidden\" name=\"" + elementId + ".credentialsName\" value=\"" + credentialsName
+ "\" /> ";
+  }
+  newTR.appendChild(newTD);
+
+  newTD = document.createElement("td");
+  newTD.innerHTML = "<a href=\"javascript:;\" " + 
+    "onclick=\"<portlet:namespace/>removePort(\'" + newTRId + "\')\">remove</a>";
+  newTR.appendChild(newTD);
+
+  var tbody = document.getElementById("<portlet:namespace/>serviceRef.tableBody");
+  var placeHolder = document.getElementById(prefix + ".placeHolder");
+  tbody.insertBefore(newTR, placeHolder);
+  <portlet:namespace/>hideElement(serviceRefId + ".addNewPort");
+}
+
+function <portlet:namespace/>removePort(trId)
+{
+  var tbody = document.getElementById("<portlet:namespace/>serviceRef.tableBody");
+  var tr = document.getElementById(trId);
+  tbody.removeChild(tr);
+}
+</script>
+
+<p><b>WAR - References</b> -- Resolve EJB, EJB Local, JDBC Connection Pool,
JavaMail Session, JMS Connection Factory, 
+ JMS Destination and Web Service References</p>
 
 <p>Map the references declared in your Web application to specific items available
in the server environment. 
 References declared in your web-app (ex. EJB, EJB Local, JDBC Connection Pool, JavaMail Session,
JMS Connection Factory and 
@@ -273,6 +370,90 @@
         </td>
       </tr>
     </c:forEach>
+  </table>
+</c:if>
+
+<!-- ENTRY FIELD: Web Service References -->
+<c:if test="${!empty(data.webServiceRefs)}">
+  <p><b>Web Service References:</b></p>
+  <table border="0" width="100%">
+    <thead>
+    <tr>
+      <th class="DarkBackground" align="center">Service Ref</th>
+      <th class="DarkBackground" align="center">Port Name</th>
+      <th class="DarkBackground" align="center">URL</th>
+      <th class="DarkBackground" align="center">Credentials Name</th>
+      <th class="DarkBackground" align="center">Actions</th>
+    </tr>
+    </thead>
+    <tfoot></tfoot>
+    <tbody id="<portlet:namespace/>serviceRef.tableBody">
+    <c:set var="backgroundClass" value='MediumBackground'/>
+    <c:forEach var="serviceRef" items="${data.webServiceRefs}" varStatus="status">
+      <c:choose>
+        <c:when test="${backgroundClass == 'MediumBackground'}" >
+          <c:set var="backgroundClass" value='LightBackground'/>
+        </c:when>
+        <c:otherwise>
+          <c:set var="backgroundClass" value='MediumBackground'/>
+        </c:otherwise>
+      </c:choose>
+      <c:set var="serviceRefId" value="serviceRef.${status.index}" />
+      <input type="hidden" name="${serviceRefId}.serviceRefName" value="${serviceRef.serviceRefName}"
/>
+      <input type="hidden" id="${serviceRefId}.port.lastIndex" name="${serviceRefId}.port.lastIndex"
value="0">
+      <tr>
+        <td class="${backgroundClass}">
+          <div align="right">${serviceRef.serviceRefName}</div>
+        </td>
+        <td class="${backgroundClass}" colspan="4"></td>
+      </tr>
+      <!-- place holder before which new ports have to be added -->
+      <div id="<portlet:namespace/>${serviceRefId}.placeHolder"></div>
+      <tr>
+        <td class="${backgroundClass}"></td>
+        <td class="${backgroundClass}" colspan="4" align="left">
+          <button onclick="<portlet:namespace/>showElement('${serviceRefId}.addNewPort');">Add
Port</button>
+          <div id="<portlet:namespace/>${serviceRefId}.addNewPort" style="display:none">
+            <table border="0">
+              <tr>
+                <th><div align="right">Port Name:</div></th>
+                <td><input type="text" id="<portlet:namespace/>${serviceRefId}.newPort.portName"/></td>
+              </tr>
+              <tr>
+                <th><div align="right">Protocol:</div></th>
+                <td><input type="text" id="<portlet:namespace/>${serviceRefId}.newPort.protocol"/></td>
+              </tr>
+              <tr>
+                <th><div align="right">Host:</div></th>
+                <td><input type="text" id="<portlet:namespace/>${serviceRefId}.newPort.host"/></td>
+              </tr>
+              <tr>
+                <th><div align="right">Port:</div></th>
+                <td><input type="text" id="<portlet:namespace/>${serviceRefId}.newPort.port"/></td>
+              </tr>
+              <tr>
+                <th><div align="right">URI:</div></th>
+                <td><input type="text" id="<portlet:namespace/>${serviceRefId}.newPort.uri"/></td>
+              </tr>
+              <tr>
+                <th><div align="right">Credentials Name:</div></th>
+                <td><input type="text" id="<portlet:namespace/>${serviceRefId}.newPort.credentialsName"/></td>
+              </tr>
+              <tr>
+                <th><div align="right"></div></th>
+                <td>
+                  <input type="button" value="Add" 
+                    onclick="<portlet:namespace/>addPort('${serviceRefId}')"/>
+                  <input type="button" value="Cancel" 
+                    onclick="<portlet:namespace/>hideElement('${serviceRefId}.addNewPort');"/>
+                </td>
+              </tr>
+            </table>
+          </div>
+        </td>
+      </tr>
+    </c:forEach>
+    </tbody>
   </table>
 </c:if>
 



Mime
View raw message