Author: chris.laprun(a)jboss.com
Date: 2008-07-15 19:56:13 -0400 (Tue, 15 Jul 2008)
New Revision: 11461
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
Log:
- JBPORTAL-1726:
+ Added wrapper around WSRP endpoints to be able to fail service factory when a
non-business error happens.
+ Should investigate implementing using AOP instead.
+ Needs more testing.
- Minor improvements.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -48,6 +48,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
import org.jboss.portal.wsrp.services.ServiceFactory;
+import java.rmi.Remote;
import java.rmi.RemoteException;
/**
@@ -72,23 +73,23 @@
registry.registerMarkupBehavior(new SimpleMarkupBehavior());
}
- public Object getService(Class clazz) throws Exception
+ public <T extends Remote> T getService(Class<T> serviceClass) throws
Exception
{
- if (WSRP_v1_ServiceDescription_PortType.class.isAssignableFrom(clazz))
+ if (WSRP_v1_ServiceDescription_PortType.class.isAssignableFrom(serviceClass))
{
- return registry.getServiceDescriptionBehavior();
+ return (T)registry.getServiceDescriptionBehavior();
}
- if (WSRP_v1_Markup_PortType.class.isAssignableFrom(clazz))
+ if (WSRP_v1_Markup_PortType.class.isAssignableFrom(serviceClass))
{
- return registry.getMarkupBehaviorFor(MARKUP);
+ return (T)registry.getMarkupBehaviorFor(MARKUP);
}
- if (WSRP_v1_PortletManagement_PortType.class.isAssignableFrom(clazz))
+ if (WSRP_v1_PortletManagement_PortType.class.isAssignableFrom(serviceClass))
{
- return registry.getPortletManagementBehavior();
+ return (T)registry.getPortletManagementBehavior();
}
- if (WSRP_v1_Registration_PortType.class.isAssignableFrom(clazz))
+ if (WSRP_v1_Registration_PortType.class.isAssignableFrom(serviceClass))
{
- return registry.getRegistrationBehavior();
+ return (T)registry.getRegistrationBehavior();
}
return null;
}
@@ -118,6 +119,11 @@
return false;
}
+ public void setFailed(boolean failed)
+ {
+ // do nothing
+ }
+
public String getServiceDescriptionURL()
{
return SD_URL;
@@ -187,10 +193,10 @@
}
protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
- throws UnsupportedWindowStateFault, InvalidCookieFault, InvalidSessionFault,
AccessDeniedFault,
- InconsistentParametersFault, InvalidHandleFault, UnsupportedLocaleFault,
UnsupportedModeFault,
- OperationFailedFault, MissingParametersFault, InvalidUserCategoryFault,
InvalidRegistrationFault,
- UnsupportedMimeTypeFault, RemoteException
+ throws UnsupportedWindowStateFault, InvalidCookieFault,
InvalidSessionFault, AccessDeniedFault,
+ InconsistentParametersFault, InvalidHandleFault, UnsupportedLocaleFault,
UnsupportedModeFault,
+ OperationFailedFault, MissingParametersFault, InvalidUserCategoryFault,
InvalidRegistrationFault,
+ UnsupportedMimeTypeFault, RemoteException
{
return MARKUP;
}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -24,7 +24,6 @@
package org.jboss.portal.test.wsrp.v1.producer;
import org.jboss.portal.common.junit.ExtendedAssert;
-import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.registration.policies.DefaultRegistrationPolicy;
@@ -65,14 +64,12 @@
protected WSRP_v1_PortletManagement_PortType portletManagementService;
private static final String CONSUMER = "test-consumer";
- public V1ProducerBaseTest()
- throws Exception
+ public V1ProducerBaseTest() throws Exception
{
this("V1ProducerBaseTest");
}
- protected V1ProducerBaseTest(String name)
- throws Exception
+ protected V1ProducerBaseTest(String name) throws Exception
{
super(name);
}
@@ -82,19 +79,14 @@
{
super.setUp();
- serviceDescriptionService = getService(WSRP_v1_ServiceDescription_PortType.class);
- markupService = getService(WSRP_v1_Markup_PortType.class);
- registrationService = getService(WSRP_v1_Registration_PortType.class);
- portletManagementService = getService(WSRP_v1_PortletManagement_PortType.class);
+ serviceDescriptionService =
getServiceFactory().getService(WSRP_v1_ServiceDescription_PortType.class);
+ markupService = getServiceFactory().getService(WSRP_v1_Markup_PortType.class);
+ registrationService =
getServiceFactory().getService(WSRP_v1_Registration_PortType.class);
+ portletManagementService =
getServiceFactory().getService(WSRP_v1_PortletManagement_PortType.class);
resetRegistrationInfo();
}
- private <T> T getService(Class<T> serviceClass) throws Exception
- {
- return (T)getServiceFactory().getService(serviceClass);
- }
-
public void tearDown() throws Exception
{
producer.getProducerRegistrationRequirements().clearRegistrationProperties();
@@ -126,13 +118,13 @@
MarkupType[] markupTypes = desc.getMarkupTypes();
ExtendedAssert.assertEquals(1, markupTypes.length);
MarkupType markupType = markupTypes[0];
- assertEquals(new MarkupType(MediaType.TEXT_HTML.getValue(), new
String[]{WSRPConstants.VIEW_MODE},
- new String[]{WSRPConstants.NORMAL_WINDOW_STATE,
WSRPConstants.MAXIMIZED_WINDOW_STATE, WSRPConstants.MINIMIZED_WINDOW_STATE},
- new String[]{"en"}, null), markupType);
+ assertEquals(new MarkupType("text/html", new
String[]{WSRPConstants.VIEW_MODE},
+ new String[]{WSRPConstants.NORMAL_WINDOW_STATE,
WSRPConstants.MAXIMIZED_WINDOW_STATE, WSRPConstants.MINIMIZED_WINDOW_STATE},
+ new String[]{"en"}, null), markupType);
}
protected ServiceDescription
checkServiceDescriptionWithOnlyBasicPortlet(GetServiceDescription gs)
- throws Exception
+ throws Exception
{
deploy("test-basic-portlet.war");
//Invoke the Web Service
@@ -143,9 +135,9 @@
// Check offered portlets
PortletDescription[] offeredPortlets = sd.getOfferedPortlets();
ExtendedAssert.assertNotNull(offeredPortlets);
- for (int i = 0; i < offeredPortlets.length; i++)
+ for (PortletDescription offeredPortlet : offeredPortlets)
{
- System.out.println("handle " +
offeredPortlets[i].getPortletHandle());
+ System.out.println("handle " + offeredPortlet.getPortletHandle());
}
ExtendedAssert.assertEquals(1, offeredPortlets.length);
@@ -159,7 +151,7 @@
}
protected RegistrationContext registerConsumer()
- throws org.jboss.portal.wsrp.core.MissingParametersFault,
org.jboss.portal.wsrp.core.OperationFailedFault, java.rmi.RemoteException
+ throws org.jboss.portal.wsrp.core.MissingParametersFault,
org.jboss.portal.wsrp.core.OperationFailedFault, java.rmi.RemoteException
{
RegistrationData registrationData = createBaseRegData();
return registrationService.register(registrationData);
@@ -183,7 +175,7 @@
{
// fix-me:
http://jira.jboss.com/jira/browse/JBPORTAL-821
RegistrationPropertyDescription regProp = new
RegistrationPropertyDescription("regProp",
- new QName("urn:oasis:names:tc:wsrp:v1:types",
"LocalizedString", "ns1"));
+ new QName("urn:oasis:names:tc:wsrp:v1:types",
"LocalizedString", "ns1"));
regProp.setDefaultLabel("Registration Property");
producer.getProducerRegistrationRequirements().addRegistrationProperty(regProp);
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -34,6 +34,7 @@
import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory;
import org.jboss.portal.wsrp.services.ServiceFactory;
+import java.rmi.Remote;
import java.util.BitSet;
/**
@@ -363,38 +364,38 @@
// todo: public for tests
public WSRP_v1_ServiceDescription_PortType getServiceDescriptionService() throws
InvokerUnavailableException
{
- return (WSRP_v1_ServiceDescription_PortType)getService(SERVICE_DESCRIPTION,
WSRP_v1_ServiceDescription_PortType.class);
+ return getService(WSRP_v1_ServiceDescription_PortType.class);
}
// todo: public for tests
public WSRP_v1_Markup_PortType getMarkupService() throws InvokerUnavailableException
{
- return (WSRP_v1_Markup_PortType)getService(MARKUP, WSRP_v1_Markup_PortType.class);
+ return getService(WSRP_v1_Markup_PortType.class);
}
// todo: public for tests
public WSRP_v1_PortletManagement_PortType getPortletManagementService() throws
InvokerUnavailableException
{
- return (WSRP_v1_PortletManagement_PortType)getService(PORTLET_MANAGEMENT,
WSRP_v1_PortletManagement_PortType.class);
+ return getService(WSRP_v1_PortletManagement_PortType.class);
}
// todo: public for tests
public WSRP_v1_Registration_PortType getRegistrationService() throws
InvokerUnavailableException
{
- return (WSRP_v1_Registration_PortType)getService(REGISTRATION,
WSRP_v1_Registration_PortType.class);
+ return getService(WSRP_v1_Registration_PortType.class);
}
- private Object getService(String description, Class clazz) throws
InvokerUnavailableException
+ private <T extends Remote> T getService(Class<T> clazz) throws
InvokerUnavailableException
{
try
{
- Object service = getServiceFactory().getService(clazz);
+ T service = getServiceFactory().getService(clazz);
clean.set(getIndexFor(clazz));
return service;
}
catch (Exception e)
{
- throw new InvokerUnavailableException("Couldn't access " +
description + " service. Cause: "
+ throw new InvokerUnavailableException("Couldn't access " +
clazz.getSimpleName() + " service. Cause: "
+ e.getLocalizedMessage(), e);
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -27,6 +27,8 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import javax.naming.InitialContext;
+import javax.xml.rpc.Service;
+import java.rmi.Remote;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -60,17 +62,17 @@
// fix-me: this is hardcoded from values from
portal-wsrp-client.jar/META-INF/jboss-client.xml... NOT GOOD!
DEFAULT_FACTORY_MAPPING = new Properties();
DEFAULT_FACTORY_MAPPING.setProperty(
- "org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType",
- "wsrp-client/service/ServiceDescriptionService");
+
"org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType",
+ "wsrp-client/service/ServiceDescriptionService");
DEFAULT_FACTORY_MAPPING.setProperty(
- "org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType",
- "wsrp-client/service/MarkupService");
+ "org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType",
+ "wsrp-client/service/MarkupService");
DEFAULT_FACTORY_MAPPING.setProperty(
- "org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType",
- "wsrp-client/service/RegistrationService");
+ "org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType",
+ "wsrp-client/service/RegistrationService");
DEFAULT_FACTORY_MAPPING.setProperty(
- "org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType",
- "wsrp-client/service/PortletManagementService");
+ "org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType",
+ "wsrp-client/service/PortletManagementService");
}
/** A Map recording the mapping between WSRP port type class name and JDNI name of the
implementing service. */
@@ -102,7 +104,7 @@
this.env = env;
}
- public Object getService(Class serviceClass) throws Exception
+ protected <T extends Remote> Service getServiceFor(Class<T> serviceClass)
throws Exception
{
if (serviceClass == null)
{
@@ -149,7 +151,7 @@
}
//
- return service;
+ return (Service)service;
}
finally
{
@@ -162,6 +164,11 @@
return failed;
}
+ public void setFailed(boolean failed)
+ {
+ this.failed = failed;
+ }
+
public Properties getPortJNDIMapping()
{
return portJNDIMapping;
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -25,10 +25,11 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
import javax.xml.rpc.Service;
+import java.rmi.Remote;
import java.util.Map;
/**
- * Perform common logic to soap based service factories. This one cache the service
retrieved from the JNDI lookup.
+ * Perform common logic to soap based service factories. This one caches the service
retrieved from the JNDI lookup.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -37,7 +38,7 @@
{
/** Cache the services. */
- private Map services = new ConcurrentReaderHashMap();
+ private Map<String, Service> services = new ConcurrentReaderHashMap();
protected void createService() throws Exception
{
@@ -62,7 +63,7 @@
*/
protected abstract Object getStubFromService(Class serviceClass, Service service)
throws Exception;
- public Object getService(Class serviceClass) throws Exception
+ public <T extends Remote> T getService(Class<T> serviceClass) throws
Exception
{
if (serviceClass == null)
{
@@ -73,10 +74,10 @@
String key = serviceClass.getName();
// Get the cached service, it's ok because they are thread safe
- Service service = (Service)services.get(key);
+ Service service = services.get(key);
if (service == null)
{
- service = (Service)super.getService(serviceClass);
+ service = super.getServiceFor(serviceClass);
//
if (service != null)
@@ -89,7 +90,7 @@
// and must be customized for every request to this method.
if (service != null)
{
- return getStubFromService(serviceClass, service);
+ return ServiceWrapper.getServiceWrapper(serviceClass,
getStubFromService(serviceClass, service), this);
}
else
{
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -25,6 +25,7 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+import java.rmi.Remote;
import java.util.Map;
/**
@@ -38,12 +39,12 @@
{
/** . */
- private static final Map cache = new ConcurrentReaderHashMap();
+ private static final Map<String, Remote> cache = new ConcurrentReaderHashMap();
/** . */
private ServiceFactory delegate;
- public Object getService(Class clazz) throws Exception
+ public <T extends Remote> T getService(Class<T> clazz) throws Exception
{
if (delegate == null)
{
@@ -55,7 +56,7 @@
}
//
- Object service = cache.get(clazz.getName());
+ Remote service = cache.get(clazz.getName());
if (service == null)
{
service = delegate.getService(clazz);
@@ -64,7 +65,7 @@
cache.put(clazz.getName(), service);
}
}
- return service;
+ return (T)service;
}
public ServiceFactory getDelegate()
@@ -88,6 +89,14 @@
return delegate == null || delegate.isFailed();
}
+ public void setFailed(boolean failed)
+ {
+ if (delegate != null)
+ {
+ delegate.setFailed(failed);
+ }
+ }
+
public String getServiceDescriptionURL()
{
if (delegate != null)
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -0,0 +1,112 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.services;
+
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
+import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.InconsistentParametersFault;
+import org.jboss.portal.wsrp.core.InitCookie;
+import org.jboss.portal.wsrp.core.InvalidCookieFault;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.InvalidSessionFault;
+import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
+import org.jboss.portal.wsrp.core.MarkupResponse;
+import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
+import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
+import org.jboss.portal.wsrp.core.ReleaseSessions;
+import org.jboss.portal.wsrp.core.ReturnAny;
+import org.jboss.portal.wsrp.core.UnsupportedLocaleFault;
+import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
+import org.jboss.portal.wsrp.core.UnsupportedModeFault;
+import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
+import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class MarkupServiceWrapper extends ServiceWrapper<WSRP_v1_Markup_PortType>
implements WSRP_v1_Markup_PortType
+{
+ public MarkupServiceWrapper(Object service, ServiceFactory parentFactory)
+ {
+ super(service, parentFactory);
+ }
+
+ public MarkupResponse getMarkup(GetMarkup getMarkup) throws
UnsupportedWindowStateFault, InvalidCookieFault, InvalidSessionFault, AccessDeniedFault,
InconsistentParametersFault, InvalidHandleFault, UnsupportedLocaleFault,
UnsupportedModeFault, OperationFailedFault, MissingParametersFault,
InvalidUserCategoryFault, InvalidRegistrationFault, UnsupportedMimeTypeFault,
RemoteException
+ {
+ try
+ {
+ return service.getMarkup(getMarkup);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public BlockingInteractionResponse
performBlockingInteraction(PerformBlockingInteraction performBlockingInteraction) throws
InvalidSessionFault, UnsupportedModeFault, UnsupportedMimeTypeFault, OperationFailedFault,
UnsupportedWindowStateFault, UnsupportedLocaleFault, AccessDeniedFault,
PortletStateChangeRequiredFault, InvalidRegistrationFault, MissingParametersFault,
InvalidUserCategoryFault, InconsistentParametersFault, InvalidHandleFault,
InvalidCookieFault, RemoteException
+ {
+ try
+ {
+ return service.performBlockingInteraction(performBlockingInteraction);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public ReturnAny releaseSessions(ReleaseSessions releaseSessions) throws
InvalidRegistrationFault, OperationFailedFault, MissingParametersFault, AccessDeniedFault,
RemoteException
+ {
+ try
+ {
+ return service.releaseSessions(releaseSessions);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public ReturnAny initCookie(InitCookie initCookie) throws AccessDeniedFault,
OperationFailedFault, InvalidRegistrationFault, RemoteException
+ {
+ try
+ {
+ return service.initCookie(initCookie);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -0,0 +1,135 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.services;
+
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.ClonePortlet;
+import org.jboss.portal.wsrp.core.DestroyPortlets;
+import org.jboss.portal.wsrp.core.DestroyPortletsResponse;
+import org.jboss.portal.wsrp.core.GetPortletDescription;
+import org.jboss.portal.wsrp.core.GetPortletProperties;
+import org.jboss.portal.wsrp.core.GetPortletPropertyDescription;
+import org.jboss.portal.wsrp.core.InconsistentParametersFault;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
+import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PortletContext;
+import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
+import org.jboss.portal.wsrp.core.PropertyList;
+import org.jboss.portal.wsrp.core.SetPortletProperties;
+import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class PortletManagementServiceWrapper extends
ServiceWrapper<WSRP_v1_PortletManagement_PortType> implements
WSRP_v1_PortletManagement_PortType
+{
+ public PortletManagementServiceWrapper(Object service, ServiceFactory parentFactory)
+ {
+ super(service, parentFactory);
+ }
+
+ public PortletDescriptionResponse getPortletDescription(GetPortletDescription
getPortletDescription) throws AccessDeniedFault, InvalidHandleFault,
InvalidUserCategoryFault, InconsistentParametersFault, MissingParametersFault,
InvalidRegistrationFault, OperationFailedFault, RemoteException
+ {
+ try
+ {
+ return service.getPortletDescription(getPortletDescription);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public PortletContext clonePortlet(ClonePortlet clonePortlet) throws
InvalidUserCategoryFault, AccessDeniedFault, OperationFailedFault, InvalidHandleFault,
InvalidRegistrationFault, InconsistentParametersFault, MissingParametersFault,
RemoteException
+ {
+ try
+ {
+ return service.clonePortlet(clonePortlet);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws
InconsistentParametersFault, MissingParametersFault, InvalidRegistrationFault,
OperationFailedFault, RemoteException
+ {
+ try
+ {
+ return service.destroyPortlets(destroyPortlets);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public PortletContext setPortletProperties(SetPortletProperties setPortletProperties)
throws OperationFailedFault, InvalidHandleFault, MissingParametersFault,
InconsistentParametersFault, InvalidUserCategoryFault, AccessDeniedFault,
InvalidRegistrationFault, RemoteException
+ {
+ try
+ {
+ return service.setPortletProperties(setPortletProperties);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public PropertyList getPortletProperties(GetPortletProperties getPortletProperties)
throws InvalidHandleFault, MissingParametersFault, InvalidRegistrationFault,
AccessDeniedFault, OperationFailedFault, InconsistentParametersFault,
InvalidUserCategoryFault, RemoteException
+ {
+ try
+ {
+ return service.getPortletProperties(getPortletProperties);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public PortletPropertyDescriptionResponse
getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription)
throws MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault,
InvalidRegistrationFault, AccessDeniedFault, InvalidHandleFault, OperationFailedFault,
RemoteException
+ {
+ try
+ {
+ return service.getPortletPropertyDescription(getPortletPropertyDescription);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -0,0 +1,86 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.services;
+
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.ModifyRegistration;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.RegistrationContext;
+import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.core.RegistrationState;
+import org.jboss.portal.wsrp.core.ReturnAny;
+import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class RegistrationServiceWrapper extends
ServiceWrapper<WSRP_v1_Registration_PortType> implements
WSRP_v1_Registration_PortType
+{
+ public RegistrationServiceWrapper(Object service, ServiceFactory parentFactory)
+ {
+ super(service, parentFactory);
+ }
+
+ public RegistrationContext register(RegistrationData register) throws
MissingParametersFault, OperationFailedFault, RemoteException
+ {
+ try
+ {
+ return service.register(register);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public ReturnAny deregister(RegistrationContext deregister) throws
OperationFailedFault, InvalidRegistrationFault, RemoteException
+ {
+ try
+ {
+ return service.deregister(deregister);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+
+ public RegistrationState modifyRegistration(ModifyRegistration modifyRegistration)
throws MissingParametersFault, OperationFailedFault, InvalidRegistrationFault,
RemoteException
+ {
+ try
+ {
+ return service.modifyRegistration(modifyRegistration);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -64,7 +64,6 @@
private static final String BASE = "base"; // some WSDL use WSRPBaseService
instead of Markup
private static final String MANAGEMENT = "management";
private static final String REGISTRATION = "registration";
- private boolean available;
public String getWsdlDefinitionURL()
@@ -83,27 +82,24 @@
try
{
initServices();
- available = true;
- failed = false;
+ setFailed(false);
}
catch (MalformedURLException e)
{
- available = false;
- failed = true;
+ setFailed(true);
throw new IllegalArgumentException("Require a well-formed URL specifying
where to find the WSRP services definition", e);
}
catch (Exception e)
{
log.info("Couldn't access WSDL information. Service won't be
available", e);
- available = false;
- failed = true;
+ setFailed(true);
throw e;
}
}
public boolean isAvailable()
{
- return available && !failed;
+ return !failed;
}
private void initServices() throws MalformedURLException
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -0,0 +1,57 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.services;
+
+import org.jboss.portal.wsrp.core.GetServiceDescription;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.ServiceDescription;
+import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ServiceDescriptionServiceWrapper extends
ServiceWrapper<WSRP_v1_ServiceDescription_PortType> implements
WSRP_v1_ServiceDescription_PortType
+{
+
+ protected ServiceDescriptionServiceWrapper(Object service, ServiceFactory
parentFactory)
+ {
+ super(service, parentFactory);
+ }
+
+ public ServiceDescription getServiceDescription(GetServiceDescription
getServiceDescription) throws OperationFailedFault, InvalidRegistrationFault,
RemoteException
+ {
+ try
+ {
+ return service.getServiceDescription(getServiceDescription);
+ }
+ catch (RemoteException e)
+ {
+ handleRemoteException(e);
+ return null; // should not happen
+ }
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java 2008-07-15
23:42:02 UTC (rev 11460)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -24,6 +24,8 @@
import org.jboss.system.Service;
+import java.rmi.Remote;
+
/**
* A factory that gives access to remote services.
*
@@ -32,12 +34,14 @@
*/
public interface ServiceFactory extends Service
{
- Object getService(Class clazz) throws Exception;
+ <T extends Remote> T getService(Class<T> clazz) throws Exception;
boolean isAvailable();
boolean isFailed();
+ void setFailed(boolean failed);
+
String getServiceDescriptionURL();
String getMarkupURL();
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java 2008-07-15
23:56:13 UTC (rev 11461)
@@ -0,0 +1,104 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.services;
+
+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;
+import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
+
+import javax.xml.rpc.soap.SOAPFaultException;
+import java.lang.reflect.ParameterizedType;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Wraps endpoints to be able to intercept RemoteExceptions on WSRP calls and fail the
associated service factory if the
+ * error is not a business exception.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ServiceWrapper<T extends Remote>
+{
+ protected T service;
+ protected ServiceFactory parentFactory;
+
+ protected ServiceWrapper(Object service, ServiceFactory parentFactory)
+ {
+ if (service == null)
+ {
+ throw new IllegalArgumentException("Cannot create a ServiceWrapper without
a valid service!");
+ }
+
+ Class serviceClass = service.getClass();
+ Class tClass =
(Class)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
+ if (tClass.isAssignableFrom(serviceClass))
+ {
+ this.service = (T)service;
+ }
+ else
+ {
+ throw new IllegalArgumentException(service + " is not an instance of "
+ tClass.getSimpleName());
+ }
+ this.parentFactory = parentFactory;
+ }
+
+ public static <T extends Remote> T getServiceWrapper(Class<T>
expectedServiceInterface, Object service, ServiceFactory parentFactory)
+ {
+ ServiceWrapper wrapper;
+ if
(WSRP_v1_ServiceDescription_PortType.class.isAssignableFrom(expectedServiceInterface))
+ {
+ wrapper = new ServiceDescriptionServiceWrapper(service, parentFactory);
+ }
+ else if (WSRP_v1_Markup_PortType.class.isAssignableFrom(expectedServiceInterface))
+ {
+ wrapper = new MarkupServiceWrapper(service, parentFactory);
+ }
+ else if
(WSRP_v1_Registration_PortType.class.isAssignableFrom(expectedServiceInterface))
+ {
+ wrapper = new RegistrationServiceWrapper(service, parentFactory);
+ }
+ else if
(WSRP_v1_PortletManagement_PortType.class.isAssignableFrom(expectedServiceInterface))
+ {
+ wrapper = new PortletManagementServiceWrapper(service, parentFactory);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknow endpoint interface " +
expectedServiceInterface);
+ }
+
+ return (T)wrapper;
+ }
+
+ protected void handleRemoteException(RemoteException e) throws RemoteException
+ {
+ // if the remote exception happens to be a SOAPFaultException, this is a business
exception, do NOT fail the factory in this case
+ if (!(e.getCause() instanceof SOAPFaultException))
+ {
+ parentFactory.setFailed(true);
+ }
+
+ throw e;
+ }
+}