Created
September 10, 2014 10:53
-
-
Save yaniv691/eb9997f4a2da8efeedfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.xyz; | |
import java.io.IOException; | |
import javax.inject.Inject; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import org.apache.xmlrpc.server.XmlRpcHandlerMapping; | |
import org.apache.xmlrpc.server.XmlRpcServerConfig; | |
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; | |
import org.apache.xmlrpc.webserver.XmlRpcServletServer; | |
import org.springframework.web.context.support.SpringBeanAutowiringSupport; | |
/** | |
* @author elad | |
*/ | |
public class MyServlet extends HttpServlet { | |
private static final long serialVersionUID = 1L; | |
private XmlRpcServletServer server; | |
@Inject | |
private HandlerRegistrator registrator; | |
@Override | |
public void init() throws ServletException { | |
super.init(); | |
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this); | |
setup(); | |
} | |
private void setup() { | |
server = new XmlRpcServletServer(); | |
setupHandlers(); | |
setupConfig(); | |
} | |
private void setupHandlers() { | |
XmlRpcHandlerMapping mapping = registrator.getMapping(); | |
server.setHandlerMapping(mapping); | |
} | |
private void setupConfig() { | |
XmlRpcServerConfig pConfig = createConfig(); | |
server.setConfig(pConfig); | |
} | |
private XmlRpcServerConfig createConfig() { | |
XmlRpcServerConfigImpl config = new XmlRpcServerConfigImpl(); | |
config.setEnabledForExtensions(true); | |
return config; | |
} | |
@Override | |
public void doPost(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException, ServletException { | |
server.execute(pRequest, pResponse); | |
} | |
@Override | |
public void log(String pMessage, Throwable pThrowable) { | |
server.getErrorLogger().log(pMessage, pThrowable); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment