1 | |
package org.apache.maven.plugin.ear; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.artifact.Artifact; |
23 | |
import org.apache.maven.plugin.ear.util.ArtifactTypeMappingService; |
24 | |
import org.apache.maven.plugin.ear.util.JavaEEVersion; |
25 | |
|
26 | |
import java.util.ArrayList; |
27 | |
import java.util.Collections; |
28 | |
import java.util.List; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public final class EarModuleFactory |
37 | |
{ |
38 | |
public static final List<String> standardArtifactTypes; |
39 | |
|
40 | |
static |
41 | |
{ |
42 | 1 | List<String> temp = new ArrayList<String>(); |
43 | 1 | temp.add( "jar" ); |
44 | 1 | temp.add( "ejb" ); |
45 | 1 | temp.add( "ejb3" ); |
46 | 1 | temp.add( "par" ); |
47 | 1 | temp.add( "ejb-client" ); |
48 | 1 | temp.add( "app-client" ); |
49 | 1 | temp.add( "rar" ); |
50 | 1 | temp.add( "war" ); |
51 | 1 | temp.add( "sar" ); |
52 | 1 | temp.add( "wsr" ); |
53 | 1 | temp.add( "har" ); |
54 | 1 | standardArtifactTypes = Collections.unmodifiableList( temp ); |
55 | 1 | } |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
@SuppressWarnings( "deprecation" ) |
71 | |
public static EarModule newEarModule( Artifact artifact, JavaEEVersion javaEEVersion, String defaultLibBundleDir, |
72 | |
Boolean includeInApplicationXml, |
73 | |
ArtifactTypeMappingService typeMappingService ) |
74 | |
throws UnknownArtifactTypeException |
75 | |
{ |
76 | |
|
77 | 0 | final String artifactType = typeMappingService.getStandardType( artifact.getType() ); |
78 | |
|
79 | 0 | if ( "jar".equals( artifactType ) ) |
80 | |
{ |
81 | 0 | return new JarModule( artifact, defaultLibBundleDir, includeInApplicationXml ); |
82 | |
} |
83 | 0 | else if ( "ejb".equals( artifactType ) ) |
84 | |
{ |
85 | 0 | return new EjbModule( artifact ); |
86 | |
} |
87 | 0 | else if ( "ejb3".equals( artifactType ) ) |
88 | |
{ |
89 | 0 | return new Ejb3Module( artifact ); |
90 | |
} |
91 | 0 | else if ( "par".equals( artifactType ) ) |
92 | |
{ |
93 | 0 | return new ParModule( artifact ); |
94 | |
} |
95 | 0 | else if ( "ejb-client".equals( artifactType ) ) |
96 | |
{ |
97 | |
|
98 | 0 | if ( javaEEVersion.le( JavaEEVersion.OneDotFour ) ) |
99 | |
{ |
100 | 0 | return new EjbClientModule( artifact, null ); |
101 | |
} |
102 | |
else |
103 | |
{ |
104 | 0 | return new EjbClientModule( artifact, defaultLibBundleDir ); |
105 | |
} |
106 | |
} |
107 | 0 | else if ( "app-client".equals( artifactType ) ) |
108 | |
{ |
109 | 0 | return new AppClientModule( artifact ); |
110 | |
} |
111 | 0 | else if ( "rar".equals( artifactType ) ) |
112 | |
{ |
113 | 0 | return new RarModule( artifact ); |
114 | |
} |
115 | 0 | else if ( "war".equals( artifactType ) ) |
116 | |
{ |
117 | 0 | return new WebModule( artifact ); |
118 | |
} |
119 | 0 | else if ( "sar".equals( artifactType ) ) |
120 | |
{ |
121 | 0 | return new SarModule( artifact ); |
122 | |
} |
123 | 0 | else if ( "wsr".equals( artifactType ) ) |
124 | |
{ |
125 | 0 | return new WsrModule( artifact ); |
126 | |
} |
127 | 0 | else if ( "har".equals( artifactType ) ) |
128 | |
{ |
129 | 0 | return new HarModule( artifact ); |
130 | |
} |
131 | |
else |
132 | |
{ |
133 | 0 | throw new IllegalStateException( "Could not handle artifact type[" + artifactType + "]" ); |
134 | |
} |
135 | |
} |
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
public static List<String> getStandardArtifactTypes() |
143 | |
{ |
144 | 18 | return standardArtifactTypes; |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
public static boolean isStandardArtifactType( final String type ) |
155 | |
{ |
156 | 52 | return standardArtifactTypes.contains( type ); |
157 | |
} |
158 | |
|
159 | |
} |