avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/framework/service WrapperServiceManager.java WrapperServiceSelector.java DefaultServiceManager.java ServiceManager.java ServiceSelector.java
Date Thu, 07 Nov 2002 08:29:04 GMT
donaldp     2002/11/07 00:29:04

  Modified:    src/java/org/apache/avalon/framework/component
                        ComponentManager.java DefaultComponentManager.java
                        DefaultComponentSelector.java
               src/java/org/apache/avalon/framework/service
                        DefaultServiceManager.java ServiceManager.java
                        ServiceSelector.java
  Added:       src/java/org/apache/avalon/framework/service
                        WrapperServiceManager.java
                        WrapperServiceSelector.java
  Log:
  Change terminology of service/component lookup in javadocs so that it matches our current
terminology. ie We no longer lookup components by role but by key.
  
  Also added in WrapperServiceManager that adapts a ComponentManager to a ServiceManager.
Berin should be happy about this! ;)
  
  Revision  Changes    Path
  1.14      +26 -26    jakarta-avalon/src/java/org/apache/avalon/framework/component/ComponentManager.java
  
  Index: ComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/component/ComponentManager.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ComponentManager.java	21 Oct 2002 16:16:48 -0000	1.13
  +++ ComponentManager.java	7 Nov 2002 08:29:03 -0000	1.14
  @@ -1,14 +1,14 @@
  -/* ==================================================================== 
  - * The Apache Software License, Version 1.1 
  - * 
  - * Copyright (c) 1997-2002 The Apache Software Foundation. All rights 
  - * reserved. 
  - * 
  - * Redistribution and use in source and binary forms, with or without 
  - * modification, are permitted provided that the following conditions 
  - * are met: 
  - * 
  - * 1. Redistributions of source code must retain the above copyright 
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  @@ -20,13 +20,13 @@
    *    if any, must include the following acknowledgment:
    *    "This product includes software developed by the
    *    Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software 
  - *    itself, if and wherever such third-party acknowledgments  
  + *    Alternately, this acknowledgment may appear in the software
  + *    itself, if and wherever such third-party acknowledgments
    *    normally appear.
    *
  - * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
  + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
    *    must not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -49,9 +49,9 @@
    *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation. For more
  - * information on the Apache Software Foundation, please see 
  + * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.avalon.framework.component;
   
   /**
  @@ -92,15 +92,15 @@
   public interface ComponentManager
   {
       /**
  -     * Get the <code>Component</code> associated with the given role.  For
  +     * Get the <code>Component</code> associated with the given key.  For
        * instance, If the <code>ComponentManager</code> had a
  -     * <code>LoggerComponent</code> stored and referenced by role, I would
use
  +     * <code>LoggerComponent</code> stored and referenced by key, I would use
        * the following call:
        * <pre>
        * try
        * {
  -     *     MyComponent log;
  -     *     myComponent = (MyComponent) manager.lookup(MyComponent.ROLE);
  +     *     LoggerComponent log;
  +     *     myComponent = (LoggerComponent) m_manager.lookup(LoggerComponent.ROLE);
        * }
        * catch (...)
        * {
  @@ -108,20 +108,20 @@
        * }
        * </pre>
        *
  -     * @param role The role name of the <code>Component</code> to retrieve.
  +     * @param key The key name of the <code>Component</code> to retrieve.
        * @return the desired component
        * @throws ComponentException if an error occurs
        */
  -    Component lookup( String role )
  +    Component lookup( String key )
           throws ComponentException;
   
       /**
  -     * Check to see if a <code>Component</code> exists for a role.
  +     * Check to see if a <code>Component</code> exists for a key.
        *
  -     * @param role  a string identifying the role to check.
  +     * @param key  a string identifying the key to check.
        * @return True if the component exists, False if it does not.
        */
  -    boolean hasComponent( String role );
  +    boolean hasComponent( String key );
   
       /**
        * Return the <code>Component</code> when you are finished with it.  This
  
  
  
  1.19      +38 -37    jakarta-avalon/src/java/org/apache/avalon/framework/component/DefaultComponentManager.java
  
  Index: DefaultComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/component/DefaultComponentManager.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DefaultComponentManager.java	21 Oct 2002 16:16:49 -0000	1.18
  +++ DefaultComponentManager.java	7 Nov 2002 08:29:03 -0000	1.19
  @@ -1,14 +1,14 @@
  -/* ==================================================================== 
  - * The Apache Software License, Version 1.1 
  - * 
  - * Copyright (c) 1997-2002 The Apache Software Foundation. All rights 
  - * reserved. 
  - * 
  - * Redistribution and use in source and binary forms, with or without 
  - * modification, are permitted provided that the following conditions 
  - * are met: 
  - * 
  - * 1. Redistributions of source code must retain the above copyright 
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  @@ -20,13 +20,13 @@
    *    if any, must include the following acknowledgment:
    *    "This product includes software developed by the
    *    Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software 
  - *    itself, if and wherever such third-party acknowledgments  
  + *    Alternately, this acknowledgment may appear in the software
  + *    itself, if and wherever such third-party acknowledgments
    *    normally appear.
    *
  - * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
  + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
    *    must not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -49,9 +49,9 @@
    *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation. For more
  - * information on the Apache Software Foundation, please see 
  + * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.avalon.framework.component;
   
   import java.util.HashMap;
  @@ -95,16 +95,16 @@
       }
   
       /**
  -     * Retrieve Component by role from ComponentManager.
  +     * Retrieve Component by key from ComponentManager.
        *
  -     * @param role the role
  +     * @param key the key
        * @return the Component
        * @throws ComponentException if an error occurs
        */
  -    public Component lookup( final String role )
  +    public Component lookup( final String key )
           throws ComponentException
       {
  -        final Component component = (Component)m_components.get( role );
  +        final Component component = (Component)m_components.get( key );
   
           if( null != component )
           {
  @@ -112,28 +112,28 @@
           }
           else if( null != m_parent )
           {
  -            return m_parent.lookup( role );
  +            return m_parent.lookup( key );
           }
           else
           {
  -            throw new ComponentException( role, "Unable to provide implementation." );
  +            throw new ComponentException( key, "Unable to provide implementation." );
           }
       }
   
       /**
  -     * Returns <code>true</code> if the component manager is managing a component
  -     * with the specified role, <code>false</code> otherwise.
  +     * Returns <code>true</code> if the component m_manager is managing a component
  +     * with the specified key, <code>false</code> otherwise.
        *
  -     * @param role role of the component you are lokking for
  -     * @return <code>true</code> if the component manager has a component with
that role
  +     * @param key key of the component you are lokking for
  +     * @return <code>true</code> if the component m_manager has a component
with that key
        */
  -    public boolean hasComponent( final String role )
  +    public boolean hasComponent( final String key )
       {
           boolean componentExists = false;
   
           try
           {
  -            this.release( this.lookup( role ) );
  +            this.release( this.lookup( key ) );
               componentExists = true;
           }
           catch( Throwable t )
  @@ -147,13 +147,13 @@
       /**
        * Place Component into ComponentManager.
        *
  -     * @param role the components role
  +     * @param key the components key
        * @param component the component
        */
  -    public void put( final String role, final Component component )
  +    public void put( final String key, final Component component )
       {
           checkWriteable();
  -        m_components.put( role, component );
  +        m_components.put( key, component );
       }
   
       /**
  @@ -209,7 +209,7 @@
       }
   
       /**
  -     * Make this component manager read only.
  +     * Make this component m_manager read only.
        */
       public void makeReadOnly()
       {
  @@ -217,17 +217,18 @@
       }
   
       /**
  -     * Check if this component manager is writeable.
  +     * Check if this component m_manager is writeable.
        *
  -     * @throws IllegalStateException if this component manager is read-only
  +     * @throws IllegalStateException if this component m_manager is read-only
        */
       protected final void checkWriteable()
           throws IllegalStateException
       {
           if( m_readOnly )
           {
  -            throw new IllegalStateException
  -                ( "ComponentManager is read only and can not be modified" );
  +            final String message =
  +                "ComponentManager is read only and can not be modified";
  +            throw new IllegalStateException( message );
           }
       }
   }
  
  
  
  1.16      +19 -19    jakarta-avalon/src/java/org/apache/avalon/framework/component/DefaultComponentSelector.java
  
  Index: DefaultComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/component/DefaultComponentSelector.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DefaultComponentSelector.java	21 Oct 2002 16:16:49 -0000	1.15
  +++ DefaultComponentSelector.java	7 Nov 2002 08:29:03 -0000	1.16
  @@ -1,14 +1,14 @@
  -/* ==================================================================== 
  - * The Apache Software License, Version 1.1 
  - * 
  - * Copyright (c) 1997-2002 The Apache Software Foundation. All rights 
  - * reserved. 
  - * 
  - * Redistribution and use in source and binary forms, with or without 
  - * modification, are permitted provided that the following conditions 
  - * are met: 
  - * 
  - * 1. Redistributions of source code must retain the above copyright 
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  @@ -20,13 +20,13 @@
    *    if any, must include the following acknowledgment:
    *    "This product includes software developed by the
    *    Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software 
  - *    itself, if and wherever such third-party acknowledgments  
  + *    Alternately, this acknowledgment may appear in the software
  + *    itself, if and wherever such third-party acknowledgments
    *    normally appear.
    *
  - * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
  + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
    *    must not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -49,9 +49,9 @@
    *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation. For more
  - * information on the Apache Software Foundation, please see 
  + * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.avalon.framework.component;
   
   import java.util.HashMap;
  @@ -156,9 +156,9 @@
       }
   
       /**
  -     * Check if this component manager is writeable.
  +     * Check if this component m_manager is writeable.
        *
  -     * @throws IllegalStateException if this component manager is read-only
  +     * @throws IllegalStateException if this component m_manager is read-only
        */
       protected final void checkWriteable()
           throws IllegalStateException
  
  
  
  1.11      +31 -31    jakarta-avalon/src/java/org/apache/avalon/framework/service/DefaultServiceManager.java
  
  Index: DefaultServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/service/DefaultServiceManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultServiceManager.java	21 Oct 2002 16:16:51 -0000	1.10
  +++ DefaultServiceManager.java	7 Nov 2002 08:29:03 -0000	1.11
  @@ -1,14 +1,14 @@
  -/* ==================================================================== 
  - * The Apache Software License, Version 1.1 
  - * 
  - * Copyright (c) 1997-2002 The Apache Software Foundation. All rights 
  - * reserved. 
  - * 
  - * Redistribution and use in source and binary forms, with or without 
  - * modification, are permitted provided that the following conditions 
  - * are met: 
  - * 
  - * 1. Redistributions of source code must retain the above copyright 
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  @@ -20,13 +20,13 @@
    *    if any, must include the following acknowledgment:
    *    "This product includes software developed by the
    *    Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software 
  - *    itself, if and wherever such third-party acknowledgments  
  + *    Alternately, this acknowledgment may appear in the software
  + *    itself, if and wherever such third-party acknowledgments
    *    normally appear.
    *
  - * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
  + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
    *    must not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -49,9 +49,9 @@
    *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation. For more
  - * information on the Apache Software Foundation, please see 
  + * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.avalon.framework.service;
   
   import java.util.HashMap;
  @@ -95,16 +95,16 @@
       }
   
       /**
  -     * Retrieve <code>Object</code> by role from <code>ServiceManager</code>.
  +     * Retrieve <code>Object</code> by key from <code>ServiceManager</code>.
        *
  -     * @param role the role
  +     * @param key the key
        * @return the <code>Object</code>
        * @throws ServiceException if an error occurs
        */
  -    public Object lookup( final String role )
  +    public Object lookup( final String key )
           throws ServiceException
       {
  -        final Object object = m_objects.get( role );
  +        final Object object = m_objects.get( key );
   
           if( null != object )
           {
  @@ -112,27 +112,27 @@
           }
           else if( null != m_parent )
           {
  -            return m_parent.lookup( role );
  +            return m_parent.lookup( key );
           }
           else
           {
  -            throw new ServiceException( role, "Unable to provide implementation for " +
role, null );
  +            throw new ServiceException( key, "Unable to provide implementation for " +
key, null );
           }
       }
   
       /**
  -     * Check to see if a <code>Object</code> exists for a role.
  +     * Check to see if a <code>Object</code> exists for a key.
        *
  -     * @param role  a string identifying the role to check.
  +     * @param key  a string identifying the key to check.
        * @return True if the object exists, False if it does not.
        */
  -    public boolean hasService( final String role )
  +    public boolean hasService( final String key )
       {
           boolean objectExists = false;
   
           try
           {
  -            this.lookup( role );
  +            this.lookup( key );
               objectExists = true;
           }
           catch( Throwable t )
  @@ -216,8 +216,9 @@
       {
           if( m_readOnly )
           {
  -            throw new IllegalStateException
  -                ( "ServiceManager is read only and can not be modified" );
  +            final String message =
  +                "ServiceManager is read only and can not be modified";
  +            throw new IllegalStateException( message );
           }
       }
   
  @@ -228,5 +229,4 @@
       public void release( Object object )
       {
       }
  -
  -}
  +}
  \ No newline at end of file
  
  
  
  1.10      +29 -30    jakarta-avalon/src/java/org/apache/avalon/framework/service/ServiceManager.java
  
  Index: ServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/service/ServiceManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ServiceManager.java	21 Oct 2002 16:16:52 -0000	1.9
  +++ ServiceManager.java	7 Nov 2002 08:29:04 -0000	1.10
  @@ -1,14 +1,14 @@
  -/* ==================================================================== 
  - * The Apache Software License, Version 1.1 
  - * 
  - * Copyright (c) 1997-2002 The Apache Software Foundation. All rights 
  - * reserved. 
  - * 
  - * Redistribution and use in source and binary forms, with or without 
  - * modification, are permitted provided that the following conditions 
  - * are met: 
  - * 
  - * 1. Redistributions of source code must retain the above copyright 
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  @@ -20,13 +20,13 @@
    *    if any, must include the following acknowledgment:
    *    "This product includes software developed by the
    *    Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software 
  - *    itself, if and wherever such third-party acknowledgments  
  + *    Alternately, this acknowledgment may appear in the software
  + *    itself, if and wherever such third-party acknowledgments
    *    normally appear.
    *
  - * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
  + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
    *    must not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -49,9 +49,9 @@
    *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation. For more
  - * information on the Apache Software Foundation, please see 
  + * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.avalon.framework.service;
   
   /**
  @@ -84,23 +84,23 @@
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
  + * @author <a href="mailto:peter at apache.org">Peter Donald</a>
    * @version 1.0
    * @see org.apache.avalon.framework.service.Serviceable
    * @see org.apache.avalon.framework.service.ServiceSelector
  - *
    */
   public interface ServiceManager
   {
       /**
  -     * Get the <code>Object</code> associated with the given role.  For
  +     * Get the <code>Object</code> associated with the given key.  For
        * instance, If the <code>ServiceManager</code> had a
  -     * <code>LoggerComponent</code> stored and referenced by role, I would
use
  -     * the following call:
  +     * <code>LoggerComponent</code> stored and referenced by key,
  +     * the following could be used:
        * <pre>
        * try
        * {
  -     *     MyComponent log;
  -     *     myComponent = (MyComponent) manager.lookup(MyComponent.ROLE);
  +     *     LoggerComponent log;
  +     *     myComponent = (LoggerComponent) manager.lookup( LoggerComponent.ROLE );
        * }
        * catch (...)
        * {
  @@ -108,20 +108,20 @@
        * }
        * </pre>
        *
  -     * @param role The role name of the <code>Object</code> to retrieve.
  +     * @param key The lookup key of the <code>Object</code> to retrieve.
        * @return an <code>Object</code> value
        * @throws ServiceException if an error occurs
        */
  -    Object lookup( String role )
  +    Object lookup( String key )
           throws ServiceException;
   
       /**
  -     * Check to see if a <code>Object</code> exists for a role.
  +     * Check to see if a <code>Object</code> exists for a key.
        *
  -     * @param role  a string identifying the role to check.
  +     * @param key a string identifying the key to check.
        * @return True if the object exists, False if it does not.
        */
  -    boolean hasService( String role );
  +    boolean hasService( String key );
   
       /**
        * Return the <code>Object</code> when you are finished with it.  This
  @@ -133,5 +133,4 @@
        * @param object The <code>Object</code> we are releasing.
        */
       void release( Object object );
  -
  -}
  +}
  \ No newline at end of file
  
  
  
  1.9       +18 -19    jakarta-avalon/src/java/org/apache/avalon/framework/service/ServiceSelector.java
  
  Index: ServiceSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/service/ServiceSelector.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ServiceSelector.java	21 Oct 2002 16:16:52 -0000	1.8
  +++ ServiceSelector.java	7 Nov 2002 08:29:04 -0000	1.9
  @@ -1,14 +1,14 @@
  -/* ==================================================================== 
  - * The Apache Software License, Version 1.1 
  - * 
  - * Copyright (c) 1997-2002 The Apache Software Foundation. All rights 
  - * reserved. 
  - * 
  - * Redistribution and use in source and binary forms, with or without 
  - * modification, are permitted provided that the following conditions 
  - * are met: 
  - * 
  - * 1. Redistributions of source code must retain the above copyright 
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  @@ -20,13 +20,13 @@
    *    if any, must include the following acknowledgment:
    *    "This product includes software developed by the
    *    Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software 
  - *    itself, if and wherever such third-party acknowledgments  
  + *    Alternately, this acknowledgment may appear in the software
  + *    itself, if and wherever such third-party acknowledgments
    *    normally appear.
    *
  - * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
  + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
    *    must not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -49,9 +49,9 @@
    *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation. For more
  - * information on the Apache Software Foundation, please see 
  + * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.avalon.framework.service;
   
   /**
  @@ -111,5 +111,4 @@
        * @param object The {@link Object} we are releasing.
        */
       void release( Object object );
  -
  -}
  +}
  \ No newline at end of file
  
  
  
  1.1                  jakarta-avalon/src/java/org/apache/avalon/framework/service/WrapperServiceManager.java
  
  Index: WrapperServiceManager.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.avalon.framework.service;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.ComponentSelector;
  
  /**
   * This is a {@link ServiceManager} implementation that can wrap around a legacy
   * {@link ComponentManager} object effectively adapting a {@link ComponentManager}
   * interface to a {@link ServiceManager} interface.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/11/07 08:29:04 $
   */
  public class WrapperServiceManager
      implements ServiceManager
  {
      /**
       * The component manager thaty this class wraps.
       */
      private final ComponentManager m_componentManager;
  
      /**
       * This constructor is a constructor for a WrapperServiceManager.
       *
       * @param componentManager the ComponentManager instance that is being wrapped
       */
      public WrapperServiceManager( final ComponentManager componentManager )
      {
          if( null == componentManager )
          {
              throw new NullPointerException( "componentManager" );
          }
  
          m_componentManager = componentManager;
      }
  
      /**
       * Retrieve a service using specified key.
       *
       * @param key the key to use to lookup component
       * @return the matching service
       * @throws ServiceException if unable to provide the service
       * @see ServiceManager#lookup
       */
      public Object lookup( final String key )
          throws ServiceException
      {
          try
          {
              final Object service = m_componentManager.lookup( key );
              if( service instanceof ComponentSelector )
              {
                  return new WrapperServiceSelector( key, (ComponentSelector)service );
              }
              else
              {
                  return service;
              }
          }
          catch( final ComponentException ce )
          {
              final String message = "Could not return a reference to the Component";
              throw new ServiceException( key, message, ce );
          }
      }
  
      /**
       * Return true if the component is available in ServiceManager.
       *
       * @param key the lookup
       * @return true if the component is available in ServiceManager
       */
      public boolean hasService( final String key )
      {
          return m_componentManager.hasComponent( key );
      }
  
      /**
       * Release the service back to the ServiceManager.
       *
       * @param service the service
       */
      public void release( final Object service )
      {
          m_componentManager.release( (Component)service );
      }
  }
  
  
  
  1.1                  jakarta-avalon/src/java/org/apache/avalon/framework/service/WrapperServiceSelector.java
  
  Index: WrapperServiceSelector.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.avalon.framework.service;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentSelector;
  
  /**
   * This is a {@link ServiceSelector} implementation that can wrap around a legacy
   * {@link ComponentSelector} object effectively adapting a {@link ComponentSelector}
   * interface to a {@link ServiceSelector} interface.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/11/07 08:29:04 $
   */
  public class WrapperServiceSelector
      implements ServiceSelector
  {
      /**
       * The Selector we are wrapping.
       */
      private final ComponentSelector m_selector;
  
      /**
       * The role that this selector was aquired via.
       */
      private final String m_role;
  
      /**
       * This constructor is a constructor for a ComponentServiceManager
       *
       * @param role the role used to aquire this selector
       * @param selector the selector to wrap
       */
      public WrapperServiceSelector( final String role,
                                     final ComponentSelector selector )
      {
          if( null == role )
          {
              throw new NullPointerException( "role" );
          }
          if( null == selector )
          {
              throw new NullPointerException( "selector" );
          }
  
          m_role = role + "/";
          m_selector = selector;
      }
  
      /**
       * Select a service based on a policy.
       *
       * @param policy the policy
       * @return the service
       * @throws ServiceException if unable to select service
       */
      public Object select( final Object policy )
          throws ServiceException
      {
          try
          {
              return m_selector.select( policy );
          }
          catch( final ComponentException ce )
          {
              final String message = "Could not return a reference to the Component";
              throw new ServiceException( m_role + policy, message, ce );
          }
      }
  
      /**
       * Check to see if a {@link Object} exists relative to the supplied policy.
       *
       * @param policy a {@link Object} containing the selection criteria
       * @return True if the component is available, False if it not.
       */
      public boolean isSelectable( final Object policy )
      {
          return m_selector.hasComponent( policy );
      }
  
      /**
       * Return the {@link Object} when you are finished with it.  This
       * allows the {@link ServiceSelector} to handle the End-Of-Life Lifecycle
       * events associated with the {@link Object}.  Please note, that no
       * Exception should be thrown at this point.  This is to allow easy use of the
       * ServiceSelector system without having to trap Exceptions on a release.
       *
       * @param object The {@link Object} we are releasing.
       */
      public void release( Object object )
      {
          m_selector.release( (Component)object );
      }
  }
  
  
  

--
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