KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > source > impl > ModuleSourceFactory


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.source.impl;
18
19 import java.io.IOException JavaDoc;
20 import java.net.MalformedURLException JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.apache.avalon.framework.context.Context;
24 import org.apache.avalon.framework.context.ContextException;
25 import org.apache.avalon.framework.context.Contextualizable;
26 import org.apache.avalon.framework.logger.AbstractLogEnabled;
27 import org.apache.avalon.framework.service.ServiceException;
28 import org.apache.avalon.framework.service.ServiceManager;
29 import org.apache.avalon.framework.service.Serviceable;
30 import org.apache.avalon.framework.thread.ThreadSafe;
31
32 import org.apache.excalibur.source.Source;
33 import org.apache.excalibur.source.SourceFactory;
34
35 import org.apache.cocoon.components.ContextHelper;
36
37 /**
38  * A factory for 'module:' sources (see {@link ModuleSource}).
39  *
40  * @author <a HREF="mailto:danielf@nada.kth.se">Daniel Fagerstrom</a>
41  */

42
43 public class ModuleSourceFactory extends AbstractLogEnabled
44   implements SourceFactory, Serviceable, Contextualizable, ThreadSafe {
45     
46     private ServiceManager manager;
47     private Context context;
48
49     /**
50      * Servicable Interface
51      */

52     public void service( ServiceManager manager ) throws ServiceException {
53         this.manager = manager;
54     }
55
56     /**
57      * Contextualizable, get the object model
58      */

59     public void contextualize( Context context ) throws ContextException {
60         this.context = context;
61     }
62     
63
64     /**
65      * Get a {@link ModuleSource} object.
66      *
67      * @param location The URI to resolve - this URI includes the scheme.
68      * @param parameters this is optional and not used here
69      */

70     public Source getSource( String JavaDoc location, Map JavaDoc parameters )
71         throws IOException JavaDoc, MalformedURLException JavaDoc {
72
73         Map JavaDoc objectModel = ContextHelper.getObjectModel( this.context );
74         return new ModuleSource( objectModel, location, this.manager, getLogger() );
75     }
76     
77     /**
78      * Release a {@link Source} object.
79      */

80     public void release( Source source ) {
81         // Do nothing here
82
}
83
84 }
85
Popular Tags