KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > axis > XMLResourceProvider


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: XMLResourceProvider.java,v 1.11.6.1 2005/03/02 14:19:53 tdiesler Exp $
9

10 package org.jboss.net.axis;
11
12 import org.jboss.axis.AxisEngine;
13 import org.jboss.axis.ConfigurationException;
14 import org.jboss.axis.configuration.FileProvider;
15 import org.jboss.axis.deployment.wsdd.WSDDGlobalConfiguration;
16 import org.jboss.axis.utils.XMLUtils;
17
18 import java.io.InputStream JavaDoc;
19 import java.net.URL JavaDoc;
20
21 /**
22  * <p>
23  * A <code>FileProvider</code> that sits on a given URL and
24  * that hosts classloader-aware deployment information.
25  * </p>
26  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
27  * @created 28. September 2001
28  * @version $Revision: 1.11.6.1 $
29  */

30
31 public class XMLResourceProvider extends FileProvider
32 {
33
34    //
35
// Attributes
36
//
37

38    /** the original resource that we host */
39    final protected URL JavaDoc resource;
40
41    /** input stream cache */
42    protected InputStream JavaDoc is;
43
44    /** the classloader that is used to interpret the deployment */
45    protected ClassLoader JavaDoc contextLoader;
46    
47    //
48
// Constructors
49
//
50

51    /**
52     * construct a new XmlResourceProvider
53     * @param resource url pointing to the deployment descriptor
54     */

55    public XMLResourceProvider(URL JavaDoc resource, ClassLoader JavaDoc loader)
56    {
57       super((InputStream JavaDoc)null);
58       this.contextLoader = loader;
59       this.resource = resource;
60    }
61
62    //
63
// Public API
64
//
65

66    /** override input stream setter to sync protected cache */
67    public void setInputStream(InputStream JavaDoc stream)
68    {
69       super.setInputStream(stream);
70       is = stream;
71    }
72
73    /** configures the given AxisEngine with the given descriptor */
74    public void configureEngine(AxisEngine engine) throws ConfigurationException
75    {
76       buildDeployment().configureEngine(engine);
77       engine.refreshGlobalOptions();
78    }
79
80    /** constructs a new deployment */
81    public synchronized Deployment buildDeployment()
82            throws ConfigurationException
83    {
84       if (getDeployment() == null)
85       {
86          try
87          {
88             if (is == null)
89             {
90                setInputStream(resource.openStream());
91             }
92
93             setDeployment(Deployment.makeSafeDeployment(XMLUtils.newDocument(is).getDocumentElement(),
94                     contextLoader));
95
96             setInputStream(null);
97
98             if (getDeployment().getGlobalConfiguration() == null)
99             {
100                WSDDGlobalConfiguration config = new WSDDGlobalConfiguration();
101                config.setOptionsHashtable(new java.util.Hashtable JavaDoc());
102                getDeployment().setGlobalConfiguration(config);
103             }
104
105          }
106          catch (Exception JavaDoc e)
107          {
108             throw new ConfigurationException(e);
109          }
110       }
111       return getMyDeployment();
112    }
113
114    /** returns out special deployment */
115    public Deployment getMyDeployment()
116    {
117       return (Deployment)getDeployment();
118    }
119
120    /** not supported, yet. Should we use http-push or what? */
121    public void writeEngineConfig(AxisEngine engine)
122    {
123       // NOOP
124
}
125
126 }
127
Popular Tags