maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject cvs commit: maven-scm/generic-scm-factory/src/java/org/apache/maven/genericscm/factory ScmFactory.java
Date Tue, 09 Dec 2003 21:29:10 GMT
evenisse    2003/12/09 13:29:10

  Added:       generic-scm-factory .cvsignore project.properties
                        project.xml
               generic-scm-factory/src/java/org/apache/maven/genericscm/factory
                        ScmFactory.java
  Log:
  Add implementation of ScmManager
  
  Revision  Changes    Path
  1.1                  maven-scm/generic-scm-factory/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  .project
  maven.log
  .classpath
  target
  
  
  1.1                  maven-scm/generic-scm-factory/project.properties
  
  Index: project.properties
  ===================================================================
  maven.junit.fork=true
  
  
  
  1.1                  maven-scm/generic-scm-factory/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <project>
    <pomVersion>3</pomVersion>
    <name>Generic SCM Factory</name>
    <groupId>genericscm</groupId>
    <id>genericscm-factory</id>
    <artifactId>genericscm-factory</artifactId>
    <currentVersion>1.0-beta1-SNAPSHOT</currentVersion>
    <description>Generic SCM Tools - Factory</description>
    <shortDescription>Generic SCM Tools - Factory</shortDescription>
    <inceptionYear>2003</inceptionYear>
    <package>org.apache.maven.genericscm</package>
    
    <versions/>
    <branches/>
  
    <developers>
      <developer>
        <name>Emmanuel Venisse</name>
        <id>evenisse</id>
        <email>emmanuel@venisse.net</email>
        <organization/>
        <roles>
          <role>Creator</role>
          <role>Project Leader</role>
          <role>Release Manager</role>
        </roles>
      </developer>
    </developers>
    
    <contributors/>
  
    <dependencies>
      <dependency>
        <groupId>genericscm</groupId>
        <artifactId>genericscm-api</artifactId>
        <version>1.0-beta1-SNAPSHOT</version>
      </dependency>
    </dependencies>
  
    <build>
      <sourceDirectory>src/java</sourceDirectory>
      <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
      <unitTest>
        <includes>
          <include>**/*Test.java</include>
        </includes>
  
        <resources>
          <resource>
            <directory>src/test-resources</directory>
            <includes>
              <include>**/*.*</include>
            </includes>
          </resource>        
        </resources>
      </unitTest>
      
      <resources>
        <resource>
          <directory>src/resources</directory>
          <includes>
            <include>**/*.*</include>
          </includes>
        </resource>        
      </resources>
    </build>
  </project>
  
  
  1.1                  maven-scm/generic-scm-factory/src/java/org/apache/maven/genericscm/factory/ScmFactory.java
  
  Index: ScmFactory.java
  ===================================================================
  package org.apache.maven.genericscm.manager;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 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-userName 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 "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" 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",
   *    "Apache Maven", 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/>.
   *
   * ====================================================================
   */
  
  import java.util.MissingResourceException;
  import java.util.ResourceBundle;
  
  import org.apache.maven.genericscm.ScmException;
  import org.apache.maven.genericscm.ScmWrapper;
  import org.apache.maven.genericscm.command.CommandWrapper;
  import org.apache.maven.genericscm.manager.ScmManager;
  import org.apache.maven.genericscm.repository.Repository;
  import org.apache.maven.genericscm.repository.RepositoryInfo;
  
  /**
   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
   * @version $Id: ScmFactory.java,v 1.1 2003/12/09 21:29:10 evenisse Exp $
   */
  public class ScmFactory implements ScmManager
  {
      public Repository getRepository(RepositoryInfo repoInfo) throws ScmException
      {
          Repository repository = lookupRepository(repoInfo);
          repository.setConnection(repoInfo.getConnection());
          repository.setDelimiter(repoInfo.getDelimiter());
          repository.setPassword(repoInfo.getPassword());
          return repository;
      }
  
      public Repository lookupRepository(RepositoryInfo repoInfo) throws ScmException
      {
          Repository repository;
  
          String scmType = repoInfo.getType();
  
          try
          {
              repository = (Repository)getInstance("maven.scm.repository." + scmType);
          }
          catch (ScmException se)
          {
              throw new ScmException("Unsupported SCM : " + scmType, se);
          }
  
          return repository;
      }
      
      public CommandWrapper getCommandWrapper(RepositoryInfo repoInfo) throws ScmException
      {
          CommandWrapper wrapper = lookupCommandWrapper(repoInfo);
          wrapper.setRepository(getRepository(repoInfo));
          return wrapper;
      }
  
      public CommandWrapper lookupCommandWrapper(RepositoryInfo repoInfo) throws ScmException
      {
          CommandWrapper wrapper;
  
          String scmType = repoInfo.getType();
  
          try
          {
              wrapper = (CommandWrapper)getInstance("maven.scm.commandwrapper." + scmType);
          }
          catch (ScmException se)
          {
              throw new ScmException("Unsupported SCM : " + scmType, se);
          }
  
          return wrapper;
      }
      
      public ScmWrapper getScmWrapper(RepositoryInfo repoInfo) throws ScmException
      {
          ScmWrapper wrapper = lookupScmWrapper();
          wrapper.setRepository(getRepository(repoInfo));
          wrapper.setCommandWrapper(getCommandWrapper(repoInfo));
          return wrapper;
      }
      
      public ScmWrapper lookupScmWrapper() throws ScmException
      {
          ScmWrapper wrapper;
  
          try
          {
              wrapper = (ScmWrapper)getInstance("maven.scm.scmwrapper");
          }
          catch (ScmException se)
          {
              throw new ScmException("ScmWrapper component isn't defined.", se);
          }
  
          return wrapper;
      }
      
      private Object getInstance(String propertyName) throws ScmException
      {
          ResourceBundle bundle = ResourceBundle.getBundle("mavenscm");
          String propertyValue = "";
          try
          {
              propertyValue = bundle.getString(propertyName);
              return this.getClass().getClassLoader().loadClass(propertyValue).newInstance();
          }
          catch (ClassNotFoundException cnfe)
          {
              throw new ScmException("Class " + propertyValue + " doesn't exists.", cnfe);
          }
          catch (InstantiationException ie)
          {
              throw new ScmException("Cannot load class " + propertyValue, ie);
          }
          catch (IllegalAccessException ie)
          {
              throw new ScmException("Illegal acces exception for class " + propertyValue,
ie);
          }
          catch(MissingResourceException me)
          {
              throw new ScmException("Missing Resource " + propertyName, me);
          }
      }
  }
  
  
  

Mime
View raw message