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-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor DefaultEmbeddor.java EmbeddorEntry.java
Date Fri, 10 May 2002 11:24:48 GMT
donaldp     02/05/10 04:24:48

  Modified:    src/java/org/apache/avalon/phoenix/components/embeddor
                        DefaultEmbeddor.java EmbeddorEntry.java
  Log:
  Removed setters for immutable data from EmbeddorEntry and passed in required info via constructor.
  
  Revision  Changes    Path
  1.58      +13 -17    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- DefaultEmbeddor.java	10 May 2002 11:08:56 -0000	1.57
  +++ DefaultEmbeddor.java	10 May 2002 11:24:48 -0000	1.58
  @@ -168,13 +168,8 @@
               final String role = children[ i ].getAttribute( "role" );
               final String classname = children[ i ].getAttribute( "class" );
               final String logger = children[ i ].getAttribute( "logger" );
  -
  -            final EmbeddorEntry entry = new EmbeddorEntry();
  -            entry.setRole( role );
  -            entry.setClassName( classname );
  -            entry.setLoggerName( logger );
  -            entry.setConfiguration( children[ i ] );
  -            m_entrys[ i ] = entry;
  +            m_entrys[ i ] =
  +                new EmbeddorEntry( role, classname, logger, children[ i ] );
           }
       }
   
  @@ -414,7 +409,7 @@
               {
                   final String className = m_entrys[ i ].getClassName();
                   final Class clazz = Class.forName( className );
  -                object = createComponent( className, clazz );
  +                object = createObject( className, clazz );
                   m_entrys[ i ].setObject( object );
               }
           }
  @@ -530,37 +525,38 @@
       /**
        * Create a component that implements an interface.
        *
  -     * @param component the name of the component
  -     * @param clazz the name of interface/type
  +     * @param classname the name of the objects class
  +     * @param service the name of interface/type
        * @return the created object
        * @throws Exception if an error occurs
        */
  -    private Object createComponent( final String component, final Class clazz )
  +    private Object createObject( final String classname,
  +                                 final Class service )
           throws Exception
       {
           try
           {
  -            final Object object = Class.forName( component ).newInstance();
  -            if( !clazz.isInstance( object ) )
  +            final Object object = Class.forName( classname ).newInstance();
  +            if( !service.isInstance( object ) )
               {
  -                final String message = REZ.getString( "bad-type.error", component, clazz.getName()
);
  +                final String message = REZ.getString( "bad-type.error", classname, service.getName()
);
                   throw new Exception( message );
               }
               return object;
           }
           catch( final IllegalAccessException iae )
           {
  -            final String message = REZ.getString( "bad-ctor.error", clazz.getName(), component
);
  +            final String message = REZ.getString( "bad-ctor.error", service.getName(),
classname );
               throw new CascadingException( message, iae );
           }
           catch( final InstantiationException ie )
           {
  -            final String message = REZ.getString( "no-instantiate.error", clazz.getName(),
component );
  +            final String message = REZ.getString( "no-instantiate.error", service.getName(),
classname );
               throw new CascadingException( message, ie );
           }
           catch( final ClassNotFoundException cnfe )
           {
  -            final String message = REZ.getString( "no-class.error", clazz.getName(), component
);
  +            final String message = REZ.getString( "no-class.error", service.getName(),
classname );
               throw new CascadingException( message, cnfe );
           }
       }
  
  
  
  1.2       +15 -24    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/EmbeddorEntry.java
  
  Index: EmbeddorEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/EmbeddorEntry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EmbeddorEntry.java	21 Mar 2002 04:39:14 -0000	1.1
  +++ EmbeddorEntry.java	10 May 2002 11:24:48 -0000	1.2
  @@ -14,20 +14,26 @@
    */
   public class EmbeddorEntry
   {
  -    private String m_role;
  -    private Configuration m_configuration;
  -    private String m_classname;
  -    private String m_loggerName;
  +    private final String m_role;
  +    private final String m_classname;
  +    private final String m_loggerName;
  +    private final Configuration m_configuration;
       private Object m_object;
   
  -    public String getRole()
  +    public EmbeddorEntry( final String role,
  +                          final String classname,
  +                          final String loggerName,
  +                          final Configuration configuration )
       {
  -        return m_role;
  +        m_role = role;
  +        m_classname = classname;
  +        m_loggerName = loggerName;
  +        m_configuration = configuration;
       }
   
  -    public void setRole( String role )
  +    public String getRole()
       {
  -        m_role = role;
  +        return m_role;
       }
   
       public Configuration getConfiguration()
  @@ -35,27 +41,17 @@
           return m_configuration;
       }
   
  -    public void setConfiguration( Configuration conf )
  -    {
  -        this.m_configuration = conf;
  -    }
  -
       public String getClassName()
       {
           return m_classname;
       }
   
  -    public void setClassName( String name )
  -    {
  -        m_classname = name;
  -    }
  -
       public Object getObject()
       {
           return m_object;
       }
   
  -    public void setObject( Object object )
  +    public void setObject( final Object object )
       {
           m_object = object;
       }
  @@ -63,10 +59,5 @@
       public String getLoggerName()
       {
           return m_loggerName;
  -    }
  -
  -    public void setLoggerName( String logger )
  -    {
  -        m_loggerName = logger;
       }
   }
  
  
  

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