JBoss Portal SVN: r11490 - in branches/JBoss_Portal_Branch_2_6: cms/src/main/org/jboss/portal/cms/impl/jcr/ha and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-07-17 19:11:34 -0400 (Thu, 17 Jul 2008)
New Revision: 11490
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/ha/HAJCRCMS.java
branches/JBoss_Portal_Branch_2_6/core-cms/build.xml
Log:
JBPORTAL-2075 - CMS failure in jboss-portal-ha when LDAP is used for authentication
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2008-07-17 22:47:52 UTC (rev 11489)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2008-07-17 23:11:34 UTC (rev 11490)
@@ -577,6 +577,11 @@
JCRCMS.turnOffWorkflow();
clusterWorkflowStatus = true;
}
+ Boolean enableUISecurityFilter = (Boolean)propagatedContext.getClusterContextInfo("enableUISecurityFilter");
+ if(enableUISecurityFilter != null)
+ {
+ JCRCMS.enableUISecurityFilter();
+ }
}
// .... add new nodes & properties and save them
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/ha/HAJCRCMS.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/ha/HAJCRCMS.java 2008-07-17 22:47:52 UTC (rev 11489)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/ha/HAJCRCMS.java 2008-07-17 23:11:34 UTC (rev 11490)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.cms.impl.jcr.ha;
+import org.apache.log4j.Logger;
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.impl.jcr.JCRCMS;
@@ -40,6 +41,7 @@
*/
public class HAJCRCMS extends JCRCMS implements HASingletonInvoker.Callback
{
+ private static Logger log = Logger.getLogger(HAJCRCMS.class);
/** The invoker. */
private HASingletonInvoker invoker;
@@ -54,71 +56,118 @@
}
else
{
+ //Add the user Identity ThreadLocal variable to the Command Context for propagation to the Master Node
+ if (this.getUserInfo().get() != null)
+ {
+ User user = (User)this.getUserInfo().get();
+ JCRCommandContext context = this.getCommandContext((JCRCommand)cmd);
+ context.setClusterContextInfo("user", new CMSUser(user.getUserName()));
+ }
+
+ //Add the Workflow ThreadLocal variable to the Command Context for propagation to the Master Node
+ if (this.turnOffWorkflow.get() != null)
+ {
+ Boolean workflowStatus = (Boolean)this.turnOffWorkflow.get();
+ JCRCommandContext context = this.getCommandContext((JCRCommand)cmd);
+ context.setClusterContextInfo("workflowStatus", workflowStatus);
+ }
+
+ //Add the enableUISecurityFilter indicator to the Command Context for propagation to the Master Node
+ if(this.isUISecurityFilterActive())
+ {
+ JCRCommandContext context = this.getCommandContext((JCRCommand)cmd);
+ context.setClusterContextInfo("enableUISecurityFilter", Boolean.TRUE);
+ }
+
+ // Use the proxy to invoke on the singleton
+ Object returnValue = null;
try
{
- //Add the user Identity ThreadLocal variable to the Command Context for propagation to the Master Node
- if (this.getUserInfo().get() != null)
+ returnValue = invoker.invoke("execute", new Class[]{Command.class}, new Object[]{cmd});
+ if(returnValue instanceof CMSException)
{
- User user = (User)this.getUserInfo().get();
- JCRCommandContext context = (JCRCommandContext)((JCRCommand)cmd).getContext();
- if (context == null)
+ if(returnValue.toString().indexOf("Access to this resource is denied") != -1)
{
- context = new JCRCommandContext(null, null, null);
- ((JCRCommand)cmd).setContext(context);
+ throw (CMSException)returnValue;
}
- context.setClusterContextInfo("user", new CMSUser(user.getUserName()));
- }
-
- //Add the Workflow ThreadLocal variable to the Command Context for propagation to the Master Node
- if (this.turnOffWorkflow.get() != null)
- {
- Boolean workflowStatus = (Boolean)this.turnOffWorkflow.get();
- JCRCommandContext context = (JCRCommandContext)((JCRCommand)cmd).getContext();
- if (context == null)
+ else
{
- context = new JCRCommandContext(null, null, null);
- ((JCRCommand)cmd).setContext(context);
+ returnValue = null;
}
- context.setClusterContextInfo("workflowStatus", workflowStatus);
}
-
- // Use the proxy to invoke on the singleton
- return invoker.invoke("execute", new Class[]{Command.class}, new Object[]{cmd});
}
- catch (Exception e)
+ catch(Exception e)
{
- e.printStackTrace();
- throw new RuntimeException("Fixme bad contract", e);
+ if(e instanceof CMSException)
+ {
+ throw (CMSException)e;
+ }
+ else
+ {
+ throw new CMSException(e);
+ }
}
+
+ return returnValue;
}
}
+ /**
+ *
+ */
public void startService() throws Exception
{
// Do nothing
}
+ /**
+ *
+ */
public void stopService()
{
// Do nothing
}
+ /**
+ *
+ */
public void setInvoker(HASingletonInvoker invoker)
{
this.invoker = invoker;
}
+ /**
+ *
+ */
public Object invoke(String methodName, Class[] types, Object[] args) throws CMSException
{
- Command cmd = (Command)args[0];
- return super.execute(cmd);
+ Object result = null;
+ try
+ {
+ Command cmd = (Command)args[0];
+ result = super.execute(cmd);
+ }
+ catch(CMSException ce)
+ {
+ if (ce.toString().indexOf("Access to this resource is denied") != -1)
+ {
+ result = ce;
+ }
+ }
+ return result;
}
+ /**
+ *
+ */
public String getDisplayName()
{
return "HAJCRCMS";
}
+ /**
+ *
+ */
public void startSingleton()
{
try
@@ -127,12 +176,34 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ log.error(this, e);
}
}
+ /**
+ *
+ */
public void stopSingleton()
{
super.stopService();
}
+
+ /**
+ *
+ * @param command
+ * @return
+ */
+ private JCRCommandContext getCommandContext(JCRCommand command)
+ {
+ JCRCommandContext context = null;
+
+ context = (JCRCommandContext)((JCRCommand)command).getContext();
+ if (context == null)
+ {
+ context = new JCRCommandContext(null, null, null);
+ ((JCRCommand)command).setContext(context);
+ }
+
+ return context;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/build.xml 2008-07-17 22:47:52 UTC (rev 11489)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/build.xml 2008-07-17 23:11:34 UTC (rev 11490)
@@ -381,6 +381,10 @@
<copy todir="${jboss.home}/server/${portal-ha.deploy.dir}/jboss-portal-ha.sar/portal-cms-ha.sar" overwrite="true">
<fileset dir="${build.lib}/portal-cms-ha-exploded.sar"/>
</copy>
+ <require file="${jboss.home}/server/${portal-ha.node2.deploy.dir}"/>
+ <copy todir="${jboss.home}/server/${portal-ha.node2.deploy.dir}/jboss-portal-ha.sar/portal-cms-ha.sar" overwrite="true">
+ <fileset dir="${build.lib}/portal-cms-ha-exploded.sar"/>
+ </copy>
</target>
<!--
@@ -397,7 +401,7 @@
description="Undeploy."
depends="init">
<require file="${jboss.home}/server/${portal-ha.deploy.dir}"/>
- <delete file="${jboss.home}/server/${portal-ha.deploy.dir}/portal-cms-ha.sar"/>
+ <delete file="${jboss.home}/server/${portal-ha.deploy.dir}/portal-cms-ha.sar"/>
</target>
<target name="tests" depends="init, _buildmagic:configure:deployment">
15 years, 11 months
JBoss Portal SVN: r11489 - branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-17 18:47:52 -0400 (Thu, 17 Jul 2008)
New Revision: 11489
Modified:
branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml
Log:
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml 2008-07-17 22:46:55 UTC (rev 11488)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml 2008-07-17 22:47:52 UTC (rev 11489)
@@ -118,9 +118,9 @@
<server:start name="default"/>
<sequential>
<antcall target="agent-deploy"/>
- <antcall target="internal-test-module">
+ <!--antcall target="internal-test-module">
<param name="module" value="cms"/>
- </antcall>
+ </antcall-->
<antcall target="internal-test-module">
<param name="module" value="faces"/>
</antcall>
15 years, 11 months
JBoss Portal SVN: r11488 - in branches/JBoss_Portal_Branch_2_6_SYBASE: testsuite and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-17 18:46:55 -0400 (Thu, 17 Jul 2008)
New Revision: 11488
Modified:
branches/JBoss_Portal_Branch_2_6_SYBASE/core/build.xml
branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml
Log:
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/core/build.xml 2008-07-17 22:36:08 UTC (rev 11487)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/core/build.xml 2008-07-17 22:46:55 UTC (rev 11488)
@@ -635,10 +635,11 @@
<zest todir="${test.reports}" name="org.jboss.portal.test.core.state.RegistrationPersistenceManagerTestCase"
outfile="TEST-RegistrationPersistenceManagerTestCase">
</zest>
-
+ <!--
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.BackwardCompatibilityInstanceTestCase">
<parameter name="Config" value="backward-jboss-beans.xml"/>
</zest>
+ -->
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectPermissionTestCase"/>
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml 2008-07-17 22:36:08 UTC (rev 11487)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml 2008-07-17 22:46:55 UTC (rev 11488)
@@ -117,7 +117,7 @@
<target name="tests" depends="init">
<server:start name="default"/>
<sequential>
- <!--antcall target="agent-deploy"/>
+ <antcall target="agent-deploy"/>
<antcall target="internal-test-module">
<param name="module" value="cms"/>
</antcall>
@@ -132,15 +132,15 @@
</antcall>
<antcall target="internal-test-module">
<param name="module" value="server"/>
- </antcall-->
+ </antcall>
<!--
<antcall target="internal-test-module">
<param name="module" value="portlet-server"/>
</antcall>
-->
- <!--antcall target="internal-test-module">
+ <antcall target="internal-test-module">
<param name="module" value="wsrp"/>
- </antcall-->
+ </antcall>
<!--
<antcall target="internal-test-module">
<param name="module" value="theme"/>
@@ -149,9 +149,9 @@
<antcall target="internal-test-module">
<param name="module" value="core"/>
</antcall>
- <!--antcall target="internal-test-module">
+ <antcall target="internal-test-module">
<param name="module" value="widget"/>
- </antcall-->
+ </antcall>
<antcall target="agent-undeploy"/>
</sequential>
<server:stop name="default"/>
15 years, 11 months
JBoss Portal SVN: r11487 - modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/shoppingcart.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-07-17 18:36:08 -0400 (Thu, 17 Jul 2008)
New Revision: 11487
Modified:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/shoppingcart/CartPortlet.java
Log:
make CartPortlet use session to store items
Modified: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/shoppingcart/CartPortlet.java
===================================================================
--- modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/shoppingcart/CartPortlet.java 2008-07-17 22:22:14 UTC (rev 11486)
+++ modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/shoppingcart/CartPortlet.java 2008-07-17 22:36:08 UTC (rev 11487)
@@ -30,6 +30,7 @@
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.PortletSession;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
@@ -41,7 +42,7 @@
*/
public class CartPortlet extends GenericPortlet
{
- List<CatalogItem> items = new ArrayList<CatalogItem>(7);
+ public static final String ITEMS = "cart_items";
@Override
protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException
@@ -49,6 +50,7 @@
renderResponse.setContentType("text/html");
Writer writer = renderResponse.getWriter();
+ List<CatalogItem> items = getItems(renderRequest.getPortletSession());
if (!items.isEmpty())
{
@@ -73,11 +75,28 @@
@Override
public void processEvent(EventRequest eventRequest, EventResponse eventResponse) throws PortletException, IOException
{
+ List<CatalogItem> items = getItems(eventRequest.getPortletSession());
+
Event event = eventRequest.getEvent();
if (event.getName().equals("CartEvent"))
{
CartEvent cartEvent = (CartEvent)event.getValue();
items.add(Catalog.get(cartEvent.getId()));
}
+
+ eventRequest.getPortletSession().setAttribute(ITEMS, items);
}
+
+ private List<CatalogItem> getItems(PortletSession session)
+ {
+ List<CatalogItem> items = (List<CatalogItem>)session.getAttribute(ITEMS);
+ if (items == null)
+ {
+ items = new ArrayList<CatalogItem>(7);
+ }
+ return items;
+ }
+
+
+
}
15 years, 11 months
JBoss Portal SVN: r11486 - branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-17 18:22:14 -0400 (Thu, 17 Jul 2008)
New Revision: 11486
Modified:
branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
Log:
One more test
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java 2008-07-17 21:38:51 UTC (rev 11485)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java 2008-07-17 22:22:14 UTC (rev 11486)
@@ -49,13 +49,13 @@
public Object fromString(String name)
{
log.info("fromString: [" + name + "]");
- return PortalObjectId.parse(name, PortalObjectPath.LEGACY_FORMAT);
+ return PortalObjectId.parse(name.trim(), PortalObjectPath.LEGACY_FORMAT);
}
public String toString(Object value)
{
log.info("fromString: [" + ((PortalObjectId)value).toString(PortalObjectPath.LEGACY_FORMAT) + "]");
- return ((PortalObjectId)value).toString(PortalObjectPath.LEGACY_FORMAT);
+ return ((PortalObjectId)value).toString(PortalObjectPath.LEGACY_FORMAT).trim();
}
public Class returnedClass()
15 years, 11 months
JBoss Portal SVN: r11485 - in branches/JBoss_Portal_Branch_2_6_SYBASE: testsuite and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-17 17:38:51 -0400 (Thu, 17 Jul 2008)
New Revision: 11485
Modified:
branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml
branches/JBoss_Portal_Branch_2_6_SYBASE/workflow/src/resources/test/conf/hibernate.cfg.xml
Log:
test
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java 2008-07-17 21:23:31 UTC (rev 11484)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java 2008-07-17 21:38:51 UTC (rev 11485)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.portal;
-import java.util.logging.Logger;
+import org.jboss.logging.Logger;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPath;
@@ -38,11 +38,11 @@
/** . */
private static final PortalObjectId EMPTY = new PortalObjectId("", PortalObjectPath.ROOT_PATH);
- Logger log = Logger.getLogger(PortalObjectIdUserType.class.getCanonicalName());
+ Logger log = Logger.getLogger(PortalObjectIdUserType.class);
public Object fromNull()
{
- log.info("fromNull");
+ log.info("fromNull");
return EMPTY;
}
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml 2008-07-17 21:23:31 UTC (rev 11484)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/testsuite/build.xml 2008-07-17 21:38:51 UTC (rev 11485)
@@ -117,7 +117,7 @@
<target name="tests" depends="init">
<server:start name="default"/>
<sequential>
- <antcall target="agent-deploy"/>
+ <!--antcall target="agent-deploy"/>
<antcall target="internal-test-module">
<param name="module" value="cms"/>
</antcall>
@@ -132,15 +132,15 @@
</antcall>
<antcall target="internal-test-module">
<param name="module" value="server"/>
- </antcall>
+ </antcall-->
<!--
<antcall target="internal-test-module">
<param name="module" value="portlet-server"/>
</antcall>
-->
- <antcall target="internal-test-module">
+ <!--antcall target="internal-test-module">
<param name="module" value="wsrp"/>
- </antcall>
+ </antcall-->
<!--
<antcall target="internal-test-module">
<param name="module" value="theme"/>
@@ -149,9 +149,9 @@
<antcall target="internal-test-module">
<param name="module" value="core"/>
</antcall>
- <antcall target="internal-test-module">
+ <!--antcall target="internal-test-module">
<param name="module" value="widget"/>
- </antcall>
+ </antcall-->
<antcall target="agent-undeploy"/>
</sequential>
<server:stop name="default"/>
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/workflow/src/resources/test/conf/hibernate.cfg.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/workflow/src/resources/test/conf/hibernate.cfg.xml 2008-07-17 21:23:31 UTC (rev 11484)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/workflow/src/resources/test/conf/hibernate.cfg.xml 2008-07-17 21:38:51 UTC (rev 11485)
@@ -8,7 +8,6 @@
<session-factory>
<!-- jdbc connection properties -->
- <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:mem:.;sql.enforce_strict_size=true</property>
<property name="hibernate.connection.username">sa</property>
15 years, 11 months
JBoss Portal SVN: r11484 - in branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp: services and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-17 17:23:31 -0400 (Thu, 17 Jul 2008)
New Revision: 11484
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java
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/ProducerInfo.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/MarkupServiceWrapper.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.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/RemoteSOAPInvokerServiceFactory.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/ServiceFactory.java
branches/JBoss_Portal_Branch_2_7/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_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-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_7/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ManageableServiceFactory.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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 2008-07-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/MarkupServiceWrapper.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_7/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2008-07-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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 2008-07-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/PortletManagementServiceWrapper.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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 2008-07-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RegistrationServiceWrapper.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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 2008-07-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceDescriptionServiceWrapper.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceFactory.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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_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 2008-07-17 21:23:08 UTC (rev 11483)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java 2008-07-17 21:23:31 UTC (rev 11484)
@@ -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;
15 years, 11 months
JBoss Portal SVN: r11483 - in branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp: services and 1 other directory.
by portal-commits@lists.jboss.org
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;
15 years, 11 months
JBoss Portal SVN: r11482 - in modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src: test/java/org/jboss/portal/test/common and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-17 16:53:57 -0400 (Thu, 17 Jul 2008)
New Revision: 11482
Modified:
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
Log:
- Fixed a bug where overriden setters and getters would be improperly detected as duplicated methods.
- Added more tests.
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java 2008-07-17 20:48:39 UTC (rev 11481)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java 2008-07-17 20:53:57 UTC (rev 11482)
@@ -22,6 +22,13 @@
******************************************************************************/
package org.jboss.portal.common.mx;
+import javax.management.Descriptor;
+import javax.management.modelmbean.ModelMBeanAttributeInfo;
+import javax.management.modelmbean.ModelMBeanConstructorInfo;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.ModelMBeanInfoSupport;
+import javax.management.modelmbean.ModelMBeanNotificationInfo;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -31,14 +38,6 @@
import java.util.Map;
import java.util.Set;
-import javax.management.Descriptor;
-import javax.management.modelmbean.ModelMBeanAttributeInfo;
-import javax.management.modelmbean.ModelMBeanConstructorInfo;
-import javax.management.modelmbean.ModelMBeanInfo;
-import javax.management.modelmbean.ModelMBeanInfoSupport;
-import javax.management.modelmbean.ModelMBeanNotificationInfo;
-import javax.management.modelmbean.ModelMBeanOperationInfo;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -46,7 +45,7 @@
* @version $Revision: 7452 $
*/
public class JavaBeanModelMBeanBuilder
-{
+{
private final static String CURRENCY_TIME_LIMIT = "currencyTimeLimit";
private final static String GET_METHOD = "getMethod";
private final static String SET_METHOD = "setMethod";
@@ -56,6 +55,9 @@
private ArrayList mmais;
private ArrayList mmois;
private String className;
+ private static final String GET = "get";
+ private static final String IS = "is";
+ private static final String SET = "set";
public JavaBeanModelMBeanBuilder(Class from, Class to) throws Exception
{
@@ -87,119 +89,49 @@
//
for (Class c = from;c != null && !c.equals(to);c = c.getSuperclass())
{
- Map currentClassGetters = new HashMap();
- Map currentClassSetters = new HashMap();
+ Map<String,Method> currentClassGetters = new HashMap<String, Method>();
+ Map<String, Method> currentClassSetters = new HashMap<String, Method>();
Method[] methods = c.getDeclaredMethods();
- for (int i = 0; i < methods.length; i++)
+ for (Method method : methods)
{
- Method method = methods[i];
int modifiers = method.getModifiers();
if (Modifier.isPublic(modifiers) &&
- !Modifier.isAbstract(modifiers) &&
- !Modifier.isStatic(modifiers))
+ !Modifier.isAbstract(modifiers) &&
+ !Modifier.isStatic(modifiers))
{
String methodName = method.getName();
Class returnType = method.getReturnType();
Class[] parameterTypes = method.getParameterTypes();
- if (methodName.startsWith("get") &&
- !void.class.equals(returnType) &&
- parameterTypes.length == 0 &&
- methodName.length() > 3)
- {
- String propertyName = methodName.substring(3);
- // Try to locate an existing setter for the same property
- Method beanSetter = (Method)currentClassSetters.get(propertyName);
- if (beanSetter == null)
- {
- beanSetter = (Method)beanSetters.get(propertyName);
- }
-
- // Check we do not have a setter with a different return type
- if (beanSetter != null && !beanSetter.getParameterTypes()[0].equals(returnType))
- {
- throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
- " type " + beanSetter.getParameterTypes()[0] + " different from the corresponding" +
- " getter type " + returnType);
- }
-
- // Get an existing bean getter
- Method beanGetter = (Method)currentClassGetters.get(propertyName);
- if (beanGetter != null)
- {
- throw new IllegalArgumentException("Property " + propertyName + " has two getters " +
- beanGetter + " and " + method);
- }
-
- //
- currentClassGetters.put(propertyName, method);
- }
- else if (methodName.startsWith("is") &&
- !void.class.equals(returnType) &&
- parameterTypes.length == 0 &&
- methodName.length() > 2)
+ int prefixLength = 0;
+ boolean isPotentialGetter = false;
+ if(methodName.startsWith(GET))
{
- String propertyName = methodName.substring(2);
-
- // Try to locate an existing setter for the same property
- Method beanSetter = (Method)beanSetters.get(propertyName);
- if (beanSetter != null)
- {
- beanSetter = (Method)currentClassSetters.get(propertyName);
- }
-
- // Check we do not have a setter with a different return type
- if (beanSetter != null && !beanSetter.getParameterTypes()[0].equals(returnType))
- {
- throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
- " type " + beanSetter.getParameterTypes()[0] + " different from the corresponding" +
- " getter type " + returnType);
- }
-
- // Get an existing getter
- Method beanGetter = (Method)beanGetters.get(propertyName);
- if (beanGetter != null)
- {
- throw new IllegalArgumentException("Property " + propertyName + " has two getters " +
- beanGetter + " and " + method);
- }
-
- //
- currentClassGetters.put(propertyName, method);
+ prefixLength = 3;
+ isPotentialGetter = true;
}
- else if (methodName.startsWith("set") &&
- void.class.equals(returnType) &&
- parameterTypes.length == 1 &&
- methodName.length() > 3)
+ else if(methodName.startsWith(IS))
{
- String propertyName = methodName.substring(3);
+ prefixLength = 2;
+ isPotentialGetter = true;
+ } else if (methodName.startsWith(SET))
+ {
+ prefixLength = 3;
+ }
- // Try to locate an existing getter
- Method beanGetter = (Method)beanGetters.get(propertyName);
- if (beanGetter == null)
+ if (methodName.length() > prefixLength)
+ {
+ if (isPotentialGetter && !void.class.equals(returnType) && parameterTypes.length == 0)
{
- beanGetter = (Method)currentClassGetters.get(propertyName);
+ processPropertyOperation(method, currentClassGetters, currentClassSetters, beanSetters,
+ prefixLength, false);
}
-
- // Check we do not have a getter with a different return type
- if (beanGetter != null && !beanGetter.getReturnType().equals(parameterTypes[0]))
+ else if (methodName.startsWith(SET) && void.class.equals(returnType) && parameterTypes.length == 1)
{
- throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
- " type " + parameterTypes[0] + " different from the corresponding" +
- " getter type " + beanGetter.getReturnType());
+ processPropertyOperation(method, currentClassSetters, currentClassGetters, beanGetters,
+ prefixLength, true);
}
-
- // Get an existing setter
- Method beanSetter = (Method)beanSetters.get(propertyName);
- if (beanSetter != null)
- {
- throw new IllegalArgumentException("Property " + propertyName + " cannot have two setters " +
- beanSetter + " and " + method);
- }
-
- //
- currentClassSetters.put(propertyName, method);
}
//
@@ -283,6 +215,63 @@
}
/**
+ * Process a property operation either setter or getter, checking for consistency. "Reverse" operation is defined here
+ * as a setter for a getter operation, and a getter for a setter operation.
+ * Hence, if we are currently checking a getter, <code>beanReverseOperations</code> will refer to known setters so far,
+ * <code>currentClassOperations</code> to the already known getter for this class at this hierachical level,
+ * <code>currentClassReverseOperations</code> to the already known setter for this class at this hierachical level.
+ *
+ * @param operation
+ * @param currentClassOperations known property operations for the hierarchy level being currently examined
+ * @param currentClassReverseOperations known property "reverse" operations for the hierarchy level being currently examined
+ * @param beanReverseOperations known "reverse" property operations for this bean
+ * @param prefixLength
+ * @param isSetter
+ */
+ private void processPropertyOperation(Method operation, Map<String, Method> currentClassOperations,
+ Map<String, Method> currentClassReverseOperations, Map beanReverseOperations,
+ int prefixLength, boolean isSetter)
+ {
+ String propertyName = operation.getName().substring(prefixLength);
+
+ // Try to locate an existing setter for the same property
+ Method reverseOp = currentClassReverseOperations.get(propertyName);
+ if (reverseOp == null)
+ {
+ reverseOp = (Method)beanReverseOperations.get(propertyName);
+ }
+
+ // check that if we know a reverse operation, the types match
+ if (reverseOp != null)
+ {
+ Class opType = isSetter ? operation.getParameterTypes()[0] : operation.getReturnType();
+ Class reverseOpType = isSetter ? reverseOp.getReturnType() : reverseOp.getParameterTypes()[0];
+ if (!reverseOpType.equals(opType))
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has a " + getterOrSetter(isSetter) +
+ " type " + reverseOpType + " different from the corresponding " + getterOrSetter(!isSetter) +
+ " type " + opType);
+ }
+ }
+
+ // Check that we don't have twice the same operation
+ Method op = currentClassOperations.get(propertyName);
+ if (op != null)
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has two " + getterOrSetter(isSetter) + "s " +
+ op + " and " + operation);
+ }
+
+ //
+ currentClassOperations.put(propertyName, operation);
+ }
+
+ private String getterOrSetter(boolean isSetter)
+ {
+ return isSetter ? "setter" : "getter";
+ }
+
+ /**
* Remove an interface from the management interface.
*/
public void remove(Class itf)
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java 2008-07-17 20:48:39 UTC (rev 11481)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java 2008-07-17 20:53:57 UTC (rev 11482)
@@ -25,20 +25,20 @@
import junit.framework.TestCase;
import org.jboss.portal.common.mx.JavaBeanModelMBeanBuilder;
+import javax.management.Attribute;
import javax.management.AttributeNotFoundException;
+import javax.management.Descriptor;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
-import javax.management.Attribute;
-import javax.management.Descriptor;
import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
import javax.management.modelmbean.RequiredModelMBean;
-import javax.management.modelmbean.ModelMBeanOperationInfo;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import java.util.Arrays;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -131,10 +131,26 @@
Set ops = getOperations(info);
Set expectedOps = new HashSet();
expectedOps.add(TestOperation.newGetter("getTest", "java.util.Set"));
+ expectedOps.add(TestOperation.newGetter("isSet", "boolean"));
+ expectedOps.add(TestOperation.newSetter("setSet", "boolean"));
+ expectedOps.add(TestOperation.newSetter("setFoo", "java.lang.String"));
assertEquals(expectedOps, ops);
}
+ public void testMismatchedPropertyOperations()
+ {
+ try
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(TestMismatchedSetterGetter.class, Object.class);
+ fail();
+ }
+ catch (Exception expected)
+ {
+ // expected
+ }
+ }
+
public void testAttributesAreNotCached() throws Exception
{
AttributesAreNotCached aanc = new AttributesAreNotCached();
@@ -337,6 +353,21 @@
//nothing
return new HashSet();
}
+
+ public boolean isSet()
+ {
+ return false;
+ }
+
+ public void setSet(boolean set)
+ {
+ // nothing
+ }
+
+ public void setFoo(String foo)
+ {
+ // nothing
+ }
}
public class TestOverridenExtend extends TestOverridenBase
@@ -346,8 +377,31 @@
//nothing
return new HashSet();
}
+
+ public boolean isSet()
+ {
+ return true;
+ }
+
+ public void setFoo(String foo)
+ {
+ // nothing
+ }
}
+ public class TestMismatchedSetterGetter
+ {
+ public void setFoo(String foo)
+ {
+ // nothing
+ }
+
+ public boolean getFoo()
+ {
+ return false;
+ }
+ }
+
public static class TestAttribute
{
15 years, 11 months
JBoss Portal SVN: r11481 - branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-17 16:48:39 -0400 (Thu, 17 Jul 2008)
New Revision: 11481
Modified:
branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
Log:
adding logging info
Modified: branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java 2008-07-17 20:03:45 UTC (rev 11480)
+++ branches/JBoss_Portal_Branch_2_6_SYBASE/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java 2008-07-17 20:48:39 UTC (rev 11481)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.portal;
+import java.util.logging.Logger;
+
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.jems.hibernate.StringWrapperUserType;
@@ -35,20 +37,25 @@
/** . */
private static final PortalObjectId EMPTY = new PortalObjectId("", PortalObjectPath.ROOT_PATH);
+
+ Logger log = Logger.getLogger(PortalObjectIdUserType.class.getCanonicalName());
public Object fromNull()
{
+ log.info("fromNull");
return EMPTY;
}
public Object fromString(String name)
{
+ log.info("fromString: [" + name + "]");
return PortalObjectId.parse(name, PortalObjectPath.LEGACY_FORMAT);
}
public String toString(Object value)
{
- return ((PortalObjectId)value).toString(PortalObjectPath.LEGACY_FORMAT).trim();
+ log.info("fromString: [" + ((PortalObjectId)value).toString(PortalObjectPath.LEGACY_FORMAT) + "]");
+ return ((PortalObjectId)value).toString(PortalObjectPath.LEGACY_FORMAT);
}
public Class returnedClass()
15 years, 11 months