Author: chris.laprun(a)jboss.com
Date: 2007-05-03 12:01:40 -0400 (Thu, 03 May 2007)
New Revision: 7183
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
Log:
- Renamed persistent fields with a persistent prefix.
- Fixed areURLsDirty.
- Added refresh method.
- Updated tests.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java 2007-05-03
15:53:26 UTC (rev 7182)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java 2007-05-03
16:01:40 UTC (rev 7183)
@@ -23,14 +23,33 @@
package org.jboss.portal.test.wsrp.framework.support;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
+import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.InconsistentParametersFault;
+import org.jboss.portal.wsrp.core.InvalidCookieFault;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.InvalidSessionFault;
+import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
+import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.UnsupportedLocaleFault;
+import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
+import org.jboss.portal.wsrp.core.UnsupportedModeFault;
+import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
import org.jboss.portal.wsrp.services.ServiceFactory;
+import java.rmi.RemoteException;
+
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
@@ -49,6 +68,7 @@
public BehaviorBackedServiceFactory()
{
registry = new BehaviorRegistry();
+ registry.registerMarkupBehavior(new SimpleMarkupBehavior());
}
public Object getService(Class clazz) throws Exception
@@ -146,4 +166,22 @@
{
throw new NotYetImplemented();
}
+
+ private class SimpleMarkupBehavior extends MarkupBehavior
+ {
+ public SimpleMarkupBehavior()
+ {
+ super(BehaviorBackedServiceFactory.this.registry);
+ registerHandle(MARKUP);
+ }
+
+ protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ throws UnsupportedWindowStateFault, InvalidCookieFault, InvalidSessionFault,
AccessDeniedFault,
+ InconsistentParametersFault, InvalidHandleFault, UnsupportedLocaleFault,
UnsupportedModeFault,
+ OperationFailedFault, MissingParametersFault, InvalidUserCategoryFault,
InvalidRegistrationFault,
+ UnsupportedMimeTypeFault, RemoteException
+ {
+ return MARKUP;
+ }
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java 2007-05-03
15:53:26 UTC (rev 7182)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java 2007-05-03
16:01:40 UTC (rev 7183)
@@ -92,19 +92,29 @@
info.setWsdlDefinitionURL(null);
}
- public void testIsRefreshNeeded() throws Exception
+ public void testRefreshWSDL() throws Exception
{
assertTrue(info.isRefreshNeeded());
assertFalse(info.isAvailable());
- info.setServiceFactory(new BehaviorBackedServiceFactory());
String bea = "http://wsrp.bea.com:7001/producer/producer?WSDL";
info.setWsdlDefinitionURL(bea);
+ info.refresh();
assertFalse(info.isRefreshNeeded());
assertTrue(info.isAvailable());
+ }
+ public void testRefresh() throws Exception
+ {
+ assertTrue(info.isRefreshNeeded());
+ assertFalse(info.isAvailable());
+
// change the service factory to a fake one to be able to simulate access to
endpoint
info.setServiceFactory(new BehaviorBackedServiceFactory());
+ info.refresh();
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+
info.setServiceDescriptionURL(url);
assertTrue(info.isRefreshNeeded());
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-05-03
15:53:26 UTC (rev 7182)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-05-03
16:01:40 UTC (rev 7183)
@@ -45,11 +45,11 @@
/** DB primary key */
private Long key;
- private String serviceDescriptionURL = UNSET;
- private String markupURL = UNSET;
- private String registrationURL;
- private String portletManagementURL;
- private String wsdlDefinitionURL;
+ private String persistentServiceDescriptionURL = UNSET;
+ private String persistentMarkupURL = UNSET;
+ private String persistentRegistrationURL;
+ private String persistentPortletManagementURL;
+ private String persistentWsdlDefinitionURL;
// transient variables
/** Access to the WS */
@@ -100,53 +100,53 @@
public boolean usesWSDL()
{
- return serviceFactory instanceof RemoteSOAPInvokerServiceFactory ||
wsdlDefinitionURL != null;
+ return serviceFactory instanceof RemoteSOAPInvokerServiceFactory ||
persistentWsdlDefinitionURL != null;
}
public String getWsdlDefinitionURL()
{
if (serviceFactory instanceof RemoteSOAPInvokerServiceFactory)
{
- wsdlDefinitionURL =
((RemoteSOAPInvokerServiceFactory)serviceFactory).getWsdlDefinitionURL();
+ persistentWsdlDefinitionURL =
((RemoteSOAPInvokerServiceFactory)serviceFactory).getWsdlDefinitionURL();
}
- return wsdlDefinitionURL;
+ return persistentWsdlDefinitionURL;
}
public String getServiceDescriptionURL()
{
if (serviceFactory != null)
{
- serviceDescriptionURL = serviceFactory.getServiceDescriptionURL();
+ persistentServiceDescriptionURL = serviceFactory.getServiceDescriptionURL();
}
- return serviceDescriptionURL;
+ return persistentServiceDescriptionURL;
}
public String getMarkupURL()
{
if (serviceFactory != null)
{
- markupURL = serviceFactory.getMarkupURL();
+ persistentMarkupURL = serviceFactory.getMarkupURL();
}
- return markupURL;
+ return persistentMarkupURL;
}
public String getPortletManagementURL()
{
if (serviceFactory != null)
{
- portletManagementURL = serviceFactory.getPortletManagementURL();
+ persistentPortletManagementURL = serviceFactory.getPortletManagementURL();
}
- return portletManagementURL;
+ return persistentPortletManagementURL;
}
public String getRegistrationURL()
{
if (serviceFactory != null)
{
- registrationURL = serviceFactory.getRegistrationURL();
+ persistentRegistrationURL = serviceFactory.getRegistrationURL();
}
- return registrationURL;
+ return persistentRegistrationURL;
}
public void setServiceDescriptionURL(String serviceDescriptionURL)
@@ -155,7 +155,7 @@
{
serviceFactory.setServiceDescriptionURL(serviceDescriptionURL);
}
- this.serviceDescriptionURL = modifyIfNeeded(this.serviceDescriptionURL,
serviceDescriptionURL, SD);
+ this.persistentServiceDescriptionURL =
modifyIfNeeded(this.persistentServiceDescriptionURL, serviceDescriptionURL, SD);
}
@@ -165,7 +165,7 @@
{
serviceFactory.setMarkupURL(markupURL);
}
- this.markupURL = modifyIfNeeded(this.markupURL, markupURL, M);
+ this.persistentMarkupURL = modifyIfNeeded(this.persistentMarkupURL, markupURL, M);
}
public void setRegistrationURL(String registrationURL)
@@ -174,7 +174,7 @@
{
serviceFactory.setRegistrationURL(registrationURL);
}
- this.registrationURL = modifyIfNeeded(this.registrationURL, registrationURL, R);
+ this.persistentRegistrationURL = modifyIfNeeded(this.persistentRegistrationURL,
registrationURL, R);
}
public void setPortletManagementURL(String portletManagementURL)
@@ -183,12 +183,12 @@
{
serviceFactory.setPortletManagementURL(portletManagementURL);
}
- this.portletManagementURL = modifyIfNeeded(this.portletManagementURL,
portletManagementURL, PM);
+ this.persistentPortletManagementURL =
modifyIfNeeded(this.persistentPortletManagementURL, portletManagementURL, PM);
}
public void setWsdlDefinitionURL(String wsdlDefinitionURL) throws RuntimeException
{
- this.wsdlDefinitionURL = wsdlDefinitionURL;
+ this.persistentWsdlDefinitionURL = wsdlDefinitionURL;
// WSDL url is optional so can be null (and in particular, it is when loaded from
Hibernate most of the time)
if (wsdlDefinitionURL != null)
@@ -223,13 +223,13 @@
}
else
{
- if (!UNSET.equals(serviceDescriptionURL) &&
!UNSET.equals(markupURL))
+ if (!UNSET.equals(persistentServiceDescriptionURL) &&
!UNSET.equals(persistentMarkupURL))
{
serviceFactory = new PerEndpointSOAPInvokerServiceFactory();
- serviceFactory.setServiceDescriptionURL(serviceDescriptionURL);
- serviceFactory.setMarkupURL(markupURL);
- serviceFactory.setPortletManagementURL(portletManagementURL);
- serviceFactory.setRegistrationURL(registrationURL);
+ serviceFactory.setServiceDescriptionURL(persistentServiceDescriptionURL);
+ serviceFactory.setMarkupURL(persistentMarkupURL);
+ serviceFactory.setPortletManagementURL(persistentPortletManagementURL);
+ serviceFactory.setRegistrationURL(persistentRegistrationURL);
}
else
{
@@ -244,7 +244,7 @@
{
try
{
-
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(wsdlDefinitionURL);
+
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(persistentWsdlDefinitionURL);
clean.set(0, 4); // if setting the WSDL URL worked, consider everything clean
}
catch (Exception e)
@@ -276,14 +276,14 @@
ParameterValidation.throwIllegalArgExceptionIfNull(serviceFactory,
"ServiceFactory");
this.serviceFactory = serviceFactory;
- serviceDescriptionURL = serviceFactory.getServiceDescriptionURL();
- markupURL = serviceFactory.getMarkupURL();
- portletManagementURL = serviceFactory.getPortletManagementURL();
- registrationURL = serviceFactory.getRegistrationURL();
+ persistentServiceDescriptionURL = serviceFactory.getServiceDescriptionURL();
+ persistentMarkupURL = serviceFactory.getMarkupURL();
+ persistentPortletManagementURL = serviceFactory.getPortletManagementURL();
+ persistentRegistrationURL = serviceFactory.getRegistrationURL();
if (serviceFactory instanceof RemoteSOAPInvokerServiceFactory)
{
- wsdlDefinitionURL =
((RemoteSOAPInvokerServiceFactory)serviceFactory).getWsdlDefinitionURL();
+ persistentWsdlDefinitionURL =
((RemoteSOAPInvokerServiceFactory)serviceFactory).getWsdlDefinitionURL();
}
}
@@ -363,6 +363,28 @@
private boolean areURLsDirty()
{
- return clean.cardinality() < 4;
+ return !clean.get(SD) || !clean.get(M) || (persistentPortletManagementURL != null
&& !clean.get(PM))
+ || (persistentRegistrationURL != null && !clean.get(R));
}
+
+ public void refresh() throws InvokerUnavailableException
+ {
+ if (isRefreshNeeded())
+ {
+ initServiceFactoryIfNeeded();
+ if (!usesWSDL())
+ {
+ getServiceDescriptionService();
+ getMarkupService();
+ if (persistentPortletManagementURL != null)
+ {
+ getPortletManagementService();
+ }
+ if (persistentRegistrationURL != null)
+ {
+ getRegistrationService();
+ }
+ }
+ }
+ }
}