View Javadoc

1   package org.apache.maven.plugin.ear;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.plugin.ear.output.FileNameMapping;
23  import org.apache.maven.plugin.ear.output.FileNameMappingFactory;
24  import org.apache.maven.plugin.ear.util.ArtifactRepository;
25  import org.apache.maven.project.MavenProject;
26  
27  /**
28   * Contains various runtime parameters used to customize the generated EAR file.
29   *
30   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
31   * @version $Id: EarExecutionContext.java 522047 2007-03-24 16:09:22Z snicoll $
32   */
33  public class EarExecutionContext
34  {
35      private static final EarExecutionContext INSTANCE = new EarExecutionContext();
36  
37      public static EarExecutionContext getInstance()
38      {
39          return INSTANCE;
40      }
41  
42      // Singleton implementation
43  
44      private String defaultLibBundleDir;
45  
46      private JbossConfiguration jbossConfiguration;
47  
48      private FileNameMapping fileNameMapping;
49  
50      private ArtifactRepository artifactRepository;
51  
52  
53      private EarExecutionContext()
54      {
55  
56      }
57  
58      public String getDefaultLibBundleDir()
59      {
60          return defaultLibBundleDir;
61      }
62  
63      public JbossConfiguration getJbossConfiguration()
64      {
65          return jbossConfiguration;
66      }
67  
68      public boolean isJbossConfigured()
69      {
70          return jbossConfiguration != null;
71      }
72  
73      public FileNameMapping getFileNameMapping()
74      {
75          return fileNameMapping;
76      }
77  
78      public ArtifactRepository getArtifactRepository()
79      {
80          return artifactRepository;
81      }
82  
83      protected void initialize( MavenProject project, String mainArtifactId, String defaultLibBundleDir, JbossConfiguration jbossConfiguration,
84                                 String fileNameMappingName )
85      {
86          this.artifactRepository = new ArtifactRepository( project.getArtifacts(), mainArtifactId);
87          this.defaultLibBundleDir = defaultLibBundleDir;
88          this.jbossConfiguration = jbossConfiguration;
89          if ( fileNameMappingName == null || fileNameMappingName.trim().length() == 0 )
90          {
91              this.fileNameMapping = FileNameMappingFactory.INSTANCE.getDefaultFileNameMapping();
92          }
93          else
94          {
95              this.fileNameMapping = FileNameMappingFactory.INSTANCE.getFileNameMapping( fileNameMappingName );
96          }
97      }
98  }