geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shiv...@apache.org
Subject svn commit: r585954 - in /geronimo/server/trunk/plugins: console/console-core/src/main/java/org/apache/geronimo/console/util/ plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ plancreator/plancreator-portlets/src...
Date Thu, 18 Oct 2007 13:09:12 GMT
Author: shivahr
Date: Thu Oct 18 06:09:12 2007
New Revision: 585954

URL: http://svn.apache.org/viewvc?rev=585954&view=rev
Log:
GERONIMO-3431 Enhance 'Create Plan' portlet to auto handle references to JavaMail resources
in a web-app

Modified:
    geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.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/EnvironmentHandler.java
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.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/java/org/apache/geronimo/console/configcreator/ReferencesHandler.java
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/view/configcreator/references.jsp

Modified: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java?rev=585954&r1=585953&r2=585954&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java
(original)
+++ geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java
Thu Oct 18 06:09:12 2007
@@ -31,6 +31,7 @@
 import org.apache.geronimo.management.EJBModule;
 import org.apache.geronimo.management.J2EEDeployedObject;
 import org.apache.geronimo.management.J2EEModule;
+import org.apache.geronimo.management.J2EEResource;
 import org.apache.geronimo.management.JDBCDataSource;
 import org.apache.geronimo.management.JDBCDriver;
 import org.apache.geronimo.management.JDBCResource;
@@ -73,6 +74,7 @@
     JDBCResource[] getJDBCResources(J2EEServer server);
     JMSResource[] getJMSResources(J2EEServer server);
     JVM[] getJavaVMs(J2EEServer server);
+    J2EEResource[] getResources(J2EEServer server);
 
     // JVM properties
     SystemLog getSystemLog(JVM jvm);

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=585954&r1=585953&r2=585954&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
Thu Oct 18 06:09:12 2007
@@ -99,6 +99,8 @@
 
     protected final static String JDBC_POOL_REF_PREFIX = "jdbcPoolRef";
 
+    protected final static String JAVAMAIL_SESSION_REF_PREFIX = "javaMailSessionRef";
+
     protected final static String REF_NAME = "refName";
 
     protected final static String REF_LINK = "refLink";
@@ -117,6 +119,8 @@
 
     protected final static String DEPLOYED_JMS_DESTINATIONS_PARAMETER = "deployedJmsDestinations";
 
+    protected final static String DEPLOYED_JAVAMAIL_SESSIONS_PARAMETER = "deployedJavaMailSessions";
+
     protected final static String DEPLOYED_SECURITY_REALMS_PARAMETER = "deployedSecurityRealms";
 
     protected final static String COMMON_LIBS_PARAMETER = "commonLibs";
@@ -180,6 +184,8 @@
 
         private List messageDestinations = new ArrayList();
 
+        private List javaMailSessionRefs = new ArrayList();
+
         private List dependencies = new ArrayList();
 
         private boolean referenceNotResolved;
@@ -210,6 +216,7 @@
             readParameters(JMS_DESTINATION_REF_PREFIX, jmsDestinationRefs, request);
             readParameters(MESSAGE_DESTINATION_PREFIX, messageDestinations, request);
             readParameters(JDBC_POOL_REF_PREFIX, jdbcPoolRefs, request);
