public void init() throws ServletException {
super.init();
}
public void init(ServletConfig servletConfig) throws ServletException {
ServerManager serverManager = ServerManager.getInstance();
ServletContext servletContext = servletConfig.getServletContext();
if ("true".equals(servletContext.getAttribute("hasAlreadyInit"))) {
return;
}
String synapseHome = resolveSynapseHome(servletConfig);
//Setting the all required system properties
if (synapseHome != null) {
if (synapseHome.endsWith("/")) {
synapseHome = synapseHome.substring(0, synapseHome.lastIndexOf("/"));
}
System.setProperty(SynapseConstants.SYNAPSE_HOME, synapseHome);
//setting axis2 repository location
String axis2Repo = System.getProperty(org.apache.axis2.Constants.AXIS2_REPO);
if (axis2Repo == null) {
ServerManager.getInstance().setAxis2Repolocation(synapseHome + "/WEB-INF" +
File.separator + "repository");
System.setProperty(org.apache.axis2.Constants.AXIS2_REPO,
synapseHome + "/WEB-INF" +
File.separator + "repository");
}
//setting axis2 configuration location
String axis2Xml = System.getProperty(org.apache.axis2.Constants.AXIS2_CONF);
if (axis2Xml == null) {
System.setProperty(org.apache.axis2.Constants.AXIS2_CONF,
synapseHome + File.separator
+ "WEB-INF/conf"
+ File.separator + org.apache.axis2.Constants.AXIS2_CONF);
}
//setting synapse configuration location
String synapseXml = System.getProperty(org.apache.synapse.SynapseConstants.SYNAPSE_XML);
if (synapseXml == null) {
System.setProperty(org.apache.synapse.SynapseConstants.SYNAPSE_XML,
synapseHome + File.separator
+ "WEB-INF/conf"
+ File.separator + org.apache.synapse.SynapseConstants.SYNAPSE_XML);
}
} else {
log.fatal("Can not resolve synapse home : startup failed");
return;
}
serverManager.start();
servletContext.setAttribute("hasAlreadyInit", "true");
}