1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.struts.flow.core.source.impl;
18
19 import java.io.IOException;
20 import java.net.MalformedURLException;
21 import java.util.Map;
22
23 import org.apache.struts.flow.core.Factory;
24 import org.apache.struts.flow.core.Logger;
25
26 import org.apache.struts.flow.core.source.Source;
27 import org.apache.struts.flow.core.source.SourceException;
28 import org.apache.struts.flow.core.source.SourceFactory;
29
30 /***
31 * A factory for the Resource protocol
32 *
33 * @avalon.component
34 * @avalon.service type=SourceFactory
35 * @x-avalon.info name=resource-source
36 * @x-avalon.lifestyle type=singleton
37 *
38 * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
39 * @version $Id: ResourceSourceFactory.java,v 1.4 2004/02/28 11:47:24 cziegeler Exp $
40 */
41 public class ResourceSourceFactory implements SourceFactory
42 {
43 /***
44 * Get a {@link Source} object.
45 * The factory creates a new {@link Source} object that can be used
46 * by the application. However, when this source object is not needed
47 * anymore it has to be released again using the {@link #release(Source)}
48 * method.
49 *
50 * @param location The URI to resolve - this URI includes the protocol.
51 * @param parameters This is optional.
52 */
53 public Source getSource( String location, Map parameters )
54 throws MalformedURLException, IOException, SourceException
55 {
56 if( getLogger().isDebugEnabled() )
57 {
58 final String message = "Creating source object for " + location;
59 getLogger().debug( message );
60 }
61 return new ResourceSource( location );
62 }
63
64 /***
65 * Release a {@link Source} object.
66 */
67 public void release( Source source )
68 {
69 if( null != source && getLogger().isDebugEnabled() )
70 {
71 final String message = "Releasing source object for " + source.getURI();
72 getLogger().debug( message );
73 }
74
75 }
76
77 public Logger getLogger() {
78 return Factory.getLogger();
79 }
80
81 }