Author: chris.laprun(a)jboss.com
Date: 2007-02-25 03:26:14 -0500 (Sun, 25 Feb 2007)
New Revision: 6399
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerException.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistryService.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml
Log:
- Added createConsumer and persistConsumer methods on ConsumerRegistry.
- Added id property in ProducerInfo that was somehow forgotten in Hibernate mapping.
- Made RegistrationInfo no-arg constructor public for Hibernate.
- Added ConsumerException.
- Added call to persistConsumer at the end of each unmarshalling of a consumer in
WSRPDeploymentFactory.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-02-25
06:33:33 UTC (rev 6398)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -63,4 +63,14 @@
return null;
}
+ public WSRPConsumer createConsumer(String id)
+ {
+ throw new UnsupportedOperationException("createConsumer is not supported on
MockConsumerRegistry");
+ }
+
+ public void persistConsumer(WSRPConsumer consumer)
+ {
+ throw new UnsupportedOperationException("persistConsumer is not supported on
MockConsumerRegistry");
+ }
+
}
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerException.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerException.java
(rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerException.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -0,0 +1,51 @@
+/*
+* 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.consumer;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerException extends RuntimeException
+{
+ public ConsumerException()
+ {
+ super();
+ }
+
+ public ConsumerException(String message)
+ {
+ super(message);
+ }
+
+ public ConsumerException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ConsumerException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-02-25
06:33:33 UTC (rev 6398)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -39,4 +39,8 @@
WSRPConsumer getConsumer(String id);
FederatingPortletInvoker getFederatingPortletInvoker();
+
+ WSRPConsumer createConsumer(String id);
+
+ void persistConsumer(WSRPConsumer consumer);
}
\ No newline at end of file
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-02-25
06:33:33 UTC (rev 6398)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -59,6 +59,39 @@
return federatingPortletInvoker;
}
+ public WSRPConsumer createConsumer(String id)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "createConsumer");
+
+ if (getConsumer(id) != null)
+ {
+ throw new ConsumerException("A Consumer with id '" + id +
"' already exists!");
+ }
+
+ Session session = sessionFactory.getCurrentSession();
+
+ ProducerInfo info = new ProducerInfo();
+ info.setId(id);
+
+ session.persist(info);
+
+ return createAndActivateConsumerIfNeeded(info);
+ }
+
+ public void persistConsumer(WSRPConsumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
+
+ Session session = sessionFactory.getCurrentSession();
+ ProducerInfo info = consumer.getProducerInfo();
+
+ session.persist(info.getEndpointConfigurationInfo());
+ session.persist(info.getRegistrationInfo());
+ session.persist(info);
+
+ createAndActivateConsumerIfNeeded(info);
+ }
+
public void setFederatingPortletInvoker(FederatingPortletInvoker
federatingPortletInvoker)
{
this.federatingPortletInvoker = federatingPortletInvoker;
@@ -83,21 +116,34 @@
Session session = sessionFactory.getCurrentSession();
Iterator producerInfos = session.createQuery("from ProducerInfo pi order by
pi.id").iterate();
ProducerInfo producerInfo;
- WSRPConsumer consumer;
while (producerInfos.hasNext())
{
producerInfo = (ProducerInfo)producerInfos.next();
- consumer = new WSRPConsumerImpl();
- consumer.setProducerInfo(producerInfo);
- consumers.put(producerInfo.getId(), consumer);
- if (producerInfo.isActive())
+ createAndActivateConsumerIfNeeded(producerInfo);
+ }
+ }
+
+ private WSRPConsumer createAndActivateConsumerIfNeeded(ProducerInfo producerInfo)
+ {
+ WSRPConsumer consumer = new WSRPConsumerImpl();
+ consumer.setProducerInfo(producerInfo);
+ consumers.put(producerInfo.getId(), consumer);
+ if (producerInfo.isActive())
+ {
+ WSRPConsumerService service = new WSRPConsumerService();
+ service.setConsumer(consumer);
+ service.setFederatingPortletInvoker(federatingPortletInvoker);
+ try
{
- WSRPConsumerService service = new WSRPConsumerService();
- service.setConsumer(consumer);
- service.setFederatingPortletInvoker(federatingPortletInvoker);
service.start();
}
+ catch (Exception e)
+ {
+ throw new ConsumerException("Couldn't start Consumer service
'" + producerInfo.getId() + "'", e);
+ }
}
+
+ return consumer;
}
protected void stopService() throws Exception
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-02-25
06:33:33 UTC (rev 6398)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -73,7 +73,7 @@
requiresRegistration = true;
}
- private RegistrationInfo()
+ public RegistrationInfo()
{
consumerName = WSRPConstants.DEFAULT_CONSUMER_NAME;
isRegistrationValid = true;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2007-02-25
06:33:33 UTC (rev 6398)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -305,6 +305,9 @@
System.out.println("addchild deployment service " + localName);
}
+ // persist consumer to the database now that it's complete
+ consumerRegistry.persistConsumer(service.getConsumer());
+
String message;
if (service.getConsumer().getServiceFactory().isAvailable())
{
Deleted:
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistry.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistry.java 2007-02-25
06:33:33 UTC (rev 6398)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistry.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -1,42 +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.portlet.consumers;
-
-import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
-import org.jboss.portal.wsrp.WSRPConsumer;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public interface ConsumersRegistry
-{
- Collection getConfiguredConsumers();
-
- WSRPConsumer getConsumer(String id);
-
- FederatingPortletInvoker getFederatingPortletInvoker();
-}
\ No newline at end of file
Deleted:
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistryService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistryService.java 2007-02-25
06:33:33 UTC (rev 6398)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/portlet/consumers/ConsumersRegistryService.java 2007-02-25
08:26:14 UTC (rev 6399)
@@ -1,159 +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.portlet.consumers;
-
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
-import org.jboss.portal.wsrp.WSRPConsumer;
-import org.jboss.portal.wsrp.consumer.ProducerInfo;
-import org.jboss.portal.wsrp.consumer.WSRPConsumerImpl;
-import org.jboss.portal.wsrp.deployment.WSRPConsumerService;
-
-import javax.naming.InitialContext;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class ConsumersRegistryService extends AbstractJBossService implements
ConsumersRegistry
-{
- /** Gives access to the Portal's portlet invokers */
- private FederatingPortletInvoker federatingPortletInvoker;
-
- private SortedMap consumers;
-
- private SessionFactory sessionFactory;
-
- private String sessionFactoryJNDIName;
-
- public FederatingPortletInvoker getFederatingPortletInvoker()
- {
- return federatingPortletInvoker;
- }
-
- public void setFederatingPortletInvoker(FederatingPortletInvoker
federatingPortletInvoker)
- {
- this.federatingPortletInvoker = federatingPortletInvoker;
- }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- protected void startService() throws Exception
- {
- sessionFactory = (SessionFactory)new
InitialContext().lookup(sessionFactoryJNDIName);
-
- // load the configured consumers
- consumers = new TreeMap();
- Session session = sessionFactory.getCurrentSession();
- Iterator producerInfos = session.createQuery("from ProducerInfo pi order by
pi.id").iterate();
- ProducerInfo producerInfo;
- WSRPConsumer consumer;
- while (producerInfos.hasNext())
- {
- producerInfo = (ProducerInfo)producerInfos.next();
- consumer = new WSRPConsumerImpl();
- consumer.setProducerInfo(producerInfo);
- consumers.put(producerInfo.getId(), consumer);
- if (producerInfo.isActive())
- {
- WSRPConsumerService service = new WSRPConsumerService();
- service.setConsumer(consumer);
- service.setFederatingPortletInvoker(federatingPortletInvoker);
- service.start();
- }
- }
- }
-
- protected void stopService() throws Exception
- {
- sessionFactory = null;
- consumers.clear();
- consumers = null;
- }
-
- public Collection getConfiguredConsumers()
- {
- return Collections.unmodifiableCollection(consumers.values());
- }
-
- public WSRPConsumer getConsumer(String id)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "consumer
id", null);
- return (WSRPConsumer)consumers.get(id);
-
- /*// first check if this consumer has already been loaded
- WSRPConsumer wsrpConsumer = (WSRPConsumer)consumers.get(id);
-
- if(wsrpConsumer != null)
- {
- return wsrpConsumer;
- }
- else
- {
- Session session = sessionFactory.getCurrentSession();
- Query query = session.createQuery("from ProducerInfo where id=:id");
- query.setString("id", id);
- ProducerInfo pi = (ProducerInfo)query.uniqueResult();
- if (pi != null)
- {
- wsrpConsumer = new WSRPConsumerImpl();
- wsrpConsumer.setProducerInfo(pi);
- consumers.put(pi.getId(), wsrpConsumer);
- if (pi.isActive())
- {
- WSRPConsumerService service = new WSRPConsumerService();
- service.setConsumer(wsrpConsumer);
- service.setFederatingPortletInvoker(federatingPortletInvoker);
- try
- {
- service.start();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Couldn't start Consumer
'" + pi.getId() + "'", e);
- }
- }
- return wsrpConsumer;
- }
- return null;
- }*/
- }
-}
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
===================================================================
---
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-02-25
06:33:33 UTC (rev 6398)
+++
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-02-25
08:26:14 UTC (rev 6399)
@@ -60,6 +60,7 @@
column="ACTIVE"
not-null="true"
unique="false"/>
+ <property name="id" not-null="true"
unique="true"/>
</class>
<class
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml 2007-02-25 06:33:33 UTC (rev
6398)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml 2007-02-25 08:26:14 UTC (rev
6399)
@@ -26,6 +26,9 @@
<method name="startService">
<trans-attribute>Required</trans-attribute>
</method>
+ <method name="persistConsumer">
+ <trans-attribute>Required</trans-attribute>
+ </method>
</metadata>
<!-- TRANSACTIONS -->