mcconnell    2003/02/27 22:09:16

  Modified:    assembly/src/java/org/apache/avalon/assembly/appliance
                        DefaultAppliance.java DefaultApplianceContext.java
                        DefaultApplianceFactory.java
               assembly/src/java/org/apache/avalon/assembly/engine
                        EngineClassLoader.java
               assembly/src/java/org/apache/avalon/assembly/locator
                        DefaultLocator.java
  Log:
  Enhancement of the appliance context management semantics (cleaning up of 
conditions where an appliance is creating an appliance).
  
  Revision  Changes    Path
  1.36      +2 -2      
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- DefaultAppliance.java     27 Feb 2003 23:28:10 -0000      1.35
  +++ DefaultAppliance.java     28 Feb 2003 06:09:15 -0000      1.36
  @@ -275,9 +275,9 @@
       */
       public void contextualize( Locator context ) throws ContextException
       {
  +        m_applianceContext = (ApplianceContext) context.get( 
"urn:assembly:appliance.context" );
           m_engine = (EngineClassLoader) context.get( "urn:assembly:engine" );
           m_lifestyle = (LifestyleService) context.get( 
"urn:assembly:lifestyle.service" );
  -        m_applianceContext = (ApplianceContext) context.get( 
"urn:assembly:appliance.context" );
           m_system = (Locator) context.get( "urn:assembly:appliance.system" );
           m_repository = (ApplianceRepository) context.get( 
"urn:assembly:appliance.repository" );
       }
  
  
  
  1.12      +18 -27    
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java
  
  Index: DefaultApplianceContext.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultApplianceContext.java      27 Feb 2003 23:06:38 -0000      1.11
  +++ DefaultApplianceContext.java      28 Feb 2003 06:09:15 -0000      1.12
  @@ -99,11 +99,6 @@
       //=====================================================================
   
       /**
  -     * The map of values managed by the context.
  -     */
  -     private Map m_map = new Hashtable();
  -
  -    /**
        * The underlying profile that this appliance is managing.
        */
        private Profile m_profile;
  @@ -179,16 +174,26 @@
       */
       public DefaultApplianceContext( Profile profile )
       {
  -        super();
  +        this( profile, null );
  +    }
  +
  +   /**
  +    * Creation of a new appliance context.
  +    * @param profile the profile
  +    * @param map a set of supplimentary context entries
  +    */
  +    public DefaultApplianceContext( Profile profile, Map map )
  +    {
  +        super( map );
           if( profile == null )
           {
               throw new NullPointerException( "profile" );
           }
  -        m_map = getData();
           m_profile = profile;
           m_activation = profile.getActivationPolicy();
       }
   
  +
       //==============================================================
       // parameters
       //==============================================================
  @@ -417,30 +422,12 @@
       }
   
      /**
  -    * Set the deployment context.
  -    * @param map the deployment context
  -    * @exception IllegalStateException if the appliance context is write 
protected
  -    * @exception NullPointerException if the supplied map is null
  -    * @see #getDeploymentContext()
  -    */
  -    //public void setDeploymentContext( final Map map ) throws 
IllegalStateException
  -    //{
  -    //    checkWriteable();
  -    //    m_context = map;
  -    //}
  -
  -   /**
       * Get the deployment context.
       * @return the deployment context
       */
       public Map getDeploymentContext()
       {
  -        return m_map;
  -        //if( m_context == null )
  -        //{
  -        //    return new Hashtable();
  -        //}
  -        //return m_context;
  +        return super.getData();
       }
   
       /**
  @@ -602,4 +589,8 @@
            return category;
       }
       
  +    public String toString()
  +    {
  +        return "[" + getName() + "]";
  +    }
   }
  
  
  
  1.12      +8 -23     
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java
  
  Index: DefaultApplianceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultApplianceFactory.java      28 Feb 2003 03:45:07 -0000      1.11
  +++ DefaultApplianceFactory.java      28 Feb 2003 06:09:15 -0000      1.12
  @@ -113,7 +113,8 @@
       * @exception ApplianceException if a creation error occurs
       */
       public static ApplianceFactory createApplianceFactory( 
  -       EngineClassLoader loader, Logger logger, ApplianceRepository 
repository, Locator system ) 
  +       EngineClassLoader loader, Logger logger, ApplianceRepository 
