List 17.3.1.1[hello.ridl] is a sample RIDL. This RIDL uses only primitive types as operation parameters and as its return value.
<?xml version="1.0"?> <interface xmlns="http://www.relaxer.org/xmlns/cdl" name="hello" namespace="http://www.example.com/hello"> <operation name="greeting"> <in name="message" type="string"/> <out name="result" type="string"/> </operation> </interface>
Execution of Relaxer with the cdl option is as follows:
$ relaxer -cdl hello.ridl
As a result, Relaxer generates 11 files, as follows:
The API is the IHello
shown in List 17.3.1.2[IHello.java].
import java.rmi.*; public interface IHello extends Remote { /** * Application interface of the operation greeting. * * @param message * @exception RemoteException * @return String */ String greeting(String message) throws RemoteException; }
The SPI is the IHelloService
shown in
List 17.3.1.3[IHelloService.java].
import java.rmi.*; public interface IHelloService extends IHello { }
List 17.3.1.4[HelloService.java.Hello] is a prototype implementation of a service provider, generated by Relaxer.
import java.rmi.RemoteException; public class HelloService extends AbstractHelloService { /** * Implementation of a operation greeting. * * @param message * @exception RemoteException * @return String */ public String greeting(String message) throws RemoteException { throw (new UnsupportedOperationException()); } }
Sample implementation of the service provider is shown in List 17.3.1.5[HelloService.java].
public class HelloService extends AbstractHelloService { /** * Implementation of operation greeting. * * @param message * @return String */ public String greeting(String message) { return (message + " World!"); } }
HelloCommand.java is a command front-end of the service. We compile it to execute the application.
$ javac HelloCommand
Execution of the HelloCommand
is shown bellow:
$ java HelloCommand -greeting Hello Hello World
The parameter -greeting
means calling the greeting
operation defined in
the RIDL hello.ridl
.
The following paramter Hello
is a parameter of the
greeting
operation.
Result of the HelloCommand execution "Hello World" is
a result of the operation greeting
in HelloService
.
List 17.3.2.1[hello.ridl] is a sample RIDL definition and List 17.3.2.2[hello.rng] is a sample RELAX NG schema that is used by the RIDL definition.
This IDL uses XML types for operation parameters and its return value.
<interface xmlns="http://www.relaxer.org/xmlns/cdl" name="hello" namespace="http://example.com/hello"> <grammar namespace="http://example.com/hello" location="hello.rng"/> <operation name="greeting"> <in name="message" label="greeting"/> <out type="string"/> </operation> </interface>
<?xml version="1.0" encoding="UTF-8" ?> <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <start> <ref name="greeting"/> </start> <define name="greeting"> <element name="greeting"> <attribute name="date"> <data type="date"/> </attribute> <attribute name="from"> <data type="token"/> </attribute> <attribute name="to"> <data type="token"/> </attribute> <element name="title"> <data type="token"/> </element> <element name="message"> <data type="string"/> </element> </element> </define> </grammar>
Execution of Relaxer with the cdl option is as follows:
$ relaxer -cdl hello.ridl
As a result, Relaxer generates 15 files, as follows:
The API is the IHello
shown in List 17.3.2.3[IHello.java].
import java.rmi.*; public interface IHello extends Remote { /** * Application interface of the operation greeting. * * @param message * @exception RemoteException * @return String */ String greeting(Greeting message) throws RemoteException; }
The SPI is the IHelloService
shown in
List 17.3.2.4[IHelloService.java].
import java.rmi.*; public interface IHelloService extends IHello { }
List 17.3.2.5[HelloService.java.Hello] is a prototype implementation of a service provider, generated by Relaxer.
import java.rmi.RemoteException; public class HelloService extends AbstractHelloService { /** * Implementation of a operation greeting. * * @param message * @exception RemoteException * @return String */ public String greeting(Greeting message) throws RemoteException { throw (new UnsupportedOperationException()); } }
Sample implementation of the service provider is shown in List 17.3.2.6[HelloService.java].
import java.rmi.RemoteException; public class HelloService extends AbstractHelloService { /** * Implementation of a operation greeting. * * @param message * @exception RemoteException * @return String */ public String greeting(Greeting message) throws RemoteException { return (message.getMessage()); } }
HelloCommand.java is a command front-end of the service. We compile it to execute the application.
$ javac HelloCommand
Execution of the HelloCommand
is shown bellow:
$ java HelloCommand -greeting hello.xml Welcome to Relaxer World!
The parameter -greeting
means calling the greeting
operation defined in
the RIDL hello.ridl
.
The following paramter hello.xml
is a file name
of a XML document which is a parameter of the greeting
operation
as the Greeting
object.
Result of the HelloCommand execution "Welcome to Relaxer World!" is
a result of the operation greeting
in HelloService
.
List 17.3.3.1[hello.rcdl] is a sample RCDL. This IDL uses only primitive types as operation parameters and its return value.
<?xml version="1.0"?> <component xmlns="http://www.relaxer.org/xmlns/cdl" namespace="http://www.example.com/hello" name="hello"> <interface namespace="http://www.example.com/hello" name="hello"> <operation name="greeting"> <in name="message" type="string"/> <out name="result" type="string"/> </operation> </interface> </component>
Execution of Relaxer with the cdl option is as follows:
$ relaxer -cdl hello.rcdl
As a result, Relaxer generates 17 files, as follows:
The API is the IHello
shown in
List 17.3.3.2[IHello.java].
import java.rmi.*; public interface IHello extends Remote { /** * Application interface of the operation greeting. * * @param message * @exception RemoteException * @return String */ String greeting(String message) throws RemoteException; }
The SPI is the IHelloService
shown in
List 17.3.3.3[IHelloService.java].
import java.rmi.*; public interface IHelloService extends IHello { }
List 17.3.3.4[HelloService.java.Hello] is a prototype implementation of a service provider, generated by Relaxer.
import java.rmi.RemoteException; public class HelloService extends AbstractHelloService { /** * Implementation of a operation greeting. * * @param message * @exception RemoteException * @return String */ public String greeting(String message) throws RemoteException { throw (new UnsupportedOperationException()); } }
Sample implementation of the service provider is shown in List 17.3.3.5[HelloService.java].
public class HelloService extends AbstractHelloService { /** * Implementation of operation greeting. * * @param message * @return String */ public String greeting(String message) { return (message + " World!"); } }
HelloCommand.java is a command front-end of the service. We compile it to execute the application.
$ javac HelloCommand
Execution of the HelloCommand
is shown bellow:
$ java HelloCommand -greeting Hello Hello World
The parameter -greeting
means calling the greeting
operation defined in
the RCDL hello.rcdl
.
The following paramter Hello
is a parameter of the
greeting
operation.
Result of the HelloCommand execution "Hello World" is
a result of the operation greeting
in HelloService
.
List 17.3.4.1[hello.rcdl] is a sample RCDL definition and List 17.3.4.2[hello.rng] is a sample RELAX NG schema used by the RCDL definition.
This IDL uses XML types for operation parameters and its return value.
<component xmlns="http://www.relaxer.org/xmlns/cdl" namespace="http://www.example.com/hello" name="hello"> <interface namespace="http://example.com/hello" name="hello"> <grammar namespace="http://example.com/hello" location="hello.rng"/> <operation name="greeting"> <in name="message" label="greeting"/> <out type="string"/> </operation> </interface> </component>
<?xml version="1.0" encoding="UTF-8" ?> <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <start> <ref name="greeting"/> </start> <define name="greeting"> <element name="greeting"> <attribute name="date"> <data type="date"/> </attribute> <attribute name="from"> <data type="token"/> </attribute> <attribute name="to"> <data type="token"/> </attribute> <element name="title"> <data type="token"/> </element> <element name="message"> <data type="string"/> </element> </element> </define> </grammar>
Execution of Relaxer with the cdl option is as follows:
$ relaxer -cdl hello.rcdl
As a result, Relaxer generates 15 files, as follows:
The API is the IHello
shown in List 17.3.4.3[IHello.java].
import java.rmi.*; public interface IHello extends Remote { /** * Application interface of the operation greeting. * * @param message * @exception RemoteException * @return String */ String greeting(Greeting message) throws RemoteException; }
The SPI is the IHelloService
shown in
List 17.3.4.4[IHelloService.java].
import java.rmi.*; public interface IHelloService extends IHello { }
List 17.3.4.5[HelloService.java.Hello] is a prototype implementation of a service provider, generated by Relaxer.
import java.rmi.RemoteException; public class HelloService extends AbstractHelloService { /** * Implementation of a operation greeting. * * @param message * @exception RemoteException * @return String */ public String greeting(Greeting message) throws RemoteException { throw (new UnsupportedOperationException()); } }
Sample implementation of the service provider is shown in List 17.3.4.6[HelloService.java].
import java.rmi.RemoteException; public class HelloService extends AbstractHelloService { /** * Implementation of a operation greeting. * * @param message * @exception RemoteException * @return String */ public String greeting(Greeting message) throws RemoteException { return (message.getMessage()); } }
HelloCommand.java is a command front-end of the service. We compile it to execute the application.
$ javac HelloCommand
Execution of the HelloCommand
is shown bellow:
$ java HelloCommand -greeting hello.xml Welcome to Relaxer World!
The parameter -greeting
means calling the greeting
operation defined in
the RCDL hello.rcdl
.
The following paramter hello.xml
is a file name
of a XML document which is a parameter of the greeting
operation
as the Greeting
object.
Result of the HelloCommand execution "Welcome to Relaxer World!" is
a result of the operation greeting
in HelloService
.