@Override protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping phm = new PropertyHandlerMapping() { @Override public XmlRpcHandler getHandler(String pHandlerName) throws XmlRpcNoSuchHandlerException, XmlRpcException { if (!pHandlerName.contains(".")) { return super.getHandler("default." + pHandlerName); } else { return super.getHandler(pHandlerName); } } }; phm.setRequestProcessorFactoryFactory(procfac); phm.addHandler("default", HomeMaticCalls.class); phm.addHandler("system", SystemCalls.class); phm.setVoidMethodEnabled(true); return phm; }
@Override protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); RequestProcessorFactoryFactory factory = new RequestSpecificProcessorFactoryFactory() { @Override protected Object getRequestProcessor(Class class1, XmlRpcRequest request) throws XmlRpcException { return super.getRequestProcessor(class1, request); } }; mapping.setRequestProcessorFactoryFactory(factory); mapping.load(Thread.currentThread().getContextClassLoader(), url); return mapping; } }
/** * Reads handler definitions from an existing Map. * @param pClassLoader The class loader being used to load * handler classes. * @param pMap The existing Map to read from * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, Map pMap) throws XmlRpcException { for (Iterator iter = pMap.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); Class c = newHandlerClass(pClassLoader, value); registerPublicMethods(key, c); } }
/** Creates a new instance of {@link PropertyHandlerMapping} by * loading the property file from the given URL. Called from * {@link #newXmlRpcHandlerMapping()}. */ protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); mapping.setAuthenticationHandler(authenticationHandler); if (requestProcessorFactoryFactory != null) { mapping.setRequestProcessorFactoryFactory(requestProcessorFactoryFactory); } if (typeConverterFactory != null) { mapping.setTypeConverterFactory(typeConverterFactory); } else { mapping.setTypeConverterFactory(server.getTypeConverterFactory()); } mapping.setVoidMethodEnabled(server.getConfig().isEnabledForExtensions()); mapping.load(Thread.currentThread().getContextClassLoader(), url); return mapping; }
/** * Adds an instance of this class to the given handler * mapping. */ public static void addSystemHandler(final PropertyHandlerMapping pMapping) throws XmlRpcException { final RequestProcessorFactoryFactory factory = pMapping.getRequestProcessorFactoryFactory(); final XmlRpcSystemImpl systemHandler = new XmlRpcSystemImpl(pMapping); pMapping.setRequestProcessorFactoryFactory(new RequestProcessorFactoryFactory(){ public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException { if (XmlRpcSystemImpl.class.equals(pClass)) { return new RequestProcessorFactory(){ public Object getRequestProcessor(XmlRpcRequest request) throws XmlRpcException { return systemHandler; } }; } else { return factory.getRequestProcessorFactory(pClass); } } }); pMapping.addHandler("system", XmlRpcSystemImpl.class); } }
PropertyHandlerMapping phm = new PropertyHandlerMapping(); phm.addHandler("WNSim", WNSim.class); phm.addHandler("WordNetPathSim", WordNetPathSim.class); phm.addHandler("WordSim", WordSim.class); phm.addHandler("Paraphrase", Paraphrase.class);
T instance) { org.apache.xmlrpc.server.XmlRpcServer xmlRpcServer = server.getXmlRpcServer(); PropertyHandlerMapping phm = new PropertyHandlerMapping(); phm.setRequestProcessorFactoryFactory(new NodeRequestProcessorFactoryFactory<T>(instance)); try { phm.addHandler("", instanceClass); } catch (XmlRpcException e) { throw new RosRuntimeException(e);
/** * Reads handler definitions from a property file. * @param pClassLoader The class loader being used to load * handler classes. * @param pURL The URL from which to load the property file * @throws IOException Loading the property file failed. * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, URL pURL) throws IOException, XmlRpcException { Properties props = new Properties(); props.load(pURL.openStream()); load(pClassLoader, props); }
/** Adds handlers for the given object to the mapping. * The handlers are build by invoking * {@link #registerPublicMethods(String, Class)}. * @param pKey The class key, which is passed * to {@link #registerPublicMethods(String, Class)}. * @param pClass Class, which is responsible for handling the request. */ public void addHandler(String pKey, Class pClass) throws XmlRpcException { registerPublicMethods(pKey, pClass); }
/** Creates a new instance of {@link PropertyHandlerMapping} by * loading the property file from the given URL. Called from * {@link #newXmlRpcHandlerMapping()}. */ protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); mapping.setAuthenticationHandler(authenticationHandler); if (requestProcessorFactoryFactory != null) { mapping.setRequestProcessorFactoryFactory(requestProcessorFactoryFactory); } if (typeConverterFactory != null) { mapping.setTypeConverterFactory(typeConverterFactory); } else { mapping.setTypeConverterFactory(server.getTypeConverterFactory()); } mapping.setVoidMethodEnabled(server.getConfig().isEnabledForExtensions()); mapping.load(Thread.currentThread().getContextClassLoader(), url); return mapping; }
/** * Adds an instance of this class to the given handler * mapping. */ public static void addSystemHandler(final PropertyHandlerMapping pMapping) throws XmlRpcException { final RequestProcessorFactoryFactory factory = pMapping.getRequestProcessorFactoryFactory(); final XmlRpcSystemImpl systemHandler = new XmlRpcSystemImpl(pMapping); pMapping.setRequestProcessorFactoryFactory(new RequestProcessorFactoryFactory(){ public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException { if (XmlRpcSystemImpl.class.equals(pClass)) { return new RequestProcessorFactory(){ public Object getRequestProcessor(XmlRpcRequest request) throws XmlRpcException { return systemHandler; } }; } else { return factory.getRequestProcessorFactory(pClass); } } }); pMapping.addHandler("system", XmlRpcSystemImpl.class); } }
public static void main(String[] args) { if (args.length != 1) System.err.println("Usage: ECServer port"); int port = (new Integer(args[0])).intValue(); try { System.out.println("Attempting to start XML-RPC Server..."); WebServer server = new WebServer(port); XmlRpcServer xmlRpcServer = server.getXmlRpcServer(); PropertyHandlerMapping phm = new PropertyHandlerMapping(); phm.addHandler("EntityComparison", EntityComparison.class); xmlRpcServer.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl)xmlRpcServer.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(false); server.start(); System.out.println("Started successfully."); System.out.println("Accepting requests. (Halt program to stop.)"); } catch (Exception exception) { System.err.println("ECServer: " + exception); } } }
/** * Reads handler definitions from a property file. * @param pClassLoader The class loader being used to load * handler classes. * @param pURL The URL from which to load the property file * @throws IOException Loading the property file failed. * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, URL pURL) throws IOException, XmlRpcException { Properties props = new Properties(); props.load(pURL.openStream()); load(pClassLoader, props); }
/** Adds handlers for the given object to the mapping. * The handlers are build by invoking * {@link #registerPublicMethods(String, Class)}. * @param pKey The class key, which is passed * to {@link #registerPublicMethods(String, Class)}. * @param pClass Class, which is responsible for handling the request. */ public void addHandler(String pKey, Class pClass) throws XmlRpcException { registerPublicMethods(pKey, pClass); }
/** * Adds an instance of this class to the given handler * mapping. */ public static void addSystemHandler(final PropertyHandlerMapping pMapping) throws XmlRpcException { final RequestProcessorFactoryFactory factory = pMapping.getRequestProcessorFactoryFactory(); final XmlRpcSystemImpl systemHandler = new XmlRpcSystemImpl(pMapping); pMapping.setRequestProcessorFactoryFactory(new RequestProcessorFactoryFactory(){ public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException { if (XmlRpcSystemImpl.class.equals(pClass)) { return new RequestProcessorFactory(){ public Object getRequestProcessor(XmlRpcRequest request) throws XmlRpcException { return systemHandler; } }; } else { return factory.getRequestProcessorFactory(pClass); } } }); pMapping.addHandler("system", XmlRpcSystemImpl.class); } }
public static void server(String indexDirectory, int port) throws IOException, XmlRpcException { log.info( "Starting descartes server at port {}, with index directory {}", Integer.valueOf(port), indexDirectory); DescartesServer.indexDirectory = indexDirectory; WebServer webServer = new WebServer(port); XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer(); PropertyHandlerMapping phm = new PropertyHandlerMapping(); phm.addHandler("DescartesServer", DescartesServer.class); xmlRpcServer.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer .getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(false); webServer.start(); log.info("Descartes is ready!"); }
/** * Reads handler definitions from an existing Map. * @param pClassLoader The class loader being used to load * handler classes. * @param pMap The existing Map to read from * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, Map pMap) throws XmlRpcException { for (Iterator iter = pMap.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); Class c = newHandlerClass(pClassLoader, value); registerPublicMethods(key, c); } }
/** * Reads handler definitions from a property file. * @param pClassLoader The class loader being used to load * handler classes. * @param pURL The URL from which to load the property file * @throws IOException Loading the property file failed. * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, URL pURL) throws IOException, XmlRpcException { Properties props = new Properties(); props.load(pURL.openStream()); load(pClassLoader, props); }
/** Adds handlers for the given object to the mapping. * The handlers are build by invoking * {@link #registerPublicMethods(String, Class)}. * @param pKey The class key, which is passed * to {@link #registerPublicMethods(String, Class)}. * @param pClass Class, which is responsible for handling the request. */ public void addHandler(String pKey, Class pClass) throws XmlRpcException { registerPublicMethods(pKey, pClass); }
/** * Reads handler definitions from an existing Map. * @param pClassLoader The class loader being used to load * handler classes. * @param pMap The existing Map to read from * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, Map pMap) throws XmlRpcException { for (Iterator iter = pMap.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); Class c = newHandlerClass(pClassLoader, value); registerPublicMethods(key, c); } }