--- /dev/null
+
+
+export M2_HOME=/opt/maven/apache-maven-3.1.1
+PATH=$M2_HOME/bin:$PATH
+PATH=/opt/java/jdk1.7.0_51/bin:$PATH
+
+mvn clean install -Dmaven.test.skip=true
+
+mvn jetty:run
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>remote-agents</artifactId>
+ <groupId>de.remote.agents</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>remote-agents-batchapp</artifactId>
+ <name>remote-agents-batchapp</name>
+ <url>http://gumartinm.name</url>
+ <properties>
+ <jetty.version>9.1.1.v20140108</jetty.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>de.remote.agents</groupId>
+ <artifactId>remote-agents-services-interfaces</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>de.remote.agents</groupId>
+ <artifactId>remote-agents-services-implementation</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.ws</groupId>
+ <artifactId>spring-ws-core</artifactId>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-web-api</artifactId>
+ <version>7.0</version>
+ <scope>provided</scope>
+ </dependency>
+ -->
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>${jetty.version}</version>
+ <configuration>
+ <jettyXml>${basedir}/src/main/jetty/jetty-http.xml</jettyXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
--- /dev/null
+package de.remote.agents.batch.app;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.log4j.Logger;
+
+public class BatchAppMain {
+ private static final Logger logger = Logger.getLogger(BatchAppMain.class);
+
+ @PostConstruct
+ public void batchAppMain() {
+ logger.info("GI JOE!");
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
+
+<!-- ============================================================= -->
+<!-- Configure the Jetty Server instance with an ID "Server" -->
+<!-- by adding a HTTP connector. -->
+<!-- This configuration must be used in conjunction with jetty.xml -->
+<!-- ============================================================= -->
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+ <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
+ <Set name="secureScheme">https</Set>
+ <Set name="securePort">
+ <Property name="jetty.secure.port" default="8443" />
+ </Set>
+ <Set name="outputBufferSize">32768</Set>
+ <Set name="requestHeaderSize">8192</Set>
+ <Set name="responseHeaderSize">8192</Set>
+ <Set name="sendServerVersion">true</Set>
+ <Set name="sendDateHeader">false</Set>
+ <Set name="headerCacheSize">512</Set>
+
+ <!-- Uncomment to enable handling of X-Forwarded- style headers
+ <Call name="addCustomizer">
+ <Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
+ </Call>
+ -->
+ </New>
+
+
+ <!-- =========================================================== -->
+ <!-- Add a HTTP Connector. -->
+ <!-- Configure an o.e.j.server.ServerConnector with a single -->
+ <!-- HttpConnectionFactory instance using the common httpConfig -->
+ <!-- instance defined in jetty.xml -->
+ <!-- -->
+ <!-- Consult the javadoc of o.e.j.server.ServerConnector and -->
+ <!-- o.e.j.server.HttpConnectionFactory for all configuration -->
+ <!-- that may be set here. -->
+ <!-- =========================================================== -->
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.eclipse.jetty.server.ServerConnector">
+ <Arg name="server">
+ <Ref refid="Server" />
+ </Arg>
+ <Arg name="factories">
+ <Array type="org.eclipse.jetty.server.ConnectionFactory">
+ <Item>
+ <New class="org.eclipse.jetty.server.HttpConnectionFactory">
+ <Arg name="config">
+ <Ref refid="httpConfig" />
+ </Arg>
+ </New>
+ </Item>
+ </Array>
+ </Arg>
+ <Set name="host">
+ <Property name="jetty.host" default="127.0.0.1"/>
+ </Set>
+ <Set name="port">
+ <Property name="jetty.port" default="8080" />
+ </Set>
+ <Set name="idleTimeout">
+ <Property name="http.timeout" default="30000"/>
+ </Set>
+ </New>
+ </Arg>
+ </Call>
+
+</Configure>
--- /dev/null
+log4j.rootLogger=INFO, stdout
+log4j.logger.org.springframework.ws=INFO
+log4j.logger.org.springframework.xml=INFO
+log4j.logger.de.spring.webservices=INFO
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyyMMddHHmmssSSS} - %-5p - [%t] - [%C] - %m%n
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.2.xsd">
+
+
+ <context:annotation-config/>
+
+ <bean id="message" class="de.remote.agents.batch.app.BatchAppMain">
+
+ </bean>
+
+</beans>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:sws="http://www.springframework.org/schema/web-services"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.2.xsd
+ http://www.springframework.org/schema/web-services
+ http://www.springframework.org/schema/web-services/web-services-2.0.xsd">
+
+
+ <import resource="classpath:service-spring.xml"/>
+
+ <bean name="/UserService.json" class="com.googlecode.jsonrpc4j.spring.JsonServiceExporter">
+ <property name="service" ref="userService"/>
+ <property name="serviceInterface" value="de.remote.agents.services.UserService"/>
+ </bean>
+
+</beans>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <display-name>Remote Agents: batch application</display-name>
+
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>spring-mainapp</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>spring-mainapp</servlet-name>
+ <url-pattern>/spring-mainapp/*</url-pattern>
+ </servlet-mapping>
+
+
+</web-app>
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>remote-agents</artifactId>
+ <groupId>de.remote.agents</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>remote-agents-clients</artifactId>
+ <name>remote-agents-clients</name>
+ <url>http://gumartinm.name</url>
+ <dependencies>
+ <dependency>
+ <groupId>com.github.briandilley.jsonrpc4j</groupId>
+ <artifactId>jsonrpc4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>de.remote.agents</groupId>
+ <artifactId>remote-agents-services-interfaces</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>de.remote.agents</groupId>
+ <artifactId>remote-agents-services-implementation</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package de.remote.agents.clients.app;
+
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
+
+import de.remote.agents.SnakeEyes;
+import de.remote.agents.SnakeEyesImpl;
+
+public class ClientsMainTest {
+ private static final Logger logger = Logger.getLogger(ClientsMainTest.class);
+
+ public static void main(final String[] args) throws Throwable {
+
+ final JsonRpcHttpClient client = new JsonRpcHttpClient(new URL(
+ "http://127.0.0.1:8080/spring-mainapp/UserService.json"));
+
+ final SnakeEyes user = client.invoke("createUser", new Object[] {
+ "Shana M. O'Hara", "Snake Eyes" }, SnakeEyesImpl.class);
+
+ logger.info("Canon: " + user.getCanon());
+ logger.info("Name: " + user.getName());
+
+
+ // I need a way to set the return type parameter, otherwise I am not
+ // going to be able to use this JSON-RPC plugin :(
+
+ // logger.info("Starting application");
+ // SpringContextLocator.getInstance();
+ //
+ // final UserService test = (UserService) SpringContextLocator
+ // .getInstance().getBean("remoteUserService");
+ //
+ // final SnakeEyes snakeEyes = test.createUser("Shana M. O'Hara",
+ // "Snake Eyes");
+ //
+ // logger.info("Canon: " + snakeEyes.getCanon());
+ // logger.info("Name: " + snakeEyes.getName());
+
+ }
+
+}
--- /dev/null
+package de.remote.agents.clients.app;
+
+import org.apache.log4j.Logger;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringContextLocator {
+ private static final Logger logger = Logger.getLogger(SpringContextLocator.class);
+
+ // Singleton Pattern
+ private static SpringContextLocator instance;
+
+ // Spring ApplicationContext
+ private static ApplicationContext context;
+
+ // Spring Context
+ private static final String SPRING_CONFIG_CONTEXT = "clients-remote-agents-spring.xml";
+
+ /**
+ * Private constructor. Singleton pattern.
+ */
+ private SpringContextLocator() {
+ logger.info("Loading context files: " + SpringContextLocator.SPRING_CONFIG_CONTEXT);
+
+ final String[] factoryFiles = new String[] { SPRING_CONFIG_CONTEXT };
+
+ context = new ClassPathXmlApplicationContext(factoryFiles);
+
+ logger.info("The context has been loaded successfully!! ");
+ }
+
+ /**
+ * Singleton pattern not thread safety. To use SingletoHolder pattern as the
+ * best approximation otherwise to use an Enum class (see Effective Java
+ * Second Edition and ) if we need serialization.
+ */
+ public static SpringContextLocator getInstance() {
+ if (instance == null) {
+ instance = new SpringContextLocator();
+ }
+ return instance;
+ }
+
+ /**
+ * Return bean from application context.
+ */
+ public Object getBean(final String name) {
+ return context.getBean(name);
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
+
+
+ <bean id="remoteUserService" class="com.googlecode.jsonrpc4j.spring.JsonProxyFactoryBean">
+ <property name="serviceUrl" value="http://127.0.0.1:8080/spring-mainapp/UserService.json"/>
+ <property name="serviceInterface" value="de.remote.agents.services.UserService"/>
+ </bean>
+
+</beans>
--- /dev/null
+log4j.rootLogger=INFO, stdout
+log4j.logger.org.springframework.ws=INFO
+log4j.logger.org.springframework.xml=INFO
+log4j.logger.de.spring.webservices=INFO
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyyMMddHHmmssSSS} - %-5p - [%t] - [%C] - %m%n
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>de.remote.agents</groupId>
+ <artifactId>remote-agents</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>remote-agents</name>
+ <url>http://gumartinm.name</url>
+ <description>Remote Agents Implementation</description>
+ <organization>
+ <name>Gustavo Martin Morcuende</name>
+ <url>http://www.gumartinm.name</url>
+ </organization>
+ <scm>
+ <developerConnection>scm:git:http://git.gumartinm.name/RemoteAgents</developerConnection>
+ <url>http://git.gumartinm.name/RemoteAgents</url>
+ </scm>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring.version>3.2.4.RELEASE</spring.version>
+ <spring.ws.version>2.1.4.RELEASE</spring.ws.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.5</version>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2.2</version>
+ </dependency>
+ </dependencies>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.ws</groupId>
+ <artifactId>spring-ws-core</artifactId>
+ <version>${spring.ws.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.mchange</groupId>
+ <artifactId>c3p0</artifactId>
+ <version>0.9.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.github.briandilley.jsonrpc4j</groupId>
+ <artifactId>jsonrpc4j</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Specification-Title>${project.description}</Specification-Title>
+ <Specification-Version>${project.version}</Specification-Version>
+ <Specification-Vendor>${project.organization.name}</Specification-Vendor>
+ <Implementation-Title>${project.description}</Implementation-Title>
+ <Implementation-Version>${project.version}</Implementation-Version>
+ <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>remote-agents</artifactId>
+ <groupId>de.remote.agents</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>remote-agents-services-implementation</artifactId>
+ <name>remote-agents-services-implementation</name>
+ <url>http://gumartinm.name</url>
+ <dependencies>
+ <dependency>
+ <groupId>com.github.briandilley.jsonrpc4j</groupId>
+ <artifactId>jsonrpc4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>de.remote.agents</groupId>
+ <artifactId>remote-agents-services-interfaces</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package de.remote.agents;
+
+public class SnakeEyesImpl implements SnakeEyes {
+
+ private String canon;
+ private String name;
+
+ public SnakeEyesImpl() {
+ };
+
+ public SnakeEyesImpl(final String canon, final String name) {
+ this.canon = canon;
+ this.name = name;
+ }
+
+ @Override
+ public String getCanon() {
+ return this.canon;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ public void setCanon(final String canon) {
+ this.canon = canon;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
--- /dev/null
+package de.remote.agents.services;
+
+import org.apache.log4j.Logger;
+
+import de.remote.agents.SnakeEyes;
+import de.remote.agents.SnakeEyesImpl;
+
+public class UserServiceImpl implements UserService {
+ private static final Logger logger = Logger.getLogger(UserServiceImpl.class);
+
+ @Override
+ public SnakeEyes createUser(final String canon, final String name) {
+ logger.info("Canon: " + canon);
+ logger.info("Name: " + name);
+
+ // TODO: spring factory :(
+ return new SnakeEyesImpl(canon, name);
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.2.xsd">
+
+
+ <bean id="userService" class="de.remote.agents.services.UserServiceImpl">
+ </bean>
+
+</beans>
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>remote-agents</artifactId>
+ <groupId>de.remote.agents</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>remote-agents-services-interfaces</artifactId>
+ <name>remote-agents-services-interfaces</name>
+ <url>http://gumartinm.name</url>
+ <dependencies>
+ <dependency>
+ <groupId>com.github.briandilley.jsonrpc4j</groupId>
+ <artifactId>jsonrpc4j</artifactId>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package de.remote.agents;
+
+public interface SnakeEyes {
+
+ public String getCanon();
+
+ public String getName();
+}
--- /dev/null
+package de.remote.agents.services;
+
+import de.remote.agents.SnakeEyes;
+
+public interface UserService {
+
+ SnakeEyes createUser(String canon, String name);
+}