You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/03/18 18:29:27 UTC
svn commit: r158112 - in cocoon/trunk/src: core/java/org/apache/cocoon/
core/java/org/apache/cocoon/core/ java/org/apache/cocoon/
java/org/apache/cocoon/components/treeprocessor/sitemap/
java/org/apache/cocoon/serialization/ java/org/apache/cocoon/servlet/
Author: cziegeler
Date: Fri Mar 18 09:29:25 2005
New Revision: 158112
URL: http://svn.apache.org/viewcvs?view=rev&rev=158112
Log:
Add more objects from the Context to the Core
Modified:
cocoon/trunk/src/core/java/org/apache/cocoon/Constants.java
cocoon/trunk/src/core/java/org/apache/cocoon/core/Core.java
cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/Constants.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/Constants.java?view=diff&r1=158111&r2=158112
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/Constants.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/Constants.java Fri Mar 18 09:29:25 2005
@@ -214,10 +214,12 @@
/**
* Application <code>Context</code> Key for the URL to the configuration file
* (usually named cocoon.xconf)
+ * @deprecated Use {@link org.apache.cocoon.configuration.Settings#getConfiguration()}.
*/
public static final String CONTEXT_CONFIG_URL = "config-url";
- /** Application <code>Context</code> Key for the default encoding */
+ /** Application <code>Context</code> Key for the default encoding.
+ * @deprecated Use {@link org.apache.cocoon.configuration.Settings#getFormEncoding()}. */
public static final String CONTEXT_DEFAULT_ENCODING = "default-encoding";
}
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/Core.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/Core.java?view=diff&r1=158111&r2=158112
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/Core.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/Core.java Fri Mar 18 09:29:25 2005
@@ -16,6 +16,7 @@
*/
package org.apache.cocoon.core;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -28,6 +29,7 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.cocoon.Constants;
import org.apache.cocoon.configuration.Settings;
/**
@@ -101,17 +103,55 @@
* 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.
+ */
+ public org.apache.cocoon.environment.Context getEnvironmentContext() {
+ try {
+ return (org.apache.cocoon.environment.Context)this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
+ } catch (ContextException ce) {
+ throw new CascadingRuntimeException("Unable to get the environment object from the context.", ce);
+ }
+ }
+
+ public File getWorkDirectory() {
+ try {
+ return (File)this.context.get(Constants.CONTEXT_WORK_DIR);
+ } catch (ContextException ce) {
+ throw new CascadingRuntimeException("Unable to get the working directory from the context.", ce);
+ }
+ }
+
+ public File getUploadDirectory() {
+ try {
+ return (File)this.context.get(Constants.CONTEXT_UPLOAD_DIR);
+ } catch (ContextException ce) {
+ throw new CascadingRuntimeException("Unable to get the upload directory from the context.", ce);
+ }
+ }
+
+ public File getCacheDirectory() {
+ try {
+ return (File)this.context.get(Constants.CONTEXT_CACHE_DIR);
+ } catch (ContextException ce) {
+ throw new CascadingRuntimeException("Unable to get the cache directory from the context.", ce);
+ }
+ }
+
+ /**
* Return the current settings.
* Please don't use this method directly, look up the Core component
* and use {@link #getSettings()} instead.
* @param context The component context.
* @return The settings.
+ * FIXME - will be removed before the release
*/
public static final Settings getSettings(Context context) {
// the settings object is always present
Modified: cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java?view=diff&r1=158111&r2=158112
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java Fri Mar 18 09:29:25 2005
@@ -143,15 +143,14 @@
((DefaultContext)this.context).makeReadOnly();
final Settings settings = Core.getSettings(this.context);
- final URL u = (URL)this.context.get(Constants.CONTEXT_CONFIG_URL);
try {
URLSource urlSource = new URLSource();
- urlSource.init(u, null);
+ urlSource.init(new URL(settings.getConfiguration()), null);
this.configurationFile = new DelayedRefreshSourceWrapper(urlSource,
settings.getConfigurationReloadDelay());
} catch (IOException ioe) {
- throw new ContextException("Could not open configuration file: " + u, ioe);
+ throw new ContextException("Could not open configuration file: " + settings.getConfiguration(), ioe);
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?view=diff&r1=158111&r2=158112
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Fri Mar 18 09:29:25 2005
@@ -24,7 +24,6 @@
import java.util.Map;
import java.util.Set;
-import org.apache.avalon.framework.configuration.AbstractConfiguration;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
Modified: cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java?view=diff&r1=158111&r2=158112
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java Fri Mar 18 09:29:25 2005
@@ -23,6 +23,8 @@
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.cocoon.Constants;
import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.core.Core;
import org.apache.cocoon.util.ClassUtils;
import org.apache.cocoon.util.TraxErrorHandler;
import org.apache.cocoon.xml.AbstractXMLPipe;
@@ -168,7 +170,8 @@
* Uses the context to retrieve a default encoding for the serializers.
*/
public void contextualize(Context context) throws ContextException {
- String defaultEncoding = (String)context.get(Constants.CONTEXT_DEFAULT_ENCODING);
+ final Settings s = Core.getSettings(context);
+ String defaultEncoding = s.getFormEncoding();
if (defaultEncoding != null) {
this.format.setProperty(OutputKeys.ENCODING, defaultEncoding);
}
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?view=diff&r1=158111&r2=158112
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java Fri Mar 18 09:29:25 2005
@@ -350,9 +350,11 @@
cacheDir.mkdirs();
this.appContext.put(Constants.CONTEXT_CACHE_DIR, cacheDir);
this.settings.setCacheDirectory(cacheDir.getAbsolutePath());
-
- this.appContext.put(Constants.CONTEXT_CONFIG_URL,
- this.getConfigFile(this.settings.getConfiguration()));
+
+ // update settings
+ final URL u = this.getConfigFile(this.settings.getConfiguration());
+ this.settings.setConfiguration(u.toExternalForm());
+ this.appContext.put(Constants.CONTEXT_CONFIG_URL, u);
parentServiceManagerClass = this.settings.getParentServiceManagerClassName();
if (parentServiceManagerClass != null) {
@@ -1150,9 +1152,8 @@
try {
this.exception = null;
- URL configFile = (URL) this.appContext.get(Constants.CONTEXT_CONFIG_URL);
if (getLogger().isInfoEnabled()) {
- getLogger().info("Reloading from: " + configFile.toExternalForm());
+ getLogger().info("Reloading from: " + this.settings.getConfiguration());
}
Cocoon c = (Cocoon) ClassUtils.newInstance("org.apache.cocoon.Cocoon");
ContainerUtil.enableLogging(c, getCocoonLogger());