Author: chris.laprun(a)jboss.com
Date: 2011-09-12 06:54:31 -0400 (Mon, 12 Sep 2011)
New Revision: 7354
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ManagedBean.java
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/web.xml
Log:
- Mark state as transient where possible and generally make JSF beans behave better in a
cluster environment (still not there yet, though).
- Made WSRP admin portlet distributable.
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2011-09-12
10:52:17 UTC (rev 7353)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2011-09-12
10:54:31 UTC (rev 7354)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -66,12 +66,14 @@
public class ConsumerBean extends ManagedBean
{
public static final SelectablePortletToHandleFunction SELECTABLE_TO_HANDLE = new
SelectablePortletToHandleFunction();
- private WSRPConsumer consumer;
- private ConsumerRegistry registry;
- private ConsumerManagerBean manager;
+ private transient WSRPConsumer consumer;
+ private transient ConsumerRegistry registry;
+ private transient ConsumerManagerBean manager;
private boolean modified;
private String wsdl;
+ private String id;
+ private static final String NULL_ID_CONSUMER = "bean_consumer_null_id";
private static final String CANNOT_FIND_CONSUMER =
"bean_consumer_cannot_find_consumer";
private static final String CANNOT_UPDATE_CONSUMER =
"bean_consumer_cannot_update_consumer";
private static final String CANNOT_REFRESH_CONSUMER =
"bean_consumer_cannot_refresh_consumer";
@@ -107,12 +109,12 @@
public boolean isRefreshNeeded()
{
- return consumer.isRefreshNeeded();
+ return getConsumer().isRefreshNeeded();
}
public String getId()
{
- return consumer.getProducerId();
+ return getConsumer().getProducerId();
}
public void setId(String id)
@@ -136,23 +138,46 @@
// we're not using modifyIfNeeded here to avoid double equality check,
so we need to set modified manually
modified = true;
+
+ this.id = id;
}
}
}
else
{
// initialization scenario
+ resolveConsumer(id);
+ }
+ }
+
+ private void resolveConsumer(String id)
+ {
+ // if we don't have an id, try to get it from the ConsumerManagerBean
+ if (id == null)
+ {
+ id = manager.getSelectedId();
+ }
+
+ // if it's still null, output an error
+ if (id == null)
+ {
+ beanContext.createErrorMessage(NULL_ID_CONSUMER);
+ }
+ else
+ {
consumer = getRegistry().getConsumer(id);
if (consumer != null)
{
EndpointConfigurationInfo endpoint =
getProducerInfo().getEndpointConfigurationInfo();
wsdl = endpoint.getWsdlDefinitionURL();
+ this.id = id;
}
else
{
beanContext.createErrorMessage(CANNOT_FIND_CONSUMER, id);
}
}
+
}
public Integer getCache()
@@ -200,7 +225,7 @@
public boolean isActive()
{
- return consumer.isActive();
+ return getConsumer().isActive();
}
public boolean isRegistered()
@@ -264,7 +289,7 @@
public ProducerInfo getProducerInfo()
{
- return consumer.getProducerInfo();
+ return getConsumer().getProducerInfo();
}
public boolean isLocalInfoPresent()
@@ -327,7 +352,7 @@
private String internalUpdate(boolean showMessage)
{
- if (consumer != null)
+ if (getConsumer() != null)
{
if (isModified())
{
@@ -366,6 +391,7 @@
public String refreshConsumer()
{
+ final WSRPConsumer consumer = getConsumer();
if (consumer != null)
{
if (isModified())
@@ -396,7 +422,7 @@
public String modifyRegistration()
{
- if (consumer != null)
+ if (getConsumer() != null)
{
ProducerInfo info = getProducerInfo();
if (isModified())
@@ -461,7 +487,7 @@
public String eraseLocalRegistration()
{
- if (consumer != null)
+ if (getConsumer() != null)
{
getProducerInfo().eraseRegistrationInfo();
return ConsumerManagerBean.CONFIGURE_CONSUMER;
@@ -516,6 +542,7 @@
{
if (portletHandles == null)
{
+ final WSRPConsumer consumer = getConsumer();
Collection<Portlet> portlets =
consumer.getProducerInfo().getPortletMap().values();
List<SelectablePortletHandle> selectableHandles =
Collections.emptyList();
if (ParameterValidation.existsAndIsNotEmpty(portlets))
@@ -555,6 +582,7 @@
public String exportPortlets()
{
+ final WSRPConsumer consumer = getConsumer();
if (consumer != null)
{
List<SelectablePortletHandle> handles =
(List<SelectablePortletHandle>)portletHandles.getWrappedData();
@@ -593,7 +621,7 @@
if (existingExports == null)
{
Locale locale = beanContext.getLocale();
- MigrationService migrationService = consumer.getMigrationService();
+ MigrationService migrationService = getConsumer().getMigrationService();
List<ExportInfo> availableExportInfos =
migrationService.getAvailableExportInfos();
List<ExportInfoDisplay> exportDisplays = new
ArrayList<ExportInfoDisplay>(availableExportInfos.size());
for (ExportInfo exportInfo : availableExportInfos)
@@ -627,6 +655,8 @@
portletsToImport.add(exportedPortlet);
}
}
+
+ final WSRPConsumer consumer = getConsumer();
ImportInfo info = consumer.importPortlets(currentExport.getExport(),
WSRPUtils.transform(portletsToImport, SELECTABLE_TO_HANDLE));
ConsumerStructureProvider structureProvider =
consumer.getMigrationService().getStructureProvider();
@@ -673,6 +703,7 @@
public String deleteExport()
{
ExportInfo export = currentExport.getExport();
+ final WSRPConsumer consumer = getConsumer();
if (consumer.getMigrationService().remove(export) == export)
{
// release the export on the producer
@@ -708,29 +739,45 @@
public boolean isSupportsExport()
{
- return isActive() && consumer.isSupportsExport();
+ return isActive() && getConsumer().isSupportsExport();
}
public boolean isAvailableExportInfosEmpty()
{
- return consumer.getMigrationService().isAvailableExportInfosEmpty();
+ return getConsumer().getMigrationService().isAvailableExportInfosEmpty();
}
public boolean isWssEnabled()
{
- return consumer.getProducerInfo().getEndpointConfigurationInfo().getWSSEnabled();
+ return getProducerInfo().getEndpointConfigurationInfo().getWSSEnabled();
}
-
+
public boolean isWssAvailable()
{
- return consumer.getProducerInfo().getEndpointConfigurationInfo().isWSSAvailable();
+ return getProducerInfo().getEndpointConfigurationInfo().isWSSAvailable();
}
public void setWssEnabled(boolean enable)
{
- consumer.getProducerInfo().getEndpointConfigurationInfo().setWSSEnabled(enable);
+ getProducerInfo().getEndpointConfigurationInfo().setWSSEnabled(enable);
}
+ public WSRPConsumer getConsumer()
+ {
+ if (consumer == null)
+ {
+ // try to resolve it
+ resolveConsumer(id);
+ }
+
+ return consumer;
+ }
+
+ public void setConsumer(WSRPConsumer consumer)
+ {
+ this.consumer = consumer;
+ }
+
public static class SelectablePortletHandle implements
Comparable<SelectablePortletHandle>
{
private String handle;
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java 2011-09-12
10:52:17 UTC (rev 7353)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java 2011-09-12
10:54:31 UTC (rev 7354)
@@ -32,6 +32,7 @@
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
+import java.io.Serializable;
import java.util.List;
import java.util.Map;
@@ -40,9 +41,9 @@
* @version $Revision: 12865 $
* @since 2.6
*/
-public class ConsumerManagerBean extends ManagedBean
+public class ConsumerManagerBean extends ManagedBean implements Serializable
{
- private ConsumerRegistry registry;
+ private transient ConsumerRegistry registry;
private String selectedId;
private static final String NO_CONSUMER =
"bean_consumermanager_no_consumer";
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ManagedBean.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ManagedBean.java 2011-09-12
10:52:17 UTC (rev 7353)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ManagedBean.java 2011-09-12
10:54:31 UTC (rev 7354)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -37,9 +37,9 @@
*/
public abstract class ManagedBean
{
- protected Logger log = LoggerFactory.getLogger(getClass());
+ protected transient Logger log = LoggerFactory.getLogger(getClass());
- protected BeanContext beanContext;
+ protected transient BeanContext beanContext;
private String cancelOutcome;
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties 2011-09-12
10:52:17 UTC (rev 7353)
+++
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties 2011-09-12
10:54:31 UTC (rev 7354)
@@ -179,6 +179,7 @@
CONSUMER_TYPE = Consumer
# ConsumerBean
+bean_consumer_null_id = No identifier was specified to resolve a consumer from. Please
refresh the app and try again.
bean_consumer_cannot_find_consumer = Couldn''t find consumer
''{0}''!
bean_consumer_cannot_update_consumer = Couldn't update consumer!
bean_consumer_cannot_refresh_consumer = Couldn't refresh consumer!
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties 2011-09-12
10:52:17 UTC (rev 7353)
+++
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties 2011-09-12
10:54:31 UTC (rev 7354)
@@ -183,4 +183,5 @@
bean_consumermanager_refresh_failure_wsdl=Le rafra\u00eechissement a \u00e9chou\u00e9
(probablement \u00e0 cause d'URL WSDL non valide)
producer_config_wsdl_v1=Adresse WSDL pour le Producteur WSRP v1:
producer_config_wsdl_v2=Adresse WSDL pour le Producteur WSRP v2:
-unavailable_service=Le service WSRP n''est pas disponible. Veuillez
l''activer avant d'utiliser cette portlet.
\ No newline at end of file
+unavailable_service=Le service WSRP n''est pas disponible. Veuillez
l''activer avant d'utiliser cette portlet.
+bean_consumer_null_id=Aucun identifiant disponible pour r�cup�rer un consommateur.
Veuillez rafra�chir l'application et r�essayer.
\ No newline at end of file
Modified: components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/web.xml
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/web.xml 2011-09-12
10:52:17 UTC (rev 7353)
+++
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/web.xml 2011-09-12
10:54:31 UTC (rev 7354)
@@ -83,6 +83,8 @@
<exception-type>java.lang.Exception</exception-type>
<location>/faces/jsf/error.xhtml</location>
</error-page>
+
+ <distributable/>
</web-app>