Java Reference
In-Depth Information
StockItem createStockItem(in string newCode,
in long newLevel);
};
};
2. Compile the IDL fi le.
As in the previous example, client and server will be run on the same machine,
so the -f fl ag will be followed by
all
. The command to execute the
idlj
compiler,
then, is:
idlj -fall StockItem.idl
This causes a sub-directory with the same name as the module (i.e.,
Sales
) to be
created, holding the following 12 fi les (six each for the two interfaces):
StockItem.java
StockItemHelper.java
StockItemHolder.java
StockItemOperations.java
_StockItemImplBase.java
_StockItemStub.java
StockItemFactory.java
StockItemFactoryHelper.java
StockItemFactoryHolder.java
StockItemFactoryOperations.java
_ StockItemFactoryImplBase.java
_ StockItemFactoryStub.java
3. Implement the interfaces.
Once again, we shall follow the convention of appending the word 'servant' to each of
our interface names to form the names of the corresponding implementation classes.
This results in classes
StockItemServant
and
StockItemFactoryServant
, which must
extend classes
_StockItemImplBase
and
_StockItemFactoryImplBase
respectively. The
code is shown below. Note that both 'get' and 'set' methods for attribute currentLevel
must be supplied and must have the same name as this attribute, whereas only the 'get'
method for the read-only attribute
code
must be supplied.
class StockItemServant extends _StockItemImplBase
{
//Declare and initialise instance variables…
private String code = "";
private int currentLevel = 0;
//Constructor…
public StockItemServant(String newCode, int newLevel)
{
code = newCode;
currentLevel = newLevel;
}
Search WWH ::
Custom Search