cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r429297 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon: components/store/impl/ core/container/spring/ servlet/
Date Mon, 07 Aug 2006 10:39:22 GMT
Author: cziegeler
Date: Mon Aug  7 03:39:21 2006
New Revision: 429297

URL: http://svn.apache.org/viewvc?rev=429297&view=rev
Log:
Use settings object to get work/cache directory
Fix role handling for child container

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java?rev=429297&r1=429296&r2=429297&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
Mon Aug  7 03:39:21 2006
@@ -29,14 +29,8 @@
 import net.sf.ehcache.Element;
 import net.sf.ehcache.Status;
 
-import org.apache.cocoon.Constants;
-import org.apache.cocoon.util.IOUtils;
-
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
@@ -45,6 +39,8 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.util.IOUtils;
 import org.apache.excalibur.store.Store;
 import org.apache.excalibur.store.StoreJanitor;
 
@@ -56,7 +52,6 @@
 public class EHDefaultStore
     extends AbstractLogEnabled 
     implements Store,
-               Contextualizable,
                Serviceable,
                Parameterizable,
                Initializable,
@@ -101,19 +96,15 @@
     }
 
     /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException {
-        this.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
-        this.cacheDir = (File)context.get(Constants.CONTEXT_CACHE_DIR);
-    }
-
-    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager aManager) throws ServiceException {
         this.manager = aManager;
         this.storeJanitor = (StoreJanitor) this.manager.lookup(StoreJanitor.ROLE);
+        final Settings settings = (Settings)this.manager.lookup(Settings.ROLE);
+        this.workDir = new File(settings.getWorkDirectory());
+        this.cacheDir = new File(settings.getCacheDirectory());
+        this.manager.release(settings);
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java?rev=429297&r1=429296&r2=429297&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
Mon Aug  7 03:39:21 2006
@@ -15,17 +15,18 @@
  */
 package org.apache.cocoon.components.store.impl;
 
-import org.apache.excalibur.store.impl.AbstractFilesystemStore;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
 import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.cocoon.Constants;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.util.IOUtils;
-import java.io.File;
-import java.io.IOException;
+import org.apache.excalibur.store.impl.AbstractFilesystemStore;
 
 /**
  * Stores objects on the filesystem: String objects as text files,
@@ -34,18 +35,25 @@
  * @version $Id$
  */
 public final class FilesystemStore
-extends AbstractFilesystemStore
-implements Contextualizable, Parameterizable {
+    extends AbstractFilesystemStore
+    implements Serviceable, Parameterizable {
 
     protected File workDir;
     protected File cacheDir;
 
-    public void contextualize(final Context context)
-    throws ContextException {
-        this.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
-        this.cacheDir = (File)context.get(Constants.CONTEXT_CACHE_DIR);
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        final Settings settings = (Settings)manager.lookup(Settings.ROLE);
+        this.workDir = new File(settings.getWorkDirectory());
+        this.cacheDir = new File(settings.getCacheDirectory());
+        manager.release(settings);
     }
 
+    /**
+     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
+     */
     public void parameterize(Parameters params)
     throws ParameterException {
         try {

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java?rev=429297&r1=429296&r2=429297&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
Mon Aug  7 03:39:21 2006
@@ -108,7 +108,7 @@
             while ( i.hasNext() ) {
                 final ComponentInfo current = (ComponentInfo)i.next();
                 if ( current.isSelector() ) {
-                    this.configInfo.getClassNames().put(current.getRole(), current.copy());
+                    this.configInfo.addRole(current.getRole(), current.copy());
                 }
             }
             // TODO - we should add the processor to each container
@@ -188,13 +188,13 @@
         this.processComponents();
 
         // add roles as components
-        final Iterator i = this.configInfo.getClassNames().values().iterator();
+        final Iterator i = this.configInfo.getRoles().iterator();
         while ( i.hasNext() ) {
             final ComponentInfo current = (ComponentInfo)i.next();
             current.setLazyInit(true);
             this.configInfo.addComponent(current);
         }
-        this.configInfo.clearClassNames();
+        this.configInfo.clearRoles();
     }
 
     protected void parseConfiguration(final Configuration configuration,
@@ -249,7 +249,7 @@
             ComponentInfo info;
             if (className == null) {
                 // Get the default class name for this role
-                info = (ComponentInfo)this.configInfo.getClassNames().get( role );
+                info = (ComponentInfo)this.configInfo.getRole( role );
                 if (info == null) {
                     if ( this.configInfo.getComponents().get( role) != null ) {
                         throw new ConfigurationException("Duplicate component definition
for role " + role + " at " + componentConfig.getLocation());
@@ -260,7 +260,7 @@
                 if ( name != null ) {
                     info = info.copy();                    
                 } else if ( !className.endsWith("Selector") ) {
-                    this.configInfo.getClassNames().remove(role);
+                    this.configInfo.removeRole(role);
                 }
             } else {                    
                 info = new ComponentInfo();
@@ -510,7 +510,7 @@
             }
 
             if ( defaultClassName != null ) {
-                ComponentInfo info = (ComponentInfo)this.configInfo.getClassNames().get(roleName);
+                ComponentInfo info = (ComponentInfo)this.configInfo.getRole(roleName);
                 if (info == null) {
                     // Create a new info and store it
                     info = new ComponentInfo();
@@ -519,7 +519,7 @@
                     info.setRole(roleName);
                     info.setConfiguration(role);
                     info.setAlias(shorthand);
-                    this.configInfo.getClassNames().put(roleName, info);
+                    this.configInfo.addRole(roleName, info);
                 } else {
                     // Check that it's consistent with the existing info
                     if (!defaultClassName.equals(info.getComponentClassName())) {

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java?rev=429297&r1=429296&r2=429297&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
Mon Aug  7 03:39:21 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 2006 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.
@@ -16,6 +16,7 @@
 package org.apache.cocoon.core.container.spring;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -36,8 +37,17 @@
     /** Map for shorthand to role mapping. */
     private final Map shorthands;
 
-    /** Map for role to default classname mapping. */
-    private final Map classNames;
+    /** Map for role to default classname mapping. 
+     * As soon as a component is configured for this role, the info
+     * will be removed from this map.
+     * @see #allRoles */
+    private final Map currentRoles;
+
+    /** Map for role to default classname mapping. This map contains
+     * all definitions to be available for maps in child containers.
+     * @see #currentRoles
+     */
+    private final Map allRoles;
 
     /** Map for role->key to classname mapping. */
     private final Map keyClassNames;
@@ -50,14 +60,16 @@
 
     public ConfigurationInfo() {
         this.shorthands = new HashMap();
-        this.classNames = new HashMap();
+        this.currentRoles = new HashMap();
         this.keyClassNames = new HashMap();
+        this.allRoles = new HashMap();
     }
 
     public ConfigurationInfo(ConfigurationInfo parent) {
         this.shorthands = new HashMap(parent.shorthands);
-        this.classNames = new HashMap(parent.classNames);
+        this.currentRoles = new HashMap();
         this.keyClassNames = new HashMap(parent.keyClassNames);
+        this.allRoles = new HashMap(parent.allRoles);
     }
 
     public Map getComponents() {
@@ -76,12 +88,29 @@
         this.components.put(info.getRole(), info);
     }
 
-    public Map getClassNames() {
-        return this.classNames;
+    public Collection getRoles() {
+        return this.currentRoles.values();
+    }
+
+    public void addRole(String role, ComponentInfo info) {
+        this.currentRoles.put(role, info);
+        this.allRoles.put(role, info);
+    }
+
+    public ComponentInfo getRole(String role) {
+        ComponentInfo info = (ComponentInfo) this.currentRoles.get(role);
+        if (info == null ) {
+            info = (ComponentInfo) this.allRoles.get(role);
+        }
+        return info;
+    }
+
+    public void removeRole(String role) {
+        this.currentRoles.remove(role);
     }
 
-    public void clearClassNames() {
-        this.classNames.clear();
+    public void clearRoles() {
+        this.currentRoles.clear();
     }
 
     public Map getShorthands() {

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java?rev=429297&r1=429296&r2=429297&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
Mon Aug  7 03:39:21 2006
@@ -16,7 +16,6 @@
 package org.apache.cocoon.servlet;
 
 import java.io.IOException;
-import java.util.Enumeration;
 import java.util.HashMap;
 
 import javax.servlet.ServletContext;



Mime
View raw message