The easiest way to create a cell class is to extend an arbitrary class by dmg.cells.nucleus.CellAdapter . The constructor of CellAdapter needs at least the name of the cell which you want to create.import dmg.cells.nucleus.* ; public class FooCell extends CellAdapter { public FooCell( String name ){ super( name ) ... say( "Cell "+getCellName()+" created." ) ; } }The CellAdapter tries to create the cell with the specified name. If the name is already in use by another cell, the constructor throws an java.lang.IllegalArgumentException with the message "Name Mismatch". If the name of the cell is not significant, an '*' can be used as last character in the cells name. The CellAdapter will find a unique name then. The getCellName() method will return the chosen name. The say method typically will send its argument to System.out.println but may configured differently. SoCellAdapter cell1 = new FooCell( "foo*" ) CellAdapter cell2 = new FooCell( "foo*" )may printCell foo-0022 created. Cell foo-0023 created.
Cell Objects can only be created ( new FooCell ) within a Domain Environment. A virtual machine creates a Domain Environment as soon as a dmg.cells.nucleus.SystemCell object has been created.SystemCell system = new SystemCell( "<domainName>" ) ;<domainName> is the name of this Domain Environment. As long as no Domains are connect to each other, the name is not significant. The name of the SystemCell will always be System. Only on SystemCell can be created within a Domain.SystemCell system = new SystemCell( "MyFirstDomain" ) ; new FooCell( "myFirstCell" ) ; new FooCell( "foo*" ) ; new FooCell( "foo*" ) ;The above codelet will create a Domain Environment with the name MyFirstDomain and four cells called System, myFirstCell, foo-001, foo-002.
The dmg.cells.services contains the code of a standard Domain with is configurable by command line options. dmg.cells.services.Domain allows you to create and remove Cells dynamically and to inspect the Cell Environment by login into it with by telnet.
NOTE : To enable the dynamic creation of cells the constructor of the cell class has to have two String arguments.public FooCell( String name , String args ){ super( name ) ; }You may choose any name as your username. The password has to be elch. You will be prompted by
- Create a file FooCell.java with the example cell above.
- make sure your current working directory and the cells.jar file is in your CLASSPATH.
- compile it 'javac FooCell.java'
- start the standard domain which listens to telnet port <nnn>.
java dmg.cells.services.Domain TestDomain -telnet <nnn>- telnet into the domain
telnet localhost <nnn>tn-<yourUserName>-100 >The shell your are logged into, provides a small set of commands to manipulate and inspect the Domain Environment. A simple help is available throu the help command.
For a list of all cells use the ps -a command.tn-patrick-100 > ps -a Cell List ------------------ tlm Active 0 TelnetLoginManager P=22123;C=dmg.cells.services.StreamLoginCell System Active 0 SystemCell TestDomain:R=0;A=0;F=0;R=0;X=0 tn-patrick-100 Active 0 StreamLoginCell patrick@localhost/127.0.0.1 tn-patrick-100 >The output list the name of the cell, the current status, the number of messages queued for this cell, the class name and a short discription of the cell itself. The description is the result of the toString method of the perticular cell object.
To get more information about a cell you may usetn-patrick-100 > ps <cellName>This command executes the getInfo() method of a cell. The toString() and getInfo() methods need to be overwritten by the cell implementation to get object specific information.
To activate an instance of your FooCell run :tn-patrick-100 > create FooCell fooCellName created : fooCellNameCheck the creation of the new FooCell instance with 'ps -a'.To remove the cell from the cell list, use the
tn-patrick-100 > kill <cellName>command.Killing the SystemCell will start the domain shutdown sequence. First all cells except the System cell are killed and finally the System.exit(0) is called.
The exit command leaves the shell and jumps into a kind of micro shell, the .. shell. Another exit command quits the telnet connection. The micro shell can connect the telnet session to an arbitrary cell.
.. > set dest <cellName> <cellName> >After issuing this command, all lines, typed in, are send to <cellName> and the respond is displayed by the telnet session. exit will return to the .. shell and.. > set dest <cellName> <cellName> >.. > set dest localreturns to the standard cell shell.
There are a set of possibilities to kill a cell.As soon as one of the kill commands is executed :
- The cell uses the kill() method to kill itself.
- A cell uses the kill( String cellName ) to kill anothercell.
- A cell is killed by the 'telnet shell'
Its up to the creator of the cell class to overwrite the cleanUp method to perform any necessary clean up activities.
- the perticular cell is scheduled for killing
- the kill command returns asynchronously
- the name of the cell is taken out of the cell list. ( no new messages can be send to this cell)
- the cell goes into 'removal' status ( ps -a )
- the cleanUp() method of the cell, which is going to be killed, is called.
- as long as this method doesn't return, the current status doesn't change. The method is called within a private thread. So no other services have to wait for the method to return.
- as soon as the method returns, the cell will be totally removed.
When logged into the