pier        2004/05/06 12:14:09

  Modified:    src/kernel/org/apache/cocoon/kernel BlockLoader.java
                        DeployedWirings.java Installer.java
                        KernelDeployer.java ProxyWire.java
               src/kernel/org/apache/cocoon/kernel/composition
                        Component.java Composer.java Lifecycle.java
               src/kernel/org/apache/cocoon/kernel/configuration
                        Configurable.java
               src/kernel/org/apache/cocoon/kernel/startup
                        KernelServlet.java
  Added:       src/kernel/org/apache/cocoon/kernel/composition
                        AbstractComposer.java Singleton.java
                        WiringsWrapper.java
  Removed:     src/kernel/org/apache/cocoon/kernel/composition
                        ComponentComposer.java LifecycleException.java
  Log:
  Removed "compilation class path" hack (can be done by walking up the path
  of parent class loaders).
  Exceptions in user-implementable methods are now generic exceptions (shorten
  stack traces where needed).
  Reworked Component contract (again - non final).
  
  Revision  Changes    Path
  1.6       +2 -26     
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/BlockLoader.java
  
  Index: BlockLoader.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/BlockLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BlockLoader.java  6 May 2004 08:43:17 -0000       1.5
  +++ BlockLoader.java  6 May 2004 19:14:09 -0000       1.6
  @@ -15,8 +15,6 @@
    */
   package org.apache.cocoon.kernel;
   
  -import java.io.File;
  -import java.io.IOException;
   import java.net.URL;
   import java.net.URLClassLoader;
   import java.util.HashMap;
  @@ -181,28 +179,6 @@
           /* Remove circular dependancies checking and return the block */
           this.creating.remove(descriptor);
           return(block);
  -    }
  -
  -    /**
  -     * <p>Return the compilation class path configured from all deployed
  -     * blocks and localized for the current operating system.</p>
  -     *
  -     * @return a <b>non null</b> [EMAIL PROTECTED] String}.
  -     */
  -    protected String getCompilationClassPath() {
  -        URL urls[] = this.loader.getURLs();
  -        StringBuffer buffer = new StringBuffer();
  -        for (int x = 0; x < urls.length; x++) {
  -            if ("file".equals(urls[x].getProtocol())) try {
  -                String path = new File(urls[x].getPath()).getCanonicalPath();
  -                buffer.append(System.getProperty("path.separator"));
  -                buffer.append(path);
  -            } catch (IOException exception) {
  -                /* TODO: log this exception? */
  -            }
  -        }
  -        if (buffer.length() > 0) buffer.deleteCharAt(0);
  -        return(buffer.toString());
       }
   
       /* 
====================================================================== */
  
  
  
  1.8       +8 -11     
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/DeployedWirings.java
  
  Index: DeployedWirings.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/DeployedWirings.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DeployedWirings.java      6 May 2004 08:43:17 -0000       1.7
  +++ DeployedWirings.java      6 May 2004 19:14:09 -0000       1.8
  @@ -23,7 +23,6 @@
   
   import org.apache.cocoon.kernel.composition.Composer;
   import org.apache.cocoon.kernel.composition.Lifecycle;
  -import org.apache.cocoon.kernel.composition.LifecycleException;
   import org.apache.cocoon.kernel.composition.Wire;
   import org.apache.cocoon.kernel.composition.WiringException;
   import org.apache.cocoon.kernel.composition.Wirings;
  @@ -226,16 +225,14 @@
       /**
        * <p>Notify this [EMAIL PROTECTED] DeployedWirings} of its 
initialization.</p>
        *
  -     * @throws LifecycleException if this instance cannot be initialized.
  +     * @throws Exception if this instance cannot be initialized.
        */
       public void init()
  -    throws LifecycleException {
  -        if (this.composer != null) try {
  -            this.composer.contextualize(this); // TODO wrap this instance
  +    throws Exception {
  +        if (this.composer != null) {
  +            /* TODO: wrap this Wirings instance */
  +            this.composer.contextualize(this);
               this.composer.configure(this.instance.configuration());
  -        } catch (Throwable throwable) {
  -            throw new LifecycleException("Unable to configure or 
contextualize"
  -                                         + " composer instance", throwable);
           }
           if (this.composer instanceof Lifecycle) {
               ((Lifecycle)this.composer).init();
  @@ -245,10 +242,10 @@
       /**
        * <p>Notify this [EMAIL PROTECTED] DeployedWirings} of its 
destruction.</p>
        *
  -     * @throws LifecycleException if this instance cannot be destroyed.
  +     * @throws Exception if this instance cannot be destroyed.
        */
       public void destroy()
  -    throws LifecycleException {
  +    throws Exception {
           if (this.composer instanceof Lifecycle) {
               ((Lifecycle)this.composer).destroy();
           }
  
  
  
  1.6       +9 -2      
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/Installer.java
  
  Index: Installer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/Installer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Installer.java    3 May 2004 20:45:50 -0000       1.5
  +++ Installer.java    6 May 2004 19:14:09 -0000       1.6
  @@ -192,7 +192,14 @@
           }
   
           /* Process parameters */
  -        instance.configure(new 
Parameters(configuration.child("parameters")));
  +        try {
  +            instance.configure(new 
Parameters(configuration.child("parameters")));
  +        } catch (ConfigurationException exception) {
  +            throw(exception);
  +        } catch (Exception exception) {
  +            String message = "Problems configuring instnace \"" + name + 
"\""; 
  +            throw new ConfigurationException(message, exception);
  +        }
   
           /* Finally, deploy the baby*/
           try {
  
  
  
  1.9       +1 -17     
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/KernelDeployer.java
  
  Index: KernelDeployer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/KernelDeployer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- KernelDeployer.java       6 May 2004 08:43:18 -0000       1.8
  +++ KernelDeployer.java       6 May 2004 19:14:09 -0000       1.9
  @@ -345,20 +345,4 @@
       protected DeployedWirings lookup(String name) {
           return((DeployedWirings)this.wiringsByName.get(name));
       }
  -
  -    /**
  -     * <p>Return the compilation class path configured from all deployed
  -     * blocks and localized for the current operating system.</p>
  -     *
  -     * @return a <b>non null</b> [EMAIL PROTECTED] String}.
  -     */
  -    public String getCompilationClassPath() {
  -        try {
  -            return(((BlockLoader)this.loader).getCompilationClassPath());
  -        } catch (Throwable t) {
  -            return("");
  -        }
  -    }
  -
  -
   }
  
  
  
  1.8       +3 -3      
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/ProxyWire.java
  
  Index: ProxyWire.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/ProxyWire.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProxyWire.java    6 May 2004 08:43:18 -0000       1.7
  +++ ProxyWire.java    6 May 2004 19:14:09 -0000       1.8
  @@ -147,7 +147,7 @@
   
               /* Contextualize the instance with the wire */
               if (instance instanceof Component) {
  -                ((Component)instance).contextualize(this.wire, null, r);
  +                ((Component)instance).contextualize(this.wire, r);
               }
   
               /* Record the original composer and instance */
  @@ -157,7 +157,7 @@
               /* Something bad happened releasing, release the instance */
               composer.release(instance);
               throw new WiringException("Unable to create wrapper for "
  -                                           + "composed component instance", 
t);
  +                                      + "composed component instance", t);
           }
       }
   
  
  
  
  1.5       +2 -4      
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Component.java
  
  Index: Component.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Component.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Component.java    4 May 2004 17:41:05 -0000       1.4
  +++ Component.java    6 May 2004 19:14:09 -0000       1.5
  @@ -67,10 +67,8 @@
        *
        * @param wire the [EMAIL PROTECTED] Wire} instance through which the 
block requesting
        *             this instance is accessing it.
  -     * @param wirings the [EMAIL PROTECTED] Wirings} instance associated 
