Author: chris.laprun(a)jboss.com
Date: 2007-03-03 21:21:15 -0500 (Sat, 03 Mar 2007)
New Revision: 6525
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/EndpointConfigurationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml
Log:
- Added ConsumerRegistry.updateProducerInfo method.
- Give access to ConsumerRegistry to ProducerInfo so that we can update it when needed.
- Moved UNSET value from ServiceFactory to EnpointConfigurationInfo to allow for better
creation and persisting.
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-03-04
02:18:31 UTC (rev 6524)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -29,6 +29,7 @@
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
import java.util.Collection;
import java.util.HashMap;
@@ -82,4 +83,9 @@
{
// do nothing
}
+
+ public void updateProducerInfo(ProducerInfo producerInfo)
+ {
+ // do nothing
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-03-04
02:18:31 UTC (rev 6524)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -45,4 +45,6 @@
void persistConsumer(WSRPConsumer consumer);
void activateConsumerWith(String id) throws ConsumerException;
+
+ void updateProducerInfo(ProducerInfo producerInfo);
}
\ 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-03-04
02:18:31 UTC (rev 6524)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.consumer;
+import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.jboss.portal.common.util.ParameterValidation;
@@ -50,8 +51,6 @@
private SortedMap consumers;
-// private Set startedConsumerIds = new HashSet();
-
private SessionFactory sessionFactory;
private String sessionFactoryJNDIName;
@@ -70,12 +69,20 @@
throw new ConsumerException("A Consumer with id '" + id +
"' already exists!");
}
- Session session = sessionFactory.getCurrentSession();
ProducerInfo info = new ProducerInfo();
info.setId(id);
+ info.setRegistry(this);
- session.persist(info);
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.persist(info);
+ }
+ catch (HibernateException e)
+ {
+ throw new ConsumerException("Couldn't create Consumer '" + id
+ "'", e);
+ }
return createConsumerFrom(info);
}
@@ -126,8 +133,7 @@
private WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
{
- WSRPConsumer consumer = new WSRPConsumerImpl();
- consumer.setProducerInfo(producerInfo);
+ WSRPConsumer consumer = new WSRPConsumerImpl(producerInfo, this);
consumers.put(producerInfo.getId(), consumer);
return consumer;
@@ -165,14 +171,25 @@
info.setActive(true);
// update ProducerInfo
- Session session = sessionFactory.getCurrentSession();
- session.beginTransaction();
+ updateProducerInfo(info);
+ }
- session.update(info);
+ }
- session.getTransaction().commit();
- }
+ public void updateProducerInfo(ProducerInfo producerInfo)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(producerInfo,
"ProducerInfo");
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.update(producerInfo);
+ }
+ catch (HibernateException e)
+ {
+ throw new ConsumerException("Couldn't update ProducerInfo for Consumer
'" + producerInfo.getId() + "'", e);
+ }
}
protected void stopService() throws Exception
@@ -191,42 +208,5 @@
{
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/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-03-04
02:18:31 UTC (rev 6524)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -43,8 +43,8 @@
/** DB primary key */
private Long key;
- private String serviceDescriptionURL;
- private String markupURL;
+ private String serviceDescriptionURL = UNSET;
+ private String markupURL = UNSET;
private String registrationURL;
private String portletManagementURL;
private String wsdlDefinitionURL;
@@ -58,7 +58,10 @@
static final String PORTLET_MANAGEMENT = "portlet management";
static final String REGISTRATION = "registration";
+ // Used to ensure that even invalid values can be persisted to DB so that it can be
accessed from the GUI
+ public final static String UNSET = "MUST BE SET";
+
public EndpointConfigurationInfo()
{
}
@@ -199,7 +202,7 @@
}
else
{
- if (serviceDescriptionURL != null && markupURL != null)
+ if (!UNSET.equals(serviceDescriptionURL) &&
!UNSET.equals(markupURL))
{
serviceFactory = new PerEndpointSOAPInvokerServiceFactory();
serviceFactory.setServiceDescriptionURL(serviceDescriptionURL);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-04
02:18:31 UTC (rev 6524)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -102,6 +102,8 @@
/** The service description sent to producer. */
private GetServiceDescription serviceDescriptionRequest;
+ private ConsumerRegistry registry;
+
/*protected org.jboss.portal.wsrp.core.ItemDescription[] userCategoryDescriptions;
protected org.jboss.portal.wsrp.core.ItemDescription[]
customUserProfileItemDescriptions;
protected org.jboss.portal.wsrp.core.ItemDescription[] customWindowStateDescriptions;
@@ -119,7 +121,16 @@
persistentRegistrationInfo = RegistrationInfo.REGISTRATION_NOT_NEEDED;
}
+ public ConsumerRegistry getRegistry()
+ {
+ return registry;
+ }
+ public void setRegistry(ConsumerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
public Long getKey()
{
return key;
@@ -184,11 +195,25 @@
*
* @param forceRefresh whether or not to force a refresh regardless of whether one
would have been required based on
* cache expiration
- * @return <code>true</code> if the producer's information just was
refreshed, <code>false</code>
+ * @return <code>true</code> if the producer's information was just
refreshed, <code>false</code> otherwise
* @throws PortletInvokerException if registration was required but couldn't be
achieved properly
*/
public boolean refresh(boolean forceRefresh) throws PortletInvokerException
{
+ boolean justRefreshed = internalRefresh(forceRefresh);
+
+ // update DB
+ if (justRefreshed)
+ {
+ registry.updateProducerInfo(this);
+ }
+
+ return justRefreshed;
+ }
+
+ private boolean internalRefresh(boolean forceRefresh)
+ throws PortletInvokerException
+ {
ServiceDescription serviceDescription;
// might neeed a different cache value: right now, we cache the whole producer info
but we might want to cache
// POPs and rest of producer info separetely...
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-04
02:18:31 UTC (rev 6524)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -117,9 +117,12 @@
/** The set of supported user scopes */
private Set supportedUserScopes = WSRP_DEFAULT_USER_SCOPE; // todo: make it possible
to support different user scopes
- public WSRPConsumerImpl()
+ WSRPConsumerImpl(ProducerInfo info, ConsumerRegistry registry)
{
- producerInfo = new ProducerInfo();
+ ParameterValidation.throwIllegalArgExceptionIfNull(info,
"ProducerInfo");
+ ParameterValidation.throwIllegalArgExceptionIfNull(registry,
"ConsumerRegistry");
+
+ producerInfo = info;
actionHandler = new ActionHandler(this);
renderHandler = new RenderHandler(this);
sessionHandler = new SessionHandler(this);
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-04
02:18:31 UTC (rev 6524)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -29,7 +29,6 @@
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.RegistrationInfo;
-import org.jboss.portal.wsrp.consumer.WSRPConsumerImpl;
import org.jboss.util.StringPropertyReplacer;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
@@ -109,9 +108,8 @@
}
// consumer didn't exist in the database, so create one and configure it
- consumer = new WSRPConsumerImpl();
+ consumer = consumerRegistry.createConsumer(id);
ProducerInfo info = consumer.getProducerInfo();
- info.setId(id);
String expirationCache = attrs.getValue("expiration-cache");
if (expirationCache != null)
@@ -147,7 +145,6 @@
ProducerInfo prodInfo = service.getConsumer().getProducerInfo();
- RegistrationInfo regInfo = null;
if ("endpoint-config".equals(localName) ||
"endpoint-wsdl-url".equals(localName))
{
return new EndpointConfigurationInfo(prodInfo);
@@ -287,8 +284,8 @@
+ service.getId() + "'. The consumer will NOT be available.";
}
- // persist the consumer once the whole information is known
- consumerRegistry.persistConsumer(service.getConsumer());
+ // update the producer info once the whole information is known
+ consumerRegistry.updateProducerInfo(service.getConsumer().getProducerInfo());
log.info(message);
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-03-04
02:18:31 UTC (rev 6524)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-03-04
02:21:15 UTC (rev 6525)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.services;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
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;
@@ -40,14 +41,11 @@
public class PerEndpointSOAPInvokerServiceFactory extends AbstractSOAPServiceFactory
{
- // Used to ensure that even invalid values can be persisted to DB so that it can be
accessed from the GUI
- public final static String UNSET = "MUST BE SET";
-
/** . */
- protected String serviceDescriptionURL = UNSET;
+ protected String serviceDescriptionURL = EndpointConfigurationInfo.UNSET;
/** . */
- protected String markupURL = UNSET;
+ protected String markupURL = EndpointConfigurationInfo.UNSET;
/** . */
protected String registrationURL;
@@ -152,6 +150,6 @@
public boolean isAvailable()
{
- return !UNSET.equals(serviceDescriptionURL) && !UNSET.equals(markupURL);
+ return !EndpointConfigurationInfo.UNSET.equals(serviceDescriptionURL) &&
!EndpointConfigurationInfo.UNSET.equals(markupURL);
}
}
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml 2007-03-04 02:18:31 UTC (rev
6524)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/wsrp-aop.xml 2007-03-04 02:21:15 UTC (rev
6525)
@@ -32,6 +32,12 @@
<method name="activateConsumerWith">
<trans-attribute>Required</trans-attribute>
</method>
+ <method name="updateProducerInfo">
+ <trans-attribute>Required</trans-attribute>
+ </method>
+ <method name="createConsumer">
+ <trans-attribute>Required</trans-attribute>
+ </method>
</metadata>
<!-- TRANSACTIONS -->