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