Reuse the DeploymentConfiguration

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1397423 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rfeng 2012-10-12 03:33:53 +00:00
parent f592a6e211
commit 0837d8e9ec

View file

@ -132,6 +132,11 @@ public class TuscanyRESTServlet extends RestServlet {
public DeploymentConfiguration getDeploymentConfiguration() throws ClassNotFoundException, InstantiationException,
IllegalAccessException, IOException {
DeploymentConfiguration config =
(DeploymentConfiguration)getServletContext().getAttribute(DeploymentConfiguration.class.getName());
if (config != null) {
return config;
}
// setup proper classLoader to work on OSGi environment
ClassLoader cl =
@ -141,9 +146,9 @@ public class TuscanyRESTServlet extends RestServlet {
"/META-INF/wink-alternate-shortcuts.properties",
"/META-INF/server/wink-providers");
DeploymentConfiguration config = null;
try {
config = super.getDeploymentConfiguration();
getServletContext().setAttribute(DeploymentConfiguration.class.getName(), config);
} finally {
if (cl != null) {
// return previous classLoader
@ -155,19 +160,19 @@ public class TuscanyRESTServlet extends RestServlet {
config.setFilterConfig(new FilterConfig() {
public ServletContext getServletContext() {
return getServletContext();
return TuscanyRESTServlet.this.getServletContext();
}
public Enumeration getInitParameterNames() {
return getInitParameterNames();
return TuscanyRESTServlet.this.getInitParameterNames();
}
public String getInitParameter(String arg0) {
return getInitParameter(arg0);
public String getInitParameter(String p) {
return TuscanyRESTServlet.this.getInitParameter(p);
}
public String getFilterName() {
return getServletName();
return TuscanyRESTServlet.this.getServletName();
}
});