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