Generating Server-side Files
You can generate server-side files by using
either of the following tools: - the RMI Wizard
- the RMI
Templates
To generate server-side files
with the RMI Wizard:
- Decide what kind of implementation you want
to create.
- From the main window, choose Tools
RMI
Wizard to open the first page of the RMI Wizard. - On the first page, specify
the package in which the wizard should place the files it generates.
-
On the second page, specify the remote interface you are creating for your server
program. This can be either a new remote interface, an extension of an existing
remote interface, or a copy of a remote interface that has been made into a template,
as follows:
- Type in the name of the remote interface you are creating.
(When you complete the wizard it will generate a file named
yourName.java
,
containing a remote interface named yourName
.) - If
you select a template from the Template drop-down, the remote interface will be
based on the template.
- If you select the "A new remote interface" radio
button, you will be able to code a new interface on the next page of the wizard.
-
If you select the "Extends an existing remote interface" button, click the ellipsis
(...) button and select the base interface.
- On the third page of
the wizard, define your remote interface:
- If you are creating
a remote interface from a template, you do not see the methods of the template
interface on this page. Any work you do on this page will add to the definition
copied from the template.
- If you are creating a new interface, the work
you do on this page will be the complete definition of the interface.
-
If you are creating an interface that extends an existing interface, you do not
see the methods of the base interface on this page. You can add methods
that extend the base interface.
- On the fourth page of the wizard,
choose values that describe the kind of implementation class that you want the
wizard to create:
- Review the implementation name. This is the name
that will be given to the implementation class. Notice that the default value
is based on the name of your remote interface, in the form
interfaceNameImpl
.
If you accept the default name, the wizard will generate a class named interfaceNameImpl
in a file named interfaceNameImpl.java
. - Review the
template choices. If you choose a template, the wizard will create an implementation
class that extends one of the RMI server base classes.
To
generate server-side files with the RMI templates:
- Decide what
kind of implementation you want to create. There are RMI templates for each of
the RMI base class types (
UnicastRemoteObject
, Activatable
,
RMIIIOP
) and for implementation classes that do not extend one of
the base classes (ClearObject
) - If you are creating
an implementation of an existing remote interface, copy that interface to the
package in which you are creating the implementation.
- From the main window,
choose File
New to
open the Template Chooser. - To create an implementation of an existing
remote interface, select one of these templates:
Activatable_Impl
ClearUnicastObject_Impl
RMIIIOP_Impl
UnicastRemoteRemoteObject_Impl
- To
create a new remote interface and an implementation for it, select one of these
templates:
Activatable Server (Group)
ClearObject
(Group)
IIOP Server (Group)
Unicast
Server (Group)
- Use the fields on the right side of the Template
Chooser to specify a name for your server file and the package in which it should
be generated. If you are using one of the
_Impl
templates to implement
an existing remote interface, use a name that matches the interface name. For
example, if you are implementing an interface named Hello
, name your
implementation class HelloImpl
. The RMI module will declare your
class as an implementation of the interface and generate method bodies for methods
declared in the remote interface. - Click the Finish button.
- The
RMI module creates an RMI server source file called
Name_You_Specified
.java
.
- If you used an
_Impl
template and used a name that matches the
interface name, the RMI module will declare your implementation class as an implementation
of the interface and generate method bodies for methods declared in the interface. -
If you used a
Group
template the RMI module also generates a remote
interface.
Legal
Notices