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 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.commons.collections.CollectionUtils;
23  import org.apache.maven.artifact.Artifact;
24  import org.codehaus.mojo.webstart.JnlpConfig;
25  import org.codehaus.mojo.webstart.JnlpExtension;
26  import org.codehaus.mojo.webstart.dependency.filenaming.DependencyFilenameStrategy;
27  
28  import java.util.Collection;
29  import java.util.List;
30  import java.util.Map;
31  
32  /**
33   * configuration of {@link Generator}.
34   * <p/>
35   * Created on 1/5/14.
36   *
37   * @author Tony Chemit <chemit@codelutin.com>
38   * @since 1.0-beta-5
39   */
40  public class GeneratorConfig
41      extends AbstractGeneratorExtraConfigWithDeps
42  {
43  
44      private final Collection<Artifact> packagedJnlpArtifacts;
45  
46      private final List<JnlpExtension> jnlpExtensions;
47  
48      private final String codebase;
49  
50      private final JnlpConfig jnlp;
51  
52      public GeneratorConfig( String libPath, boolean pack200, boolean outputJarVersions, 
53      		                boolean useUniqueVersions, Artifact artifactWithMainClass,
54                              DependencyFilenameStrategy dependencyFilenameStrategy,
55                              Collection<Artifact> packagedJnlpArtifacts, List<JnlpExtension> jnlpExtensions,
56                              String codebase, JnlpConfig jnlp )
57      {
58          super( libPath, pack200, outputJarVersions, useUniqueVersions, artifactWithMainClass, dependencyFilenameStrategy );
59  
60          this.packagedJnlpArtifacts = packagedJnlpArtifacts;
61          this.jnlpExtensions = jnlpExtensions;
62          this.codebase = codebase;
63          this.jnlp = jnlp;
64      }
65  
66      /**
67       * {@inheritDoc}
68       */
69      public Collection<Artifact> getPackagedJnlpArtifacts()
70      {
71          return packagedJnlpArtifacts;
72      }
73  
74      public List<JnlpExtension> getJnlpExtensions()
75      {
76          return jnlpExtensions;
77      }
78  
79      public boolean hasJnlpExtensions()
80      {
81          return CollectionUtils.isNotEmpty( jnlpExtensions );
82      }
83  
84      /**
85       * {@inheritDoc}
86       */
87      public String getJnlpSpec()
88      {
89          // shouldn't we automatically identify the spec based on the features used in the spec?
90          // also detect conflicts. If user specified 1.0 but uses a 1.5 feature we should fail in checkInput().
91          if ( jnlp.getSpec() != null )
92          {
93              return jnlp.getSpec();
94          }
95          return "1.0+";
96      }
97  
98      /**
99       * {@inheritDoc}
100      */
101     public String getOfflineAllowed()
102     {
103         if ( jnlp.getOfflineAllowed() != null )
104         {
105             return jnlp.getOfflineAllowed();
106         }
107         return "false";
108     }
109 
110     /**
111      * {@inheritDoc}
112      */
113     public String getAllPermissions()
114     {
115         if ( jnlp.getAllPermissions() != null )
116         {
117             return jnlp.getAllPermissions();
118         }
119         return "true";
120     }
121 
122     /**
123      * {@inheritDoc}
124      */
125     public String getJ2seVersion()
126     {
127         if ( jnlp.getJ2seVersion() != null )
128         {
129             return jnlp.getJ2seVersion();
130         }
131         return "1.5+";
132     }
133 
134     /**
135      * {@inheritDoc}
136      */
137     public String getJnlpCodeBase()
138     {
139         return codebase;
140     }
141 
142     /**
143      * {@inheritDoc}
144      */
145     public Map<String, String> getProperties()
146     {
147         return jnlp.getProperties();
148     }
149 }