avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon/src/proposal/resolver Resolveable.java package.html Query.java Resolver.java ResolverException.java Token.java
Date Mon, 11 Feb 2002 16:08:40 GMT
bloritsch    02/02/11 08:08:40

  Modified:    src/proposal/resolver Query.java Resolver.java
                        ResolverException.java Token.java
  Added:       src/proposal/resolver Resolveable.java package.html
  Log:
  update to latest resolver approach
  
  Revision  Changes    Path
  1.3       +1 -1      jakarta-avalon/src/proposal/resolver/Query.java
  
  Index: Query.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/proposal/resolver/Query.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Query.java	11 Feb 2002 15:17:14 -0000	1.2
  +++ Query.java	11 Feb 2002 16:08:40 -0000	1.3
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE.txt file.
    */
  -package org.apache.avalon.framework.service;
  +package org.apache.avalon.framework.resolver;
   
   import org.apache.avalon.framework.context.Context;
   
  
  
  
  1.3       +1 -1      jakarta-avalon/src/proposal/resolver/Resolver.java
  
  Index: Resolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/proposal/resolver/Resolver.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resolver.java	11 Feb 2002 15:17:14 -0000	1.2
  +++ Resolver.java	11 Feb 2002 16:08:40 -0000	1.3
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE.txt file.
    */
  -package org.apache.avalon.framework.service;
  +package org.apache.avalon.framework.resolver;
   
   /**
    * A <code>Resolver</code> will resolve one or more objects and return a token.
  
  
  
  1.2       +1 -1      jakarta-avalon/src/proposal/resolver/ResolverException.java
  
  Index: ResolverException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/proposal/resolver/ResolverException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResolverException.java	11 Feb 2002 15:08:58 -0000	1.1
  +++ ResolverException.java	11 Feb 2002 16:08:40 -0000	1.2
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE.txt file.
    */
  -package org.apache.avalon.framework.service;
  +package org.apache.avalon.framework.resolver;
   
   import org.apache.avalon.framework.CascadingException;
   
  
  
  
  1.2       +1 -1      jakarta-avalon/src/proposal/resolver/Token.java
  
  Index: Token.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/proposal/resolver/Token.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Token.java	11 Feb 2002 15:08:58 -0000	1.1
  +++ Token.java	11 Feb 2002 16:08:40 -0000	1.2
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE.txt file.
    */
  -package org.apache.avalon.framework.service;
  +package org.apache.avalon.framework.Resolver;
   
   /**
    * A <code>Token</code> is responsible for returning the actual Objects requested
  
  
  
  1.1                  jakarta-avalon/src/proposal/resolver/Resolveable.java
  
  Index: Resolveable.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.framework.resolver;
  
  /**
   * A <code>Resolveable</code> will pass a reference of the <code>Resolver</code>
   * to your component.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   */
  public interface Resolveable
  {
      /**
       * Provide the reference to the resolver.
       */
      void resolver( Resolver resolver )
          throws ResolverException;
  
  }
  
  
  
  1.1                  jakarta-avalon/src/proposal/resolver/package.html
  
  Index: package.html
  ===================================================================
  <html>
    <head>
      <title>Package Documentation for org.apache.avalon.framework.resolver Package</title>
    </head>
    <body bgcolor="white">
      A flexible Object resolver mechanism.
      <br><br>
      <a name="doc.Description"></a>
      <div align="center">
        <a href="#doc.Intro">[Introduction]</a>
      </div>
  
      <a name="doc.Intro"></a>
      <h2>Introduction</h2>
      <p>The <code>org.apache.avalon.excalibur.resolver</code> package contains
interfaces and classes
      for resolving objects, components, and services. The design is sufficiently flexible
to handle all
      lookup needs.  Below is an example component that demonstrates how the package can be
used.
      </p>
      <pre>
        public class SampleComponent implements Parameterizable, Resolveable, Sample
        {
            private final Query      m_query;
            private       Resolver   m_resolver;
            private       Parameters m_params;
  
            public SampleComponent()
            {
                m_query = new Query();
                m_query.addKey( Query.COMPONENT, DataSourceComponent.ROLE );
                m_query.addKey( Query.COMPONENT, Parser.ROLE );
                m_query.addKey( Query.COMPONENT, EntityResolver.ROLE );
            }
  
            /**
             * Add parameters to specialize the query.
             */
            public void parameterize( Parameters params )
                throws ParameterException
            {
                m_params = params;
                m_query.addAttribute("database", m_params.getParameter( "dbname", "default"
));
            }
  
            /**
             * Ensure a valid working space
             */
            public void resolver( Resolver resolver )
                throws ResolverException
            {
                m_resolver = resolver;
                boolean[] isReferenced resolver.hasReferences( m_query );
  
                // test if the optional reference to the resolver exists
                if ( ! isReferenced[2] ) {
                    // if not remove the lookup (it will cause resolver to throw an exception
                    m_query.removeKey( EntityResolver.ROLE );
                }
  
                // test if the required references are available
                if ( ! isReferenced[0] || ! isReferenced[1] ) {
                    throw new ResolverException("Required references not available");
                }
            }
  
            /**
             * Perform the work from the Sample interface
             */
            public Object doWork()
            {
                Token values = null;
  
                try
                {
                    values = m_resolver.lookup( m_query );
                    Object[] refs = values.references();
  
                    DataSourceComponent datasource = (DataSourceComponent) refs[0];
                    Parser parser = (Parser) refs[1];
  
                    // ... do stuff with the datasource to get input stream
                    if (refs.length &gt; 2) {
                        parser.setEntityResolver( (EntityResolver)refs[2] );
                    }
  
                    SampleContentHandler handler = getContentHandler();
                    parser.parse(handler);
                    return handler().getObject();
                }
                catch (Exception e)
                {
                    // handle the exception
                }
                finally
                {
                    if ( null != values )
                    {
                        values.release();
                    }
                }
            }
  
            /**
             * The ContentHandler for the parser.
             */
            SampleContentHandler getContentHandler()
            {
                //defined elsewhere
                return new SampleContentHandler();
            }
        }
      </pre>
   </body>
  </html>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message