24
24
* SOFTWARE.
25
25
*/
26
26
27
- import org .codehaus .plexus .component .annotations .Component ;
28
- import org .codehaus .plexus .component .annotations .Requirement ;
29
27
30
28
import org .codehaus .plexus .resource .loader .FileResourceCreationException ;
31
29
import org .codehaus .plexus .resource .loader .ResourceIOException ;
42
40
import java .io .InputStream ;
43
41
import java .io .OutputStream ;
44
42
import java .util .Map ;
43
+ import javax .inject .Inject ;
44
+ import javax .inject .Named ;
45
45
46
46
/**
47
47
* @author <a href="mailto:[email protected] ">Trygve Laugstøl</a>
48
48
* @author Jason van Zyl
49
49
* @version $Id$
50
50
*/
51
- @ Component ( role = ResourceManager . class , instantiationStrategy = "per-lookup" )
51
+ @ Named
52
52
public class DefaultResourceManager implements ResourceManager
53
53
{
54
54
private static final Logger LOGGER = LoggerFactory .getLogger ( DefaultResourceManager .class );
55
55
56
- @ Requirement ( role = ResourceLoader .class )
57
- private Map <String , ResourceLoader > resourceLoaders ;
56
+ private final Map <String , ResourceLoader > resourceLoaders ;
58
57
59
58
private File outputDirectory ;
60
59
60
+ @ Inject
61
+ private DefaultResourceManager ( Map <String , ResourceLoader > resourceLoaders )
62
+ {
63
+ this .resourceLoaders = resourceLoaders ;
64
+ }
65
+
61
66
// ----------------------------------------------------------------------
62
67
// ResourceManager Implementation
63
68
// ----------------------------------------------------------------------
64
69
65
70
public InputStream getResourceAsInputStream ( String name )
66
- throws ResourceNotFoundException
71
+ throws ResourceNotFoundException
67
72
{
68
73
PlexusResource resource = getResource ( name );
69
74
try
@@ -77,13 +82,13 @@ public InputStream getResourceAsInputStream( String name )
77
82
}
78
83
79
84
public File getResourceAsFile ( String name )
80
- throws ResourceNotFoundException , FileResourceCreationException
85
+ throws ResourceNotFoundException , FileResourceCreationException
81
86
{
82
87
return getResourceAsFile ( getResource ( name ) );
83
88
}
84
89
85
90
public File getResourceAsFile ( String name , String outputPath )
86
- throws ResourceNotFoundException , FileResourceCreationException
91
+ throws ResourceNotFoundException , FileResourceCreationException
87
92
{
88
93
if ( outputPath == null )
89
94
{
@@ -104,7 +109,7 @@ public File getResourceAsFile( String name, String outputPath )
104
109
}
105
110
106
111
public File resolveLocation ( String name , String outputPath )
107
- throws IOException
112
+ throws IOException
108
113
{
109
114
// Honour what the original locator does and return null ...
110
115
try
@@ -118,7 +123,7 @@ public File resolveLocation( String name, String outputPath )
118
123
}
119
124
120
125
public File resolveLocation ( String name )
121
- throws IOException
126
+ throws IOException
122
127
{
123
128
// Honour what the original locator does and return null ...
124
129
try
@@ -149,7 +154,7 @@ public void addSearchPath( String id, String path )
149
154
}
150
155
151
156
public PlexusResource getResource ( String name )
152
- throws ResourceNotFoundException
157
+ throws ResourceNotFoundException
153
158
{
154
159
for ( ResourceLoader resourceLoader : resourceLoaders .values () )
155
160
{
@@ -164,15 +169,15 @@ public PlexusResource getResource( String name )
164
169
catch ( ResourceNotFoundException e )
165
170
{
166
171
LOGGER .debug ( "The resource '{}' was not found with resourceLoader '{}'" ,
167
- name , resourceLoader .getClass ().getName () );
172
+ name , resourceLoader .getClass ().getName () );
168
173
}
169
174
}
170
175
171
176
throw new ResourceNotFoundException ( name );
172
177
}
173
178
174
179
public File getResourceAsFile ( PlexusResource resource )
175
- throws FileResourceCreationException
180
+ throws FileResourceCreationException
176
181
{
177
182
try
178
183
{
@@ -194,7 +199,7 @@ public File getResourceAsFile( PlexusResource resource )
194
199
}
195
200
196
201
public void createResourceAsFile ( PlexusResource resource , File outputFile )
197
- throws FileResourceCreationException
202
+ throws FileResourceCreationException
198
203
{
199
204
InputStream is = null ;
200
205
OutputStream os = null ;
0 commit comments