with the block
  -     *                instance in which this [EMAIL PROTECTED] Component} is 
defined.
        * @param resolver the [EMAIL PROTECTED] Resolver} instance resolving 
resources in the
        *                 calling block instance.
        */
  -    public void contextualize(Wire wire, Wirings wirings, Resolver resolver);
  +    public void contextualize(Wire wire, Resolver resolver);
   }
  
  
  
  1.4       +4 -4      
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Composer.java
  
  Index: Composer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Composer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Composer.java     31 Mar 2004 13:01:38 -0000      1.3
  +++ Composer.java     6 May 2004 19:14:09 -0000       1.4
  @@ -104,10 +104,10 @@
        *
        * @param wirings the [EMAIL PROTECTED] Wirings} instance associated with
        *                this [EMAIL PROTECTED] Composer}'s block.
  -     * @throws WiringException if there was an error performing operations
  -     *                              on the supplied [EMAIL PROTECTED] 
Wirings} instance.
  +     * @throws Exception if there was an error performing operations on the
  +     *                   supplied [EMAIL PROTECTED] Wirings} instance.
        */
       public void contextualize(Wirings wirings)
  -    throws WiringException;
  +    throws Exception;
   
   }
  
  
  
  1.4       +7 -7      
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Lifecycle.java
  
  Index: Lifecycle.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Lifecycle.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Lifecycle.java    31 Mar 2004 13:01:38 -0000      1.3
  +++ Lifecycle.java    6 May 2004 19:14:09 -0000       1.4
  @@ -50,10 +50,10 @@
        * has been called, as this method defines the beginning of lifecycle
        * awareness.</p>
        *
  -     * @throws LifecycleException if this instance cannot be initialized.
  +     * @throws Exception if this instance cannot be initialized.
        */
       public void init()
  -    throws LifecycleException;
  +    throws Exception;
   
       /**
        * <p>Notify this instance of its destruction.</p>
  @@ -66,14 +66,14 @@
        * of this interface are guaranteed that this method will be the last one
        * called before garbage collection, release or disposal.</p>
        *
  -     * <p>If this method throws a [EMAIL PROTECTED] LifecycleException} and 
this instance
  -     * was acquired from a [EMAIL PROTECTED] Composer}, its instance <b>will 
not</b> be
  +     * <p>If this method throws an [EMAIL PROTECTED] Exception} and this 
instance was
  +     * acquired from a [EMAIL PROTECTED] Composer}, its instance <b>will 
not</b> be
        * [EMAIL PROTECTED] Composer#release(Object) released} to it (which 
would be its
        * normal behavior), but rather [EMAIL PROTECTED] 
Composer#dispose(Object) disposed}
        * back through it.</p>
        *
  -     * @throws LifecycleException if this instance cannot be destroyed.
  +     * @throws Exception if this instance cannot be destroyed.
        */
       public void destroy()
  -    throws LifecycleException;
  +    throws Exception;
   }
  
  
  
  1.1                  
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/AbstractComposer.java
  
  Index: AbstractComposer.java
  ===================================================================
  /*
   * 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.kernel.composition;
  
  import org.apache.cocoon.kernel.configuration.Parameters;
  
  
  /**
   * <p>An abstract implementation of the [EMAIL PROTECTED] Composer} 
interface.</p> 
   *
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Pier Fumagalli</a>
   * @version 1.0 (CVS $Revision: 1.1 $)
   */
  public abstract class AbstractComposer implements Composer {
  
      /** <p>The [EMAIL PROTECTED] Wirings} instance contextualized in this 
instance.</p> */
      protected Wirings wirings = null;
  
      /** <p>The [EMAIL PROTECTED] Parameters} instance configured in this 
instance.</p> */
      protected Parameters parameters = null;
  
      /**
       * <p>Create a new [EMAIL PROTECTED] AbstractComposer} instance.</p>
       */
      public AbstractComposer() {
          super();
      }
  
      /**
       * <p>This method will simply invoke [EMAIL PROTECTED] #dispose(Object)}. 
</p>
       */
      public void release(Object object) {
          this.dispose(object);
      }
  
      /**
       * <p>Contextualize this instance and store the supplied [EMAIL 
PROTECTED] Wirings}
       * instance.</p>
       * 
       * <p>The contextualized [EMAIL PROTECTED] Wirings} instance will be 
available in the
       * protected [EMAIL PROTECTED] #wirings} field.</p>
       * 
       * @param wirings the [EMAIL PROTECTED] Wirings} contextualizing this 
instance.
       * @throws Exception if an error occurred contextualizing this instance.
       */
      public void contextualize(Wirings wirings)
      throws Exception {
          this.wirings = wirings;
      }
  
      /**
       * <p>Configure this instance and store the supplied [EMAIL PROTECTED] 
Parameters}
       * instance.</p>
       * 
       * <p>The configure [EMAIL PROTECTED] Parameters} instance will be 
available in the
       * protected [EMAIL PROTECTED] #parameters} field.</p>
       * 
       * @param parameters the [EMAIL PROTECTED] Parameters} configuring this 
instance.
       * @throws Exception if an error occurred configuring this instance.
       */
      public void configure(Parameters parameters)
      throws Exception {
          this.parameters = parameters;
      }
  }
  
  
  
  1.1                  
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Singleton.java
  
  Index: Singleton.java
  ===================================================================
  /*
   * 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.kernel.composition;
  
  
  /**
   * <p>The [EMAIL PROTECTED] Singleton} class represents a simple [EMAIL 
PROTECTED] Composer}
   * returning its own instance in the [EMAIL PROTECTED] #acquire()} 
method.</p> 
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Pier Fumagalli</a>
   * @version 1.0 (CVS $Revision: 1.1 $)
   */
  public abstract class Singleton extends AbstractComposer {
  
      /**
       * <p>Create a new [EMAIL PROTECTED] Singleton} instance.</p>
       */
      protected Singleton() {
          super();
      }
  
      /**
       * <p>Acquire this [EMAIL PROTECTED] Singleton} instance.</p>
       *
       * @return <b>this</b> [EMAIL PROTECTED] Singleton} instance.
       */
      public final Object acquire()
      throws Throwable {
          return(this);
      }
  
      /**
       * <p>This method will not perform any operation.</p>
       */
      public final void release(Object object) {
          /* Nothing to do */
      }
  
      /**
       * <p>This method will not perform any operation.</p>
       */
      public final void dispose(Object object) {
          /* Nothing to do */
      }
  }
  
  
  
  1.1                  
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/WiringsWrapper.java
  
  Index: WiringsWrapper.java
  ===================================================================
  /*
   * 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.kernel.composition;
  
  import org.apache.cocoon.kernel.resolution.Resource;
  
  
  /**
   * <p>The [EMAIL PROTECTED] WiringsWrapper} class is a simple wrapper around 
the
   * [EMAIL PROTECTED] Wirings} interface.</p>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Pier Fumagalli</a>
   * @version 1.0 (CVS $Revision: 1.1 $)
   */
  public class WiringsWrapper implements Wirings {
  
      /** <p>The wrapped [EMAIL PROTECTED] Wirings} instance. */
      protected Wirings instance = null;
  
      /**
       * <p>Create a new [EMAIL PROTECTED] WiringsWrapper} instance around a 
specified
       * [EMAIL PROTECTED] Wirings} instance.</p>
       * 
       * @param wirings the @{link Wirings} instance to wrap.
       * @throws NullPointerException if the specified instance was null.
       */
      public WiringsWrapper(Wirings wirings) {
          if (wirings == null) throw new NullPointerException("Null wirings");
          this.instance = wirings;
      }
  
      public Wire lookup(Class role, String name)
      throws WiringException {
          return(this.instance.lookup(role, name));
      }
  
      public Resource resolve(String name) {
          return(this.instance.resolve(name));
      }
  }
  
  
  
  1.4       +3 -3      
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/configuration/Configurable.java
  
  Index: Configurable.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/configuration/Configurable.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Configurable.java 31 Mar 2004 13:01:38 -0000      1.3
  +++ Configurable.java 6 May 2004 19:14:09 -0000       1.4
  @@ -32,8 +32,8 @@
        * <p>Configure this instance with the specified [EMAIL PROTECTED] 
Parameters}.</p>
        *
        * @param parameters the [EMAIL PROTECTED] Parameters} configuring the 
instance.
  -     * @throws ConfigurationException if this instance could not be 
configured.
  +     * @throws Exception if this instance could not be configured.
        */
       public void configure(Parameters parameters)
  -    throws ConfigurationException;
  +    throws Exception;
   }
  
  
  
  1.3       +1 -4      
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/KernelServlet.java
  
  Index: KernelServlet.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/KernelServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- KernelServlet.java        6 May 2004 08:43:18 -0000       1.2
  +++ KernelServlet.java        6 May 2004 19:14:09 -0000       1.3
  @@ -121,9 +121,6 @@
               this.config = config;
               this.wirings = new CoreWirings(this.deployer);
               KernelServlet.instance = this;
  -            /* TODO: this doesn't get updated upon blocks changes */
  -            ctxt.setAttribute("org.apache.cocoon.kernel.class.path",
  -                              deployer.getCompilationClassPath());
   
           } catch (Throwable throwable) {
               String message = "An error occurred initializing the kernel";
  
  
  

Reply via email to