Author: vgritsenko
Date: Thu Jul 29 05:23:22 2004
New Revision: 30919
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletEnvironment.java
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletRequest.java
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletSession.java
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
cocoon/branches/BRANCH_2_1_X/status.xml
Log:
Sync with 2.2:
Portal: CocoonPortlet has new configuration parameter,
default-session-scope.
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml Thu Jul
29 05:23:22 2004
@@ -13,50 +13,182 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
+ CVS $Id: portlet.xml,v 1.4 2004/07/06 20:26:12 vgritsenko Exp $
-->
-<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>
+<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">
+
+ <!--
+ - Simple test portlet for testing
+ -->
+ <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>
+
+
+ <!--
+ - Cocoon JSR168 Portlet.
+ - You can deploy this portlet in any 3rd party portal implementing JSR168
+ - and make your Cocoon application available as a portlet.
+ -
+ - Cocoon portlet will create an instance of the Cocoon with parameters
+ - specified below.
+ -->
+ <portlet>
+ <portlet-name>CocoonPortlet</portlet-name>
+ <display-name>JSR-168 Cocoon Portlet</display-name>
+
<portlet-class>org.apache.cocoon.portlet.ManagedCocoonPortlet</portlet-class>
+
+ <!--
+ This parameter indicates the category id of the logger from the LogKit
+ configuration used by the CocoonServlet.
+ -->
+ <init-param>
+ <name>portlet-logger</name>
+ <value>access</value>
+ </init-param>
+
+ <!--
+ Causes all files in multipart requests to be processed.
+ Default is false for security reasons.
+ Unsupported values will be interpreted as false.
+ -->
+ <init-param>
+ <name>enable-uploads</name>
+ <value>true</value>
+ </init-param>
+
+ <!--
+ Causes all files in multipart requests to be saved to upload-dir.
+ Default is true for security reasons.
+ Unsupported values will be interpreted as false.
+ -->
+ <init-param>
+ <name>autosave-uploads</name>
+ <value>true</value>
+ </init-param>
+
+ <!--
+ Specify handling of name conflicts when saving uploaded files
+ to disk. Acceptable values are deny, allow, rename (default).
+ Files are renamed x_filename where x is an integer value incremented
+ to make the new filename unique.
+ -->
+ <init-param>
+ <name>overwrite-uploads</name>
+ <value>rename</value>
+ </init-param>
+
+ <!--
+ Specify maximum allowed size of the upload. Defaults to 10 Mb.
+
+ <init-param>
+ <name>upload-max-size</name>
+ <value>10000000</value>
+ </init-param>
+ -->
+
+ <!--
+ If you set this parameter to 'true' or 'yes', Cocoon will add processing
+ time to the end of each response. Value 'hide' adds processing time as
an HTML
+ comment. By default, processing time is not added (corresponds to value
'no').
+
+ <init-param>
+ <name>show-time</name>
+ <value>hide</value>
+ </init-param>
+ -->
+
+ <!--
+ If true or not set, this class will try to catch and handle all Cocoon
exceptions.
+ If false, it will rethrow them to the servlet container.
+ -->
+ <init-param>
+ <name>manage-exceptions</name>
+ <value>true</value>
+ </init-param>
+
+ <!--
+ Set encoding used by the container. If not set the ISO-8859-1 encoding
will be assumed.
+
+ <init-param>
+ <name>container-encoding</name>
+ <value>utf-8</value>
+ </init-param>
+ -->
+
+ <!--
+ Set form encoding. This will be the character set used to decode request
parameters.
+ If not set the ISO-8859-1 encoding will be assumed.
+
+ <init-param>
+ <name>form-encoding</name>
+ <value>utf-8</value>
+ </init-param>
+ -->
+
+ <init-param>
+ <name>servlet-path</name>
+ <value>samples/blocks/portal/portlets/hello</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>
+
+ <portlet-info>
+ <title>JSR-168 Cocoon Portlet</title>
+ <short-title>Cocoon Portlet</short-title>
+ <keywords>Apache, Cocoon, XML, Jakarta, Pluto, Portlet, WSRP, WSRP4J,
JSR-168</keywords>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletEnvironment.java
==============================================================================
---
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletEnvironment.java
(original)
+++
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletEnvironment.java
Thu Jul 29 05:23:22 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,10 +23,8 @@
import org.apache.cocoon.environment.Session;
import javax.portlet.PortletContext;
-
import java.io.IOException;
import java.io.OutputStream;
-import java.net.MalformedURLException;
/**
* Implements [EMAIL PROTECTED] org.apache.cocoon.environment.Environment}
interface for the JSR-168
@@ -67,6 +65,11 @@
*/
public static final String SESSION_APPLICATION_SCOPE =
"portlet-application-";
+ /**
+ * This is the prefix for portlet scope session attributes.
+ */
+ public static final String SESSION_PORTLET_SCOPE = "portlet-portlet-";
+
/**
* The PortletRequest
@@ -95,6 +98,10 @@
*/
private boolean hasRedirected;
+ /**
+ * @see #getDefaultSessionScope()
+ */
+ private int defaultSessionScope;
/**
* Constructs a PortletEnvironment object from a PortletRequest
@@ -108,8 +115,9 @@
PortletContext portletContext,
Context context,
String containerEncoding,
- String defaultFormEncoding)
- throws MalformedURLException, IOException {
+ String defaultFormEncoding,
+ int defaultSessionScope)
+ throws IOException {
super(uri, null, root, null);
String pathInfo = request.getParameter(PARAMETER_PATH_INFO);
@@ -119,6 +127,7 @@
this.request.setContainerEncoding(containerEncoding);
this.response = new ActionResponse(response, request.getPreferences(),
(ActionRequest) this.request, uri);
this.context = context;
+ this.defaultSessionScope = defaultSessionScope;
setView(extractView(this.request));
setAction(extractAction(this.request));
@@ -138,8 +147,9 @@
PortletContext portletContext,
Context context,
String containerEncoding,
- String defaultFormEncoding)
- throws MalformedURLException, IOException {
+ String defaultFormEncoding,
+ int defaultSessionScope)
+ throws IOException {
super(uri, null, root, null);
String pathInfo = request.getParameter(PARAMETER_PATH_INFO);
@@ -149,6 +159,7 @@
this.request.setContainerEncoding(containerEncoding);
this.response = new RenderResponse(response, request.getPreferences());
this.context = context;
+ this.defaultSessionScope = defaultSessionScope;
setView(extractView(this.request));
setAction(extractAction(this.request));
@@ -310,5 +321,14 @@
*/
public boolean isExternal() {
return true;
+ }
+
+ /**
+ * Default scope for the session attributes, either
+ * [EMAIL PROTECTED] javax.portlet.PortletSession#PORTLET_SCOPE} or
+ * [EMAIL PROTECTED] javax.portlet.PortletSession#APPLICATION_SCOPE}.
+ */
+ int getDefaultSessionScope() {
+ return this.defaultSessionScope;
}
}
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletRequest.java
==============================================================================
---
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletRequest.java
(original)
+++
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletRequest.java
Thu Jul 29 05:23:22 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -65,8 +65,8 @@
/** The current session */
private PortletSession session;
- private Cookie[] wrappedCookies = null;
- private Map wrappedCookieMap = null;
+ private Cookie[] wrappedCookies;
+ private Map wrappedCookieMap;
protected String portletRequestURI;
@@ -267,7 +267,8 @@
}
} else {
// new wrapper
- this.session = new PortletSession(serverSession);
+ this.session = new PortletSession(serverSession,
+
this.environment.getDefaultSessionScope());
}
} else {
// invalidate
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletSession.java
==============================================================================
---
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletSession.java
(original)
+++
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/environment/portlet/PortletSession.java
Thu Jul 29 05:23:22 2004
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@
/**
* Provides access to the JSR-168 (Portlet) environment session.
*
- * Portlet scope and application scope session attributes are differentiated
+ * <p>Portlet scope and application scope session attributes are differentiated
* using attribute name prefix, [EMAIL PROTECTED]
PortletEnvironment#SESSION_APPLICATION_SCOPE}.
*
* @see javax.portlet.PortletSession
@@ -34,13 +34,22 @@
public final class PortletSession implements Session {
private static final String APP_SCOPE =
PortletEnvironment.SESSION_APPLICATION_SCOPE;
+ private static final String PORTLET_SCOPE =
PortletEnvironment.SESSION_PORTLET_SCOPE;
javax.portlet.PortletSession session;
/**
+ * Default session scope. One of
+ * [EMAIL PROTECTED] javax.portlet.PortletSession#APPLICATION_SCOPE},
+ * [EMAIL PROTECTED] javax.portlet.PortletSession#PORTLET_SCOPE}.
+ */
+ private int scope;
+
+ /**
* Construct a new session from an PortletSession
*/
- public PortletSession(javax.portlet.PortletSession session) {
+ public PortletSession(javax.portlet.PortletSession session, int scope) {
+ this.scope = scope;
this.session = session;
}
@@ -48,13 +57,13 @@
* Returns the time when this session was created, measured
* in milliseconds since midnight January 1, 1970 GMT.
*
- * @return a <code>long</code> specifying
- * when this session was created,
- * expressed in
- * milliseconds since 1/1/1970 GMT
+ * @return a <code>long</code> specifying
+ * when this session was created,
+ * expressed in
+ * milliseconds since 1/1/1970 GMT
*
- * @exception IllegalStateException if this method is called on an
- * invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * invalidated session
*/
public long getCreationTime() {
return this.session.getCreationTime();
@@ -65,11 +74,11 @@
* to this session. The identifier is assigned
* by the context container and is implementation dependent.
*
- * @return a string specifying the
identifier
- * assigned to this session
+ * @return a string specifying the identifier
+ * assigned to this session
*
- * @exception IllegalStateException if this method is called on an
- * invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * invalidated session
*/
public String getId() {
return this.session.getId();
@@ -84,14 +93,14 @@
* a value associated with the session, do not affect the access
* time.
*
- * @return a <code>long</code>
- * representing the last time
- * the client sent a request
associated
- * with this session, expressed in
- * milliseconds since 1/1/1970 GMT
+ * @return a <code>long</code>
+ * representing the last time
+ * the client sent a request associated
+ * with this session, expressed in
+ * milliseconds since 1/1/1970 GMT
*
- * @exception IllegalStateException if this method is called on an
- * invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * invalidated session
*/
public long getLastAccessedTime() {
return this.session.getLastAccessedTime();
@@ -136,31 +145,39 @@
*
* @return the object with the specified name
*
- * @exception IllegalStateException if this method is called on an
- * invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * invalidated session
*/
public Object getAttribute(String name) {
if (name.startsWith(APP_SCOPE)) {
return
this.session.getAttribute(name.substring(APP_SCOPE.length()),
javax.portlet.PortletSession.APPLICATION_SCOPE);
+ } else if (name.startsWith(PORTLET_SCOPE)) {
+ return
this.session.getAttribute(name.substring(PORTLET_SCOPE.length()),
+
javax.portlet.PortletSession.PORTLET_SCOPE);
+ } else {
+ return this.session.getAttribute(name, this.scope);
}
- return this.session.getAttribute(name);
}
/**
* Returns an <code>Enumeration</code> of <code>String</code> objects
* containing the names of all the objects bound to this session.
*
+ * <p>Objects' names in portlet session scope will be prefixed with
+ * [EMAIL PROTECTED] #PORTLET_SCOPE}, and names in application scope will
be prefixed
+ * with [EMAIL PROTECTED] #APP_SCOPE}.
+ *
* @return an <code>Enumeration</code> of
* <code>String</code> objects specifying
the
* names of all the objects bound to
* this session
*
- * @exception IllegalStateException if this method is called on an
- * invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * invalidated session
*/
public Enumeration getAttributeNames() {
- final Enumeration names1 = this.session.getAttributeNames();
+ final Enumeration names1 =
this.session.getAttributeNames(javax.portlet.PortletSession.PORTLET_SCOPE);
final Enumeration names2 =
this.session.getAttributeNames(javax.portlet.PortletSession.APPLICATION_SCOPE);
return new Enumeration() {
@@ -170,9 +187,9 @@
public Object nextElement() throws NoSuchElementException {
if (names1.hasMoreElements()) {
- return names1.nextElement();
+ return PORTLET_SCOPE + names1.nextElement();
} else if (names2.hasMoreElements()) {
- return names2.nextElement();
+ return APP_SCOPE + names2.nextElement();
}
throw new NoSuchElementException();
@@ -191,16 +208,20 @@
*
* @param value the object to be bound; cannot be
null
*
- * @exception IllegalStateException if this method is called on an
- * invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * invalidated session
*/
public void setAttribute(String name, Object value) {
if (name.startsWith(APP_SCOPE)) {
this.session.setAttribute(name.substring(APP_SCOPE.length()),
value,
javax.portlet.PortletSession.APPLICATION_SCOPE);
+ } else if (name.startsWith(PORTLET_SCOPE)) {
+ this.session.setAttribute(name.substring(PORTLET_SCOPE.length()),
+ value,
+
javax.portlet.PortletSession.PORTLET_SCOPE);
} else {
- this.session.setAttribute(name, value);
+ this.session.setAttribute(name, value, this.scope);
}
}
@@ -210,26 +231,29 @@
* bound with the specified name, this method does nothing.
*
*
- * @param name the name of the object to
- * remove from this session
+ * @param name the name of the object to
+ * remove from this session
*
- * @exception IllegalStateException if this method is called on an
- * invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * invalidated session
*/
public void removeAttribute(String name) {
if (name.startsWith(APP_SCOPE)) {
this.session.removeAttribute(name.substring(APP_SCOPE.length()),
javax.portlet.PortletSession.APPLICATION_SCOPE);
+ } else if (name.startsWith(PORTLET_SCOPE)) {
+
this.session.removeAttribute(name.substring(PORTLET_SCOPE.length()),
+
javax.portlet.PortletSession.PORTLET_SCOPE);
} else {
- this.session.removeAttribute(name);
+ this.session.removeAttribute(name, this.scope);
}
}
/**
* Invalidates this session to it.
*
- * @exception IllegalStateException if this method is called on an
- * already invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * already invalidated session
*/
public void invalidate() {
this.session.invalidate();
@@ -242,12 +266,12 @@
* the client had disabled the use of cookies, then a session would
* be new on each request.
*
- * @return <code>true</code> if the
- * server has created a session,
- * but the client has not yet joined
+ * @return <code>true</code> if the
+ * server has created a session,
+ * but the client has not yet joined
*
- * @exception IllegalStateException if this method is called on an
- * already invalidated session
+ * @exception IllegalStateException if this method is called on an
+ * already invalidated session
*/
public boolean isNew() {
return this.session.isNew();
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
==============================================================================
---
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
(original)
+++
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
Thu Jul 29 05:23:22 2004
@@ -15,6 +15,20 @@
*/
package org.apache.cocoon.portlet;
+import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
+import org.apache.avalon.excalibur.logger.LoggerManager;
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.LogKitLogger;
+import org.apache.avalon.framework.logger.Logger;
+
import org.apache.cocoon.Cocoon;
import org.apache.cocoon.ConnectionResetException;
import org.apache.cocoon.Constants;
@@ -31,21 +45,9 @@
import org.apache.cocoon.util.IOUtils;
import org.apache.cocoon.util.StringUtils;
import org.apache.cocoon.util.log.CocoonLogFormatter;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
-import org.apache.avalon.excalibur.logger.LoggerManager;
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.logger.LogKitLogger;
-import org.apache.avalon.framework.logger.Logger;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.SystemUtils;
import org.apache.excalibur.instrument.InstrumentManager;
import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
import org.apache.log.ContextMap;
@@ -61,7 +63,6 @@
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -103,7 +104,7 @@
// Used by "show-time"
static final float SECOND = 1000;
static final float MINUTE = 60 * SECOND;
- static final float HOUR = 60 * MINUTE;
+ static final float HOUR = 60 * MINUTE;
private Logger log;
private LoggerManager loggerManager;
@@ -230,6 +231,17 @@
protected String servletPath;
/**
+ * Default scope for the session attributes, either
+ * [EMAIL PROTECTED] javax.portlet.PortletSession#PORTLET_SCOPE} or
+ * [EMAIL PROTECTED] javax.portlet.PortletSession#APPLICATION_SCOPE}.
+ * This corresponds to <code>default-session-scope</code>
+ * parameter, with default value <code>portlet</code>.
+ *
+ * @see org.apache.cocoon.environment.portlet.PortletSession
+ */
+ protected int defaultSessionScope;
+
+ /**
* Initialize this <code>CocoonPortlet</code> instance.
*
* @param conf The PortletConfig object from the portlet container.
@@ -482,6 +494,13 @@
}
}
+ final String sessionScopeParam =
getInitParameter("default-session-scope", "portlet");
+ if ("application".equalsIgnoreCase(sessionScopeParam)) {
+ this.defaultSessionScope =
javax.portlet.PortletSession.APPLICATION_SCOPE;
+ } else {
+ this.defaultSessionScope =
javax.portlet.PortletSession.PORTLET_SCOPE;
+ }
+
// Add the portlet configuration
this.appContext.put(CONTEXT_PORTLET_CONFIG, conf);
this.createCocoon();
@@ -614,10 +633,10 @@
}
buildClassPath.append(File.pathSeparatorChar)
- .append(System.getProperty("java.class.path"));
+ .append(SystemUtils.JAVA_CLASS_PATH);
buildClassPath.append(File.pathSeparatorChar)
- .append(getExtraClassPath());
+ .append(getExtraClassPath());
return buildClassPath.toString();
}
@@ -713,7 +732,7 @@
String extraClassPath = this.getInitParameter("extra-classpath");
if (extraClassPath != null) {
StringBuffer sb = new StringBuffer();
- StringTokenizer st = new StringTokenizer(extraClassPath,
System.getProperty("path.separator"), false);
+ StringTokenizer st = new StringTokenizer(extraClassPath,
SystemUtils.PATH_SEPARATOR, false);
int i = 0;
while (st.hasMoreTokens()) {
String s = st.nextToken();
@@ -770,9 +789,9 @@
* file.
*/
protected void initLogger() {
- String logLevel = getInitParameter("log-level", "INFO");
+ final String logLevel = getInitParameter("log-level", "INFO");
- final String accesslogger = getInitParameter("servlet-logger");
+ final String accesslogger = getInitParameter("portlet-logger",
"cocoon");
final Priority logPriority = Priority.getPriorityForName(logLevel);
@@ -839,7 +858,8 @@
*
* @throws PortletException
*/
- private URL getConfigFile(final String configFileName) throws
PortletException {
+ private URL getConfigFile(final String configFileName)
+ throws PortletException {
final String usedFileName;
if (configFileName == null) {
@@ -871,7 +891,7 @@
if (result == null) {
File resultFile = new File(usedFileName);
- if (resultFile.isFile())
+ if (resultFile.isFile()) {
try {
result = resultFile.getCanonicalFile().toURL();
} catch (Exception e) {
@@ -879,6 +899,7 @@
getLogger().error(msg, e);
throw new PortletException(msg, e);
}
+ }
}
if (result == null) {
@@ -960,8 +981,12 @@
}
}
+ /**
+ * Process the specified <code>ActionRequest</code> producing output
+ * on the specified <code>ActionResponse</code>.
+ */
public void processAction(ActionRequest req, ActionResponse res)
- throws PortletException, IOException {
+ throws PortletException, IOException {
/* HACK for reducing class loader problems.
*/
/* example: xalan extensions fail if someone adds xalan jars in
tomcat3.2.1/lib */
@@ -1125,8 +1150,12 @@
}
}
+ /**
+ * Process the specified <code>RenderRequest</code> producing output
+ * on the specified <code>RenderResponse</code>.
+ */
public void render(RenderRequest req, RenderResponse res)
- throws PortletException, IOException {
+ throws PortletException, IOException {
/* HACK for reducing class loader problems.
*/
/* example: xalan extensions fail if someone adds xalan jars in
tomcat3.2.1/lib */
@@ -1386,7 +1415,8 @@
this.portletContext,
(PortletContext)
this.appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT),
this.containerEncoding,
- formEncoding);
+ formEncoding,
+ this.defaultSessionScope);
env.enableLogging(getLogger());
return env;
}
@@ -1413,7 +1443,8 @@
this.portletContext,
(PortletContext)
this.appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT),
this.containerEncoding,
- formEncoding);
+ formEncoding,
+ this.defaultSessionScope);
env.enableLogging(getLogger());
return env;
}
@@ -1427,8 +1458,10 @@
* @return the parent component manager, or <code>null</code>.
*/
protected synchronized ComponentManager getParentComponentManager() {
- if (parentComponentManager != null && parentComponentManager
instanceof Disposable)
+ if (parentComponentManager != null && parentComponentManager
instanceof Disposable) {
((Disposable) parentComponentManager).dispose();
+ }
+
parentComponentManager = null;
if (parentComponentManagerClass != null) {
try {
@@ -1454,11 +1487,11 @@
return parentComponentManager;
}
-
/**
* Creates the Cocoon object and handles exception handling.
*/
- private synchronized void createCocoon() throws PortletException {
+ private synchronized void createCocoon()
+ throws PortletException {
/* HACK for reducing class loader problems.
*/
/* example: xalan extensions fail if someone adds xalan jars in
tomcat3.2.1/lib */
@@ -1530,7 +1563,7 @@
* @return an <code>InstrumentManager</code> instance
*/
private InstrumentManager getInstrumentManager()
- throws Exception {
+ throws Exception {
String imConfig = getInitParameter("instrumentation-config");
if (imConfig == null) {
throw new PortletException("Please define the init-param
'instrumentation-config' in your web.xml");
@@ -1581,7 +1614,7 @@
* changed or we are reloading.
*/
private void getCocoon(final String reloadParam)
- throws PortletException {
+ throws PortletException {
if (this.allowReload) {
boolean reload = false;
@@ -1658,9 +1691,9 @@
getLogger().debug(name + " was not set - defaulting to '" +
defaultValue + "'");
}
return defaultValue;
- } else {
- return BooleanUtils.toBoolean(value);
}
+
+ return BooleanUtils.toBoolean(value);
}
protected int getInitParameterAsInteger(String name, int defaultValue) {
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Jul 29 05:23:22 2004
@@ -211,8 +211,9 @@
<changes>
<release version="@version@" date="@date@">
- <action dev="NN" type="update">
- Dummy
+ <action dev="VG" type="update">
+ Portal: CocoonPortlet has new configuration parameter,
+ default-session-scope.
</action>
</release>
<release version="2.1.5.1" date="July 9 2004">