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