Author: chris.laprun(a)jboss.com
Date: 2008-07-17 17:23:08 -0400 (Thu, 17 Jul 2008)
New Revision: 11483
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java
Log:
- JBPORTAL-1726: improved recovery on error, better management of service factories.
- Tests are broken pending common and test module updates.
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -332,7 +332,10 @@
public void stop() throws Exception
{
- getServiceFactory().stop();
+ if (serviceFactory != null)
+ {
+ serviceFactory.stop();
+ }
}
// todo: public for tests
@@ -449,11 +452,16 @@
{
if (isRefreshNeeded())
{
- initServiceFactoryIfNeeded();
- refreshServices();
+ forceRefresh();
}
}
+ void forceRefresh() throws InvokerUnavailableException
+ {
+ initServiceFactoryIfNeeded();
+ refreshServices();
+ }
+
private void refreshServices() throws InvokerUnavailableException
{
if (areURLsDirty())
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -311,12 +311,18 @@
}
catch (InvokerUnavailableException e)
{
- log.debug("Couldn't refresh endpoint information: " + e);
+ log.debug("Couldn't refresh endpoint information, attempting a
second time: " + e);
+
+ // try again as refresh on a failed service factory will fail without
attempting the refresh
+ persistentEndpointInfo.forceRefresh();
// todo: should we fail fast here?
-// throw new PortletInvokerException("Couldn't refresh endpoint
information: " + e.getLocalizedMessage());
+ // throw new PortletInvokerException("Couldn't refresh endpoint
information: " + e.getLocalizedMessage());
}
- // save changes to endpoint
- registry.updateProducerInfo(this);
+ finally
+ {
+ // save changes to endpoint
+ registry.updateProducerInfo(this);
+ }
// get the service description from the producer
try
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -42,7 +42,7 @@
* @noinspection ALL
* @since 2.4
*/
-public abstract class AbstractJNDIServiceFactory extends AbstractJBossService implements
ServiceFactory
+public abstract class AbstractJNDIServiceFactory extends AbstractJBossService implements
ManageableServiceFactory
{
/** The logger. */
@@ -54,9 +54,12 @@
/** Default mapping between WSRP port type class and associated JNDI name */
private static Properties DEFAULT_FACTORY_MAPPING;
- /** Wheter or not this ServiceFactory has an error condition */
+ /** Whether or not this ServiceFactory has an unrecoverable error condition */
protected boolean failed = false;
+ /** Whether or not this ServiceFactory is availble to provide services */
+ protected boolean available = true;
+
static
{
// fix-me: this is hardcoded from values from
portal-wsrp-client.jar/META-INF/jboss-client.xml... NOT GOOD!
@@ -120,6 +123,7 @@
String key = serviceClass.getName();
if (!portJNDIMapping.containsKey(key))
{
+ setFailed(true);
throw new IllegalArgumentException("Unknown service class: " + key);
}
@@ -127,6 +131,7 @@
log.debug("Looking up service for class " + key + " using JNDI name
" + jndiName);
if (jndiName == null)
{
+ setFailed(true);
throw new IllegalArgumentException("No such service " +
serviceClass);
}
@@ -169,6 +174,16 @@
this.failed = failed;
}
+ public boolean isAvailable()
+ {
+ return available && !failed;
+ }
+
+ public void setAvailable(boolean available)
+ {
+ this.available = available;
+ }
+
public Properties getPortJNDIMapping()
{
return portJNDIMapping;
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -40,11 +40,6 @@
/** Cache the services. */
private Map<String, Service> services = new ConcurrentReaderHashMap();
- protected void createService() throws Exception
- {
- super.createService();
- }
-
protected void destroyService() throws Exception
{
services = null;
@@ -90,7 +85,13 @@
// and must be customized for every request to this method.
if (service != null)
{
- return ServiceWrapper.getServiceWrapper(serviceClass,
getStubFromService(serviceClass, service), this);
+ T result = ServiceWrapper.getServiceWrapper(serviceClass,
getStubFromService(serviceClass, service), this);
+
+ // if we managed to retrieve a service, we're probably available
+ setFailed(false);
+ setAvailable(true);
+
+ return result;
}
else
{
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -35,14 +35,14 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class CachingServiceFactory extends AbstractJBossService implements
ServiceFactory
+public class CachingServiceFactory extends AbstractJBossService implements
ManageableServiceFactory
{
/** . */
private static final Map<String, Remote> cache = new ConcurrentReaderHashMap();
/** . */
- private ServiceFactory delegate;
+ private ManageableServiceFactory delegate;
public <T extends Remote> T getService(Class<T> clazz) throws Exception
{
@@ -73,7 +73,7 @@
return delegate;
}
- public void setDelegate(ServiceFactory delegate)
+ public void setDelegate(ManageableServiceFactory delegate)
{
this.delegate = delegate;
}
@@ -97,6 +97,14 @@
}
}
+ public void setAvailable(boolean available)
+ {
+ if(delegate != null)
+ {
+ delegate.setAvailable(available);
+ }
+ }
+
public String getServiceDescriptionURL()
{
if (delegate != null)
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -0,0 +1,34 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+interface ManageableServiceFactory extends ServiceFactory
+{
+ void setFailed(boolean failed);
+
+ void setAvailable(boolean available);
+}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -51,9 +51,9 @@
* @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
+class MarkupServiceWrapper extends ServiceWrapper<WSRP_v1_Markup_PortType>
implements WSRP_v1_Markup_PortType
{
- public MarkupServiceWrapper(Object service, ServiceFactory parentFactory)
+ public MarkupServiceWrapper(Object service, ManageableServiceFactory parentFactory)
{
super(service, parentFactory);
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -62,6 +62,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(serviceDescriptionURL,
"Mandatory Service Description interface", null);
this.serviceDescriptionURL = serviceDescriptionURL;
+ setFailed(false); // reset failed status to false since we can't assert it
anymore
}
public String getMarkupURL()
@@ -73,6 +74,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(markupURL,
"Mandatory Markup interface", null);
this.markupURL = markupURL;
+ setFailed(false); // reset failed status to false since we can't assert it
anymore
}
public String getRegistrationURL()
@@ -83,6 +85,7 @@
public void setRegistrationURL(String registrationURL)
{
this.registrationURL = registrationURL;
+ setFailed(false); // reset failed status to false since we can't assert it
anymore
}
public String getPortletManagementURL()
@@ -93,6 +96,7 @@
public void setPortletManagementURL(String portletManagementURL)
{
this.portletManagementURL = portletManagementURL;
+ setFailed(false); // reset failed status to false since we can't assert it
anymore
}
/** If retrieve object is of javax.xml.rpc.Service class, we're using the WS stack
and we need to get the port. */
@@ -133,6 +137,7 @@
{
if (isMandatoryInterface)
{
+ setFailed(true);
throw new IllegalStateException("Mandatory interface URLs were not
properly initialized: no proper service URL for "
+ serviceClass.getName());
}
@@ -150,6 +155,7 @@
public boolean isAvailable()
{
- return !failed &&
!EndpointConfigurationInfo.UNSET.equals(serviceDescriptionURL) &&
!EndpointConfigurationInfo.UNSET.equals(markupURL);
+ return super.isAvailable() &&
!EndpointConfigurationInfo.UNSET.equals(serviceDescriptionURL)
+ && !EndpointConfigurationInfo.UNSET.equals(markupURL);
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -48,9 +48,9 @@
* @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
+class PortletManagementServiceWrapper extends
ServiceWrapper<WSRP_v1_PortletManagement_PortType> implements
WSRP_v1_PortletManagement_PortType
{
- public PortletManagementServiceWrapper(Object service, ServiceFactory parentFactory)
+ public PortletManagementServiceWrapper(Object service, ManageableServiceFactory
parentFactory)
{
super(service, parentFactory);
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -38,9 +38,9 @@
* @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
+class RegistrationServiceWrapper extends
ServiceWrapper<WSRP_v1_Registration_PortType> implements
WSRP_v1_Registration_PortType
{
- public RegistrationServiceWrapper(Object service, ServiceFactory parentFactory)
+ public RegistrationServiceWrapper(Object service, ManageableServiceFactory
parentFactory)
{
super(service, parentFactory);
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -92,16 +92,11 @@
catch (Exception e)
{
log.info("Couldn't access WSDL information. Service won't be
available", e);
- setFailed(true);
+ setAvailable(false);
throw e;
}
- }
+ }
- public boolean isAvailable()
- {
- return !failed;
- }
-
private void initServices() throws MalformedURLException
{
try
@@ -111,9 +106,9 @@
Definition def = getWSDLDefinition(wsdlURL);
javax.wsdl.Service serve = def.getService(new QName(WSRP_URN,
DEFAULT_SERVICE_NAME));
Collection ports = serve.getPorts().values();
- for (Iterator iterator = ports.iterator(); iterator.hasNext();)
+ for (Object o : ports)
{
- Port port = (Port)iterator.next();
+ Port port = (Port)o;
initServiceURL(port.getName(), getLocation(port));
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -34,10 +34,10 @@
* @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
+class ServiceDescriptionServiceWrapper extends
ServiceWrapper<WSRP_v1_ServiceDescription_PortType> implements
WSRP_v1_ServiceDescription_PortType
{
- protected ServiceDescriptionServiceWrapper(Object service, ServiceFactory
parentFactory)
+ protected ServiceDescriptionServiceWrapper(Object service, ManageableServiceFactory
parentFactory)
{
super(service, parentFactory);
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -36,12 +36,24 @@
{
<T extends Remote> T getService(Class<T> clazz) throws Exception;
+ /**
+ * Determines whether or not this ServiceFactory is able to provide services. A
non-available ServiceFactory might be
+ * in a temporary state of non-availability (e.g. if the remote host is not currently
reachable) or permanently
+ * (because, e.g. its configuration is invalid). Permanent failure is indicated by
{@link #isFailed()} status.
+ *
+ * @return <code>true</code> if this ServiceFactory is ready to provide
services, <code>false</code> otherwise.
+ */
boolean isAvailable();
+ /**
+ * Determines whether or not this ServiceFactory is in a permanent state of failure
which cannot be recovered from
+ * without user intervention. This notably happens if the configuration is incorrect
(i.e. remote host URLs are
+ * invalid).
+ *
+ * @return <code>true</code> if this ServiceFactory is not configured
properly, <code>false</code> otherwise.
+ */
boolean isFailed();
- void setFailed(boolean failed);
-
String getServiceDescriptionURL();
String getMarkupURL();
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java 2008-07-17
20:53:57 UTC (rev 11482)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java 2008-07-17
21:23:08 UTC (rev 11483)
@@ -39,12 +39,12 @@
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
*/
-public class ServiceWrapper<T extends Remote>
+class ServiceWrapper<T extends Remote>
{
protected T service;
- protected ServiceFactory parentFactory;
+ protected ManageableServiceFactory parentFactory;
- protected ServiceWrapper(Object service, ServiceFactory parentFactory)
+ protected ServiceWrapper(Object service, ManageableServiceFactory parentFactory)
{
if (service == null)
{
@@ -64,7 +64,7 @@
this.parentFactory = parentFactory;
}
- public static <T extends Remote> T getServiceWrapper(Class<T>
expectedServiceInterface, Object service, ServiceFactory parentFactory)
+ public static <T extends Remote> T getServiceWrapper(Class<T>
expectedServiceInterface, Object service, ManageableServiceFactory parentFactory)
{
ServiceWrapper wrapper;
if
(WSRP_v1_ServiceDescription_PortType.class.isAssignableFrom(expectedServiceInterface))
@@ -96,7 +96,7 @@
// 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);
+ parentFactory.setAvailable(false);
}
throw e;