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
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.List;
28
29
30
31
32
33
34
35 public final class EarModuleFactory
36 {
37 public final static List standardArtifactTypes;
38
39 static
40 {
41 List temp = new ArrayList();
42 temp.add( "jar" );
43 temp.add( "ejb" );
44 temp.add( "ejb3" );
45 temp.add( "par" );
46 temp.add( "ejb-client" );
47 temp.add( "rar" );
48 temp.add( "war" );
49 temp.add( "sar" );
50 temp.add( "wsr" );
51 temp.add( "har" );
52 standardArtifactTypes = Collections.unmodifiableList( temp );
53 }
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 public static EarModule newEarModule( Artifact artifact, String javaEEVersion, String defaultLibBundleDir,
69 Boolean includeInApplicationXml,
70 ArtifactTypeMappingService typeMappingService )
71 throws UnknownArtifactTypeException
72 {
73
74 final String artifactType = typeMappingService.getStandardType( artifact.getType() );
75
76 if ( "jar".equals( artifactType ) )
77 {
78 return new JarModule( artifact, defaultLibBundleDir, includeInApplicationXml );
79 }
80 else if ( "ejb".equals( artifactType ) )
81 {
82 return new EjbModule( artifact );
83 }
84 else if ( "ejb3".equals( artifactType ) )
85 {
86 return new Ejb3Module( artifact );
87 }
88 else if ( "par".equals( artifactType ) )
89 {
90 return new ParModule( artifact );
91 }
92 else if ( "ejb-client".equals( artifactType ) )
93 {
94
95 if ( AbstractEarMojo.VERSION_1_3.equals( javaEEVersion ) ||
96 AbstractEarMojo.VERSION_1_4.equals( javaEEVersion ) )
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 }