[portal-commits] JBoss Portal SVN: r5932 - in trunk/wsrp/src/main/org/jboss/portal/wsrp: deployment endpoints services

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Dec 22 19:24:50 EST 2006


Author: chris.laprun at jboss.com
Date: 2006-12-22 19:24:47 -0500 (Fri, 22 Dec 2006)
New Revision: 5932

Modified:
   trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
Log:
- JBPORTAL-1169: Improve handling of unavailable producers when deploying -wsrp.xml files.
- As a consequence, ServiceFactories should now provide better validation of input data.

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -22,6 +22,7 @@
  ******************************************************************************/
 package org.jboss.portal.wsrp.deployment;
 
+import org.jboss.logging.Logger;
 import org.jboss.portal.wsrp.WSRPTypeFactory;
 import org.jboss.portal.wsrp.consumer.WSRPConsumerImpl;
 import org.jboss.portal.wsrp.core.Property;
@@ -46,6 +47,7 @@
  */
 public class WSRPDeploymentFactory implements ObjectModelFactory
 {
+   private final Logger log = Logger.getLogger(getClass());
    private static final boolean DEBUG = false;
 
    /** . */
@@ -304,6 +306,15 @@
          System.out.println("addchild deployment service " + localName);
       }
 
-      deployment.getServices().add(service);
+      if (service.getConsumer().getServiceFactory().isAvailable())
+      {
+         log.info("Added consumer for producer '" + service.getId() + "'");
+         deployment.getServices().add(service);
+      }
+      else
+      {
+         log.info("There was a problem initializing the WSRP interface for producer '"
+            + service.getId() + "'. The consumer will NOT be available.");
+      }
    }
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -41,14 +41,6 @@
    public void init(Object object) throws ServiceException
    {
       context = (ServletEndpointContext)object; // per init javadoc
-
-      /*
-      // put the request and response in ServletAccess... not working, using a filter for now
-      MessageContext messageContext = context.getMessageContext();
-      HttpServletRequest request = (HttpServletRequest)messageContext.getProperty("transport.http.servletRequest");
-      HttpServletResponse response = (HttpServletResponse)messageContext.getProperty("transport.http.servletResponse");
-      ServletAccess.setRequestAndResponse(request, response);
-      */
    }
 
    public void destroy()

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -85,6 +85,11 @@
          throw new IllegalArgumentException("Null class not accepted to perform lookup");
       }
 
+      if (!isAvailable())
+      {
+         throw new IllegalStateException("This ServiceFactory is not ready to service clients!");
+      }
+
       //
       String key = serviceClass.getName();
       if (!portJNDIMapping.containsKey(key))

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -76,4 +76,10 @@
    {
       this.delegate = delegate;
    }
+
+
+   public boolean isAvailable()
+   {
+      return delegate != null && delegate.isAvailable();
+   }
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -22,6 +22,7 @@
  ******************************************************************************/
 package org.jboss.portal.wsrp.services;
 
+import org.jboss.portal.common.util.ParameterValidation;
 import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
 import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
 import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
@@ -58,6 +59,7 @@
 
    public void setServiceDescriptionURL(String serviceDescriptionURL)
    {
+      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(serviceDescriptionURL, "Mandatory Service Description interface", null);
       this.serviceDescriptionURL = serviceDescriptionURL;
    }
 
@@ -68,6 +70,7 @@
 
    public void setMarkupURL(String markupURL)
    {
+      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(markupURL, "Mandatory Markup interface", null);
       this.markupURL = markupURL;
    }
 
@@ -99,13 +102,16 @@
 
       //
       String portAddress = null;
+      boolean isMandatoryInterface = false;
       if (WSRP_v1_ServiceDescription_PortType.class.equals(serviceClass))
       {
          portAddress = serviceDescriptionURL;
+         isMandatoryInterface = true;
       }
       else if (WSRP_v1_Markup_PortType.class.equals(serviceClass))
       {
          portAddress = markupURL;
+         isMandatoryInterface = true;
       }
       else if (WSRP_v1_Registration_PortType.class.equals(serviceClass))
       {
@@ -124,11 +130,25 @@
       }
       else
       {
-         throw new IllegalStateException("Service URLs were not properly initialized: no proper service URL for "
-            + serviceClass.getName());
+         if (isMandatoryInterface)
+         {
+            throw new IllegalStateException("Mandatory interface URLs were not properly initialized: no proper service URL for "
+               + serviceClass.getName());
+         }
+         else
+         {
+            throw new IllegalStateException("No URL was provided for optional interface "
+               + serviceClass.getName());
+         }
       }
 
       //
       return stub;
    }
+
+
+   public boolean isAvailable()
+   {
+      return markupURL != null && serviceDescriptionURL != null;
+   }
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RMIInvokerServiceFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -45,4 +45,10 @@
       portJNDIMapping.put(WSRP_v1_Registration_PortType.class.getName(), "wsrp/invoker/RegistrationService");
       portJNDIMapping.put(WSRP_v1_PortletManagement_PortType.class.getName(), "wsrp/invoker/PortletManagementService");
    }
+
+
+   public boolean isAvailable()
+   {
+      return true;
+   }
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -69,7 +69,7 @@
       return wsdlDefinitionURL;
    }
 
-   public void setWsdlDefinitionURL(String wsdlDefinitionURL)
+   public void setWsdlDefinitionURL(String wsdlDefinitionURL) throws RuntimeException
    {
       if (wsdlDefinitionURL == null || wsdlDefinitionURL.length() == 0)
       {
@@ -102,9 +102,9 @@
          iae.initCause(e);
          throw iae;
       }
-      catch (WSDLException e)
+      catch (Exception e)
       {
-         log.info("WSDL Exception", e);
+         log.info("Couldn't initialize services for WSDL at '" + wsdlDefinitionURL + "'", e);
       }
    }
 

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -23,6 +23,7 @@
 
 package org.jboss.portal.wsrp.services;
 
+import org.jboss.portal.common.util.ParameterValidation;
 import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
 import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
 import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
@@ -63,6 +64,7 @@
 
    public void setEndpointURL(String endpointURL)
    {
+      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(endpointURL, "Mandatory endpoint URL", null);
       this.endpointURL = endpointURL;
    }
 
@@ -81,4 +83,10 @@
       }
       return stub;
    }
+
+
+   public boolean isAvailable()
+   {
+      return endpointURL != null;
+   }
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java	2006-12-22 21:18:22 UTC (rev 5931)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java	2006-12-23 00:24:47 UTC (rev 5932)
@@ -33,4 +33,6 @@
 public interface ServiceFactory extends Service
 {
    Object getService(Class clazz) throws Exception;
+
+   boolean isAvailable();
 }




More information about the portal-commits mailing list