KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.cocoon.components.source.impl;
17
18 import org.apache.avalon.framework.context.Context;
19 import org.apache.avalon.framework.context.ContextException;
20 import org.apache.avalon.framework.context.Contextualizable;
21 import org.apache.avalon.framework.thread.ThreadSafe;
22 import org.apache.cocoon.components.ContextHelper;
23 import org.apache.excalibur.source.Source;
24 import org.apache.excalibur.source.SourceFactory;
25
26 import java.io.IOException JavaDoc;
27 import java.net.MalformedURLException JavaDoc;
28 import java.util.Map JavaDoc;
29
30 /**
31  * A factory for {@link org.apache.cocoon.servlet.multipart.Part} based sources (see {@link PartSource}).
32  *
33  * @author <a HREF="mailto:paul.crabtree@dna.co.uk">Paul Crabtree</a>
34  * @version $Id: PartSourceFactory.java 293304 2005-10-03 11:05:59Z sylvain $
35  */

36 public class PartSourceFactory implements SourceFactory, Contextualizable, ThreadSafe
37 {
38     Context context;
39     
40     /*
41      * Returns a new {@link PartSource} based on the uri.
42      *
43      * @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String, java.util.Map)
44      */

45     public Source getSource(String JavaDoc uri, Map JavaDoc parameters) throws IOException JavaDoc, MalformedURLException JavaDoc
46     {
47         Map JavaDoc objectModel = ContextHelper.getObjectModel(context);
48         return new PartSource(uri, objectModel);
49     }
50
51     /**
52      * Do nothing, {@link PartSource}s don't need to be released.
53      *
54      * @see org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
55      */

56     public void release(Source source)
57     {
58         // Nothing to do here
59
}
60
61     /**
62      * Get the objectModel from the Context
63      */

64     public void contextualize(org.apache.avalon.framework.context.Context context)
65     throws ContextException {
66          this.context = context;
67     }
68 }
69
Popular Tags