View Javadoc
1   package org.codehaus.mojo.webstart.generator;
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 work for additional information
7    * regarding copyright ownership.  The ASF licenses file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use 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.artifact.Artifact;
23  import org.codehaus.mojo.webstart.JnlpExtension;
24  import org.codehaus.mojo.webstart.dependency.filenaming.DependencyFilenameStrategy;
25  
26  import java.util.Collections;
27  import java.util.List;
28  import java.util.Map;
29  
30  /**
31   * Created on 1/6/14.
32   *
33   * @author Tony Chemit <chemit@codelutin.com>
34   * @since 1.0-beta-5
35   */
36  public class ExtensionGeneratorConfig
37      extends AbstractGeneratorExtraConfigWithDeps
38  {
39  
40      private final Map<JnlpExtension, List<Artifact>> extensionsJnlpArtifacts;
41  
42      private final JnlpExtension extension;
43  
44      private final String codebase;
45  
46      public ExtensionGeneratorConfig( String libPath, boolean pack200, boolean outputJarVersions,
47      		                         boolean useUniqueVersions, Artifact artifactWithMainClass,
48                                       DependencyFilenameStrategy dependencyFilenameStrategy,
49                                       Map<JnlpExtension, List<Artifact>> extensionsJnlpArtifacts, String codebase,
50                                       JnlpExtension extension )
51      {
52          super( libPath, pack200, outputJarVersions, useUniqueVersions, artifactWithMainClass, dependencyFilenameStrategy );
53          this.extensionsJnlpArtifacts = extensionsJnlpArtifacts;
54          this.extension = extension;
55          this.codebase = codebase;
56      }
57  
58      public JnlpExtension getExtension()
59      {
60          return extension;
61      }
62  
63      public String getCodebase()
64      {
65          return codebase;
66      }
67  
68      public List<Artifact> getExtensionJnlpArtifacts( JnlpExtension extension )
69      {
70          return extensionsJnlpArtifacts.get( extension );
71      }
72  
73      /**
74       * {@inheritDoc}
75       */
76      public String getJnlpSpec()
77      {
78          // shouldn't we automatically identify the spec based on the features used in the spec?
79          // also detect conflicts. If user specified 1.0 but uses a 1.5 feature we should fail in checkInput().
80          if ( extension.getSpec() != null )
81          {
82              return extension.getSpec();
83          }
84          return "1.0+";
85      }
86  
87      /**
88       * {@inheritDoc}
89       */
90      public String getOfflineAllowed()
91      {
92          if ( extension.getOfflineAllowed() != null )
93          {
94              return extension.getOfflineAllowed();
95          }
96          return "false";
97      }
98  
99      /**
100      * {@inheritDoc}
101      */
102     public String getAllPermissions()
103     {
104         if ( extension.getAllPermissions() != null )
105         {
106             return extension.getAllPermissions();
107         }
108         return "true";
109     }
110 
111     /**
112      * {@inheritDoc}
113      */
114     public String getJ2seVersion()
115     {
116         if ( extension.getJ2seVersion() != null )
117         {
118             return extension.getJ2seVersion();
119         }
120         return "1.5+";
121     }
122 
123     /**
124      * {@inheritDoc}
125      */
126     public String getJnlpCodeBase()
127     {
128         return codebase;
129     }
130 
131     /**
132      * {@inheritDoc}
133      */
134     public Map<String, String> getProperties()
135     {
136         return Collections.emptyMap();
137     }
138 }