Author: julien(a)jboss.com
Date: 2008-02-21 20:12:15 -0500 (Thu, 21 Feb 2008)
New Revision: 10074
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerUserInfo.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
Log:
cleanup in metadata usage in container impl, now it does not use anymore the meta data
build from the xml descriptors
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-22
00:12:06 UTC (rev 10073)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -40,6 +40,7 @@
import org.jboss.portal.portlet.impl.metadata.PortletApplication20MetaData;
import org.jboss.portal.portlet.impl.metadata.PublicRenderParameterMetaData;
import org.jboss.portal.portlet.impl.metadata.ListenerMetaData;
+import org.jboss.portal.portlet.impl.metadata.UserAttributeMetaData;
import org.jboss.portal.portlet.impl.metadata.filter.FilterMetaData;
import org.jboss.portal.portlet.impl.metadata.filter.FilterMappingMetaData;
import org.jboss.portal.portlet.info.MetaInfo;
@@ -67,6 +68,7 @@
import java.util.LinkedHashMap;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Set;
import java.net.URI;
import java.net.URISyntaxException;
@@ -150,6 +152,9 @@
private ContainerPortletApplicationInfo portletApplication;
/** . */
+ private final String portletApplicationId;
+
+ /** . */
private final Map<String, ContainerPortletInfo> portlets;
/** . */
@@ -159,9 +164,11 @@
private Map<String, ContainerOptionInfo> applicationOptions;
public ContainerInfoBuilder(
+ String portletApplicationId,
PortletApplication10MetaData portletApplicationMD,
ContainerInfoBuilderContext context)
{
+ this.portletApplicationId = portletApplicationId;
this.portletApplicationMD = portletApplicationMD;
this.context = context;
this.events = new LinkedHashMap<QName, ContainerEventInfo>();
@@ -409,7 +416,25 @@
}
//
- return new ContainerPortletApplicationInfo(defaultNamespace, allFilters.values(),
listeners);
+ Map<String, UserAttributeMetaData> userAttributesMD =
portletApplicationMD.getUserAttributes();
+ Set<String> supportedUserAttributes;
+ if (userAttributesMD != null)
+ {
+ supportedUserAttributes =
Collections.unmodifiableSet(userAttributesMD.keySet());
+ }
+ else
+ {
+ supportedUserAttributes = Collections.emptySet();
+ }
+ ContainerUserInfo user = new ContainerUserInfo(supportedUserAttributes);
+
+ //
+ return new ContainerPortletApplicationInfo(
+ portletApplicationId,
+ defaultNamespace,
+ allFilters.values(),
+ listeners,
+ user);
}
private ContainerListenerInfo build(ListenerMetaData listenerMD)
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java 2008-02-22
00:12:06 UTC (rev 10073)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -36,18 +36,26 @@
{
/** . */
+ private final String id;
+
+ /** . */
private final String defaultNamespace;
/** . */
private final List<ContainerListenerInfo> listeners;
/** . */
+ private final ContainerUserInfo user;
+
+ /** . */
private final Map<String, ContainerFilterInfo> filters;
public ContainerPortletApplicationInfo(
+ String id,
String defaultNamespace,
Collection<ContainerFilterInfo> filters,
- List<ContainerListenerInfo> listeners)
+ List<ContainerListenerInfo> listeners,
+ ContainerUserInfo user)
{
LinkedHashMap<String, ContainerFilterInfo> tmp = new LinkedHashMap<String,
ContainerFilterInfo>();
for (ContainerFilterInfo filter : filters)
@@ -56,11 +64,18 @@
}
//
+ this.id = id;
this.defaultNamespace = defaultNamespace;
this.listeners = listeners;
this.filters = Collections.unmodifiableMap(tmp);
+ this.user = user;
}
+ public String getId()
+ {
+ return id;
+ }
+
public String getDefaultNamespace()
{
return defaultNamespace;
@@ -75,4 +90,9 @@
{
return filters;
}
+
+ public ContainerUserInfo getUser()
+ {
+ return user;
+ }
}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerUserInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerUserInfo.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerUserInfo.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.info;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContainerUserInfo
+{
+
+ /** . */
+ private Set<String> supportedUserAttributes;
+
+ public ContainerUserInfo(Set<String> supportedUserAttributes)
+ {
+ this.supportedUserAttributes = supportedUserAttributes;
+ }
+
+ public Set<String> getSupportedUserAttributes()
+ {
+ return supportedUserAttributes;
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-22
00:12:06 UTC (rev 10073)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -25,11 +25,9 @@
import org.jboss.portal.portlet.impl.jsr168.api.PortletContextImpl;
import org.jboss.portal.portlet.impl.jsr168.api.PortletURLGenerationListenerChain;
import org.jboss.portal.portlet.impl.jsr168.api.FilterConfigImpl;
-import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
import org.jboss.portal.portlet.impl.info.ContainerListenerInfo;
import org.jboss.portal.portlet.impl.info.ContainerFilterInfo;
-import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.container.PortletContainer;
@@ -57,18 +55,12 @@
/** . */
protected final ContainerPortletApplicationInfo info;
- /** . */
- protected final PortletApplication10MetaData metaData;
+ /** Logger. */
+ protected final Logger log;
/** . */
- protected final JBossApplicationMetaData jbossMetaData;
-
- /** . */
protected PortletApplicationContext context;
- /** Logger. */
- protected Logger log;
-
/** . */
protected LinkedHashMap<String, PortletContainer> portlets;
@@ -76,24 +68,16 @@
protected PortletContextImpl portletContext;
/** . */
- protected String version;
-
- /** . */
protected PortletURLGenerationListener urlListener;
/**
- * Todo remove meta data reference and use info instead.
+ * @param info the portlet application info
*/
- public PortletApplicationImpl(
- ContainerPortletApplicationInfo info,
- PortletApplication10MetaData metaData,
- JBossApplicationMetaData jbossMetaData)
+ public PortletApplicationImpl(ContainerPortletApplicationInfo info)
{
this.info = info;
- this.metaData = metaData;
- this.jbossMetaData = jbossMetaData;
this.portlets = new LinkedHashMap<String, PortletContainer>();
- this.log = Logger.getLogger(PortletApplication.class);
+ this.log = Logger.getLogger(PortletApplication.class.getName() + "." +
info.getId().replace('.', '_'));
}
public void setContext(PortletApplicationContext context)
@@ -103,17 +87,17 @@
public String getId()
{
- return metaData.getId();
+ return info.getId();
}
public void addPortletFilter(org.jboss.portal.portlet.container.PortletFilter filter)
{
-
+ //
}
public void removePortletFilter(org.jboss.portal.portlet.container.PortletFilter
filter)
{
-
+ //
}
public ContainerPortletApplicationInfo getInfo()
@@ -121,16 +105,6 @@
return info;
}
- public PortletApplication10MetaData getMetaData()
- {
- return metaData;
- }
-
- public JBossApplicationMetaData getJBossMetaData()
- {
- return jbossMetaData;
- }
-
public void addPortletContainer(PortletContainer container)
{
portlets.put(container.getId(), container);
@@ -145,8 +119,6 @@
public void start() throws Exception
{
-// this.log = Logger.getLogger(PortletApplication.class.getName() + "." +
context.getContextPath().replace('.', '_'));
-
PortletContextImpl portletContext = new
PortletContextImpl(context.getServletContext());
//
@@ -184,23 +156,16 @@
}
//
- this.version = metaData.getVersion();
this.portletContext = portletContext;
this.urlListener = listeners.size() == 0 ? null : new
PortletURLGenerationListenerChain(Collections.unmodifiableList(listeners));
}
public void stop()
{
- this.version = null;
this.portletContext = null;
this.urlListener = null;
}
- public String getVersion()
- {
- return version;
- }
-
public PortletContext getPortletContext()
{
return portletContext;
@@ -254,44 +219,9 @@
public String toString()
{
- return "PortletWebApp[" + metaData.getId() + "]";
+ return "PortletApplication[" + getId() + "]";
}
- private static class FilterKey
- {
-
- /** . */
- private final String name;
-
- /** . */
- private final Class<? extends PortletFilter> phase;
-
- private FilterKey(String name, Class<? extends PortletFilter> phase)
- {
- this.name = name;
- this.phase = phase;
- }
-
- public int hashCode()
- {
- return name.hashCode() + name.hashCode();
- }
-
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
- if (obj instanceof FilterKey)
- {
- FilterKey that = (FilterKey)obj;
- return name.equals(that.name) && phase == that.phase;
- }
- return false;
- }
- }
-
static class FilterLifecycle extends ClassInstanceLifeCycle<PortletFilter>
{
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-02-22
00:12:06 UTC (rev 10073)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -22,8 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168;
-import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
-import org.jboss.portal.portlet.impl.metadata.UserAttributeMetaData;
+import org.jboss.portal.portlet.impl.info.ContainerUserInfo;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.container.PortletContainer;
@@ -106,14 +105,13 @@
{
// Get portlet application metadata
PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getPortletApplication();
- PortletApplication10MetaData pamd = portletApp.getMetaData();
- Map<String, UserAttributeMetaData> uaMD = pamd.getUserAttributes();
+ ContainerUserInfo userInfo = portletApp.getInfo().getUser();
// Clone the map
infos = new HashMap<String, String>(infos);
// Keep only what is of interest with respect to what the portlet app
defines
- infos.keySet().retainAll(uaMD.keySet());
+ infos.keySet().retainAll(userInfo.getSupportedUserAttributes());
// Make it immutable
infos = Collections.unmodifiableMap(infos);
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java 2008-02-22
00:12:06 UTC (rev 10073)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -22,11 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.spi;
-import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-import org.jboss.portal.common.i18n.ResourceBundleManager;
/**
* Enables the creation of custom portlet info implementations.
@@ -40,13 +37,7 @@
* Create a new portlet info from the provided meta data.
*
* @param portletMD the portlet meta data
- * @param jbossPortletMD
- * @param resourceBundleManager the resource bundle manager
* @return the runtime portlet meta data
*/
- PortletInfo createPortletInfo(
- PortletApplicationContext portletApplicationContext,
- PortletMetaData portletMD,
- JBossPortletMetaData jbossPortletMD,
- ResourceBundleManager resourceBundleManager);
+ PortletInfo createPortletInfo(PortletMetaData portletMD);
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-02-22
00:12:06 UTC (rev 10073)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -29,7 +29,6 @@
import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventBroadcaster;
import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEvent;
-import org.jboss.portal.portlet.container.managed.ManagedObjectAddedEvent;
import org.jboss.portal.portlet.container.managed.ManagedObjectEvent;
import org.jboss.portal.portlet.container.managed.ManagedObject;
import org.jboss.portal.portlet.container.managed.ManagedObjectLifeCycleEvent;
@@ -263,7 +262,6 @@
// Unmarshal
PortletApplication10MetaData portletApplicationMD =
(PortletApplication10MetaData)unmarshaller.unmarshal(in, new ValueTrimmingFilter(factory),
null);
- portletApplicationMD.setId(webApp.getContextPath());
//
return portletApplicationMD;
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-22
00:12:06 UTC (rev 10073)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-22
01:12:15 UTC (rev 10074)
@@ -42,7 +42,6 @@
import org.jboss.portal.portlet.container.PortletContainerContext;
import org.jboss.portal.portlet.container.PortletFilterContext;
import org.jboss.portal.portlet.container.managed.ManagedObjectRegistryEventListener;
-import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.web.WebApp;
/**
@@ -90,14 +89,11 @@
//
ContainerInfoBuilderContext builderContext = new
ContainerInfoBuilderContextImpl(metaData, webApp);
- ContainerInfoBuilder builder = new ContainerInfoBuilder(metaData, builderContext);
+ ContainerInfoBuilder builder = new ContainerInfoBuilder(webApp.getContextPath(),
metaData, builderContext);
builder.build();
//
- PortletApplicationObject portletApplicationObject = new PortletApplicationImpl(
- builder.getApplication(),
- metaData,
- new JBossApplicationMetaData());
+ PortletApplicationObject portletApplicationObject = new
PortletApplicationImpl(builder.getApplication());
PortletApplicationContext portletApplicationContext = new
PortletApplicationContextImpl(webApp);
@@ -129,7 +125,7 @@
// Now create deps
for (String filterRef : containerInfo.getFilterRefs())
{
- PortletFilterLifeCycle portletFilterLifeCycle =
(PortletFilterLifeCycle)portletApplicationLifeCycle.getManagedPortletFilter(filterRef);
+ PortletFilterLifeCycle portletFilterLifeCycle =
portletApplicationLifeCycle.getManagedPortletFilter(filterRef);
//
if (portletFilterLifeCycle != null)