Corn Gate

  Corn gate module is designed to simplify service definitions and implementations in Java. It comes with several handy out of the box functionality like security, registry, Spring and EJB integration, filters, shared data stages, client context etc.  It's published in the maven central repository, so you can use corn-gate by adding the dependency below to your pom.xml. 

pom.xml

<dependency>
    <groupId>net.sf.corn</groupId>
    <artifactId>corn-gate</artifactId>
    <version>${gate.version}</version>
</dependency>
 
    If you don't prefer to use maven, you can always download and use jar files from the project files from the sourceforge.net web site

Hello World 

    We believe that using external service definitions generally cause more complex web services developments.  Corn gate accepts that plain Java interface classes are just enough to define service interfaces. Below is a service definition implementation which as you can guess HelloWorldService: 

@GateService(name="HelloWorldService",componentTarget="net.sf.corn.gate.sample.service.HelloWorldServiceImpl")
public interface IHelloWorldService {
   public String sayHelloWorld();
}

public class HelloWorldServiceImpl {
    public String sayHelloWorld(){
        return "Hello World";
    } 
}    

    Behind the scenes, the service scoped for requests  and  it enabled for both remote and local access. Please notice that the service implementation does not implements the interface at all. 

Below are the couple of samples to access to  HelloWorldService from various clients :

1- JavaScript Client AJAX Call:

var jsonrq = new JsonRpcRequest("http://localhost:8888/jsonrpc");
var response = jsonrq.send("358", "HelloWorldService", "sayHelloWorld");

2-Java Remote Client:

JsonRpcClient client= new JsonRpcClient(new URI("http://localhost/jsonrpc"));
JsonRpcResponse resp= client.callAService("HelloWorldService","sayHelloWorld");

3-REST client (Browser) 

http://localhost:8888/jsonrpc/HelloWorldService/sayHelloWorld


4-Java Local Client

ServiceResponse response = CallDelegator.execute( new ServiceRequest("HelloWorld", "sayHelloWorld"));

5-Java Local Client (through proxy) 

IHelloWorldService service = CallDelegator.getServiceProxy(IHelloWorldService.class);
String resp = service.sayHelloWorld();

6-GWT Client
HelloWorldServiceAsync helloService = GWT.create(HelloWorldService.class);
ServiceDefTarget target = (ServiceDefTarget) echoService;
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "gwtrpc");
helloService.sayHelloWorld( new AsyncCallback<String>() {
    public void onFailure(Throwable caught) {
           //TODO handle exception
    }
    public void onSuccess(String result) {
      //TODO Handle Result
    }
});


   If you interested the way of service implementation, please switch on the users guide page to learn more details.

Subpages (1): Users Guide