Hi Amila, Thanks for the reply. The article explain how to write a custom deployer but the Deployer interface in Axis2 assume that services will be loaded from the file system (and thus are binded to a file extension). I think this assumtion is right in most case but Axis should also support deployer that have their own persistence mecanism (a database for example).
Also, my biggest problem is not really the deployer. In fact, I already sublassed the AxisServlet to load my services when the servlet is initialized. My biggest problem is with the AxisConfigurator. Did you looked at the NullPointerException I get when using loadFromClassPath? Again, thank you for your time. Manuel On Fri, Nov 7, 2008 at 4:44 AM, Amila Suriarachchi < [EMAIL PROTECTED]> wrote: > > > On Fri, Nov 7, 2008 at 4:01 AM, Manuel Darveau <[EMAIL PROTECTED]>wrote: > >> 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. > > > If you can keep Axis2.xml and modules in the file system, and only to load > the services from the Database you can use a custom deployer[1]. > Custom deployers gives you the configuration context object using which you > can do any thing. You can register a custom deployer with some extension > into some folder. > e.g service.ds > This file may contain user name password details to database. Then at the > deploy method you can extract the data from the database and add services. > > thanks, > Amila. > > > [1] http://wso2.org/library/3708 > >> >> >> 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 >> > > > > -- > Amila Suriarachchi > WSO2 Inc. > blog: http://amilachinthaka.blogspot.com/ >