repository, 
  +       Locator system ) 
          throws ApplianceException
       {
           return createApplianceFactory( 
  @@ -131,7 +132,8 @@
       * @exception ApplianceException if a creation error occurs
       */
       public static ApplianceFactory createApplianceFactory( 
  -      EngineClassLoader loader, String classname, Logger logger, 
ApplianceRepository repository, Locator system ) 
  +      EngineClassLoader loader, String classname, Logger logger, 
  +      ApplianceRepository repository, Locator system ) 
         throws ApplianceException
       {
           if( classname == null )
  @@ -293,6 +295,7 @@
           // we are building a custom appliance
           // 
           
  +
           LifestyleService lifestyle = createLifestyleService( engine, m_pool 
);
           DefaultLocator locator = null;
           try
  @@ -316,7 +319,6 @@
           String classname = context.getApplianceClassname();
           if(( classname == null ) || ( classname.equals( 
DefaultAppliance.class.getName() ) ) )
           {
  -
               //
               // bootstrap the appliance using DefaultAppliance
               //
  @@ -345,9 +347,10 @@
   
               try
               {
  +                Map map = context.getDeploymentContext();
                   Type type = engine.getRepository().getTypeManager().getType( 
classname );
                   Profile profile = 
engine.getRepository().getProfileManager().getProfile( type );
  -                DefaultApplianceContext cntx = new DefaultApplianceContext( 
profile );
  +                DefaultApplianceContext cntx = new DefaultApplianceContext( 
profile, map );
                   cntx.put( "urn:assembly:engine", engine );
                   cntx.put( "urn:assembly:lifestyle.service", lifestyle );
                   cntx.put( "urn:assembly:appliance.context", context );
  @@ -378,24 +381,6 @@
                   throw new ApplianceException( error, e );
               }
           }
  -
  -        /*
  -        Appliance appliance = getApplianceInstance( engine, context );
  -        appliance.enableLogging( logger );
  -
  -        try
  -        {
  -            appliance.contextualize( locator );
  -            appliance.initialize();
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Unable to create appliance from context: " + 
context.getName();
  -            throw new ApplianceException( error, e );
  -        }
  -        return appliance;
  -        */
       }
   
      /**
  
  
  
  1.39      +9 -89     
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- EngineClassLoader.java    28 Feb 2003 03:44:07 -0000      1.38
  +++ EngineClassLoader.java    28 Feb 2003 06:09:16 -0000      1.39
  @@ -838,89 +838,6 @@
                 "Unexpected exception while attampting to expand the supplied 
classpath.";
               throw new EngineRuntimeException( error, e );
           }
  -
  -        /*
  -        if( m_base != null )
  -        {
  -            URL[] urls = ClasspathDescriptor.expand( m_base, classpath );
  -            for( int j = 0; j < urls.length; j++ )
  -            {
  -                URL inc = urls[ j ];
  -                try
  -                {
  -                    addURL( inc );
  -                }
  -                catch( Throwable e )
  -                {
  -                    throw new EngineRuntimeException( 
  -                      REZ.getString( "classpath.include.error", inc ) , e );
  -                }
  -            }
  -            return;
  -        }
  -        else
  -        {
  -           getLogger().debug( "expanding a classpath without a base" );
  -        }
  -        */
  -
  -        //
  -        // #########################################################
  -        // we should be able to drop the rest once we update the m_base to 
be a required
  -        // context value - or we construct a rationale default
  -        // ##########################################################
  -
  -        /*
  -        List list = new ArrayList();
  -        FilesetDescriptor[] dirs = classpath.getFilesetDescriptors();
  -        if( getLogger().isDebugEnabled() )
  -        {
  -           getLogger().debug( REZ.getString( "add.classpath.info", "" + 
dirs.length ) );
  -        }
  -        
  -        for( int i = 0; i < dirs.length; i++ )
  -        {
  -            FilesetDescriptor descriptor = dirs[ i ];
  -            File anchor;
  -            try
  -            {
  -                anchor = new File( m_home, descriptor.getBaseDirectory() 
).getCanonicalFile();
  -                if( !anchor.exists() )
  -                {
  -                    throw new EngineRuntimeException( 
  -                      REZ.getString( "classpath.dir.error", anchor ) );
  -                }
  -            }
  -            catch( Throwable e )
  -            {
  -                throw new EngineRuntimeException( 
  -                  REZ.getString( "classpath.base.error", descriptor ) , e );
  -            }
  -
  -            IncludeDescriptor[] includes = 
descriptor.getIncludeDescriptors();
  -            if( getLogger().isDebugEnabled() )
  -            {
  -               getLogger().debug( REZ.getString( "classpath.include", "" + 
includes.length ) );
  -            }
  -            for( int j = 0; j < includes.length; j++ )
  -            {
  -                String inc = includes[ j ].getFile();
  -                try
  -                {
  -                    addURL( new File( anchor, inc 
).getCanonicalFile().toURL() );
  -                }
  -                catch( Throwable e )
  -                {
  -                    throw new EngineRuntimeException( 
  -                      REZ.getString( "classpath.include.error", inc ) , e );
  -                }
  -            }
  -        }
  -        if( getLogger().isDebugEnabled() )
  -        {
  -           getLogger().debug( REZ.getString( "classpath.ok" ) );
  -        }
  -        */
       }
   
      /**
  @@ -1009,7 +926,8 @@
       * @param dependency a service depedency descriptor
       * @return the appliance
       */
  -    public Appliance resolve( DependencyGraph graph, DependencyDescriptor 
dependency ) throws Exception
  +    public Appliance resolve( DependencyGraph graph, DependencyDescriptor 
dependency ) 
  +      throws Exception
       {
           return resolve( graph, dependency, "" );
       }
  @@ -1023,7 +941,8 @@
       * @return the appliance
       */
       public Appliance resolve( 
  -      DependencyGraph graph, DependencyDescriptor dependency, String 
partition ) throws Exception
  +      DependencyGraph graph, DependencyDescriptor dependency, String 
