01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.source.impl;
18:
19: import org.apache.avalon.framework.logger.AbstractLogEnabled;
20: import org.apache.avalon.framework.service.ServiceException;
21: import org.apache.avalon.framework.service.ServiceManager;
22: import org.apache.avalon.framework.service.Serviceable;
23: import org.apache.avalon.framework.thread.ThreadSafe;
24:
25: import org.apache.excalibur.source.Source;
26: import org.apache.excalibur.source.SourceException;
27: import org.apache.excalibur.source.SourceFactory;
28:
29: import java.io.IOException;
30: import java.net.MalformedURLException;
31: import java.util.Map;
32:
33: /**
34: * A factory for 'blob:' sources.
35: *
36: * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
37: * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
38: * @version CVS $Id: BlobSourceFactory.java 433543 2006-08-22 06:22:54Z crossley $
39: */
40: public class BlobSourceFactory extends AbstractLogEnabled implements
41: Serviceable, SourceFactory, ThreadSafe {
42:
43: /** The ServiceManager instance */
44: protected ServiceManager manager;
45:
46: /**
47: * Get a <code>Source</code> object.
48: * @param parameters This is optional.
49: */
50: public Source getSource(String location, Map parameters)
51: throws MalformedURLException, IOException, SourceException {
52: BlobSource blob = new BlobSource(location);
53: this .setupLogger(blob);
54: blob.service(this .manager);
55: return blob;
56: }
57:
58: /**
59: * Release a {@link Source} object.
60: */
61: public void release(Source source) {
62: // Nothing to do
63: }
64:
65: /**
66: * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
67: */
68: public void service(ServiceManager manager) throws ServiceException {
69: this.manager = manager;
70: }
71:
72: }
|