avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon/repository/test/src/test/org/apache/avalon/repository/main DefaultInitialContextFactoryTestCase.java
Date Wed, 18 Feb 2004 02:23:58 GMT
mcconnell    2004/02/17 18:23:58

  Modified:    repository/main/src/java/org/apache/avalon/repository/main
                        DefaultInitialContext.java
                        DefaultInitialContextFactory.java
               repository/spi/src/java/org/apache/avalon/repository/provider
                        InitialContext.java
               repository/test/src/test/org/apache/avalon/repository/main
                        DefaultInitialContextFactoryTestCase.java
  Log:
  Expose the application key on the intial context so we can hook into this from within a
factory.
  
  Revision  Changes    Path
  1.20      +23 -2     avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContext.java
  
  Index: DefaultInitialContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContext.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DefaultInitialContext.java	18 Feb 2004 00:21:47 -0000	1.19
  +++ DefaultInitialContext.java	18 Feb 2004 02:23:57 -0000	1.20
  @@ -142,6 +142,11 @@
       //------------------------------------------------------------------
       // immutable state 
       //------------------------------------------------------------------
  +
  +   /** 
  +    * The application key.
  +    */
  +    private final String m_key;
           
      /** 
       * The instantiated delegate repository factory.
  @@ -251,6 +256,8 @@
         File base, ClassLoader loader, Artifact artifact, File cache, String[] hosts ) 
         throws RepositoryException
       {
  +        m_key = "avalon";
  +
           m_base = setupBaseDirectory( base );
           m_cache = setupCache( cache, base );
           m_hosts = setupHosts( hosts, base );
  @@ -340,15 +347,17 @@
        * @throws RepositoryException if an error occurs during establishment
        */
       DefaultInitialContext( 
  -      ClassLoader parent, Artifact artifact, File base, File cache, String[] hosts ) 
  +      String key, ClassLoader parent, Artifact artifact, File base, File cache, String[]
hosts ) 
         throws RepositoryException
       {
  +        if( null == key ) throw new NullPointerException( "key" ); 
           if( null == base ) throw new NullPointerException( "base" ); 
           if( null == parent ) throw new NullPointerException( "parent" ); 
           if( null == artifact ) throw new NullPointerException( "artifact" ); 
           if( null == cache ) throw new NullPointerException( "cache" ); 
           if( null == hosts ) throw new NullPointerException( "hosts" ); 
   
  +        m_key = key;
           m_base = base;
           m_cache = cache;
           m_hosts = hosts;
  @@ -416,6 +425,18 @@
       // ------------------------------------------------------------------------
       // InitialContext
       // ------------------------------------------------------------------------
  +
  +    /**
  +     * Return the application key.  The value of the key may be used 
  +     * to resolve property files by using the convention 
  +     * [key].properties.
  +     * 
  +     * @return the application key.
  +     */
  +    public String getApplicationKey()
  +    {
  +        return m_key;
  +    }
   
       /**
        * Return the base working directory.
  
  
  
  1.3       +16 -1     avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContextFactory.java
  
  Index: DefaultInitialContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContextFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultInitialContextFactory.java	17 Feb 2004 12:17:29 -0000	1.2
  +++ DefaultInitialContextFactory.java	18 Feb 2004 02:23:57 -0000	1.3
  @@ -152,10 +152,15 @@
        * @param key the application key
        * @param work the working directory
        * @throws IOException if an error occurs during establishment
  +     * @exception NullPointerException if tyhe supplied key or work 
  +     *    arguments are null
        */
       public DefaultInitialContextFactory( String key, File work ) 
         throws IOException
       {
  +        if( null == key ) throw new NullPointerException( "key" );
  +        if( null == work ) throw new NullPointerException( "work" );
  +
           m_key = key;
           m_work = work;
           m_defaults = new DefaultsBuilder( key, work );
  @@ -252,6 +257,7 @@
           try
           {
               return new DefaultInitialContext(
  +              getApplicationKey(),
                 getParentClassLoader(),
                 getImplementation(),
                 getWorkingDirectory(),
  @@ -264,6 +270,15 @@
                 "Could not create initial context.";
               throw new RepositoryRuntimeException( error, e );
           }
  +    }
  +
  +
  +   /**
  +    * Return the application key.
  +    */
  +    public String getApplicationKey()
  +    {
  +        return m_key;
       }
   
      /**
  
  
  
  1.9       +10 -1     avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContext.java
  
  Index: InitialContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContext.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- InitialContext.java	17 Feb 2004 11:06:17 -0000	1.8
  +++ InitialContext.java	18 Feb 2004 02:23:58 -0000	1.9
  @@ -54,6 +54,15 @@
         "\n-----------------------------------------------------------";
   
       /**
  +     * Return the application key.  The value of the key may be used 
  +     * to resolve property files by using the convention 
  +     * [key].properties.
  +     * 
  +     * @return the application key.
  +     */
  +    String getApplicationKey();
  +
  +    /**
        * Return the base working directory.
        * 
        * @return the base directory
  
  
  
  1.2       +2 -1      avalon/repository/test/src/test/org/apache/avalon/repository/main/DefaultInitialContextFactoryTestCase.java
  
  Index: DefaultInitialContextFactoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/test/src/test/org/apache/avalon/repository/main/DefaultInitialContextFactoryTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultInitialContextFactoryTestCase.java	17 Feb 2004 11:06:17 -0000	1.1
  +++ DefaultInitialContextFactoryTestCase.java	18 Feb 2004 02:23:58 -0000	1.2
  @@ -42,6 +42,7 @@
           System.out.println( "" );
           System.out.println( "InitialContextFactory" );
           System.out.println( "---------------------" );
  +        System.out.println( "  key: " + factory.getApplicationKey() );
           System.out.println( "  home: " + factory.getHomeDirectory() );
           System.out.println( "  cache: " + factory.getCacheDirectory() );
           System.out.println( "  work: " + factory.getWorkingDirectory() );
  
  
  

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


Mime
View raw message