Hi,
I am trying to write a custom Configurator since my deployment is a bit
special.
I don't want to rely on file system at all. My axis configuration will be
comming from a database and I want to load services programatically. All
service classes will already be in the classpath and the list of service
will be dynamic and controlled by a remote interface.
I created a MemoryAxisServlet since everything will be deployed in embedded
Jetty:
public class MemoryAxisServlet extends AxisServlet{
protected ConfigurationContext initConfigContext(ServletConfig config)
throws ServletException {
ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContext(new
MemoryAxisConfigurator());
configContext.setProperty(Constants.CONTAINER_MANAGED,
Constants.VALUE_TRUE);
return configContext;
}
}
public class MemoryAxisConfigurator extends DeploymentEngine{
public MemoryAxisConfigurator(){
InputStream in = ...;
populateAxisConfiguration(in);
}
public void engageGlobalModules() throws AxisFault {
engageModules();
}
public AxisConfiguration getAxisConfiguration() throws AxisFault {
// Load modules from classpath
loadFromClassPath();
axisConfig.setConfigurator(this);
return axisConfig;
}
public void setConfigContext(ConfigurationContext configContext) {
// setting ServletContext into configctx
configContext.setProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT,
config.getServletContext());
// TODO Is this property really needed?
try {
Parameter servletConfigParam = new Parameter();
servletConfigParam.setName(HTTPConstants.HTTP_SERVLETCONFIG);
servletConfigParam.setValue(config);
configContext.getAxisConfiguration().addParameter(servletConfigParam);
} catch (AxisFault axisFault) {
log.error(axisFault.getMessage(), axisFault);
}
super.setConfigContext(configContext);
}
}
My problem is that I get a:
java.lang.NullPointerException
at
org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:131)
at
org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:82)
at
com.eightd.ftk.webservices.MemoryAxisServlet.initConfigContext(MemoryAxisServlet.java:70)
... 15 more
It seems that since I am using loadFromClassPath() in
getAxisConfiguration(), the repoListener variable is not set (in
DeploymentEngine) like it would be when using loadRepository(String
repoDir).
Does "new RepositoryListener(this, true);" in loadFromClassPath() should
simply be replaced by "repoListener = new RepositoryListener(this, true);"?
What about loadServicesFromUrl(), it does not even create a
RepositoryListener.
In the mean time, I can overridein my MemoryConfigurator loadServices() to
do nothing but I am not sure if I will have some side effects.
Thank you!
BTW, if you have a better solution for my context, I would be glad to hear
it!
Manuel