Author: chris.laprun(a)jboss.com
Date: 2007-03-31 01:20:07 -0400 (Sat, 31 Mar 2007)
New Revision: 6892
Removed:
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployment.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
Log:
- Removed WSRPConsumerService and related modifications.
- WSRPDeploymentFactory now extends GenericObjectModelFactory to bypass the fact that XB
introspection only works on concrete types, not interfaces.
- Adapted test case.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-31
02:00:07 UTC (rev 6891)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -31,7 +31,6 @@
import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.RegistrationData;
-import org.jboss.portal.wsrp.deployment.WSRPConsumerService;
import org.jboss.portal.wsrp.deployment.WSRPDeployment;
import org.jboss.portal.wsrp.deployment.WSRPDeploymentFactory;
import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory;
@@ -74,19 +73,18 @@
// deployment should only contains the consumers with available service factories
WSRPDeployment deployment = (WSRPDeployment)o;
- List services = deployment.getServices();
+ List services = deployment.getConsumers();
assertNotNull(services);
assertEquals(4, services.size());
//
Object service = services.get(0);
- assertTrue(service instanceof WSRPConsumerService);
- WSRPConsumerService consumerService = (WSRPConsumerService)service;
- assertEquals("endpoint1", consumerService.getId());
- WSRPConsumer consumer = consumerService.getConsumer();
+ assertTrue(service instanceof WSRPConsumer);
+ WSRPConsumer consumer = (WSRPConsumer)service;
+ assertEquals("endpoint1", consumer.getProducerId());
ProducerInfo info = consumer.getProducerInfo();
assertNotNull(info);
- assertEquals(consumerService.getId(), info.getId());
+ assertEquals(consumer.getProducerId(), info.getId());
EndpointConfigurationInfo endInfo = info.getEndpointConfigurationInfo();
assertNotNull(endInfo);
assertNotNull(consumer.getServiceFactory());
@@ -102,8 +100,7 @@
assertEquals(endInfo.getPortletManagementURL(),
serviceFactory.getPortletManagementURL());
// inDB2 is active and configured from the DB (configured in MockConsumerRegistry)
- service = services.get(1);
- consumer = ((WSRPConsumerService)service).getConsumer();
+ consumer = (WSRPConsumer)services.get(1);
assertEquals("inDB2", consumer.getProducerId());
assertNull(consumer.getProducerInfo().getExpirationCacheSeconds());
// since inDB2 is loaded from MockConsumerRegistry, it shouldn't be processed
by WSRPDeploymentFactory and should
@@ -113,11 +110,8 @@
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
//
- service = services.get(2);
- assertTrue(service instanceof WSRPConsumerService);
- consumerService = (WSRPConsumerService)service;
- assertEquals("producer1", consumerService.getId());
- consumer = consumerService.getConsumer();
+ consumer = (WSRPConsumer)services.get(2);
+ assertEquals("producer1", consumer.getProducerId());
info = consumer.getProducerInfo();
assertEquals(120, info.getExpirationCacheSeconds().intValue());
assertTrue(consumer.getServiceFactory() instanceof
RemoteSOAPInvokerServiceFactory);
@@ -143,10 +137,8 @@
assertEquals("en-US", property.getLang());
assertEquals("value", property.getStringValue());
- service = services.get(3);
- consumerService = (WSRPConsumerService)service;
- assertEquals("producer2", consumerService.getId());
- consumer = consumerService.getConsumer();
+ consumer = (WSRPConsumer)services.get(3);
+ assertEquals("producer2", consumer.getProducerId());
registrationData =
consumer.getProducerInfo().getRegistrationInfo().getRegistrationData();
assertNotNull(registrationData);
assertNotNull(registrationData.getConsumerName());
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-03-31
02:00:07 UTC (rev 6891)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -29,7 +29,6 @@
import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
-import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import java.util.Collection;
import java.util.HashMap;
@@ -43,14 +42,7 @@
public class MockConsumerRegistry implements ConsumerRegistry
{
private Map consumers = new HashMap(3);
- private final static RegistrationInfo NULL_REGISTRATION_INFO = new
RegistrationInfo();
- static
- {
- NULL_REGISTRATION_INFO.setRequiresRegistration(false);
- }
-
-
public MockConsumerRegistry()
{
consumers.put("inDB", new MockWSRPConsumer("inDB"));
@@ -98,11 +90,6 @@
// do nothing
}
- public RegistrationInfo getDefaultRegistrationInfo()
- {
- return NULL_REGISTRATION_INFO;
- }
-
public void deactivateConsumerWith(String id) throws ConsumerException
{
// do nothing
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-31
02:00:07 UTC (rev 6891)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -33,7 +33,6 @@
import org.jboss.portal.portlet.federation.FederatedPortletInvoker;
import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
import org.jboss.portal.wsrp.WSRPConsumer;
-import org.jboss.portal.wsrp.deployment.WSRPConsumerService;
import javax.naming.InitialContext;
import java.util.Collection;
@@ -117,6 +116,8 @@
{
throw new ConsumerException(CONSUMER_WITH_ID + id + "' doesn't
exist!");
}
+
+ log.info(CONSUMER_WITH_ID + id + "' destroyed");
}
public void persistConsumer(WSRPConsumer consumer)
@@ -298,11 +299,7 @@
throw new IllegalArgumentException(CONSUMER_WITH_ID + id + "'
doesn't exist!");
}
- // todo: remove WSRPConsumerService
- WSRPConsumerService service = new WSRPConsumerService();
- service.setConsumer(consumer);
- service.setFederatingPortletInvoker(federatingPortletInvoker);
- service.start();
+ federatingPortletInvoker.registerInvoker(id, consumer);
consumer.activate();
}
else
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-31
02:00:07 UTC (rev 6891)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -463,7 +463,7 @@
{
if (!started)
{
- startService();
+ start();
log.info("Consumer with id '" + getProducerId() + "'
activated");
}
producerInfo.setActive(getServiceFactory().isAvailable());
@@ -474,7 +474,7 @@
producerInfo.setActive(false);
if (started)
{
- stopService();
+ stop();
log.info("Consumer with id '" + getProducerId() + "'
deactivated");
}
}
Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java 2007-03-31
02:00:07 UTC (rev 6891)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -1,88 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.deployment;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
-import org.jboss.portal.wsrp.WSRPConsumer;
-
-/**
- * todo: Remove, since it shouldn't be needed anymore now that we can register to a
FederatingPortletInvoker directly
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class WSRPConsumerService extends AbstractJBossService
-{
-
- /** . */
- private WSRPConsumer consumer;
-
- /** . */
- private FederatingPortletInvoker federatingPortletInvoker;
-
- public WSRPConsumer getConsumer()
- {
- return consumer;
- }
-
- public void setConsumer(WSRPConsumer consumer)
- {
- this.consumer = consumer;
- }
-
- public String getId()
- {
- return consumer.getProducerId();
- }
-
- public PortletInvoker getPortletInvoker()
- {
- return consumer;
- }
-
- public FederatingPortletInvoker getFederatingPortletInvoker()
- {
- return federatingPortletInvoker;
- }
-
- public void setFederatingPortletInvoker(FederatingPortletInvoker
federatingPortletInvoker)
- {
- this.federatingPortletInvoker = federatingPortletInvoker;
- }
-
- protected void startService() throws Exception
- {
- super.startService();
- federatingPortletInvoker.registerInvoker(getId(), consumer);
- consumer.start();
- }
-
- protected void stopService() throws Exception
- {
- consumer.stop();
- federatingPortletInvoker.unregisterInvoker(getId());
- super.stopService();
- }
-}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java 2007-03-31
02:00:07 UTC (rev 6891)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployer.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -26,6 +26,7 @@
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.SubDeployerSupport;
import org.jboss.portal.common.xml.NullEntityResolver;
+import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.Unmarshaller;
@@ -115,22 +116,22 @@
{
super.start(di);
WSRPDeployment deployment = (WSRPDeployment)di.metaData;
- for (Iterator i = deployment.getServices().iterator(); i.hasNext();)
+ for (Iterator i = deployment.getConsumers().iterator(); i.hasNext();)
{
- WSRPConsumerService service = (WSRPConsumerService)i.next();
- consumerRegistry.activateConsumerWith(service.getId());
+ WSRPConsumer consumer = (WSRPConsumer)i.next();
+ consumerRegistry.activateConsumerWith(consumer.getProducerId());
}
}
public void stop(DeploymentInfo di) throws DeploymentException
{
WSRPDeployment deployment = (WSRPDeployment)di.metaData;
- for (Iterator i = deployment.getServices().iterator(); i.hasNext();)
+ for (Iterator i = deployment.getConsumers().iterator(); i.hasNext();)
{
try
{
- WSRPConsumerService service = (WSRPConsumerService)i.next();
- service.stop();
+ WSRPConsumer consumer = (WSRPConsumer)i.next();
+ consumer.stop();
}
catch (Exception e)
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployment.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployment.java 2007-03-31
02:00:07 UTC (rev 6891)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployment.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -40,7 +40,7 @@
services = new ArrayList();
}
- public List getServices()
+ public List getConsumers()
{
return services;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2007-03-31
02:00:07 UTC (rev 6891)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2007-03-31
05:20:07 UTC (rev 6892)
@@ -30,7 +30,7 @@
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.util.StringPropertyReplacer;
-import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.GenericObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
@@ -40,7 +40,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class WSRPDeploymentFactory implements ObjectModelFactory
+public class WSRPDeploymentFactory implements GenericObjectModelFactory
{
private final Logger log = Logger.getLogger(getClass());
@@ -73,27 +73,74 @@
return root;
}
+ public Object newChild(Object parent, UnmarshallingContext unmarshallingContext,
String nsURI, String localName, Attributes attributes)
+ {
+ if (parent instanceof WSRPDeployment)
+ {
+ return newChild((WSRPDeployment)parent, unmarshallingContext, nsURI, localName,
attributes);
+ }
+ if (parent instanceof RegistrationInfo)
+ {
+ return newChild((RegistrationInfo)parent, unmarshallingContext, nsURI,
localName, attributes);
+ }
+ if (parent instanceof WSRPConsumer)
+ {
+ return newChild((WSRPConsumer)parent, unmarshallingContext, nsURI, localName,
attributes);
+ }
+ return null;
+ }
+
+ public void addChild(Object parent, Object child, UnmarshallingContext
unmarshallingContext, String nsURI, String localName)
+ {
+ if (parent instanceof RegistrationInfo && child instanceof Property)
+ {
+ addChild((RegistrationInfo)parent, (Property)child, unmarshallingContext, nsURI,
localName);
+ }
+ else if (parent instanceof WSRPDeployment && child instanceof
WSRPConsumer)
+ {
+ addChild((WSRPDeployment)parent, (WSRPConsumer)child, unmarshallingContext,
nsURI, localName);
+ }
+ }
+
+ public void setValue(Object parent, UnmarshallingContext unmarshallingContext, String
nsURI, String localName, String value)
+ {
+ if (parent instanceof EndpointConfigurationInfo)
+ {
+ setValue((EndpointConfigurationInfo)parent, unmarshallingContext, nsURI,
localName, value);
+ }
+ else if (parent instanceof Property)
+ {
+ setValue((Property)parent, unmarshallingContext, nsURI, localName, value);
+ }
+ else if (parent instanceof RegistrationInfo)
+ {
+ setValue((RegistrationInfo)parent, unmarshallingContext, nsURI, localName,
value);
+ }
+ }
+
public Object newChild(WSRPDeployment deployment, UnmarshallingContext nav, String
nsURI, String localName,
Attributes attrs)
{
+ if (DEBUG)
+ {
+ System.out.println("newchild deployment " + localName);
+ }
+
if (WSRP_PRODUCER.equals(localName))
{
String id = attrs.getValue("id");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "producer
identifier", "Configuring a producer");
- WSRPConsumerService service = new WSRPConsumerService();
-
// check that the consumer doesn't exist in the database first
WSRPConsumer consumer = consumerRegistry.getConsumer(id);
if (consumer != null)
{
- service.setConsumer(consumer);
- String message = "Added consumer for producer '" +
service.getId() + "' with status: ";
+ String message = "Added consumer for producer '" + id +
"' with status: ";
// if consumer is active, add it to the list of services
if (consumer.getProducerInfo().isActive())
{
- deployment.getServices().add(service);
+ deployment.getConsumers().add(consumer);
message += "active";
}
else
@@ -124,9 +171,7 @@
// consumer didn't exist in the database, so create one and configure it
consumer = consumerRegistry.createConsumer(id, expirationCacheSeconds);
- service.setConsumer(consumer);
-
- return service;
+ return consumer;
}
else
{
@@ -134,7 +179,7 @@
}
}
- public Object newChild(WSRPConsumerService service, UnmarshallingContext nav, String
nsURI, String localName,
+ public Object newChild(WSRPConsumer consumer, UnmarshallingContext nav, String nsURI,
String localName,
Attributes attrs)
{
if (DEBUG)
@@ -142,7 +187,7 @@
System.out.println("newchild service " + localName);
}
- ProducerInfo prodInfo = service.getConsumer().getProducerInfo();
+ ProducerInfo prodInfo = consumer.getProducerInfo();
if ("endpoint-config".equals(localName) ||
"endpoint-wsdl-url".equals(localName))
{
@@ -262,27 +307,26 @@
registrationInfo.setRegistrationPropertyValue(property.name,
property.value).setLang(property.lang);
}
- public void addChild(WSRPDeployment deployment, WSRPConsumerService service,
UnmarshallingContext nav, String nsURI,
+ public void addChild(WSRPDeployment deployment, WSRPConsumer consumer,
UnmarshallingContext nav, String nsURI,
String localName)
{
+ ProducerInfo info = consumer.getProducerInfo();
+
if (DEBUG)
{
- System.out.println("addchild deployment service " + localName);
+ System.out.println("adding consumer " + info.getId() + " to
deployment - localName: " + localName);
}
-
- ProducerInfo info = service.getConsumer().getProducerInfo();
-
String message;
- if (service.getConsumer().getServiceFactory().isAvailable())
+ if (consumer.getServiceFactory().isAvailable())
{
- message = "Added consumer for producer '" + service.getId() +
"' from xml configuration.";
- deployment.getServices().add(service);
+ message = "Added consumer for producer '" +
consumer.getProducerId() + "' from xml configuration.";
+ deployment.getConsumers().add(consumer);
}
else
{
message = "There was a problem initializing the WSRP interface for producer
'"
- + service.getId() + "'. The consumer will NOT be available.";
+ + consumer.getProducerId() + "'. The consumer will NOT be
available.";
info.setActive(false);
}
@@ -294,7 +338,7 @@
catch (Exception e)
{
// if we couldn't update the info, remove it from the list of service to be
activated
- deployment.getServices().remove(service);
+ deployment.getConsumers().remove(consumer);
log.info("Couldn't update the ProducerInfo for Consumer '" +
info.getId() + "'", e);
return;
}