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 public static EarModule newEarModule( Artifact artifact, String defaultLibBundleDir,
64 Boolean includeInApplicationXml )
65 throws UnknownArtifactTypeException
66 {
67
68 final String artifactType = ArtifactTypeMappingService.getInstance().getStandardType( artifact.getType() );
69
70 if ( "jar".equals( artifactType ) )
71 {
72 return new JarModule( artifact, defaultLibBundleDir, includeInApplicationXml );
73 }
74 else if ( "ejb".equals( artifactType ) )
75 {
76 return new EjbModule( artifact );
77 }
78 else if ( "ejb3".equals( artifactType ) )
79 {
80 return new Ejb3Module( artifact );
81 }
82 else if ( "par".equals( artifactType ) )
83 {
84 return new ParModule( artifact );
85 }
86 else if ( "ejb-client".equals( artifactType ) )
87 {
88 return new EjbClientModule( artifact, null );
89 }
90 else if ( "rar".equals( artifactType ) )
91 {
92 return new RarModule( artifact );
93 }
94 else if ( "war".equals( artifactType ) )
95 {
96 return new WebModule( artifact );
97 }
98 else if ( "sar".equals( artifactType ) )
99 {
100 return new SarModule( artifact );
101 }
102 else if ( "wsr".equals( artifactType ) )
103 {
104 return new WsrModule( artifact );
105 }
106 else if ( "har".equals( artifactType ) )
107 {
108 return new HarModule( artifact );
109 }
110 else
111 {
112 throw new IllegalStateException( "Could not handle artifact type[" + artifactType + "]" );
113 }
114 }
115
116
117
118
119
120
121 public static List getStandardArtifactTypes()
122 {
123 return standardArtifactTypes;
124 }
125
126
127
128
129
130
131
132
133 public static boolean isStandardArtifactType( final String type )
134 {
135 return standardArtifactTypes.contains( type );
136 }
137
138 }