Author: cziegeler
Date: Fri Apr 22 04:03:32 2005
New Revision: 164219
URL: http://svn.apache.org/viewcvs?rev=164219&view=rev
Log:
Remove obsolete method and fix startup problems
Modified:
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
cocoon/trunk/src/java/org/apache/cocoon/core/Core.java
cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentEnvironment.java
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentFactory.java
cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java
cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
Modified:
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java
URL:
http://svn.apache.org/viewcvs/cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
---
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java
(original)
+++
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java
Fri Apr 22 04:03:32 2005
@@ -102,12 +102,6 @@
*/
protected Exception exception;
- /**
- * Avalon application context
- */
- protected org.apache.avalon.framework.context.Context appContext;
-
-
private String containerEncoding;
protected javax.portlet.PortletContext portletContext;
@@ -162,6 +156,8 @@
/** Settings */
protected Settings settings;
+ protected Context environmentContext;
+
/**
* Initialize this <code>CocoonPortlet</code> instance.
*
@@ -238,7 +234,7 @@
try {
this.coreUtil = new CoreUtil(env);
- this.appContext = coreUtil.getCore().getContext();
+ this.environmentContext = env.getEnvironmentContext();
this.log = env.logger;
} catch (Exception e) {
if ( e instanceof PortletException ) {
@@ -392,8 +388,7 @@
// Add a unique request id (threadName + currentTime
ctxMap.set("request-id", threadName +
System.currentTimeMillis());
- if (this.cocoon.process(env)) {
- } else {
+ if (!this.cocoon.process(env)) {
// We reach this when there is nothing in the processing
change that matches
// the request. For example, no matcher matches.
getLogger().fatalError("The Cocoon engine failed to
process the request.");
@@ -757,7 +752,7 @@
req,
res,
this.portletContext,
- (PortletContext)
this.appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT),
+ this.environmentContext,
this.containerEncoding,
formEncoding,
this.defaultSessionScope);
@@ -786,7 +781,7 @@
req,
res,
this.portletContext,
- (PortletContext)
this.appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT),
+ this.environmentContext,
this.containerEncoding,
formEncoding,
this.defaultSessionScope);
@@ -852,6 +847,7 @@
private final File writeableContextPath;
private final String contextPath;
public Logger logger;
+ private final Context environmentContext;
public PortletBootstrapEnvironment(PortletConfig config,
ClassLoader cl,
@@ -865,6 +861,7 @@
this.writeableContextPath = new File(writeablePath);
}
this.contextPath = path;
+ this.environmentContext = new
PortletContext(this.config.getPortletContext());
}
/**
@@ -918,7 +915,7 @@
* @see
org.apache.cocoon.core.BootstrapEnvironment#getEnvironmentContext()
*/
public Context getEnvironmentContext() {
- return new PortletContext(this.config.getPortletContext());
+ return this.environmentContext;
}
/**
Modified:
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
URL:
http://svn.apache.org/viewcvs/cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
---
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
(original)
+++
cocoon/blocks/supported/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
Fri Apr 22 04:03:32 2005
@@ -399,8 +399,7 @@
// Add a unique request id (threadName + currentTime
ctxMap.set("request-id", threadName +
System.currentTimeMillis());
- if (cocoon.process(env)) {
- } else {
+ if (!cocoon.process(env)) {
// We reach this when there is nothing in the processing
change that matches
// the request. For example, no matcher matches.
getLogger().fatalError("The Cocoon engine failed to
process the request.");
@@ -547,8 +546,7 @@
// Add a unique request id (threadName + currentTime
ctxMap.set("request-id", threadName +
System.currentTimeMillis());
- if (cocoon.process(env)) {
- } else {
+ if (!cocoon.process(env)) {
// We reach this when there is nothing in the processing
change that matches
// the request. For example, no matcher matches.
getLogger().fatalError("The Cocoon engine failed to
process the request.");
@@ -828,10 +826,9 @@
if (getLogger() != null && getLogger().isDebugEnabled()) {
getLogger().debug(name + " was not set - defaulting to '" +
defaultValue + "'");
}
- return defaultValue;
- } else {
- return result;
- }
+ result = defaultValue;
+ }
+ return result;
}
/** Convenience method to access boolean portlet parameters */
@@ -854,9 +851,8 @@
getLogger().debug(name + " was not set - defaulting to '" +
defaultValue + "'");
}
return defaultValue;
- } else {
- return Integer.parseInt(value);
}
+ return Integer.parseInt(value);
}
protected void initLogger() {
Modified: cocoon/trunk/src/java/org/apache/cocoon/core/Core.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/Core.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/Core.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/Core.java Fri Apr 22 04:03:32
2005
@@ -93,16 +93,6 @@
}
/**
- * Return the component context.
- * This method allows access to the component context for other components
- * that are not created by an Avalon based container.
- * FIXME - will be removed before the release
- */
- public Context getContext() {
- return this.context;
- }
-
- /**
* Return the environment context object.
* @return The environment context.
*/
Modified: cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java Fri Apr 22
04:03:32 2005
@@ -72,8 +72,6 @@
/** Parameter map for the context protocol */
protected static final Map CONTEXT_PARAMETERS =
Collections.singletonMap("force-traversable", Boolean.TRUE);
- protected final static String CORE_KEY = Core.class.getName();
-
/** The callback to the real environment */
protected final BootstrapEnvironment env;
@@ -254,11 +252,14 @@
// settings can't be changed anymore
settings.makeReadOnly();
+
+ // put the core into the context
+ this.appContext.put(Core.ROLE, core);
}
public Core getCore() {
try {
- return (Core)this.parentManager.lookup(CORE_KEY);
+ return (Core)this.parentManager.lookup(Core.ROLE);
} catch (ServiceException ignore) {
// this can never happen!
throw new RuntimeException("Fatal error: no Cocoon core
available.");
@@ -571,7 +572,7 @@
* @see
org.apache.avalon.framework.service.ServiceManager#hasService(java.lang.String)
*/
public boolean hasService(String key) {
- if ( CORE_KEY.equals(key) ) {
+ if ( Core.ROLE.equals(key) ) {
return true;
}
if ( this.parent != null ) {
@@ -584,7 +585,7 @@
* @see
org.apache.avalon.framework.service.ServiceManager#lookup(java.lang.String)
*/
public Object lookup(String key) throws ServiceException {
- if ( CORE_KEY.equals(key) ) {
+ if ( Core.ROLE.equals(key) ) {
return this.cocoon;
}
if ( this.parent != null ) {
Modified:
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentEnvironment.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentEnvironment.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentEnvironment.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentEnvironment.java
Fri Apr 22 04:03:32 2005
@@ -21,8 +21,8 @@
import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.components.ComponentInfo;
import org.apache.cocoon.configuration.ConfigurationBuilder;
@@ -63,8 +63,8 @@
this.context = context;
this.serviceManager = serviceManager;
try {
- this.core = (Core)this.serviceManager.lookup(Core.ROLE);
- } catch (ServiceException ignore) {
+ this.core = (Core)this.context.get(Core.ROLE);
+ } catch (ContextException ignore) {
// this can never happen
}
}
Modified:
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentFactory.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentFactory.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentFactory.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/core/container/ComponentFactory.java
Fri Apr 22 04:03:32 2005
@@ -20,10 +20,10 @@
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
import org.apache.cocoon.components.ComponentInfo;
import org.apache.cocoon.core.Core;
import org.apache.cocoon.core.Settings;
@@ -67,8 +67,8 @@
final ComponentInfo info)
throws Exception {
try {
- this.core = (Core)environment.serviceManager.lookup(Core.ROLE);
- } catch (ServiceException ignore) {
+ this.core = (Core)environment.context.get(Core.ROLE);
+ } catch (ContextException ignore) {
// this can never happen
}
this.environment = environment;
@@ -120,7 +120,9 @@
}
try {
this.configureSettingsMethod =
this.serviceClass.getMethod("configure", new Class[] {Settings.class});
- } catch (NoSuchMethodException ignore) {
+ } catch (Throwable ignore) {
+ // we have to catch throwable here, as the above test can
+ // result in NoClassDefFound exceptions etc.
this.configureSettingsMethod = null;
}
}
Modified:
cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/core/container/CoreServiceManager.java
Fri Apr 22 04:03:32 2005
@@ -133,13 +133,6 @@
// Always create a role manager, it can be filled several times either
through
// the root "roles" attribute or through loading of includes
this.roleManager = new RoleManager(parentRoleManager);
-
- // get settings
- try {
- this.settings = ((Core)parent.lookup(Core.ROLE)).getSettings();
- } catch (ServiceException ignore) {
- // this can never happen!
- }
}
//=============================================================================================
@@ -157,8 +150,10 @@
/* (non-Javadoc)
* @see
org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
*/
- public void contextualize( final Context context ) {
+ public void contextualize( final Context context )
+ throws ContextException {
this.context = context;
+ this.settings = ((Core)context.get(Core.ROLE)).getSettings();
}
/**
Modified:
cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
Fri Apr 22 04:03:32 2005
@@ -23,6 +23,7 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.cocoon.environment.AbstractEnvironment;
+import org.apache.cocoon.environment.Context;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.util.NetUtils;
@@ -44,9 +45,6 @@
/** The HttpResponse */
private HttpResponse response;
- /** The HttpContext */
- private HttpContext webcontext;
-
/** Cache content type as there is no getContentType() in reponse object */
private String contentType;
@@ -59,7 +57,7 @@
HttpServletRequest req,
HttpServletResponse res,
ServletContext servletContext,
- HttpContext context,
+ Context context,
String containerEncoding,
String defaultFormEncoding)
throws IOException {
@@ -69,14 +67,13 @@
this.request.setCharacterEncoding(defaultFormEncoding);
this.request.setContainerEncoding(containerEncoding);
this.response = new HttpResponse(res);
- this.webcontext = context;
setView(extractView(this.request));
setAction(extractAction(this.request));
this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request);
this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, this.response);
- this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT,
this.webcontext);
+ this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT, context);
// This is a kind of a hack for the components that need
// the real servlet objects to pass them along to other
Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java?rev=164219&r1=164218&r2=164219&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java Fri Apr
22 04:03:32 2005
@@ -104,11 +104,6 @@
*/
protected Exception exception;
- /**
- * Avalon application context
- */
- protected org.apache.avalon.framework.context.Context appContext;
-
private String containerEncoding;
protected ServletContext servletContext;
@@ -140,6 +135,8 @@
/** The logger */
protected Logger log;
+ protected Context environmentContext;
+
/**
* Initialize this <code>CocoonServlet</code> instance. You will
* notice that I have broken the init into sub methods to make it
@@ -211,7 +208,7 @@
try {
this.coreUtil = new CoreUtil(env);
- this.appContext = coreUtil.getCore().getContext();
+ this.environmentContext = env.getEnvironmentContext();
this.log = env.logger;
} catch (Exception e) {
if ( e instanceof ServletException ) {
@@ -577,7 +574,7 @@
req,
res,
this.servletContext,
- (HttpContext)
this.appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT),
+ this.environmentContext,
this.containerEncoding,
formEncoding);
env.enableLogging(getLogger());
@@ -642,6 +639,7 @@
private final File writeableContextPath;
private final String contextPath;
public Logger logger;
+ private final HttpContext environmentContext;
public ServletBootstrapEnvironment(ServletConfig config,
ClassLoader cl,
@@ -655,6 +653,7 @@
this.writeableContextPath = new File(writeablePath);
}
this.contextPath = path;
+ this.environmentContext = new
HttpContext(this.config.getServletContext());
}
/**
@@ -708,7 +707,7 @@
* @see
org.apache.cocoon.core.BootstrapEnvironment#getEnvironmentContext()
*/
public Context getEnvironmentContext() {
- return new HttpContext(this.config.getServletContext());
+ return this.environmentContext;
}
/**