Author: chris.laprun(a)jboss.com
Date: 2011-09-13 09:55:51 -0400 (Tue, 13 Sep 2011)
New Revision: 7382
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/BeanContext.java
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/JSFBeanContext.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/java/org/gatein/wsrp/admin/ui/ProducerBean.java
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/faces-config.xml
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/ConsumerBeanTestCase.java
Log:
- More progress on clustering the admin UI:
+ Marked objects as Serializable where needed.
+ Added to retrieve transient beans when they haven't been set as this isn't
done by PortletBridge if the beans are not replicated (which is quite annoying).
+ Removed ConsumerRegistry property on ConsumerBean by retrieving it from
ConsumerManagerBean instance.
+ Added ability to resolve beans from name on BeanContext.
+ Still need to work on Producer configuration.
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/BeanContext.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/BeanContext.java 2011-09-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/BeanContext.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -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.
@@ -27,6 +27,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.Map;
@@ -38,7 +39,7 @@
* @version $Revision: 13374 $
* @since 2.6
*/
-public abstract class BeanContext
+public abstract class BeanContext implements Serializable
{
protected final static Logger log = LoggerFactory.getLogger(BeanContext.class);
@@ -192,7 +193,8 @@
/**
* Removes the object identified by the specified name(s) from the session. For a JSF
backed implementation, this
- * will allow for the object/bean (defined as session-scoped in
<code>faces-config.xml</code>) to be recreated by JSF
+ * will allow for the object/bean (defined as session-scoped in
<code>faces-config.xml</code>) to be recreated by
+ * JSF
* when needed.
*
* @param name name of the object to be removed
@@ -257,7 +259,8 @@
* @param expectedClass expected class of the object
* @param <T> type of the object to be retrieved
* @return the session object associated with the specified name
- * @throws IllegalArgumentException if the value associated with the specified name is
not <code>null</code> and does
+ * @throws IllegalArgumentException if the value associated with the specified name is
not <code>null</code> and
+ * does
* not match the specified expected class
*/
public <T> T getFromSession(String name, Class<T> expectedClass)
@@ -275,12 +278,18 @@
* at runtime
* @param <T> the type of the object to be retrieved
* @return the value associated with the specified name
- * @throws IllegalArgumentException if the value associated with the specified name is
not <code>null</code> and does
+ * @throws IllegalArgumentException if the value associated with the specified name is
not <code>null</code> and
+ * does
* not match the specified expected class
*/
private <T> T getFromSession(String name, Class<T> expectedClass,
Map<String, Object> sessionMap, String errorMessage)
{
Object result = sessionMap.get(name);
+ return checkObject(result, expectedClass, errorMessage);
+ }
+
+ protected <T> T checkObject(Object result, Class<T> expectedClass, String
errorMessage)
+ {
if (result != null && !expectedClass.isAssignableFrom(result.getClass()))
{
throw new IllegalArgumentException(errorMessage.replace(CURRENT_PLACEHOLDER,
result.toString()));
@@ -288,4 +297,6 @@
return expectedClass.cast(result);
}
+
+ public abstract <T> T findBean(String name, Class<T> type);
}
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-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -47,6 +47,7 @@
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
import javax.xml.namespace.QName;
+import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -63,11 +64,10 @@
* @version $Revision: 12865 $
* @since 2.6
*/
-public class ConsumerBean extends ManagedBean
+public class ConsumerBean extends ManagedBean implements Serializable
{
public static final SelectablePortletToHandleFunction SELECTABLE_TO_HANDLE = new
SelectablePortletToHandleFunction();
private transient WSRPConsumer consumer;
- private transient ConsumerRegistry registry;
private transient ConsumerManagerBean manager;
private boolean modified;
private String wsdl;
@@ -92,11 +92,6 @@
private DataModel existingExports;
private ExportInfoDisplay currentExport;
- public void setRegistry(ConsumerRegistry registry)
- {
- this.registry = registry;
- }
-
public void setManager(ConsumerManagerBean manager)
{
this.manager = manager;
@@ -155,7 +150,7 @@
// if we don't have an id, try to get it from the ConsumerManagerBean
if (id == null)
{
- id = manager.getSelectedId();
+ id = getManager().getSelectedId();
}
// if it's still null, output an error
@@ -406,7 +401,7 @@
// if the registration is locally modified, bypass the refresh as it will not
yield a proper result
if (!isRegistrationLocallyModified())
{
- manager.refresh(consumer);
+ getManager().refresh(consumer);
}
else
{
@@ -533,7 +528,7 @@
public ConsumerRegistry getRegistry()
{
- return registry;
+ return getManager().getRegistry();
}
public DataModel getPortlets()
@@ -778,6 +773,15 @@
this.consumer = consumer;
}
+ public ConsumerManagerBean getManager()
+ {
+ if (manager == null)
+ {
+ manager = beanContext.getFromSession("consumersMgr",
ConsumerManagerBean.class);
+ }
+ return manager;
+ }
+
public static class SelectablePortletHandle implements
Comparable<SelectablePortletHandle>
{
private String handle;
@@ -979,12 +983,12 @@
public static class FailedPortletsDisplay
{
private QName errorCode;
- private List<String> faiedPortlets;
+ private List<String> faliedPortlets;
public FailedPortletsDisplay(QName errorCode, List<String> failedPortlets)
{
this.errorCode = errorCode;
- this.faiedPortlets = failedPortlets;
+ this.faliedPortlets = failedPortlets;
}
public QName getErrorCode()
@@ -994,7 +998,7 @@
public List<String> getFailedPortlets()
{
- return faiedPortlets;
+ return faliedPortlets;
}
}
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-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -68,6 +68,12 @@
public ConsumerRegistry getRegistry()
{
+ // if the registry is not set, get it from the application scope
+ if (registry == null)
+ {
+ registry = beanContext.findBean("ConsumerRegistry",
ConsumerRegistry.class);
+ }
+
return registry;
}
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/JSFBeanContext.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/JSFBeanContext.java 2011-09-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/JSFBeanContext.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -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.
@@ -32,6 +32,7 @@
import javax.faces.context.FacesContext;
import javax.portlet.PortletRequest;
import javax.servlet.http.HttpServletRequest;
+import java.io.Serializable;
import java.util.Locale;
import java.util.Map;
@@ -40,7 +41,7 @@
* @version $Revision: 13413 $
* @since 2.6
*/
-public class JSFBeanContext extends BeanContext
+public class JSFBeanContext extends BeanContext implements Serializable
{
public String getParameter(String key)
{
@@ -58,6 +59,14 @@
return JSFBeanContext.getSessionMap(FacesContext.getCurrentInstance());
}
+ @Override
+ public <T> T findBean(String name, Class<T> type)
+ {
+ final FacesContext facesContext = FacesContext.getCurrentInstance();
+ final Object candidate =
facesContext.getApplication().evaluateExpressionGet(facesContext, "#{" + name +
"}", type);
+ return checkObject(candidate, type, "Bean named '" + name +
"' is not of type '" + type.getSimpleName() + "'");
+ }
+
public static Map<String, Object> getSessionMap(FacesContext facesContext)
{
return facesContext.getExternalContext().getSessionMap();
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-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ManagedBean.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -27,6 +27,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.Serializable;
import java.util.regex.Pattern;
@@ -35,11 +36,11 @@
* @version $Revision: 13413 $
* @since 2.6
*/
-public abstract class ManagedBean
+public abstract class ManagedBean implements Serializable
{
protected transient Logger log = LoggerFactory.getLogger(getClass());
- protected transient BeanContext beanContext;
+ protected BeanContext beanContext;
private String cancelOutcome;
@@ -47,7 +48,7 @@
public static final String INVALID_PATH = "INVALID_PATH_ERROR";
public static final String DUPLICATE = "DUPLICATE_ERROR";
- public static interface PropertyValidator
+ public static interface PropertyValidator extends Serializable
{
boolean checkForDuplicates();
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java 2011-09-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -48,13 +48,13 @@
*/
public class ProducerBean extends ManagedBean
{
- private ProducerConfigurationService configurationService;
+ private transient ProducerConfigurationService configurationService;
private String policyClassName;
private String validatorClassName;
private static final String PROPERTY = "property";
private static final String PRODUCER = "producer";
private String selectedProp;
- private LocalProducerConfiguration localProducerConfiguration;
+ private transient LocalProducerConfiguration localProducerConfiguration;
public ProducerConfigurationService getConfigurationService()
{
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/faces-config.xml 2011-09-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/main/webapp/WEB-INF/faces-config.xml 2011-09-13
13:55:51 UTC (rev 7382)
@@ -93,11 +93,6 @@
<value>#{beanContext}</value>
</managed-property>
<managed-property>
- <property-name>registry</property-name>
-
<property-class>org.gatein.wsrp.consumer.registry.ConsumerRegistry</property-class>
- <value>#{applicationScope.ConsumerRegistry}</value>
- </managed-property>
- <managed-property>
<property-name>id</property-name>
<value>#{sessionScope.consumerId}</value>
</managed-property>
Modified:
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java 2011-09-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -1,24 +1,25 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+ * JBoss, a division of Red Hat
+ * 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.
+ *
+ * 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.gatein.wsrp.admin.ui;
@@ -115,5 +116,11 @@
{
throw new UnsupportedOperationException();
}
+
+ @Override
+ public <T> T findBean(String name, Class<T> type)
+ {
+ throw new UnsupportedOperationException();
+ }
}
}
Modified:
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/ConsumerBeanTestCase.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/ConsumerBeanTestCase.java 2011-09-13
11:54:01 UTC (rev 7381)
+++
components/wsrp/branches/clustering/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/ConsumerBeanTestCase.java 2011-09-13
13:55:51 UTC (rev 7382)
@@ -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.
@@ -54,7 +54,6 @@
bean = new ConsumerBean();
ConsumerRegistry registry = new TestInMemoryConsumerRegistry();
registry.createConsumer(CONSUMER_ID, null, WSDL);
- bean.setRegistry(registry);
bean.setBeanContext(new TestBeanContext());
// consumer associated with bean is null at this point so it should be loaded from
the registry
@@ -158,6 +157,12 @@
{
throw new NotYetImplemented();
}
+
+ @Override
+ public <T> T findBean(String name, Class<T> type)
+ {
+ throw new NotYetImplemented();
+ }
}
private static class TestInMemoryConsumerRegistry extends InMemoryConsumerRegistry