partition ) 
  +      throws Exception
       {
           if( graph == null )
           {
  @@ -1092,7 +1011,8 @@
       * @param partition the partition to assign to a new appliance if 
creation is necessary
       * @return the appliance
       */
  -    public Appliance resolve( DependencyGraph graph, StageDescriptor stage, 
String partition ) throws Exception
  +    public Appliance resolve( DependencyGraph graph, StageDescriptor stage, 
String partition ) 
  +      throws Exception
       {
           if( stage == null )
           {
  @@ -1139,7 +1059,8 @@
       * @param context the appliance context
       * @return the appliance
       */
  -    public Appliance createAppliance( ApplianceContext context ) throws 
ApplianceException
  +    public Appliance createAppliance( ApplianceContext context ) 
  +      throws ApplianceException
       {
           return createAppliance( context, true );
       }
  @@ -1188,7 +1109,6 @@
           }
   
           Appliance appliance = factory.createAppliance( getSystemContext(), 
this, context, logger );
  -
           if( shared )
           {
               m_manager.addAppliance( appliance );
  
  
  
  1.6       +9 -7      
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/DefaultLocator.java
  
  Index: DefaultLocator.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/DefaultLocator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultLocator.java       7 Feb 2003 15:39:14 -0000       1.5
  +++ DefaultLocator.java       28 Feb 2003 06:09:16 -0000      1.6
  @@ -129,7 +129,7 @@
       /**
        * Create a Locator with specified data.
        *
  -     * @param contextData the context data
  +     * @param contextData the context data (may be null)
        */
       public DefaultLocator( final Map data )
       {
  @@ -143,13 +143,13 @@
        */
       public DefaultLocator( final Locator parent )
       {
  -        this( new Hashtable(), parent );
  +        this( null, parent );
       }
   
       /**
        * Create a Locator with specified data and parent locator.
        *
  -     * @param data the locator data
  +     * @param data the locator data (may be null)
        * @param parent the parent Locator (may be null)
        */
       public DefaultLocator( final Map data, final Locator parent )
  @@ -162,21 +162,23 @@
        *
        * @param data the locator data
        * @param parent the parent Locator (may be null)
  -     * @exception NullPointerException if either the supplied dictionary or 
  -     *    data arguments are null
  +     * @exception NullPointerException if the supplied dictionary is null
        */
       public DefaultLocator( final Map data, final Locator parent, final 
Dictionary dictionary )
         throws NullPointerException
       {
           if( data == null )
           {
  -            throw new NullPointerException( "data" );
  +            m_data = new Hashtable();
  +        }
  +        else
  +        {
  +            m_data = data;
           }
           if( dictionary == null )
           {
               throw new NullPointerException( "dictionary" );
           }
  -        m_data = data;
           m_dictionary = dictionary;
           m_parent = parent;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to