cziegeler 2004/01/27 00:05:35
Modified: src/blocks/portal/java/org/apache/cocoon/portal/pluto/om WebApplicationDefinitionImpl.java PortletDefinitionImpl.java PortletDefinitionRegistryImpl.java servletdefinitionmapping.xml src/blocks/portal/samples/profiles/copletinstancedata portal.xml src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl PortletAdapter.java src/blocks/portal/samples/profiles/copletdata portal.xml src/blocks/portal/java/org/apache/cocoon/portal/pluto/services/factory FactoryManagerServiceImpl.java src/blocks/portal/samples/profiles/layout portal.xml Added: src/blocks/portal/samples/profiles/copletinstancedata portal-user-anonymous.xml src/blocks/portal/WEB-INF portlet.xml src/blocks/portal/java/org/apache/cocoon/portal/pluto/factory PortletInvokerFactoryImpl.java LocalPortletInvokerImpl.java src/blocks/portal/java/org/apache/cocoon/portal/pluto/test TestPortlet.java Log: Add support for "local" portlets Revision Changes Path 1.3 +15 -16 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/WebApplicationDefinitionImpl.java Index: WebApplicationDefinitionImpl.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/WebApplicationDefinitionImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WebApplicationDefinitionImpl.java 23 Jan 2004 12:34:31 -0000 1.2 +++ WebApplicationDefinitionImpl.java 27 Jan 2004 08:05:34 -0000 1.3 @@ -81,28 +81,27 @@ // <not used variables - only for castor> - public String icon = null; - public String distributable = null; - public String sessionConfig = null; - public String mimeMapping = null; - public String welcomeFileList = null; - public String errorPage = null; - public String taglib = null; - public String resourceRef = null; - public String securityConstraint = null; - public String loginConfig = null; - public String securityRole = null; - public String envEntry = null; - public String ejbRef = null; + public String icon; + public String distributable; + public String sessionConfig; + public String welcomeFileList; + public String errorPage; + public String taglib; + public String resourceRef; + public String securityConstraint; + public String loginConfig; + public String securityRole; + public String envEntry; + public String ejbRef; // </not used variables - only for castor> - private String contextPath = null; + private String contextPath; private DescriptionSet descriptions = new DescriptionSetImpl(); private DisplayNameSet displayNames = new DisplayNameSetImpl(); private String id = ""; private ParameterSet initParams = new ParameterSetImpl(); - private ObjectID objectId = null; + private ObjectID objectId; private Collection servletMappings = new ArrayList(); private ServletDefinitionList servlets = new ServletDefinitionListImpl(); private SecurityRoleSet securityRoles = new SecurityRoleSetImpl(); 1.2 +83 -97 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionImpl.java Index: PortletDefinitionImpl.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PortletDefinitionImpl.java 22 Jan 2004 14:01:20 -0000 1.1 +++ PortletDefinitionImpl.java 27 Jan 2004 08:05:34 -0000 1.2 @@ -59,6 +59,7 @@ import org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl; import org.apache.cocoon.portal.pluto.om.common.SecurityRoleRefSetImpl; import org.apache.cocoon.portal.pluto.om.common.Support; +import org.apache.pluto.invoker.PortletInvoker; import org.apache.pluto.om.common.Description; import org.apache.pluto.om.common.DescriptionSet; import org.apache.pluto.om.common.DisplayName; @@ -112,10 +113,15 @@ // contains Locale objects private ArrayList supportedLocales = new ArrayList(); + /** is this a local portlet? */ + protected boolean localPortlet = false; + + /** The local portlet invoker */ + protected PortletInvoker localPortletInvoker; + // PortletDefinition implementation. - public ObjectID getId() - { + public ObjectID getId() { if (objectId==null) { objectId = org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl.createFromString(getGUID()); } @@ -123,13 +129,11 @@ return objectId; } - public String getClassName() - { + public String getClassName() { return className; } - public String getName() - { + public String getName() { return name; } @@ -140,67 +144,55 @@ return descriptions.get(locale); } - public LanguageSet getLanguageSet() - { + public LanguageSet getLanguageSet() { ((LanguageSetImpl)castorResources).setClassLoader(this.getPortletClassLoader()); return castorResources; } - public ParameterSet getInitParameterSet() - { + public ParameterSet getInitParameterSet() { return initParams; } - public SecurityRoleRefSet getInitSecurityRoleRefSet() - { + public SecurityRoleRefSet getInitSecurityRoleRefSet() { return initSecurityRoleRefs; } - public PreferenceSet getPreferenceSet() - { + public PreferenceSet getPreferenceSet() { ((PreferenceSetImpl)preferences).setClassLoader(this.getPortletClassLoader()); return preferences; } - public ContentTypeSet getContentTypeSet() - { + public ContentTypeSet getContentTypeSet() { return contentTypes; } - public PortletApplicationDefinition getPortletApplicationDefinition() - { + public PortletApplicationDefinition getPortletApplicationDefinition() { return application; } - public ServletDefinition getServletDefinition() - { + public ServletDefinition getServletDefinition() { return servlet; } - public DisplayName getDisplayName(Locale locale) - { + public DisplayName getDisplayName(Locale locale) { return displayNames.get(locale); } - public String getExpirationCache() - { + public String getExpirationCache() { return expirationCache; } // PortletDefinitionCtrl implementation. - public void setId(String id) - { + public void setId(String id) { // todo excep } - public void setClassName(String className) - { + public void setClassName(String className) { this.className = className; } - public void setName(String name) - { + public void setName(String name) { this.name = name; } @@ -211,24 +203,20 @@ this.descriptions = descriptions; } - public void setDisplayNames(DisplayNameSet displayNames) - { + public void setDisplayNames(DisplayNameSet displayNames) { this.displayNames = displayNames; } - public void setPortletClassLoader(ClassLoader loader) - { + public void setPortletClassLoader(ClassLoader loader) { this.classLoader = loader; } - public void store() throws java.io.IOException - { + public void store() throws java.io.IOException { // not supported } - public void postBuild(Object parameter) throws Exception - { + public void postBuild(Object parameter) throws Exception { setServletDefinition((ServletDefinition)parameter); ((Support)contentTypes).postBuild(this); if (castorResources!=null) { @@ -236,8 +224,7 @@ } } - public void postLoad(Object parameter) throws Exception - { + public void postLoad(Object parameter) throws Exception { ((Support)contentTypes).postLoad(this); // create Locale objects for given locale entries @@ -271,23 +258,20 @@ ((Support)displayNames).postLoad(parameter); } - public void postStore(Object parameter) throws Exception - { + public void postStore(Object parameter) throws Exception { ((Support)contentTypes).postStore(this); if (castorResources!=null) { ((Support)castorResources).postStore(this); } } - public void preBuild(Object parameter) throws Exception - { + public void preBuild(Object parameter) throws Exception { setPortletApplicationDefinition((PortletApplicationDefinition)parameter); ((Support)contentTypes).preBuild(this); if (castorResources!=null) { ((Support)castorResources).preBuild(this); } } - public void preStore(Object parameter) throws Exception - { + public void preStore(Object parameter) throws Exception { ((Support)contentTypes).preStore(this); if (castorResources!=null) { ((Support)castorResources).preStore(this); @@ -296,43 +280,35 @@ // additional methods. - public Collection getCastorContentTypes() - { + public Collection getCastorContentTypes() { return(ContentTypeSetImpl)contentTypes; } - public Collection getCastorDisplayNames() - { + public Collection getCastorDisplayNames() { return(DisplayNameSetImpl)displayNames; } - public Collection getCastorDescriptions() - { + public Collection getCastorDescriptions() { return(DescriptionSetImpl)descriptions; } - public Collection getDescriptions() - { + public Collection getDescriptions() { return(DescriptionSetImpl)descriptions; } - public Collection getCastorInitParams() - { + public Collection getCastorInitParams() { return(ParameterSetImpl)initParams; } - public SecurityRoleRefSet getCastorInitSecurityRoleRefs() - { + public SecurityRoleRefSet getCastorInitSecurityRoleRefs() { return initSecurityRoleRefs; } - public PreferenceSet getCastorPreferences() - { + public PreferenceSet getCastorPreferences() { return preferences; } - public LanguageSet getCastorResources() - { + public LanguageSet getCastorResources() { return castorResources; } @@ -349,14 +325,12 @@ // additional internal methods - public Collection getCastorSupportedLocales() - { + public Collection getCastorSupportedLocales() { return castorSupportedLocales; } - private String getGUID() - { + private String getGUID() { String portletID = ""; if (getName()!=null) portletID += getName(); @@ -364,80 +338,92 @@ return portletID; } - public ClassLoader getPortletClassLoader() - { + public ClassLoader getPortletClassLoader() { return classLoader; } - public String getResourceBundle() - { + public String getResourceBundle() { return this.resourceBundle; } - public Collection getSupportedLocales() - { + public Collection getSupportedLocales() { return supportedLocales; } - public void setCastorContentTypes(ContentTypeSet castorContentTypes) - { + public void setCastorContentTypes(ContentTypeSet castorContentTypes) { this.contentTypes = castorContentTypes; } - public void setCastorInitParams(ParameterSet castorInitParams) - { + public void setCastorInitParams(ParameterSet castorInitParams) { this.initParams = castorInitParams; } - public void setCastorInitSecurityRoleRefs(SecurityRoleRefSet castorInitSecurityRoleRefs) - { + public void setCastorInitSecurityRoleRefs(SecurityRoleRefSet castorInitSecurityRoleRefs) { this.initSecurityRoleRefs = castorInitSecurityRoleRefs; } - public void setCastorDisplayNames(DisplayNameSet castorDisplayNames) - { + public void setCastorDisplayNames(DisplayNameSet castorDisplayNames) { this.displayNames = castorDisplayNames; } - public void setCastorDescriptions(DescriptionSet castorDescriptions) - { + public void setCastorDescriptions(DescriptionSet castorDescriptions) { this.descriptions = castorDescriptions; } - public void setCastorPreferences(PreferenceSet castorPreferences) - { + public void setCastorPreferences(PreferenceSet castorPreferences) { this.preferences = castorPreferences; } - public void setCastorResources(LanguageSet resources) - { + public void setCastorResources(LanguageSet resources) { this.castorResources = resources; } - public void setCastorSupportedLocales(Collection castorSupportedLocales) - { + public void setCastorSupportedLocales(Collection castorSupportedLocales) { this.castorSupportedLocales = (ArrayList)castorSupportedLocales; } - public void setExpirationCache(String expirationCache) - { + public void setExpirationCache(String expirationCache) { this.expirationCache = expirationCache; } - protected void setPortletApplicationDefinition(PortletApplicationDefinition application) - { + protected void setPortletApplicationDefinition(PortletApplicationDefinition application) { this.application = application; } - public void setResourceBundle(String resourceBundle) - { + public void setResourceBundle(String resourceBundle) { this.resourceBundle = resourceBundle; } - protected void setServletDefinition(ServletDefinition servlet) - { + protected void setServletDefinition(ServletDefinition servlet) { this.servlet = servlet; } + /** + * @return Returns the localPortlet. + */ + public boolean isLocalPortlet() { + return this.localPortlet; + } + + /** + * @param localPortlet The localPortlet to set. + */ + public void setLocalPortlet(boolean localPortlet) { + this.localPortlet = localPortlet; + } + + /** + * @return Returns the localPortletInvoker. + */ + public PortletInvoker getLocalPortletInvoker() { + return this.localPortletInvoker; + } + /** + * Set a local portlet invoker for caching + * @param localPortletInvoker The localPortletInvoker to set. + */ + public void setLocalPortletInvoker(PortletInvoker localPortletInvoker) { + this.localPortletInvoker = localPortletInvoker; + } } 1.2 +11 -3 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java Index: PortletDefinitionRegistryImpl.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PortletDefinitionRegistryImpl.java 22 Jan 2004 14:01:20 -0000 1.1 +++ PortletDefinitionRegistryImpl.java 27 Jan 2004 08:05:34 -0000 1.2 @@ -104,7 +104,10 @@ // Helper lists and hashtables to access the data as fast as possible // List containing all portlet applications available in the system protected PortletApplicationDefinitionListImpl registry = new PortletApplicationDefinitionListImpl(); + /** All portlet definitions, hashed by ObjectId */ protected Map portletsKeyObjectId = new HashMap(); + /** Our context name */ + protected String contextName; /* (non-Javadoc) * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) @@ -152,7 +155,9 @@ } String baseWMDir = servletContext.getRealPath(""); - baseWMDir = baseWMDir.substring(0, baseWMDir.lastIndexOf(File.separatorChar)+1); + int lastIndex = baseWMDir.lastIndexOf(File.separatorChar); + this.contextName = baseWMDir.substring(lastIndex+1); + baseWMDir = baseWMDir.substring(0, lastIndex+1); this.load(baseWMDir,mappingPortletXml, mappingWebXml); } catch (Exception e) { e.printStackTrace(); @@ -254,8 +259,11 @@ final Iterator portlets = portletApp.getPortletDefinitionList().iterator(); while (portlets.hasNext()) { final PortletDefinition portlet = (PortletDefinition)portlets.next(); - portletsKeyObjectId.put(portlet.getId(), portlet); + + if (this.contextName.equals(webModule)) { + ((PortletDefinitionImpl)portlet).setLocalPortlet(true); + } } } 1.2 +0 -3 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/servletdefinitionmapping.xml Index: servletdefinitionmapping.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/servletdefinitionmapping.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- servletdefinitionmapping.xml 22 Jan 2004 14:01:20 -0000 1.1 +++ servletdefinitionmapping.xml 27 Jan 2004 08:05:34 -0000 1.2 @@ -189,9 +189,6 @@ <field name="sessionConfig" transient="true" direct="true"> <bind-xml name="session-config" node="element"/> </field> - <field name="mimeMapping" transient="true" direct="true"> - <bind-xml name="mime-mapping" node="element"/> - </field> <field name="welcomeFileList" transient="true" direct="true"> <bind-xml name="welcome-file-list" node="element"/> </field> 1.9 +4 -0 cocoon-2.1/src/blocks/portal/samples/profiles/copletinstancedata/portal.xml Index: portal.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/copletinstancedata/portal.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- portal.xml 22 Jan 2004 14:12:49 -0000 1.8 +++ portal.xml 27 Jan 2004 08:05:34 -0000 1.9 @@ -75,4 +75,8 @@ <coplet-data>Portlet2</coplet-data> </coplet-instance-data> + <coplet-instance-data id="TestPortlet-1" name="standard"> + <coplet-data>TestPortlet1</coplet-data> + </coplet-instance-data> + </coplets> 1.1 cocoon-2.1/src/blocks/portal/samples/profiles/copletinstancedata/portal-user-anonymous.xml Index: portal-user-anonymous.xml =================================================================== <?xml version="1.0" encoding="UTF-8"?> <coplets> <coplet-instance-data id="Portal-Intro-1" name="standard"> <coplet-data>Portal-Intro</coplet-data> </coplet-instance-data> <coplet-instance-data id="Portal-Right-1" name="standard"> <coplet-data>Portal-Right</coplet-data> </coplet-instance-data> <coplet-instance-data id="Portal-Left-1" name="standard"> <coplet-data>Portal-Left</coplet-data> </coplet-instance-data> <coplet-instance-data id="Portal-Bottom-1" name="standard"> <coplet-data>Portal-Bottom</coplet-data> </coplet-instance-data> <coplet-instance-data id="Portal-Demo-1" name="standard"> <coplet-data>Portal-Demo</coplet-data> </coplet-instance-data> <coplet-instance-data id="Login-1" name="standard"> <coplet-data>Login</coplet-data> </coplet-instance-data> </coplets> 1.3 +35 -24 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java Index: PortletAdapter.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PortletAdapter.java 23 Jan 2004 12:34:31 -0000 1.2 +++ PortletAdapter.java 27 Jan 2004 08:05:34 -0000 1.3 @@ -47,6 +47,7 @@ import java.util.Map; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.avalon.framework.context.Context; @@ -55,6 +56,7 @@ import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.cocoon.components.ContextHelper; +import org.apache.cocoon.environment.http.HttpEnvironment; import org.apache.cocoon.portal.PortalManager; import org.apache.cocoon.portal.coplet.CopletInstanceData; import org.apache.cocoon.portal.impl.PortletPortalManager; @@ -63,6 +65,7 @@ import org.apache.cocoon.portal.pluto.om.PortletWindowImpl; import org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl; import org.apache.cocoon.portal.pluto.servlet.ServletRequestImpl; +import org.apache.cocoon.portal.pluto.servlet.ServletResponseImpl; import org.apache.cocoon.portal.serialization.IncludingHTMLSerializer; import org.apache.cocoon.xml.AttributesImpl; import org.apache.pluto.PortletContainer; @@ -131,30 +134,38 @@ PortletApplicationEntity pae = registry.getPortletApplicationEntityList().get(ObjectIDImpl.createFromString("cocoon")); PortletEntity portletEntity = ((PortletEntityListImpl)pae.getPortletEntityList()).add(pae, portletEntityId, coplet, registry); - - // create the window - PortletWindow portletWindow = new PortletWindowImpl(portletEntityId); - ((PortletWindowCtrl)portletWindow).setId(coplet.getId()); - ((PortletWindowCtrl)portletWindow).setPortletEntity(portletEntity); - PortletWindowList windowList = portletEntity.getPortletWindowList(); - ((PortletWindowListCtrl)windowList).add(portletWindow); - coplet.setAttribute("window", portletWindow); - // load the portlet - final Map objectModel = ContextHelper.getObjectModel(this.context); - final ServletRequestImpl req = (ServletRequestImpl) objectModel.get("portlet-request"); - final HttpServletResponse res = (HttpServletResponse) objectModel.get("portlet-response"); - PortletPortalManager.copletInstanceData.set(coplet); - try { - this.portletContainer.portletLoad(portletWindow, req.getRequest(portletWindow), - res); - } catch (Exception e) { - this.getLogger().error("Error loading portlet " + portletEntityId, e); - // remove portlet entity - coplet.removeAttribute("window"); - ((PortletEntityListImpl)pae.getPortletEntityList()).remove(portletEntity); - } finally { - PortletPortalManager.copletInstanceData.set(null); + if ( portletEntity.getPortletDefinition() != null ) { + // create the window + PortletWindow portletWindow = new PortletWindowImpl(portletEntityId); + ((PortletWindowCtrl)portletWindow).setId(coplet.getId()); + ((PortletWindowCtrl)portletWindow).setPortletEntity(portletEntity); + PortletWindowList windowList = portletEntity.getPortletWindowList(); + ((PortletWindowListCtrl)windowList).add(portletWindow); + coplet.setAttribute("window", portletWindow); + + // load the portlet + final Map objectModel = ContextHelper.getObjectModel(this.context); + ServletRequestImpl req = (ServletRequestImpl) objectModel.get("portlet-request"); + if ( req == null ) { + final HttpServletResponse res = (HttpServletResponse) objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT); + objectModel.put("portlet-response", new ServletResponseImpl(res)); + req = new ServletRequestImpl((HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT), null); + objectModel.put("portlet-request", req); + } + final HttpServletResponse res = (HttpServletResponse) objectModel.get("portlet-response"); + PortletPortalManager.copletInstanceData.set(coplet); + try { + this.portletContainer.portletLoad(portletWindow, req.getRequest(portletWindow), + res); + } catch (Exception e) { + this.getLogger().error("Error loading portlet " + portletEntityId, e); + // remove portlet entity + coplet.removeAttribute("window"); + ((PortletEntityListImpl)pae.getPortletEntityList()).remove(portletEntity); + } finally { + PortletPortalManager.copletInstanceData.set(null); + } } } 1.1 cocoon-2.1/src/blocks/portal/WEB-INF/portlet.xml Index: portlet.xml =================================================================== <?xml version="1.0" encoding="UTF-8"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> <portlet> <description>This is a Test Portlet</description> <portlet-name>TestPortlet1</portlet-name> <display-name>Test Portlet #1</display-name> <portlet-class>org.apache.cocoon.portal.pluto.test.TestPortlet</portlet-class> <init-param> <name>dummyName</name> <value>dummyValue</value> </init-param> <expiration-cache>-1</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> <portlet-mode>EDIT</portlet-mode> <portlet-mode>HELP</portlet-mode> </supports> <supported-locale>en</supported-locale> <supported-locale>de</supported-locale> <portlet-info> <title>Test Portlet #1</title> <short-title>Test1</short-title> <keywords>Test, Testen</keywords> </portlet-info> <portlet-preferences> <preference> <name>dumnmyName</name> <value>dummyValue</value> <read-only>false</read-only> </preference> <preference> <name>dummyName2</name> <value>dummyValue2</value> </preference> <preferences-validator>org.apache.pluto.core.impl.PreferencesValidatorImpl</preferences-validator> </portlet-preferences> </portlet> </portlet-app> 1.15 +12 -0 cocoon-2.1/src/blocks/portal/samples/profiles/copletdata/portal.xml Index: portal.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/copletdata/portal.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- portal.xml 22 Jan 2004 14:01:22 -0000 1.14 +++ portal.xml 27 Jan 2004 08:05:35 -0000 1.15 @@ -246,4 +246,16 @@ <value xsi:type="java:java.lang.Boolean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">true</value> </attribute> </coplet-data> + <coplet-data id="TestPortlet1" name="standard"> + <title>Portlet-Test</title> + <coplet-base-data>Portlet</coplet-base-data> + <attribute> + <name>portlet</name> + <value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">webapp.TestPortlet1</value> + </attribute> + <attribute> + <name>buffer</name> + <value xsi:type="java:java.lang.Boolean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">true</value> + </attribute> + </coplet-data> </coplets> 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/factory/PortletInvokerFactoryImpl.java Index: PortletInvokerFactoryImpl.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 2004 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.apache.cocoon.portal.pluto.factory; import org.apache.cocoon.portal.pluto.om.PortletDefinitionImpl; import org.apache.pluto.factory.PortletInvokerFactory; import org.apache.pluto.invoker.PortletInvoker; import org.apache.pluto.invoker.impl.PortletInvokerImpl; import org.apache.pluto.om.portlet.PortletDefinition; /** * The implementation of the invoker factory * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * * @version CVS $Id: PortletInvokerFactoryImpl.java,v 1.1 2004/01/27 08:05:35 cziegeler Exp $ */ public class PortletInvokerFactoryImpl extends AbstractFactory implements PortletInvokerFactory { /* (non-Javadoc) * @see org.apache.pluto.factory.PortletInvokerFactory#getPortletInvoker(org.apache.pluto.om.portlet.PortletDefinition) */ public PortletInvoker getPortletInvoker(PortletDefinition portletDefinition) { // test, if this is a local portlet boolean local = false; PortletInvoker invoker; if ( portletDefinition instanceof PortletDefinitionImpl ) { local = ((PortletDefinitionImpl)portletDefinition).isLocalPortlet(); } if (local) { invoker = ((PortletDefinitionImpl)portletDefinition).getLocalPortletInvoker(); if ( invoker == null ) { invoker = new LocalPortletInvokerImpl(portletDefinition, this.servletConfig); ((PortletDefinitionImpl)portletDefinition).setLocalPortletInvoker(invoker); } } else { invoker = new PortletInvokerImpl(portletDefinition, this.servletConfig); } return invoker; } /* (non-Javadoc) * @see org.apache.pluto.factory.PortletInvokerFactory#releasePortletInvoker(org.apache.pluto.invoker.PortletInvoker) */ public void releasePortletInvoker(PortletInvoker arg0) { // nothing to do here } } 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/factory/LocalPortletInvokerImpl.java Index: LocalPortletInvokerImpl.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 2004 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.apache.cocoon.portal.pluto.factory; import java.io.IOException; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.Portlet; import javax.portlet.PortletConfig; import javax.portlet.PortletContext; import javax.portlet.PortletException; import javax.portlet.PortletRequest; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.servlet.ServletConfig; import org.apache.cocoon.util.ClassUtils; import org.apache.pluto.factory.PortletObjectAccess; import org.apache.pluto.invoker.PortletInvoker; import org.apache.pluto.om.portlet.PortletDefinition; /** * This is an invoker for a "local" portlet, which is a portlet running inside Cocoon. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * * @version CVS $Id: LocalPortletInvokerImpl.java,v 1.1 2004/01/27 08:05:35 cziegeler Exp $ */ public class LocalPortletInvokerImpl implements PortletInvoker { /** servlet configuration */ protected final ServletConfig servletConfig; /** The portlet definition */ protected final PortletDefinition portletDefinition; /** The portlet */ protected Portlet portlet; /** * Constructor */ public LocalPortletInvokerImpl(PortletDefinition portletDefinition, ServletConfig servletConfig) { this.portletDefinition = portletDefinition; this.servletConfig = servletConfig; try { final String clazzName = portletDefinition.getClassName(); this.portlet = (Portlet)ClassUtils.newInstance(clazzName); } catch (Exception ignore) { // we ignore the exception here and throw later on a portlet exception } } /* (non-Javadoc) * @see org.apache.pluto.invoker.PortletInvoker#action(javax.portlet.ActionRequest, javax.portlet.ActionResponse) */ public void action(ActionRequest request, ActionResponse response) throws PortletException, IOException { if ( this.portlet == null ) { throw new PortletException("Unable to instantiate portlet from class " + this.portletDefinition.getClassName()); } this.portlet.processAction(request, response); } /* (non-Javadoc) * @see org.apache.pluto.invoker.PortletInvoker#render(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { if ( this.portlet == null ) { throw new PortletException("Unable to instantiate portlet from class " + this.portletDefinition.getClassName()); } this.portlet.render(request, response); } /* (non-Javadoc) * @see org.apache.pluto.invoker.PortletInvoker#load(javax.portlet.PortletRequest, javax.portlet.RenderResponse) */ public void load(PortletRequest request, RenderResponse response) throws PortletException { if ( this.portlet == null ) { throw new PortletException("Unable to instantiate portlet from class " + this.portletDefinition.getClassName()); } PortletContext portletContext; PortletConfig portletConfig; portletContext = PortletObjectAccess.getPortletContext(this.servletConfig.getServletContext(), portletDefinition.getPortletApplicationDefinition()); portletConfig = PortletObjectAccess.getPortletConfig(this.servletConfig, portletContext, portletDefinition); this.portlet.init(portletConfig); } } 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java Index: TestPortlet.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 2004 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.apache.cocoon.portal.pluto.test; import java.io.IOException; import java.io.Writer; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.Portlet; import javax.portlet.PortletConfig; import javax.portlet.PortletException; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; /** * This is a very simple test portlet * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * * @version CVS $Id: TestPortlet.java,v 1.1 2004/01/27 08:05:35 cziegeler Exp $ */ public class TestPortlet implements Portlet { /* (non-Javadoc) * @see javax.portlet.Portlet#destroy() */ public void destroy() { System.out.println("Destroying TestPortlet"); } /* (non-Javadoc) * @see javax.portlet.Portlet#init(javax.portlet.PortletConfig) */ public void init(PortletConfig config) throws PortletException { System.out.println("Initializing TestPortlet"); } /* (non-Javadoc) * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse) */ public void processAction(ActionRequest req, ActionResponse res) throws PortletException, IOException { } /* (non-Javadoc) * @see javax.portlet.Portlet#render(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ public void render(RenderRequest req, RenderResponse res) throws PortletException, IOException { System.out.println("Rendering TestPortlet"); res.setContentType("text/html"); Writer writer = res.getWriter(); writer.write("<h1>Simple TestPortlet</h1>\n"); writer.write("<p>This is a Cocoon test portlet.</p>\n"); } } 1.3 +2 -2 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/services/factory/FactoryManagerServiceImpl.java Index: FactoryManagerServiceImpl.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/pluto/services/factory/FactoryManagerServiceImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FactoryManagerServiceImpl.java 23 Jan 2004 12:34:31 -0000 1.2 +++ FactoryManagerServiceImpl.java 27 Jan 2004 08:05:35 -0000 1.3 @@ -70,6 +70,7 @@ import org.apache.avalon.framework.context.Contextualizable; import org.apache.cocoon.portal.pluto.factory.ControllerFactoryImpl; import org.apache.cocoon.portal.pluto.factory.ObjectIDFactoryImpl; +import org.apache.cocoon.portal.pluto.factory.PortletInvokerFactoryImpl; import org.apache.cocoon.portal.pluto.factory.PortletPreferencesFactoryImpl; import org.apache.cocoon.servlet.CocoonServlet; import org.apache.pluto.factory.Factory; @@ -84,7 +85,6 @@ import org.apache.pluto.factory.impl.RenderRequestFactoryImpl; import org.apache.pluto.factory.impl.RenderResponseFactoryImpl; import org.apache.pluto.invoker.PortletInvoker; -import org.apache.pluto.invoker.impl.PortletInvokerFactoryImpl; import org.apache.pluto.om.ControllerFactory; import org.apache.pluto.services.factory.FactoryManagerService; import org.apache.pluto.util.NamespaceMapper; 1.19 +14 -5 cocoon-2.1/src/blocks/portal/samples/profiles/layout/portal.xml Index: portal.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/layout/portal.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- portal.xml 22 Jan 2004 14:12:49 -0000 1.18 +++ portal.xml 27 Jan 2004 08:05:35 -0000 1.19 @@ -142,16 +142,25 @@ </composite-layout> </named-item> <named-item name="JSR-168"> - <composite-layout name="column"> + <composite-layout name="row"> <item> <coplet-layout name="coplet"> - <coplet-instance-data>Portlet-1</coplet-instance-data> + <coplet-instance-data>TestPortlet-1</coplet-instance-data> </coplet-layout> </item> <item> - <coplet-layout name="coplet"> - <coplet-instance-data>Portlet-2</coplet-instance-data> - </coplet-layout> + <composite-layout name="column"> + <item> + <coplet-layout name="coplet"> + <coplet-instance-data>Portlet-1</coplet-instance-data> + </coplet-layout> + </item> + <item> + <coplet-layout name="coplet"> + <coplet-instance-data>Portlet-2</coplet-instance-data> + </coplet-layout> + </item> + </composite-layout> </item> </composite-layout> </named-item>