pier        2004/05/04 10:41:05

  Modified:    src/kernel/org/apache/cocoon/kernel/composition
                        Component.java Wire.java
  Added:       src/kernel/org/apache/cocoon/kernel/composition
                        ComponentComposer.java
  Log:
  Simplifying the Wire and Component interfaces.
  
  Revision  Changes    Path
  1.4       +14 -8     
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Component.java    31 Mar 2004 13:01:38 -0000      1.3
  +++ Component.java    4 May 2004 17:41:05 -0000       1.4
  @@ -17,14 +17,16 @@
   
   import java.net.URL;
   
  +import org.apache.cocoon.kernel.resolution.Resolver;
  +
   /**
    * <p>The [EMAIL PROTECTED] Component} interface identifies a component 
aware of its
    * deployment in a block-enabled environment.</p>
    *
    * <p>Any component implementing this interface <b>must be aware</b> that
  - * the [EMAIL PROTECTED] Wire} they will be given will resolve [EMAIL 
PROTECTED] URL}s in the context
  - * of the <b>calling</b> block and not in the context of the block they are
  - * defined in.</p>
  + * the [EMAIL PROTECTED] Resolver} they will be given will resolve [EMAIL 
PROTECTED] URL}s in the
  + * context of the <b>calling</b> block and not in the context of the block 
they
  + * are defined in.</p>
    *
    * <p>This is done because resource management is decoupled entirely from
    * component management, and because in block-enabled environments, it will
  @@ -61,10 +63,14 @@
   public interface Component {
   
       /**
  -     * <p>Contextualize this [EMAIL PROTECTED] Component} component instance 
with the
  -     * [EMAIL PROTECTED] Wire} through which its caller is accessing it.</p>
  +     * <p>Contextualize this [EMAIL PROTECTED] Component} instance.</p>
        *
  -     * @param wire the [EMAIL PROTECTED] Wire} instance associated with this 
instance.
  +     * @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);
  +    public void contextualize(Wire wire, Wirings wirings, Resolver resolver);
   }
  
  
  
  1.4       +2 -50     
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Wire.java
  
  Index: Wire.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/Wire.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Wire.java 31 Mar 2004 13:01:38 -0000      1.3
  +++ Wire.java 4 May 2004 17:41:05 -0000       1.4
  @@ -15,9 +15,6 @@
    */
   package org.apache.cocoon.kernel.composition;
   
  -import org.apache.cocoon.kernel.resolution.Resolver;
  -import org.apache.cocoon.kernel.resolution.Resource;
  -
   /**
    * <p>The [EMAIL PROTECTED] Wire} interface defines a component as returned 
by a
    * [EMAIL PROTECTED] Wirings} instance.</p>
  @@ -61,52 +58,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Pier Fumagalli</a>
    * @version 1.0 (CVS $Revision$)
    */
  -public interface Wire extends Resolver {
  -
  -    /**
  -     * <p>Resolve a resource visible from a [EMAIL PROTECTED] Component} 
into a
  -     * [EMAIL PROTECTED] Resource}.</p>
  -     *
  -     * <p>This method will resolve resources local to the block requesting
  -     * this wire.</p>
  -     *
  -     * <p>If the specified [EMAIL PROTECTED] String} assumes a format like
  -     * <code>wiring:/resource/path</code> where <code>wiring</code> is the
  -     * wiring name as required in the block's deployment descriptor, the
  -     * resolution of the [EMAIL PROTECTED] Resource} will be performed 
relative to the
  -     * block target of the wiring.</p>
  -     *
  -     * <p>[EMAIL PROTECTED] Component}s using a [EMAIL PROTECTED] Wire} for 
resource resolution
  -     * <b>must</b> be aware that resolution will happen in the context of the
  -     * requesting block, rather than in the context of the block composing 
the
  -     * [EMAIL PROTECTED] Component}.</p>
  -     *
  -     * <p>This is done because resource management is decoupled entirely from
  -     * component management, and because in block-enabled environments, it 
will
  -     * be possible to have components provided by wired blocks to operate on
  -     * resources available from other wired blocks.</p>
  -     * 
  -     * <p>Let's examine a simple example based (for example) on Apache 
Cocoon:
  -     * the <i>ForrestPipeline</i> block (a block providing a 
<code>Pipeline</code>
  -     * component for Apache Forrest) is wired to two other blocks: the first 
is
  -     * the <i>XSLTransformer</i> block (providing <code>Transformer</code>
  -     * component instances) and the second one is an instance of the
  -     * <i>ForrestSkin</i> block (a block providing XSLT stylesheets to be 
used
  -     * while processing the forrest pipeline).</p>
  -     *
  -     * <p>Being an implementation of [EMAIL PROTECTED] Component}, the 
<code>Transformer</code>
  -     * component instantiated by the <i>ForrestPipeline</i> block will have 
direct
  -     * access (and will be able to resolve) a resource in the form of
  -     * <code>skin:/document2xhtml.xsl</code>, which represents a resource 
provided
  -     * by any <i>ForrestSkin</i> implementation, wired to the 
<i>ForrestPipeline</i>
  -     * block, but completely separated from the 
original<i>XSLTransformer</i> block
  -     * which provides the <code>Transformer</code> instance.</p>
  -     * 
  -     * @param name the local (or wired) resource name.
  -     * @return a [EMAIL PROTECTED] Resource} instance, or <b>null</b> if the 
resource was
  -     *         not found or was not accessible.
  -     */
  -    public Resource resolve(String name);
  +public interface Wire {
   
       /**
        * <p>Check wether the wire between this [EMAIL PROTECTED] Wirings} 
instance and the
  
  
  
  1.1                  
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/composition/ComponentComposer.java
  
  Index: ComponentComposer.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.ConfigurationException;
  import org.apache.cocoon.kernel.configuration.Parameters;
  
  
  /**
   * <p>The [EMAIL PROTECTED] ComponentComposer} 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 ComponentComposer implements Composer {
  
      /** <p>The contextualized [EMAIL PROTECTED] Wirings} instance.</p> */
      protected Wirings wirings = null;
  
      /** <p>The configured [EMAIL PROTECTED] Parameters} instance.</p> */
      protected Parameters parameters = null;
  
      /**
       * <p>Create a new [EMAIL PROTECTED] ComponentComposer} instance.</p>
       */
      protected ComponentComposer() {
          super();
      }
  
      /**
       * <p>Acquire this [EMAIL PROTECTED] ComponentComposer} instance.</p>
       *
       * @return this [EMAIL PROTECTED] ComponentComposer} instance.
       */
      public Object acquire()
      throws Throwable {
          return(this);
      }
  
      /**
       * <p>Release a previously acquired [EMAIL PROTECTED] ComponentComposer} 
instance.</p>
       * 
       * <p>This method does not do anything.</p>
       *
       * @return this [EMAIL PROTECTED] ComponentComposer} instance.
       */
      public void release(Object object) {
          /* Nothing to do here */
      }
  
      /**
       * <p>Dispose a previously acquired [EMAIL PROTECTED] ComponentComposer} 
instance.</p>
       * 
       * <p>This method simply invokes the [EMAIL PROTECTED] #release()} 
method.</p>
       *
       * @return this [EMAIL PROTECTED] ComponentComposer} instance.
       */
      public void dispose(Object object) {
          this.release(object);
      }
  
      /**
       * <p>Contextualize this [EMAIL PROTECTED] ComponentComposer} with the 
[EMAIL PROTECTED] Wirings}
       * associated to the block where it resides.</p>
       *
       * @param wirings the [EMAIL PROTECTED] Wirings} instance associated with 
the block in
       *                which this [EMAIL PROTECTED] ComponentComposer} was 
deployed.
       * @throws WiringException if there was an error performing operations
       *                         on the supplied [EMAIL PROTECTED] Wirings} 
instance.
       */
      public void contextualize(Wirings wirings)
      throws WiringException {
          this.wirings = wirings;
       }
  
      /**
       * <p>Configure this [EMAIL PROTECTED] ComponentComposer} 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.
       */
      public void configure(Parameters parameters)
      throws ConfigurationException {
          this.parameters = parameters;
      }
  }
  
  
  

Reply via email to