+            readParameters(JAVAMAIL_SESSION_REF_PREFIX, javaMailSessionRefs, request);
         }
 
         private void readParameters(String prefix1, List list, PortletRequest request) {
@@ -423,6 +430,10 @@
 
         public List getMessageDestinations() {
             return messageDestinations;
+        }
+
+        public List getJavaMailSessionRefs() {
+            return javaMailSessionRefs;
         }
 
         public boolean isReferenceNotResolved() {

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/EnvironmentHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/EnvironmentHandler.java?rev=585954&r1=585953&r2=585954&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/EnvironmentHandler.java
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/EnvironmentHandler.java
Thu Oct 18 06:09:12 2007
@@ -55,7 +55,8 @@
             throws PortletException, IOException {
         WARConfigData data = getSessionData(request);
         data.readEnvironmentData(request);
-        if (data.getEjbRefs().size() > 0 || data.getEjbLocalRefs().size() > 0 || data.getJdbcPoolRefs().size()
> 0
+        if (data.getEjbRefs().size() > 0 || data.getEjbLocalRefs().size() > 0 
+                || data.getJdbcPoolRefs().size() > 0 || data.getJavaMailSessionRefs().size()
> 0 
                 || data.getJmsConnectionFactoryRefs().size() > 0 || data.getJmsDestinationRefs().size()
> 0) {
             return REFERENCES_MODE + "-before";
         }

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java?rev=585954&r1=585953&r2=585954&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java
Thu Oct 18 06:09:12 2007
@@ -30,6 +30,7 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.management.EJBModule;
+import org.apache.geronimo.management.J2EEResource;
 import org.apache.geronimo.management.geronimo.JCAAdminObject;
 import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
 import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
@@ -191,6 +192,31 @@
             }
         }
         return list;
+    }
+
+    protected static List getJavaMailSessions(PortletRequest request) {
+        List mailSessionList = new ArrayList();
+        J2EEResource[] j2eeResources = PortletManager.getManagementHelper(request).getResources(
+                PortletManager.getCurrentServer(request));
+        for (int i = 0; i < j2eeResources.length; i++) {
+            try {
+                ObjectName objectName = ObjectName.getInstance(j2eeResources[i].getObjectName());
+                if (NameFactory.JAVA_MAIL_RESOURCE.equals(objectName.getKeyProperty(NameFactory.J2EE_TYPE)))
{
+                    String mailSesssionName = objectName.getKeyProperty(NameFactory.J2EE_NAME);
+                    String configurationName = objectName.getKeyProperty(NameFactory.SERVICE_MODULE)
+ "/";
+                    ReferredData data = new ReferredData(mailSesssionName + " (" + configurationName
+ ")",
+                            configurationName + "/" + mailSesssionName);
+                    mailSessionList.add(data);
+                }
+            } catch (MalformedObjectNameException e) {
+                // log.error(e.getMessage(), e);
+                e.printStackTrace();
+            } catch (NullPointerException e) {
+                // log.error(e.getMessage(), e);
+                e.printStackTrace();
+            }
+        }
+        return mailSessionList;
     }
 
     protected static List getCommonLibs(PortletRequest request) {

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=585954&r1=585953&r2=585954&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
Thu Oct 18 06:09:12 2007
@@ -194,6 +194,8 @@
                     || "javax.jms.QueueConnectionFactory".equalsIgnoreCase(refType)
                     || "javax.jms.TopicConnectionFactory".equalsIgnoreCase(refType)) {
                 data.getJmsConnectionFactoryRefs().add(new ReferenceData(refName));
+            } else if ("javax.mail.Session".equalsIgnoreCase(refType)) {
+                data.getJavaMailSessionRefs().add(new ReferenceData(refName));
             }
         }
         /*ddBeans = ddBean.getChildBean("resource-ref");
@@ -267,7 +269,7 @@
     }
 
     public static String getDependencyString(String patternString) {
-        String[] elements = patternString.split("/");
+        String[] elements = patternString.split("/", 6);
         return elements[0] + "/" + elements[1] + "/" + elements[2] + "/" + elements[3];
     }
 
@@ -362,7 +364,8 @@
             }
         }
 
-        int numResourceRefs = data.getJdbcPoolRefs().size() + data.getJmsConnectionFactoryRefs().size();
+        int numResourceRefs = data.getJdbcPoolRefs().size() + data.getJmsConnectionFactoryRefs().size()
+                + data.getJavaMailSessionRefs().size();
         if (numResourceRefs > 0) {
             ResourceRef[] resourceRefs = new ResourceRef[numResourceRefs];
             for (int i = 0; i < numResourceRefs; i++) {
@@ -382,6 +385,12 @@
                 resourceRef.setRefName(referenceData.getRefName());
                 resourceRef.setPattern(createPattern(referenceData.getRefLink()));
             }
+            for (int n = 0; n < data.getJavaMailSessionRefs().size(); n++, i++) {
+                ResourceRef resourceRef = resourceRefs[i];
+                ReferenceData referenceData = (ReferenceData) data.getJavaMailSessionRefs().get(n);
+                resourceRef.setRefName(referenceData.getRefName());
+                resourceRef.setPattern(createPattern(referenceData.getRefLink()));
+            }
         }
 
         int numMessageDestinations = data.getMessageDestinations().size();
@@ -429,7 +438,7 @@
 
     private static Pattern createPattern(String patternString) {
         Pattern pattern = new Pattern();
-        String[] elements = patternString.split("/");
+        String[] elements = patternString.split("/", 6);
         pattern.setGroupId(elements[0]);
         pattern.setArtifactId(elements[1]);
         pattern.setVersion(elements[2]);

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ReferencesHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ReferencesHandler.java?rev=585954&r1=585953&r2=585954&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ReferencesHandler.java
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ReferencesHandler.java
Thu Oct 18 06:09:12 2007
@@ -55,6 +55,7 @@
         request.setAttribute(DEPLOYED_JDBC_CONNECTION_POOLS_PARAMETER, JSR77_Util.getJDBCConnectionPools(request));
         request.setAttribute(DEPLOYED_JMS_CONNECTION_FACTORIES_PARAMETER, JSR77_Util.getJMSConnectionFactories(request));
         request.setAttribute(DEPLOYED_JMS_DESTINATIONS_PARAMETER, JSR77_Util.getJMSDestinations(request));
+        request.setAttribute(DEPLOYED_JAVAMAIL_SESSIONS_PARAMETER, JSR77_Util.getJavaMailSessions(request));
     }
 
     public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel
model)
@@ -65,6 +66,7 @@
         if (processRefs(data.getEjbRefs(), dependenciesSet)
                 && processRefs(data.getEjbLocalRefs(), dependenciesSet)
                 && processRefs(data.getJdbcPoolRefs(), dependenciesSet)
+                && processRefs(data.getJavaMailSessionRefs(), dependenciesSet)
                 && processRefs(data.getJmsConnectionFactoryRefs(), dependenciesSet)
                 && processRefs(data.getJmsDestinationRefs(), dependenciesSet)) {
             data.getDependencies().clear();

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=585954&r1=585953&r2=585954&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
Thu Oct 18 06:09:12 2007
@@ -22,11 +22,11 @@
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <portlet:defineObjects />
 
-<p><b>WAR - References</b> -- Resolve EJB, EJB Local, JDBC Connection Pool,
JMS Connection Factory and 
+<p><b>WAR - References</b> -- Resolve EJB, EJB Local, JDBC Connection Pool,
JavaMail Session, JMS Connection Factory and 
 JMS Destination 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, JMS Connection
Factory and 
+References declared in your web-app (ex. EJB, EJB Local, JDBC Connection Pool, JavaMail Session,
JMS Connection Factory and 
 JMS Destination references) are shown below to the left and the resources (available in the
server environment) 
 to which they can be linked are shown to the right.</p>
 
@@ -233,6 +233,41 @@
               <option value="${jmsDestination.patternName}" 
                 <c:if test="${fn:startsWith(jmsDestination.displayName, refData.refLink)}">
selected="selected"</c:if>
               >${jmsDestination.displayName}</option>
+            </c:forEach>
+          </select>
+        </td>
+      </tr>
+    </c:forEach>
+  </table>
+</c:if>
+
+<!-- ENTRY FIELD: JavaMail Session References -->
+<c:if test="${!empty(data.javaMailSessionRefs)}">
+  <p><b>JavaMail Session References:</b></p>
+  <table border="0" width="100%">
+    <tr>
+      <th class="DarkBackground" align="center">Mail Session Ref</th>
+      <th class="DarkBackground" align="center">Mail Sessions Available</th>
+    </tr>
+    <c:set var="backgroundClass" value='MediumBackground'/>
+    <c:forEach var="refData" items="${data.javaMailSessionRefs}" 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>
+      <input type="hidden" name="javaMailSessionRef.${status.index}.refName" value="${refData.refName}"
/>
+      <tr>
+        <td class="${backgroundClass}">
+          <div align="right">${refData.refName}</div>
+        </td>
+        <td class="${backgroundClass}">
+          <select name="javaMailSessionRef.${status.index}.refLink">
+            <c:forEach var="javaMailSession" items="${deployedJavaMailSessions}">
+              <option value="${javaMailSession.patternName}">${javaMailSession.displayName}</option>
             </c:forEach>
           </select>
         </td>



Mime
View raw message