cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [40/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/logging/SettingsContext.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/logging/SettingsContext.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/logging/SettingsContext.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/logging/SettingsContext.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.logging;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.cocoon.core.Settings;
+
+/**
+ * This is an extension the default context implementation.
+ * It first looks into the settings object and only if the key
+ * is not found there, it delegates to the parent.
+ * 
+ * @version $Id: SettingsContext.java 225167 2005-07-25 19:24:01Z cziegeler $
+ * @since 2.2
+ */
+public class SettingsContext extends DefaultContext {
+
+    private final Settings settings;
+
+    public SettingsContext(Context parentContext, Settings s) {
+        super(parentContext);
+        this.settings = s;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.context.Context#get(java.lang.Object)
+     */
+    public Object get(Object name) throws ContextException {
+        if ( this.settings.getProperty(name.toString()) != null ) {
+            return this.settings.getProperty(name.toString());
+        }
+        return super.get(name);
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/logging/SettingsContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2005 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.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.osgi;
+
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.Cocoon;
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.core.BootstrapEnvironment;
+import org.apache.cocoon.core.Core;
+import org.apache.cocoon.core.container.CoreServiceManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @version $Id: CoreBlockActivator.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public class CoreBlockActivator extends ServiceManagerActivator {
+
+    private Core core;
+    private Processor processor;
+
+    public void start(final BundleContext ctx) throws Exception {
+        Thread.currentThread().setContextClassLoader(CoreBlockActivator.class.getClassLoader());
+        BootstrapEnvironment env = new OSGiBootstrapEnvironment(ctx);
+        env.log("OSGiBootstrapEnvironment created");
+        OSGICoreUtil coreUtil = new OSGICoreUtil(env);
+        env.log("CoreUtil created");
+        this.core = coreUtil.getCore();
+        this.processor = coreUtil.createCocoon();
+
+        super.start(ctx);
+    }
+
+    public void stop(BundleContext ctx) throws Exception {
+        super.stop(ctx);
+    }
+
+    protected Context getContext() throws Exception {
+        return this.core.getContext();
+    }
+
+    /**
+     * This method may be overwritten by subclasses to provide an own
+     * configuration
+     */
+//     protected Configuration getConfiguration() {
+//         DefaultConfiguration config = new DefaultConfiguration("cocoon", "CoreBlockActivator");
+//         return config;
+//     }
+
+    /**
+     * This method may be overwritten by subclasses to add aditional
+     * components.
+     */
+    protected void addComponents(CoreServiceManager manager) 
+    throws ServiceException, ConfigurationException {
+        manager.addInstance(Core.ROLE, this.core);
+        manager.addInstance(Cocoon.class.getName(), this.processor);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreBlockActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreOSGIServiceException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreOSGIServiceException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreOSGIServiceException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreOSGIServiceException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2005 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.osgi;
+
+import org.apache.cocoon.core.CoreException;
+
+/**
+ * @version $Id$
+ * @since 2.2
+ */
+public final class CoreOSGIServiceException extends CoreException {
+
+    public CoreOSGIServiceException(String message) {
+        super(message, null);
+    }
+
+    public CoreOSGIServiceException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/CoreOSGIServiceException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGICoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGICoreUtil.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGICoreUtil.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGICoreUtil.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2005 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.osgi;
+
+import org.apache.cocoon.core.BootstrapEnvironment;
+import org.apache.cocoon.core.CoreUtil;
+
+/**
+ * @version $Id: OSGICoreUtil.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public class OSGICoreUtil extends CoreUtil {
+
+    public OSGICoreUtil(BootstrapEnvironment environment) throws Exception {
+        super(environment);
+    }
+
+    protected void createClassloader() throws Exception {
+        this.classloader = OSGICoreUtil.class.getClassLoader();
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGICoreUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,227 @@
+/*
+ * Copyright 1999-2005 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.osgi;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.apache.avalon.excalibur.logger.LoggerManager;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.core.BootstrapEnvironment;
+import org.apache.cocoon.core.MutableSettings;
+import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.impl.AbstractContext;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * @version $Id: OSGiBootstrapEnvironment.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public class OSGiBootstrapEnvironment implements BootstrapEnvironment {
+
+    private final String configuration = "/WEB-INF/block.xml";
+
+    public Logger logger = null;
+    private final String contextPath;
+    private final Context environmentContext;
+
+
+    public OSGiBootstrapEnvironment(BundleContext bc)
+        throws Exception {
+
+        // Create a logger manager that delegates to OSGi
+        // FIXME: have the maximum level as a property of the bundle
+        LoggerManager logManager = new OSGiLoggerManager(bc, LogService.LOG_DEBUG);
+        this.logger = logManager.getDefaultLogger();
+
+        Bundle bundle = bc.getBundle();
+        if (bundle == null) {
+            throw new Exception("No sitemap bundle");
+        }
+
+        // Try to figure out the path of the root from that of /WEB-INF/block.xml
+        URL pathURL = bundle.getResource(this.configuration);
+        if (pathURL == null) {
+            throw new FileNotFoundException("Unable to get resource '/WEB-INF/block.xml' from bundle ." + bundle);
+        }
+
+        String path = pathURL.toString();
+        path = path.substring(0, path.length() - (this.configuration.length() - 1));
+        this.contextPath = path;
+
+        this.environmentContext = new OSGiContext(bundle);
+    }
+
+    /**
+     * @see org.apache.cocoon.core.BootstrapEnvironment#getBootstrapLogger(org.apache.cocoon.core.BootstrapEnvironment.LogLevel)
+     */
+    public Logger getBootstrapLogger(LogLevel logLevel) {
+        return this.logger;
+    }
+
+    /** Log a message during bootstrapping. This is used to log
+     * information before the logging system is setup.
+     * @param message A message.
+     */
+    public void log(String message) {
+        this.logger.info(message);
+    }
+
+    /** Log a message during bootstrapping. This is used to log
+     * information before the logging system is setup.
+     * @param message A message.
+     * @param error   An error.
+     */
+    public void log(String message, Throwable error) {
+        this.logger.info(message, error);
+    }
+
+    /**
+     * Pass the root logger back to the environment. As soon as the
+     * logging system is set up, this method is called.
+     * @param rootLogger The root logger.
+     */
+    public void setLogger(Logger rootLogger) {
+        this.logger = rootLogger;
+    }
+
+    /**
+     * Get the input stream from a resource at the given
+     * path. Only paths relative to the bootstrap context are
+     * supported. Returns null if no resource exists at the
+     * specified path
+     */
+    public InputStream getInputStream(String path) {
+        try {
+            return (new URL(this.contextPath + path)).openStream();
+        } catch (IOException e) {
+            this.log("Couldn't open " + this.contextPath + path);
+            return null;
+        }
+    }
+
+    public void configure(MutableSettings settings) {
+        // FIXME: Should be found from block.xml
+        settings.setConfiguration("/WEB-INF/cocoon.xconf");
+        settings.setWorkDirectory("work");
+        settings.setLoggingConfiguration("/WEB-INF/logkit.xconf");
+    }
+
+    public void configureLoggingContext(DefaultContext context) {
+        // simply do nothing
+    }
+
+    public void configure(DefaultContext context) {
+    }
+
+    public Context getEnvironmentContext() {
+        return this.environmentContext;
+    }
+
+    /**
+     * Returns the URL to the application context.
+     */
+    public String getContextURL() {
+        return this.contextPath;
+    }
+
+    /**
+     * Returns a file to the application context.
+     * @return A file pointing to the context or null if the context is not
+     *         writeable.
+     */
+    public File getContextForWriting() {
+        return null;
+    }
+
+    /**
+     * Set the ConfigFile for the Cocoon object.
+     *
+     * @param configFileName The file location for the cocoon.xconf
+     *
+     * @throws Exception
+     */
+    public URL getConfigFile(String configFileName) throws Exception {
+        this.logger.debug("getConfigFile: contextPath=" + this.contextPath +
+                          " configFileName=" + configFileName);
+        return new URL(this.contextPath + configFileName);
+    }
+
+    public class OSGiContext extends AbstractContext {
+
+        private Bundle bundle;
+        private Hashtable attributes = new Hashtable();
+        private Hashtable initparameters = new Hashtable();
+
+        public OSGiContext(Bundle bundle) {
+            this.bundle = bundle;
+            this.initparameters.put("work-directory", "work");
+        }
+
+        public Object getAttribute(String name) {
+            return attributes.get(name);
+        }
+
+        public void setAttribute(String name, Object value) {
+            attributes.put(name, value);
+        }
+
+        public void removeAttribute(String name) {
+            attributes.remove(name);
+        }
+
+        public Enumeration getAttributeNames() {
+            return attributes.keys();
+        }
+
+        public URL getResource(String path) throws MalformedURLException {
+            return this.bundle.getResource(path);
+        }
+
+        public String getRealPath(String path) {
+            // Everything is zipped up, no path.
+            return null;
+        }
+
+        public String getMimeType(String file) {
+            // TODO Implement
+            throw new UnsupportedOperationException("Not Implemented");
+        }
+
+        public String getInitParameter(String name) {
+            return (String) initparameters.get(name);
+        }
+
+        public InputStream getResourceAsStream(String path) {
+            try {
+                return bundle.getResource(path).openStream();
+            } catch (IOException e) {
+                // FIXME Error handling
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2002-2005 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.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.osgi;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.components.ComponentInfo;
+import org.apache.cocoon.core.container.CoreServiceManager;
+import org.apache.cocoon.core.container.DefaultServiceSelector;
+import org.apache.cocoon.core.container.handler.ComponentHandler;
+import org.apache.cocoon.core.container.handler.PoolableComponentHandler;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * An extension of {@link org.apache.cocoon.core.container.CoreServiceManager} that registers some
+ * of its components as OSGi services.
+ * <p>
+ * The component role is used to find a component's interface. If the role is a hinted one (e.g.
+ * "org.apache.cocoon.generation.Generator/file", then the hint is registered as the "component.hint"
+ * property of the OSGi service.
+ * <p>
+ * Only those components whose configuration has an <code>exported="true"</code> attribute are exported.
+ * An important constraint is that such components be singleton (either real singletons or singleton proxies
+ * to non-singleton components).
+ * 
+ * @version $Id: OSGiCoreServiceManager.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public class OSGiCoreServiceManager extends CoreServiceManager {
+    
+    BundleContext ctx;
+    
+    public OSGiCoreServiceManager(ServiceManager parent, ClassLoader classloader, BundleContext ctx) {
+        super(parent, classloader);
+        this.ctx = ctx;
+    }
+
+    /**
+     * Catch component declarations and register exported ones as OSGi services.
+     */
+    public void addComponent(String role, String className, Configuration configuration, ComponentInfo info) throws ConfigurationException {
+        super.addComponent(role, className, configuration, info);
+
+        Class clazz;
+        try {
+            clazz = this.componentEnv.loadClass(className);
+        } catch(ClassNotFoundException cnfe) {
+            throw new ConfigurationException("Cannot load class " + className + " for component at " +
+                                             configuration.getLocation(), cnfe);
+        }
+
+        // The DefaultServiceSelector just add its children, no need to add it as a service
+        if (DefaultServiceSelector.class.isAssignableFrom(clazz))
+            return;
+        if (configuration.getAttributeAsBoolean("exported", true)) {
+            ComponentHandler handler = (ComponentHandler)super.componentHandlers.get(role);
+            // Shouldn't PoolableComponentHandler be marked as a singleton?
+            if (handler.isSingleton() ||
+                handler instanceof PoolableComponentHandler) {
+                this.addService(role, handler);
+            } else {
+                throw new ConfigurationException("Only singleton services and thread safe pool proxies can be exported as OSGi services, at " +
+                                                 configuration.getLocation() +
+                                                 " handler=" + handler);
+            }
+        }
+    }
+    
+    /**
+     * Catch a component insertion and register it as OSGi services.
+     */
+    public void addInstance(String role, Object instance) throws ServiceException {
+        super.addInstance(role, instance);
+        ComponentHandler handler = (ComponentHandler)super.componentHandlers.get(role);
+        this.addService(role, handler);
+    }
+
+    /**
+     * Register a component as an OSGi service.
+     */
+    protected void addService(String role, ComponentHandler handler) {
+        String itfName = OSGiServiceManager.getServiceInterface(role);
+        String hint = OSGiServiceManager.getServiceHint(role);
+        Dictionary dict = null;
+        if (hint != null) {
+            dict = new Hashtable();
+            dict.put(OSGiServiceManager.HINT_PROPERTY, hint);
+        }
+
+        Object service = new ComponentHandlerFactory(handler);
+        ctx.registerService(itfName, service, dict);
+    }
+    
+    /**
+     * An OSGi service factory implemented on top of a {@link ComponentHandler}.
+     * @author sylvain
+     *
+     */
+    public static class ComponentHandlerFactory implements ServiceFactory {
+        
+        private ComponentHandler handler;
+
+        public ComponentHandlerFactory(ComponentHandler handler) {
+            this.handler = handler;
+        }
+
+        public Object getService(Bundle bundle, ServiceRegistration reg) {
+            try {
+                return handler.get();
+            } catch (Exception e) {
+                throw new CoreOSGIServiceException("Cannot get service", e);
+            }
+        }
+
+        public void ungetService(Bundle bundle, ServiceRegistration reg, Object obj) {
+            try {
+                handler.put(obj);
+            } catch (Exception e) {
+                throw new CoreOSGIServiceException("Cannot unget service", e);
+            }
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiCoreServiceManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiLoggerManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiLoggerManager.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiLoggerManager.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiLoggerManager.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2005 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.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.osgi;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.excalibur.logger.LoggerManager;
+import org.apache.avalon.framework.logger.Logger;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * An implementation of Avalon's <code>LoggerManager</code> on top of OSGi's <code>LogService</code>.
+ * OSGi's service provides no way to check if a particular log level is enabled. Rather than always
+ * considering all levels to be enabled, which can lead to useless expensive expressions, the maximum
+ * log level is given at manager creation time, and is uses by all log categories within the bundle.
+ * 
+ * @version $Id: OSGiLoggerManager.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public class OSGiLoggerManager implements LoggerManager {
+    
+    LogService logService;
+    int maxLevel;
+    
+    /**
+     * Create an <code>OSGiLoggerManager</code>.
+     * 
+     * @param ctx the <code>BundleContext</code> used to get the <code>LogService</code>
+     * @param maxLevel the maximum log level (error is the lowest, debug the highest).
+     */
+    public OSGiLoggerManager(final BundleContext ctx, int maxLevel) {
+        this.maxLevel = maxLevel;
+        
+        // Lookup the log service
+        final ServiceReference logRef = ctx.getServiceReference(LogService.class.getName());
+        this.logService = (LogService)ctx.getService(logRef);
+        
+        // FIXME: check if we need this
+        ctx.addBundleListener(new BundleListener() {
+
+            public void bundleChanged(BundleEvent ev) {
+                if (ev.getType() == BundleEvent.STOPPED) {
+                    // release the log service.
+                    ctx.ungetService(logRef);
+                }
+            }
+        });
+    }
+
+    /** Loggers by category */
+    private Map loggers = Collections.synchronizedMap(new HashMap());
+
+    public Logger getLoggerForCategory(String category) {
+        Logger result = (Logger)loggers.get(category);
+        if (result == null) {
+            result = new OSGiLogger(category);
+            loggers.put(category, result);
+        }
+        return result;
+    }
+
+    public Logger getDefaultLogger() {
+        return getLoggerForCategory("");
+    }
+    
+    /**
+     * A Logger delegating to OSGi's LogService
+     */
+    private class OSGiLogger implements Logger {
+        
+        private String category;
+
+        OSGiLogger(String category) {
+            this.category = category;
+        }
+        
+        private void log(int level, String msg) {
+            if (level <= maxLevel) {
+                logService.log(level, "[" + category + "] " + msg);
+            }
+        }
+        
+        private void log(int level, String msg, Throwable thr) {
+            if (level <= maxLevel) {
+                logService.log(level, msg, thr);
+            }
+        }
+        
+        public Logger getChildLogger(String category) {
+            return getLoggerForCategory(this.category.length() == 0 ? category : this.category + "." + category);
+        }
+        
+        private boolean isLevelEnabled(int level) {
+            return level <= maxLevel;
+        }
+
+        public void debug(String msg) {
+            log(LogService.LOG_DEBUG, msg);
+        }
+
+        public void debug(String msg, Throwable thr) {
+            log(LogService.LOG_DEBUG, msg, thr);
+            
+        }
+
+        public boolean isDebugEnabled() {
+            return isLevelEnabled(LogService.LOG_DEBUG);
+        }
+
+        public void info(String msg) {
+            log(LogService.LOG_INFO, msg);
+        }
+
+        public void info(String msg, Throwable thr) {
+            log(LogService.LOG_INFO, msg, thr);
+        }
+
+        public boolean isInfoEnabled() {
+            return isLevelEnabled(LogService.LOG_INFO);
+        }
+
+        public void warn(String msg) {
+            log(LogService.LOG_WARNING, msg);
+        }
+
+        public void warn(String msg, Throwable thr) {
+            log(LogService.LOG_WARNING, msg, thr);
+        }
+
+        public boolean isWarnEnabled() {
+            return isLevelEnabled(LogService.LOG_WARNING);
+        }
+
+        public void error(String msg) {
+            log(LogService.LOG_ERROR, msg);
+        }
+
+        public void error(String msg, Throwable thr) {
+            log(LogService.LOG_ERROR, msg, thr);
+        }
+
+        public boolean isErrorEnabled() {
+            return isLevelEnabled(LogService.LOG_ERROR);
+        }
+
+        public void fatalError(String msg) {
+            // OSGi has no "fatal" level
+            log(LogService.LOG_ERROR, msg);
+        }
+
+        public void fatalError(String msg, Throwable thr) {
+            // OSGi has no "fatal" level
+            log(LogService.LOG_ERROR, msg, thr);
+        }
+
+        public boolean isFatalErrorEnabled() {
+            // OSGi has no "fatal" level
+           return isLevelEnabled(LogService.LOG_ERROR);
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiLoggerManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiServiceManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiServiceManager.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiServiceManager.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiServiceManager.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2005 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.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.core.osgi;
+
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A <code>ServiceManager</code> that looks up components by getting OSGi services.
+ * <p>
+ * Roles are supposed to be interface names, which the OSGi framework will use. As some
+ * roles may contain hints (e.g. "org.apache.cocoon.generation.Generator/file"), in such
+ * cases the interface name is extracted, and the hint is expected to be found in the
+ * "<code>component.hint</code>" service property.
+ *
+ * @version $Id: OSGiServiceManager.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public class OSGiServiceManager implements ServiceManager {
+    
+    /**
+     * The property that's used to hold component hints in component selectors.
+     */
+    public static final String HINT_PROPERTY = "component.hint";
+    
+    private BundleContext context;
+
+    /** Mapping from service instance to ServiceReference */
+    private Map serviceReferences = new IdentityHashMap();
+
+    public OSGiServiceManager(BundleContext context) {
+        this.context = context;
+    }
+
+    public Object lookup(String role) throws ServiceException {
+        // Get the service
+        ServiceReference ref;
+        try {
+            ref = getServiceReference(this.context, role);
+        } catch (InvalidSyntaxException e) {
+            throw new ServiceException(role, "Cannot lookup OSGi service", e);
+        }
+
+        if (ref == null) {
+            throw new ServiceException(role, "OSGi service not available");
+        }
+        
+        // Important hypothesis: for a given (role, requesting bundle) value, OSGi
+        // always returns the same service instance. This seems to be implied by the
+        // specification, and how the knopflerfish implementation behaves.
+        Object service = context.getService(ref);
+        
+        // Keep track of its reference
+        synchronized(this) {
+            this.serviceReferences.put(service, ref);
+        }
+
+        return service;
+    }
+
+    public boolean hasService(String role) {
+        try {
+            return getServiceReference(this.context, role) != null;
+        } catch (InvalidSyntaxException e) {
+            return false;
+        }
+   }
+
+    public void release(Object obj) {
+        ServiceReference ref = (ServiceReference)this.serviceReferences.get(obj);
+        
+        if (ref == null) {
+            // not handled here
+            return;
+        }
+        
+        synchronized(this) {
+            if (this.context.ungetService(ref)) {
+                // No more used here: remove it from our map.
+                this.serviceReferences.remove(obj);
+            }
+        }
+    }
+    
+    public static ServiceReference getServiceReference(BundleContext ctx, String role) throws InvalidSyntaxException {
+        ServiceReference result;
+
+        int pos = role.indexOf('/');
+
+        if (pos == -1) {
+            // Single interface role
+            result = ctx.getServiceReference(role);
+        } else {
+            // Hinted role: split it
+            String itf = role.substring(0, pos);
+            String query = "(" + HINT_PROPERTY + "=" + role.substring(pos + 1) + ")";
+            ServiceReference[] results = ctx.getServiceReferences(itf, query);
+            result = (results != null && results.length > 1) ? results[0] : null;
+        }
+
+        return result;
+    }
+    
+    public static String getServiceInterface(String role) {
+        int pos = role.indexOf('/');
+        
+        return pos == -1 ? role : role.substring(0, pos);
+    }
+    
+    public static String getServiceHint(String role) {
+        int pos = role.indexOf('/');
+        return pos == -1 ? null : role.substring(pos+1);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiServiceManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2005 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.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.osgi;
+
+import java.net.URL;
+
+import org.apache.avalon.excalibur.logger.LoggerManager;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.core.Core;
+import org.apache.cocoon.core.container.CoreServiceManager;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * @version $Id: ServiceManagerActivator.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public class ServiceManagerActivator implements BundleActivator {
+
+
+//  Registering services must go through the ServiceFactory class wrapping the componentHandler
+    
+    private ServiceManager parentManager;
+    private OSGiCoreServiceManager manager;
+
+    public void start(final BundleContext ctx) throws Exception {
+        
+        // Create a logger manager that delegates to OSGi
+        // FIXME: have the maximum level as a property of the bundle
+        LoggerManager logManager = new OSGiLoggerManager(ctx, LogService.LOG_DEBUG);
+
+        // Create a parent manager that will lookup registered OSGi services
+        this.parentManager = new OSGiServiceManager(ctx);
+        
+        // Create a regular manager
+        this.manager = new OSGiCoreServiceManager(parentManager, this.getClass().getClassLoader(), ctx) {
+        };
+
+        //---- LogEnabled
+        this.manager.enableLogging(logManager.getDefaultLogger());
+        
+        //---- Contextualizable
+        //DefaultContext avalonCtx = new ComponentContext();
+        // Context entries defined in CocoonServlet/CoreUtil:
+        // "servlet-config"
+        // "servlet-context"
+        // ContextHelper.CONTEXT_ROOT_URL
+        // Constants.CONTEXT_ENVIRONMENT_CONTEXT
+        // Constants.CONTEXT_WORK_DIR
+        // Constants.CONTEXT_UPLOAD_DIR
+        // Constants.CONTEXT_CACHE_DIR
+        // Constants.CONTEXT_CONFIG_URL
+        // Constants.CONTEXT_DEFAULT_ENCODING
+        // Constants.CONTEXT_CLASS_LOADER
+        // Core.ROLE (???)
+        // Constants.CONTEXT_CLASSPATH
+
+        this.manager.contextualize(this.getContext());
+        
+        //---- LoggerManager
+        this.manager.setLoggerManager(logManager);
+        
+        //---- RoleManager
+        // No parent role manager
+        this.manager.setRoleManager(null);
+        
+        //---- Configurable
+        this.manager.configure(this.getConfiguration(ctx));
+        this.addComponents(this.manager);
+        
+        //---- Initializable
+        this.manager.initialize();
+
+    }
+
+    public void stop(BundleContext ctx) throws Exception {
+        // Dispose the ServiceManager
+        this.manager.dispose();
+    }
+
+    protected Context getContext() throws Exception {
+        Core core = (Core)this.parentManager.lookup(Core.ROLE);
+        return core.getContext();
+    }
+
+    /**
+     * This method may be overwritten by subclasses to provide an own
+     * configuration
+     */
+    protected Configuration getConfiguration(BundleContext ctx) throws Exception {
+	URL confURL = ctx.getBundle().getResource("/WEB-INF/block.xml");
+	DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+	Configuration block = builder.build(confURL.openStream());
+	Configuration components = block.getChild("components");
+
+        return components;
+    }
+
+    /**
+     * This method may be overwritten by subclasses to add aditional
+     * components.
+     */
+    protected void addComponents(CoreServiceManager manager) 
+    throws ServiceException, ConfigurationException {
+        // subclasses can add components here
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/ServiceManagerActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/source/SimpleSourceResolver.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/source/SimpleSourceResolver.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/source/SimpleSourceResolver.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/source/SimpleSourceResolver.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,193 @@
+/* 
+ * Copyright 2002-2005 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.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.source;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+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.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.source.impl.ContextSourceFactory;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.impl.ResourceSourceFactory;
+import org.apache.excalibur.source.impl.URLSourceFactory;
+
+/**
+ * A minimalist <code>SourceResolver</code> that handles a fixed restricted number of protocols. It is
+ * used as a bootstrap resolver to load roles and imported files in a service manager.
+ * <p>
+ * The supported protocols schemes are:
+ * <ul>
+ * <li><code>resource</code> to load resources in the classpath,</li>
+ * <li><code>context</code> to load resources from the context, defined by the <code>context-root</code>
+ *     entry in the Avalon {@link Context} (either a {@link File} or an {@link URL}), or if not
+ *     present, from the <code>user.dir</code> system property,</li>
+ * <li>all standard JDK schemes (http, file, etc).
+ * </ul>
+ * Relative URIs are resolved relatively to the context root, i.e. similarily to "<code>context:</code>".
+ * 
+ * @version $Id: SimpleSourceResolver.java 312637 2005-10-10 13:00:42Z cziegeler $
+ * @since 2.2
+ */
+public final class SimpleSourceResolver extends AbstractLogEnabled
+    implements ThreadSafe, Contextualizable, SourceResolver {
+    
+    // The base URI, initialized in contextualize()
+    private String contextBase;
+    
+    // The three factories we use (no need for a selector nor a Map)
+    private ResourceSourceFactory resourceFactory = new ResourceSourceFactory();
+    private URLSourceFactory urlFactory = new URLSourceFactory();    
+    private ContextSourceFactory contextFactory = new ContextSourceFactory();
+    
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(Logger logger) {
+        super.enableLogging(logger);
+        this.resourceFactory.enableLogging(logger);
+        this.urlFactory.enableLogging(logger);
+        this.contextFactory.enableLogging(logger);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     */
+    public void contextualize(Context context) throws ContextException {
+        this.contextFactory.contextualize(context);
+        try {
+            this.contextFactory.service(new SimpleServiceManager(this));            
+        } catch (ServiceException se) {
+            throw new ContextException("Unable to service context factory.", se);
+        }
+
+        try {
+            // Similar to Excalibur's SourceResolverImpl, and consistent with ContextHelper.CONTEXT_ROOT_URL
+            if( context.get("context-root") instanceof URL) {
+                contextBase = ((URL)context.get("context-root")).toExternalForm();
+            } else {
+                contextBase = ((File)context.get("context-root")).toURL().toExternalForm();
+            }
+        } catch(ContextException ce) {
+            // set the base URL to the current directory
+            try {
+                contextBase = new File(System.getProperty("user.dir")).toURL().toExternalForm();
+            } catch( MalformedURLException mue) {
+                throw new ContextException( "Malformed URL for user.dir, and no context-root exists", mue);
+            }
+        } catch( MalformedURLException mue) {
+            throw new ContextException("Malformed URL for context-root", mue);
+        }
+        
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Base URL set to " + this.contextBase);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.excalibur.source.SourceResolver#resolveURI(java.lang.String)
+     */
+    public Source resolveURI(String uri) throws MalformedURLException, IOException {
+        return resolveURI(uri, contextBase, null);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.excalibur.source.SourceResolver#resolveURI(java.lang.String, java.lang.String, java.util.Map)
+     */
+    public Source resolveURI(String uri, String base, Map params) throws MalformedURLException, IOException {
+        if (uri.startsWith("resource://")) {
+            return resourceFactory.getSource(uri, null);
+        } else if (uri.startsWith("context://")) {
+            return this.contextFactory.getSource(uri, params);
+        } else {
+            // special handling for windows and unix file paths
+            if( uri.length() > 1 && uri.charAt( 1 ) == ':' ) {
+                uri = "file:/" + uri;
+                base = null;
+            } else if( uri.length() > 2 && uri.charAt(0) == '/' && uri.charAt(2) == ':' ) {
+                uri = "file:" + uri;
+                base = null;
+            }
+            URL url;
+            if ( base == null ) {
+                url = new URL(uri);
+            } else {
+                URL baseURL = new URL(base);
+                url = new URL(baseURL, uri);
+            }
+            return this.urlFactory.getSource(url.toExternalForm(), params);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.excalibur.source.SourceResolver#release(org.apache.excalibur.source.Source)
+     */
+    public void release(Source source) {
+        if ( source != null ) {
+            if ( "context".equals(source.getScheme()) ) {
+                this.contextFactory.release(source);
+            } else if ( "resource".equals(source.getScheme()) ) {
+                this.resourceFactory.release(source);
+            } else {
+                this.urlFactory.release(source);
+            }
+        }
+    }
+    
+    public static final class SimpleServiceManager implements ServiceManager {
+        
+        private final SourceResolver resolver;
+        
+        public SimpleServiceManager(SourceResolver resolver) {
+            this.resolver = resolver;
+        }
+                
+        /* (non-Javadoc)
+         * @see org.apache.avalon.framework.service.ServiceManager#hasService(java.lang.String)
+         */
+        public boolean hasService(String role) {
+            return SourceResolver.ROLE.equals(role);
+        }
+        
+        /* (non-Javadoc)
+         * @see org.apache.avalon.framework.service.ServiceManager#lookup(java.lang.String)
+         */
+        public Object lookup(String role) throws ServiceException {
+            if ( !SourceResolver.ROLE.equals(role) ) {
+                throw new ServiceException("SimpleServiceManager", "Unable to lookup component with role: " + role);
+            }
+            return this.resolver;
+        }
+        
+        /* (non-Javadoc)
+         * @see org.apache.avalon.framework.service.ServiceManager#release(java.lang.Object)
+         */
+        public void release(Object component) {
+            // nothing to do
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/core/source/SimpleSourceResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,296 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.util.BufferedOutputStream;
+import org.apache.commons.collections.iterators.IteratorEnumeration;
+
+/**
+ * Base class for any environment
+ *
+ * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
+ * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: AbstractEnvironment.java 226274 2005-07-28 22:45:26Z vgritsenko $
+ */
+public abstract class AbstractEnvironment 
+    extends AbstractLogEnabled 
+    implements Environment {
+
+    /** The current uri in progress */
+    protected String uri;
+
+    /** The prefix */
+    protected String prefix = "";
+    
+    /** The View requested */
+    protected String view;
+
+    /** The Action requested */
+    protected String action;
+
+    /** The object model */
+    protected Map objectModel = new HashMap();
+
+    /** The attributes */
+    private Map attributes = new HashMap();
+
+    /** The secure Output Stream */
+    protected BufferedOutputStream secureOutputStream;
+
+    /** The real output stream */
+    protected OutputStream outputStream;
+
+    /**
+     * Constructs the abstract environment
+     */
+    public AbstractEnvironment(String uri, String view) {
+        this(uri, view, null);
+    }
+
+    /**
+     * Constructs the abstract environment
+     */
+    public AbstractEnvironment(String uri, String view, String action) {
+        this.uri = uri;
+        this.view = view;
+        this.action = action;
+    }
+
+    /**
+     * Allow implementations to set view later than in super() constructor.
+     * View can be set only once, and should be set in implementation's constructor.
+     */
+    protected void setView(String view) {
+        if (this.view != null) {
+            throw new IllegalStateException("View was already set on this environment");
+        }
+        this.view = view;
+    }
+
+    /**
+     * Allow implementations to set action later than in super() constructor
+     * Action can be set only once, and should be set in implementation's constructor.
+     */
+    protected void setAction(String action) {
+        if (this.action != null) {
+            throw new IllegalStateException("Action was already set on this environment");
+        }
+        this.action = action;
+    }
+
+    /**
+     * Helper method to extract the view name from the request.
+     */
+    protected static String extractView(Request request) {
+        return request.getParameter(Constants.VIEW_PARAM);
+    }
+
+    /**
+     * Helper method to extract the action name from the request.
+     */
+    protected static String extractAction(Request req) {
+        String action = req.getParameter(Constants.ACTION_PARAM);
+        if (action != null) {
+            /* TC: still support the deprecated syntax */
+            return action;
+        }
+        for(Enumeration e = req.getParameterNames(); e.hasMoreElements(); ) {
+            String name = (String)e.nextElement();
+            if (name.startsWith(Constants.ACTION_PARAM_PREFIX)) {
+                if (name.endsWith(".x") || name.endsWith(".y")) {
+                    return name.substring(Constants.ACTION_PARAM_PREFIX.length(),name.length()-2);
+                }
+                 return name.substring(Constants.ACTION_PARAM_PREFIX.length());
+            }
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getURI()
+     */
+    public String getURI() {
+        return this.uri;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getURIPrefix()
+     */
+    public String getURIPrefix() {
+        return this.prefix;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setURI(java.lang.String)
+     */
+    public void setURI(String prefix, String value) {
+        this.prefix = prefix;
+        this.uri = value;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getView()
+     */
+    public String getView() {
+        return this.view;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getAction()
+     */
+    public String getAction() {
+        return this.action;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setStatus(int)
+     */
+    public void setStatus(int statusCode) {
+        // for subclasses
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getObjectModel()
+     */
+    public Map getObjectModel() {
+        return this.objectModel;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#isResponseModified(long)
+     */
+    public boolean isResponseModified(long lastModified) {
+        return true; // always modified
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setResponseIsNotModified()
+     */
+    public void setResponseIsNotModified() {
+        // does nothing
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return this.attributes.get(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object value) {
+        this.attributes.put(name, value);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+        this.attributes.remove(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getAttributeNames()
+     */
+    public Enumeration getAttributeNames() {
+        return new IteratorEnumeration(this.attributes.keySet().iterator());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#getOutputStream(int)
+     */
+    public OutputStream getOutputStream(int bufferSize)
+    throws IOException {
+
+        // This method could be called several times during request processing
+        // with differing values of bufferSize and should handle this situation
+        // correctly.
+
+        if (bufferSize == -1) {
+            if (this.secureOutputStream == null) {
+                this.secureOutputStream = new BufferedOutputStream(this.outputStream);
+            }
+            return this.secureOutputStream;
+        } else if (bufferSize == 0) {
+            // Discard secure output stream if it was created before.
+            if (this.secureOutputStream != null) {
+                this.secureOutputStream = null;
+            }
+            return this.outputStream;
+        } else {
+            // FIXME Triple buffering, anyone?
+            this.outputStream = new java.io.BufferedOutputStream(this.outputStream, bufferSize);
+            return this.outputStream;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#tryResetResponse()
+     */
+    public boolean tryResetResponse()
+    throws IOException {
+        if (this.secureOutputStream != null) {
+            this.secureOutputStream.clearBuffer();
+            return true;
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#commitResponse()
+     */
+    public void commitResponse()
+    throws IOException {
+        if (this.secureOutputStream != null) {
+            this.setContentLength(this.secureOutputStream.getCount());
+            this.secureOutputStream.realFlush();
+        } else if ( this.outputStream != null ){
+            this.outputStream.flush();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#startingProcessing()
+     */
+    public void startingProcessing() {
+        // do nothing here
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#finishingProcessing()
+     */
+    public void finishingProcessing() {
+        // do nothing here
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Environment#isInternRedirect()
+     */
+    public boolean isInternalRedirect() {
+        return false;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/CocoonRunnable.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/CocoonRunnable.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/CocoonRunnable.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/CocoonRunnable.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1999-2005 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+
+/**
+ * A <code>Runnable</code> wrapper or base class that inherits the execution
+ * context of the thread creating it, as it was at the time of creation.
+ * <p>
+ * It is meant to be used when processing of a request is to be split across several
+ * cooperating threads (e.g. parallel aggregation).
+ * <p>
+ * <strong>Note</strong>: a <code>CocoonRunnable</code> should not live longer than the
+ * end of the execution of the request in the creating thread, otherwise some unexpected
+ * behaviours may happen because the parent's environment has been released.
+ * 
+ * @since 2.1.8
+ * @version $Id: CocoonRunnable.java 189934 2005-06-10 09:37:54Z sylvain $
+ */
+public class CocoonRunnable extends EnvironmentHelper.AbstractCocoonRunnable {
+    Runnable target;
+
+    /**
+     * Creates an empty <code>CocoonRunnable</code> and copies the environment context
+     * of the calling thread, for later use when calling {@link #doRun()}. Users of this
+     * constructor will override the {@link #doRun()} method where the actual job gets done.
+     */
+    public CocoonRunnable() {
+        // Nothing special here
+    }
+
+    /**
+     * Wraps an existing <code>Runnable</code> and copies the environment context of
+     * the calling thread, for later use when the <code>Runnable</code>'s <code>run()</code>
+     * method is called.
+     * 
+     * @param target the wrapped <code>Runnable</code>
+     */
+    public CocoonRunnable(Runnable target) {
+        this.target = target;
+    }
+
+    /**
+     * Does the actual job, in the environment of the creating thread. Calls the wrapped
+     * <code>Runnable</code> if one was given, and does nothing otherwise.
+     */
+    protected void doRun() {
+        if (target != null) {
+            target.run();
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/CocoonRunnable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Context.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Context.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Context.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Context.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 1999-2005 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Map;
+import java.io.InputStream;
+
+/**
+ * Defines an interface to provide context information.
+ *
+ * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
+ * @version CVS $Id: Context.java 170542 2005-05-17 08:10:19Z danielf $
+ *
+ */
+
+public interface Context {
+
+    Object getAttribute(String name);
+
+    void setAttribute(String name, Object value);
+
+    /**
+     * Utility method for getting a <code>Map</code> view of the context attributes.
+     * Returns a <code>Map</code> with context attributes.
+     *
+     * @return                a <code>Map</code> containing the context attributes.
+     *
+     * @since 2.2
+     */
+    Map getAttributes();
+
+    void removeAttribute(String name);
+
+    Enumeration getAttributeNames();
+
+    URL getResource(String path) throws MalformedURLException;
+
+    String getRealPath(String path);
+
+    String getMimeType(String file);
+
+    String getInitParameter(String name);
+
+    InputStream getResourceAsStream(String path);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Context.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Cookie.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Cookie.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Cookie.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Cookie.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,363 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+/**
+ *
+ * Creates a cookie, a small amount of information sent by a servlet to
+ * a Web browser, saved by the browser, and later sent back to the server.
+ * A cookie's value can uniquely
+ * identify a client, so cookies are commonly used for session management.
+ *
+ * <p>A cookie has a name, a single value, and optional attributes
+ * such as a comment, path and domain qualifiers, a maximum age, and a
+ * version number. Some Web browsers have bugs in how they handle the
+ * optional attributes, so use them sparingly to improve the interoperability
+ * of your servlets.
+ *
+ * <p>The servlet sends cookies to the browser by using the
+ * {@link Response#addCookie(Cookie)} method, which adds
+ * fields to HTTP response headers to send cookies to the
+ * browser, one at a time. The browser is expected to
+ * support 20 cookies for each Web server, 300 cookies total, and
+ * may limit cookie size to 4 KB each.
+ *
+ * <p>The browser returns cookies to the servlet by adding
+ * fields to HTTP request headers. Cookies can be retrieved
+ * from a request by using the {@link Request#getCookies()} method.
+ * Several cookies might have the same name but different path attributes.
+ *
+ * <p>Cookies affect the caching of the Web pages that use them.
+ * HTTP 1.0 does not cache pages that use cookies created with
+ * this class. This class does not support the cache control
+ * defined with HTTP 1.1.
+ *
+ * <p>This class supports both the Version 0 (by Netscape) and Version 1
+ * (by RFC 2109) cookie specifications. By default, cookies are
+ * created using Version 0 to ensure the best interoperability.
+ *
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: Cookie.java 160568 2005-04-08 17:33:05Z sylvain $
+ *
+ */
+
+public interface Cookie {
+
+    /**
+     *
+     * Specifies a comment that describes a cookie's purpose.
+     * The comment is useful if the browser presents the cookie
+     * to the user. Comments
+     * are not supported by Netscape Version 0 cookies.
+     *
+     * @param purpose		a <code>String</code> specifying the comment
+     *				to display to the user
+     *
+     * @see #getComment()
+     *
+     */
+
+    void setComment(String purpose);
+
+
+
+
+    /**
+     * Returns the comment describing the purpose of this cookie, or
+     * <code>null</code> if the cookie has no comment.
+     *
+     * @return			a <code>String</code> containing the comment,
+     *				or <code>null</code> if none
+     *
+     * @see #setComment(String)
+     *
+     */
+
+    String getComment();
+
+
+
+
+    /**
+     *
+     * Specifies the domain within which this cookie should be presented.
+     *
+     * <p>The form of the domain name is specified by RFC 2109. A domain
+     * name begins with a dot (<code>.foo.com</code>) and means that
+     * the cookie is visible to servers in a specified Domain Name System
+     * (DNS) zone (for example, <code>www.foo.com</code>, but not
+     * <code>a.b.foo.com</code>). By default, cookies are only returned
+     * to the server that sent them.
+     *
+     *
+     * @param pattern		a <code>String</code> containing the domain name
+     *				within which this cookie is visible;
+     *				form is according to RFC 2109
+     *
+     * @see #getDomain()
+     *
+     */
+
+    void setDomain(String pattern);
+
+
+
+
+
+    /**
+     * Returns the domain name set for this cookie. The form of
+     * the domain name is set by RFC 2109.
+     *
+     * @return			a <code>String</code> containing the domain name
+     *
+     * @see #setDomain(String)
+     *
+     */
+
+    String getDomain();
+
+
+
+
+    /**
+     * Sets the maximum age of the cookie in seconds.
+     *
+     * <p>A positive value indicates that the cookie will expire
+     * after that many seconds have passed. Note that the value is
+     * the <i>maximum</i> age when the cookie will expire, not the cookie's
+     * current age.
+     *
+     * <p>A negative value means
+     * that the cookie is not stored persistently and will be deleted
+     * when the Web browser exits. A zero value causes the cookie
+     * to be deleted.
+     *
+     * @param expiry		an integer specifying the maximum age of the
+     * 				cookie in seconds; if negative, means
+     *				the cookie is not stored; if zero, deletes
+     *				the cookie
+     *
+     *
+     * @see #getMaxAge()
+     *
+     */
+
+    void setMaxAge(int expiry);
+
+
+
+
+    /**
+     * Returns the maximum age of the cookie, specified in seconds,
+     * By default, <code>-1</code> indicating the cookie will persist
+     * until browser shutdown.
+     *
+     *
+     * @return			an integer specifying the maximum age of the
+     *				cookie in seconds; if negative, means
+     *				the cookie persists until browser shutdown
+     *
+     *
+     * @see #setMaxAge(int)
+     *
+     */
+
+    int getMaxAge();
+
+
+
+
+    /**
+     * Specifies a path for the cookie
+     * to which the client should return the cookie.
+     *
+     * <p>The cookie is visible to all the pages in the directory
+     * you specify, and all the pages in that directory's subdirectories.
+     * A cookie's path must include the servlet that set the cookie,
+     * for example, <i>/catalog</i>, which makes the cookie
+     * visible to all directories on the server under <i>/catalog</i>.
+     *
+     * <p>Consult RFC 2109 (available on the Internet) for more
+     * information on setting path names for cookies.
+     *
+     *
+     * @param uri		a <code>String</code> specifying a path
+     *
+     *
+     * @see #getPath()
+     *
+     */
+
+    void setPath(String uri);
+
+
+
+
+    /**
+     * Returns the path on the server
+     * to which the browser returns this cookie. The
+     * cookie is visible to all subpaths on the server.
+     *
+     *
+     * @return		a <code>String</code> specifying a path that contains
+     *			a servlet name, for example, <i>/catalog</i>
+     *
+     * @see #setPath(String)
+     *
+     */
+
+    String getPath();
+
+
+
+
+
+    /**
+     * Indicates to the browser whether the cookie should only be sent
+     * using a secure protocol, such as HTTPS or SSL.
+     *
+     * <p>The default value is <code>false</code>.
+     *
+     * @param flag	if <code>true</code>, sends the cookie from the browser
+     *			to the server using only when using a secure protocol;
+     *			if <code>false</code>, sent on any protocol
+     *
+     * @see #getSecure()
+     *
+     */
+
+    void setSecure(boolean flag);
+
+
+
+
+    /**
+     * Returns <code>true</code> if the browser is sending cookies
+     * only over a secure protocol, or <code>false</code> if the
+     * browser can send cookies using any protocol.
+     *
+     * @return		<code>true</code> if the browser can use
+     *			any standard protocol; otherwise, <code>false</code>
+     *
+     * @see #setSecure(boolean)
+     *
+     */
+
+    boolean getSecure();
+
+
+
+
+
+    /**
+     * Returns the name of the cookie. The name cannot be changed after
+     * creation.
+     *
+     * @return		a <code>String</code> specifying the cookie's name
+     *
+     */
+
+    String getName();
+
+
+
+
+
+    /**
+     *
+     * Assigns a new value to a cookie after the cookie is created.
+     * If you use a binary value, you may want to use BASE64 encoding.
+     *
+     * <p>With Version 0 cookies, values should not contain white
+     * space, brackets, parentheses, equals signs, commas,
+     * double quotes, slashes, question marks, at signs, colons,
+     * and semicolons. Empty values may not behave the same way
+     * on all browsers.
+     *
+     * @param newValue		a <code>String</code> specifying the new value
+     *
+     *
+     * @see #getValue()
+     * @see Cookie
+     *
+     */
+
+    void setValue(String newValue);
+
+
+
+
+    /**
+     * Returns the value of the cookie.
+     *
+     * @return			a <code>String</code> containing the cookie's
+     *				present value
+     *
+     * @see #setValue(String)
+     * @see Cookie
+     *
+     */
+
+    String getValue();
+
+
+
+
+    /**
+     * Returns the version of the protocol this cookie complies
+     * with. Version 1 complies with RFC 2109,
+     * and version 0 complies with the original
+     * cookie specification drafted by Netscape. Cookies provided
+     * by a browser use and identify the browser's cookie version.
+     *
+     *
+     * @return			0 if the cookie complies with the
+     *				original Netscape specification; 1
+     *				if the cookie complies with RFC 2109
+     *
+     * @see #setVersion(int)
+     *
+     */
+
+    int getVersion();
+
+
+
+
+    /**
+     * Sets the version of the cookie protocol this cookie complies
+     * with. Version 0 complies with the original Netscape cookie
+     * specification. Version 1 complies with RFC 2109.
+     *
+     * <p>Since RFC 2109 is still somewhat new, consider
+     * version 1 as experimental; do not use it yet on production sites.
+     *
+     *
+     * @param v			0 if the cookie should comply with
+     *				the original Netscape specification;
+     *				1 if the cookie should comply with RFC 2109
+     *
+     * @see #getVersion()
+     *
+     */
+
+    void setVersion(int v);
+
+
+
+}
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Cookie.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Environment.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Environment.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Environment.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Environment.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,194 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.Map;
+
+/**
+ * Base interface for an environment abstraction
+ *
+ * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
+ * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: Environment.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public interface Environment {
+
+    /**
+     * Get the URI to process. The prefix is stripped off.
+     */
+    String getURI();
+
+    /**
+     * Get the prefix of the URI in progress.
+     */
+    String getURIPrefix();
+
+    /**
+     * Set the URI and the prefix to process.
+     */
+    void setURI(String prefix, String value);
+
+    /**
+     * Get the view to process
+     */
+    String getView();
+
+    /**
+     * Get the action to process
+     */
+    String getAction();
+
+    /**
+     * Redirect to the given URL
+     */
+    void redirect(String url, boolean global, boolean permanent) 
+    throws IOException;
+
+    /**
+     * Set the content type of the generated resource
+     */
+    void setContentType(String mimeType);
+
+    /**
+     * Get the content type of the resource
+     */
+    String getContentType();
+
+    /**
+     * Set the length of the generated content
+     */
+    void setContentLength(int length);
+
+    /**
+     * Set the response status code
+     */
+    void setStatus(int statusCode);
+
+    /**
+     * Get the output stream where to write the generated resource.
+     * The returned stream is buffered by the environment. If the
+     * buffer size is -1 then the complete output is buffered.
+     * If the buffer size is 0, no buffering takes place.
+     */
+    OutputStream getOutputStream(int bufferSize) throws IOException;
+
+    /**
+     * Get the underlying object model
+     */
+    Map getObjectModel();
+
+    /**
+     * Check if the response has been modified since the same
+     * "resource" was requested.
+     * The caller has to test if it is really the same "resource"
+     * which is requested.
+     * @return true if the response is modified or if the
+     *         environment is not able to test it
+     */
+    boolean isResponseModified(long lastModified);
+
+    /**
+     * Mark the response as not modified.
+     */
+    void setResponseIsNotModified();
+
+    /**
+     * Binds an object to this environment, using the name specified. This allows
+     * the pipeline assembly engine to store for its own use objects that souldn't
+     * be exposed to other components (generators, selectors, etc) and therefore
+     * cannot be put in the object model.
+     * <p>
+     * If an object of the same name is already bound, the object is replaced.
+     *
+     * @param name  the name to which the object is bound
+     * @param value the object to be bound
+     */
+    void setAttribute(String name, Object value);
+
+    /**
+     * Returns the object bound with the specified name, or <code>null</code>
+     * if no object is bound under the name.
+     *
+     * @param name                a string specifying the name of the object
+     * @return                    the object with the specified name
+     */
+    Object getAttribute(String name);
+
+    /**
+     * Removes the object bound with the specified name from
+     * this environment. If the environment does not have an object
+     * bound with the specified name, this method does nothing.
+     *
+     * @param name the name of the object to remove
+     */
+    void removeAttribute(String name);
+
+    /**
+     * Returns an <code>Enumeration</code> of <code>String</code> objects
+     * containing the names of all the objects bound to this environment.
+     *
+     * @return an <code>Enumeration</code> of <code>String</code>s.
+     */
+    Enumeration getAttributeNames();
+
+    /**
+     * Reset the response if possible. This allows error handlers to have
+     * a higher chance to produce clean output if the pipeline that raised
+     * the error has already output some data.
+     * If a buffered output stream is used, resetting is always successful.
+     *
+     * @return true if the response was successfully reset
+     */
+    boolean tryResetResponse() throws IOException;
+
+
+    /**
+     * Commit the response
+     */
+    void commitResponse() throws IOException;
+    
+    /**
+     * Notify that the processing starts.
+     */
+    void startingProcessing();
+    
+    /**
+     * Notify that the processing is finished
+     * This can be used to cleanup the environment object
+     */
+    void finishingProcessing();
+    
+    /**
+     * Is this environment external ? An external environment is one that 
+     * is created in response to an external request (http, commandline, etc.). 
+     * Environments created by the "cocoon:" protocol aren't external.
+     * 
+     * @return true if this environment is external
+     */
+    boolean isExternal();
+    
+    /**
+     * Is this an internal redirect?
+     * An environment is on internal redirect if it is an internal request
+     * (via the cocoon: protocol) and used for a redirect.
+     */
+    boolean isInternalRedirect();
+}
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Environment.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message