View Javadoc

1   package org.apache.maven.ejb;
2   
3   /* ====================================================================
4    *   Copyright 2001-2005 The Apache Software Foundation.
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   * ====================================================================
18   */
19  
20  import org.apache.maven.MavenException;
21  import org.apache.maven.project.Project;
22  import org.apache.maven.repository.ArtifactTypeHandler;
23  
24  /***
25   *  This will do until wagon debuts.
26   * 
27   * @author <a href="mailto:havard@tracetracker.com">H?vard Bj?stad</a>
28   * @author <a href="mailto:vmassol@apache.org>Vincent Massol</a>
29   * @version $Id: EJBArtifactTypeHandler.java 232640 2005-08-14 20:46:54Z vmassol $
30   */
31  public class EJBArtifactTypeHandler implements ArtifactTypeHandler
32  {
33      /***
34       * Map an artifact to a repository directory path.
35       * 
36       * @param project the project for the artifact
37       * @param type  The type of the artifact 
38       * @return the path
39       */
40      public String constructRepositoryDirectoryPath(String type, Project project) throws MavenException
41      {
42          StringBuffer path = new StringBuffer();
43          path.append(project.getArtifactDirectory());
44          path.append("/ejbs/");
45          return path.toString();
46      }
47  
48      /***
49       * Map an artifact to a repository path.
50       * 
51       * @param project the project for the artifact
52       * @param type  The type of the artifact 
53       * @param version  The version of the artifact (may be a snapshot)
54       * @return the path
55       */
56      public String constructRepositoryFullPath(String type, Project project, String version) throws MavenException
57      {
58          StringBuffer path = new StringBuffer(constructRepositoryDirectoryPath(type, project));
59          path.append(project.getArtifactId());
60          path.append("-");
61          path.append(version);
62          
63          if ( type.equals( "ejb-client" ) ) {
64              path.append( "-client.jar" );
65          }
66          else if ( type.equals( "ejb" ) ) {
67              path.append(".jar");
68          }
69          else {
70              throw new MavenException("Unrecognised ejb type (is " + type + ")");
71          }
72  
73          return path.toString();
74      }
75  }