//To store the context path
private String contextRoot = null;
public void init(final ServletConfig config) throws ServletException {
super.init(config);
EmbeddedRegistryService embeddedRegistryService;
try {
// read the registry.xml file from the configured location. if not configured, read the
// default registry.xml file bundled with the webapp.
String configPath = config.getInitParameter(RegistryConstants.REGISTRY_CONFIG_PATH);
InputStream configStream;
if (configPath != null) {
try {
configStream = new FileInputStream(configPath);
} catch (FileNotFoundException e) {
throw new ServletException("Couldn't find specified config file '" +
configPath + "'", e);
}
} else {
configStream =
config.getServletContext().getResourceAsStream("/WEB-INF/registry.xml");
}
RegistryContext registryContext = RegistryContext.getBaseInstance(configStream,
new RegistryContext.RegURLSupplier() {
public String getURL() {
return config.getServletContext().getRealPath("/WEB-INF");
}
});
embeddedRegistryService = registryContext.getEmbeddedRegistryService();
// create a system registry and put it in the context
UserRegistry systemRegistry = embeddedRegistryService.getConfigSystemRegistry();
// add configured handers to the jdbc registry
// note: no need to do this here. this is done inside the registry context
//Iterator<HandlerConfiguration> handlers =
// registryContext.getHandlerConfigurations().iterator();