avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/repository/api/src/java/org/apache/avalon/repository ApplicationDirective.java
Date Mon, 17 Nov 2003 10:02:34 GMT
mcconnell    2003/11/17 02:02:34

  Added:       repository/api/src/java/org/apache/avalon/repository
                        ApplicationDirective.java
  Log:
  Move from main bootstrap to api (this is the class that describes the target implementation
jar and factory parameters).
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/ApplicationDirective.java
  
  Index: ApplicationDirective.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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", "Apache Avalon", "Avalon Framework" 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 (INCLU-
   DING, 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.repository ;
  
  
  import java.util.Properties ;
  
  
  /**
   * A build descriptor can be generated from a jar that has extra jar build 
   * properties packaged with it.
   * 
   * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
   * @author $Author: mcconnell $
   * @version $Revision: 1.1 $
   */
  public class ApplicationDirective
  {
      //-----------------------------------------------------------
      // static
      //-----------------------------------------------------------
  
     /** 
      * the key used to get the defualt comma delimited 
      * repository urls
      */
      public static final String REPOS_KEY = "avalon.target.repos" ;
  
     /** 
      * the key used to get the aplication artifact group
      */
      public static final String GROUP_KEY = "avalon.target.group" ;
  
     /** 
      * the key used to get the artifact name within the group
      */
      public static final String NAME_KEY = "avalon.target.name" ;
  
     /** 
      * the version of the application artifact
      */
      public static final String VERSION_KEY = "avalon.target.version" ;
  
      //-----------------------------------------------------------
      // static
      //-----------------------------------------------------------
      
     /** 
      * the jar descriptor that identifes the implemetation jar
      */
      private final JarDescriptor m_implementation ;
  
     /** 
      * default repos that will contain this jar and project descriptors 
      */
      private final String[] m_repos ;
  
      /**
       * Creates a ApplicationDirective
       * 
       * @param reference the service provider implementation reference
       * @param a_props supplimentary properties
       */
      public ApplicationDirective( ArtifactReference reference, String[] repositories ) 
        throws RepositoryException
      {
          if( reference == null ) throw new NullPointerException( "reference" );
          if( repositories == null ) throw new NullPointerException( "repositories" );
  
          Properties properties = RepositoryUtils.getProperties( repositories, reference );
  
          final String group = properties.getProperty( GROUP_KEY );
          final String name = properties.getProperty( NAME_KEY  );
          final String version = properties.getProperty( VERSION_KEY );
  
          m_implementation = new JarDescriptor( group, name, version );
          
          // gets the comma separated repository list
          String[] repos = 
            RepositoryUtils.getDelimited( ',', properties.getProperty( REPOS_KEY ) ) ;
          if( repos != null )
          {
              m_repos = repos;
          }
          else
          {
              m_repos = repositories;
          }
      }
  
      /**
       * Gets the artifact descriptor that declares the final implementation class
       * and implementation dependencies.
       * 
       * @return the artifact descriptor for the jar
       */
      public JarDescriptor getJarDescriptor()
      {
          return m_implementation;
      }
      
      /**
       * Gets the default or bootstrap repositories guaranteed to contain the jar.
       * 
       * @return the repo urls as strings
       */
      public String[] getDefaultRepositories()
      {
          return m_repos ;
      }
  }
  
  
  

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


Mime
View raw message