1 | |
package org.apache.maven.plugin.ear.output; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public class FileNameMappingFactory |
35 | |
{ |
36 | |
static final String STANDARD_FILE_NAME_MAPPING = "standard"; |
37 | |
|
38 | |
static final String FULL_FILE_NAME_MAPPING = "full"; |
39 | |
|
40 | |
static final String NO_VERSION_FILE_NAME_MAPPING = "no-version"; |
41 | |
|
42 | |
static final String NO_VERSION_FOR_EJB_FILE_NAME_MAPPING = "no-version-for-ejb"; |
43 | |
|
44 | |
private FileNameMappingFactory() |
45 | 0 | { |
46 | 0 | } |
47 | |
|
48 | |
public static FileNameMapping getDefaultFileNameMapping() |
49 | |
{ |
50 | 4 | return new StandardFileNameMapping(); |
51 | |
} |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
public static FileNameMapping getFileNameMapping( final String nameOrClass ) |
62 | |
throws IllegalStateException |
63 | |
{ |
64 | 14 | if ( STANDARD_FILE_NAME_MAPPING.equals( nameOrClass ) ) |
65 | |
{ |
66 | 2 | return getDefaultFileNameMapping(); |
67 | |
} |
68 | 12 | if ( FULL_FILE_NAME_MAPPING.equals( nameOrClass ) ) |
69 | |
{ |
70 | 2 | return new FullFileNameMapping(); |
71 | |
} |
72 | 10 | if ( NO_VERSION_FILE_NAME_MAPPING.equals( nameOrClass ) ) |
73 | |
{ |
74 | 2 | return new NoVersionFileNameMapping(); |
75 | |
} |
76 | 8 | if ( NO_VERSION_FOR_EJB_FILE_NAME_MAPPING.equals( nameOrClass ) ) |
77 | |
{ |
78 | 2 | return new NoVersionForEjbFileNameMapping(); |
79 | |
} |
80 | |
try |
81 | |
{ |
82 | 6 | final Class<?> c = Class.forName( nameOrClass ); |
83 | 4 | return (FileNameMapping) c.newInstance(); |
84 | |
} |
85 | 2 | catch ( ClassNotFoundException e ) |
86 | |
{ |
87 | 2 | throw new IllegalStateException( |
88 | |
"File name mapping implementation[" + nameOrClass + "] was not found " + e.getMessage() ); |
89 | |
} |
90 | 0 | catch ( InstantiationException e ) |
91 | |
{ |
92 | 0 | throw new IllegalStateException( "Could not instantiate file name mapping implementation[" + nameOrClass + |
93 | |
"] make sure it has a default public constructor" ); |
94 | |
} |
95 | 0 | catch ( IllegalAccessException e ) |
96 | |
{ |
97 | 0 | throw new IllegalStateException( "Could not access file name mapping implementation[" + nameOrClass + |
98 | |
"] make sure it has a default public constructor" ); |
99 | |
} |
100 | 0 | catch ( ClassCastException e ) |
101 | |
{ |
102 | 0 | throw new IllegalStateException( |
103 | |
"Specified class[" + nameOrClass + "] does not implement[" + FileNameMapping.class.getName() + "]" ); |
104 | |
} |
105 | |
} |
106 | |
} |