readObject(java.io.DataInput)
and writeObject(java.io.DataOutput)
methods. MobileRPC supports inheritance of structures.
java.lang.Exception
.
Files for structures and exceptions are the same for a J2ME application and server part of an application.
java.io.IOException
to indicate any communication problem.
Stub has one costructor with String
parameters. This parameter is a URL of this interface servant.
mobileRPC
name and has
three attributes. commonPackage
attribute specifies java package where MobileRPC will put common
files for J2ME and server parts. These files are structures and exceptions. serverPackage
attribute
specifies package for server files. Server files are abstract servlets. j2mePackage
specifies
java package for J2ME interface stubs files.
<mobileRPC commonPackage="example.common" serverPackage="example.server" j2mePackage="example.j2me">
...
</mobileRPC>
Inside the mobileRPC
there are three possible children elements: struct
,
exception
and interface
.
struct
element defines structs. struct
element has name
attribute
which defines name of the struct and optional extends
attribute which defines superclass of the
structure.
Inside the struct
element there can be constant
and attribute
elements.
constant
element defines structure's constants. It will become public static final
field of the java class. constant
element has name
, type
, optional
array
and value
attributes which define field's name, type and value respectively.
array
attribute has true
value it means that the constant has array type.
attribute
element defines structure's attribute. MobileRPC will generate getter and setter
method for every attribute and a constructor to initialize all structure attributes. Default constructor will be also
generated. attribute
element has name
, type
and optional array
attributes. name
and type
define attribute name and type. If array
attribute
has true
value it means that the attribute has array type.
Example:
<struct name="Document" extends="IdNameObject">
<constant name="TEXT_TYPE" type="int" value="0"/>
<constant name="IMAGE_TYPE" type="int" value="1"/>
<attribute name="type" type="int"/>
<attribute name="modificationDate" type="java.util.Date"/>
</struct>
exception
element defines exceptions. exception
element has name
and optional extends
attributes. name
attribute is exception class name,
extends
attribute is exception superclass name. If extends
attribute is missed
java.lang.Exception
is used as superclass.
Example:
<exception name="SecurityException"/>
<exception name="NoPermissionException" extends="SecurityException"/>
interface
element defines interfaces. interface
element has
interface
element can have zero or more constant
element just like
structure
element.
interface
element has one or more method
elements. method
element has
name
and optional returnType
, array
and throws
attributes.
name
attribute defines method name. If returnType
exists it defines method return type
otherwise method is void
. If array
attribute has true
value it means that
the method return type is array type. throws
attribute is a comma separated list of exceptions
thrown by the method.
method
element has zero or more parameter
elements which define mehtod parameters.
Attributes of the parameter
element are the same as attributes of the attribute
element.
Example:
<interface name="TreeInterface">
<method name="getTree" returnType="Node" throws="DatabaseException, NoPermissionException"/>
<method name="getDocuments" returnType="Document" array="true" throws="DatabaseException, NoPermissionException">
<parameter name="nodeId" type="long"/>
</method>
</interface>
Supported Types
The following types are supported by MobileRPC:
boolean
byte
short
int
long
char
String
Boolean
Byte
Short
Integer
Long
Character
java.util.Date
Also every structure is available as type after declaration.