Author: chris.laprun(a)jboss.com
Date: 2010-10-06 09:47:55 -0400 (Wed, 06 Oct 2010)
New Revision: 4539
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/MarkupService.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1MarkupService.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java
Log:
- GTNWSRP-85: Changed implementation of isUsingWSRP2 method so that it doesn't depend
on the MarkupService but rather is determined by the underlying ServiceFactory which
should prevent unneeded refreshes (and associated side-effects such as automatic
registration).
- ServiceFactory now provides a getWSRPVersion method.
- Removed getVersion method on MarkupService.
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -24,6 +24,7 @@
package org.gatein.wsrp.consumer;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.common.util.Version;
import org.gatein.pc.api.InvokerUnavailableException;
import org.gatein.wsrp.services.MarkupService;
import org.gatein.wsrp.services.PortletManagementService;
@@ -233,4 +234,9 @@
{
return serviceFactory.getWSOperationTimeOut();
}
+
+ Version getWSRPVersion()
+ {
+ return serviceFactory.getWSRPVersion();
+ }
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -25,6 +25,7 @@
import org.gatein.common.NotYetImplemented;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.common.util.Version;
import org.gatein.pc.api.InvalidPortletIdException;
import org.gatein.pc.api.InvokerUnavailableException;
import org.gatein.pc.api.NoSuchPortletException;
@@ -989,13 +990,13 @@
public boolean isUsingWSRP2()
{
- try
+ Version wsrpVersion = getWSRPVersion();
+ if (wsrpVersion != null)
{
- return getMarkupService().getVersion() > 1;
+ return wsrpVersion.getMajor() >= 2;
}
- catch (PortletInvokerException e)
+ else
{
- log.debug("Couldn't determine WSRP version supported by this
Consumer", e);
return false;
}
}
@@ -1004,4 +1005,9 @@
{
return migrationService;
}
+
+ public Version getWSRPVersion()
+ {
+ return producerInfo.getEndpointConfigurationInfo().getWSRPVersion();
+ }
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -97,8 +97,7 @@
String preferOperationAsString =
resourceMap.get(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION);
boolean preferOperation = (preferOperationAsString != null &&
Boolean.parseBoolean(preferOperationAsString));
- int version = consumer.getMarkupService().getVersion();
- if (version == 2 && (preferOperation || resourceURL == null ||
(resourceId != null && resourceId.length() > 0)))
+ if (consumer.isUsingWSRP2() && (preferOperation || resourceURL == null
|| (resourceId != null && resourceId.length() > 0)))
{
handler = resourceHandler;
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/MarkupService.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/MarkupService.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/MarkupService.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -1,24 +1,25 @@
/*
-* 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.wsrp.services;
@@ -136,6 +137,4 @@
UserContext userContext)
throws AccessDenied, InvalidRegistration, ModifyRegistrationRequired,
OperationFailed, OperationNotSupported,
ResourceSuspended;
-
- public abstract int getVersion();
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -24,6 +24,7 @@
package org.gatein.wsrp.services;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.common.util.Version;
import org.gatein.wsrp.services.v1.V1MarkupService;
import org.gatein.wsrp.services.v1.V1PortletManagementService;
import org.gatein.wsrp.services.v1.V1RegistrationService;
@@ -356,6 +357,25 @@
}
}
+ public Version getWSRPVersion()
+ {
+ if (isAvailable())
+ {
+ if (isV2)
+ {
+ return WSRP2;
+ }
+ else
+ {
+ return WSRP1;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
protected class WSDLInfo
{
private final QName wsrp2ServiceQName;
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2010, 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.
@@ -22,6 +22,8 @@
*/
package org.gatein.wsrp.services;
+import org.gatein.common.util.Version;
+
/**
* A factory that gives access to remote services.
*
@@ -31,6 +33,8 @@
public interface ServiceFactory
{
int DEFAULT_TIMEOUT_MS = 10000;
+ Version WSRP2 = new Version("WSRP", 2, 0, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA), "WSRP2");
+ Version WSRP1 = new Version("WSRP", 1, 0, 0, new
Version.Qualifier(Version.Qualifier.Prefix.GA), "WSRP1");
<T> T getService(Class<T> clazz) throws Exception;
@@ -77,4 +81,12 @@
PortletManagementService getPortletManagementService() throws Exception;
RegistrationService getRegistrationService() throws Exception;
+
+ /**
+ * Returns the WSRP version of the remote service that this ServiceFactory connects to
or <code>null</code> if the
+ * ServiceFactory is not available.
+ *
+ * @return
+ */
+ Version getWSRPVersion();
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1MarkupService.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1MarkupService.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1MarkupService.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -307,10 +307,4 @@
throw V1ToV2Converter.toV2Exception(OperationFailed.class, operationFailed);
}
}
-
- @Override
- public int getVersion()
- {
- return 1;
- }
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v2/V2MarkupService.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -106,10 +106,4 @@
{
return service.initCookie(registrationContext, userContext);
}
-
- @Override
- public int getVersion()
- {
- return 2;
- }
}
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -24,6 +24,7 @@
package org.gatein.wsrp.test.protocol.v1;
import org.gatein.common.NotYetImplemented;
+import org.gatein.common.util.Version;
import org.gatein.pc.api.Mode;
import org.gatein.pc.api.WindowState;
import org.gatein.wsrp.services.MarkupService;
@@ -173,6 +174,11 @@
return new V1RegistrationService(getService(WSRPV1RegistrationPortType.class));
}
+ public Version getWSRPVersion()
+ {
+ return ServiceFactory.WSRP1;
+ }
+
public void create() throws Exception
{
throw new NotYetImplemented();
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java 2010-10-06
12:37:59 UTC (rev 4538)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java 2010-10-06
13:47:55 UTC (rev 4539)
@@ -24,6 +24,7 @@
package org.gatein.wsrp.test.protocol.v2;
import org.gatein.common.NotYetImplemented;
+import org.gatein.common.util.Version;
import org.gatein.pc.api.Mode;
import org.gatein.pc.api.WindowState;
import org.gatein.wsrp.services.MarkupService;
@@ -132,6 +133,11 @@
return new V2RegistrationService(getService(WSRPV2RegistrationPortType.class));
}
+ public Version getWSRPVersion()
+ {
+ return ServiceFactory.WSRP2;
+ }
+
public BehaviorRegistry getRegistry()
{
return registry;