com.ibm.aglets
Class LocalAgletRef

java.lang.Object
  |
  +--com.ibm.aglet.AgletStub
        |
        +--com.ibm.aglets.LocalAgletRef
All Implemented Interfaces:
AgletRef, Ref

public final class LocalAgletRef
extends AgletStub
implements AgletRef

Class LocalAgletRef is the implementation of AgletStub. The purpose of this class is to provide a mechanism to control the aglet.

Version:
$Revision: 1.3 $ $Date: 2002/01/19 22:10:43 $ $Author: kbd4hire $
Author:
Danny B. Lange, Mitsuru Oshima, ONO Kouichi

Method Summary
 void activate()
          Activate the aglet
 void checkValidation()
           
protected  java.lang.Object clone()
          Clones the aglet ref.
protected  void deactivate(long duration)
          Deactivate aglet till the specified date.
 void delegateMessage(Message msg)
          Delegates a message to the ref.
protected  void dispatch(Ticket ticket)
           
protected  void dispatch(java.net.URL url)
           
 void dispatchEvent(AgletEvent ev)
           
protected  void dispose()
          Disposes the aglet.
 java.lang.String getAddress()
          Gets the address.
 Aglet getAglet()
          Gets the aglet.
protected  AgletContext getAgletContext()
           
 AgletInfo getAgletInfo()
          Gets the information of the aglet
 java.security.cert.Certificate getCertificate()
          Gets the Certificate of the aglet's class.
protected  MessageManager getMessageManager()
          Gets the aglet's message manager object.
 Name getName()
           
protected  java.security.PermissionCollection getProtections()
          Gets the protections: permission collection about who can send what kind of messages to the aglet
 Ref getRef(VirtualRef vref)
           
 java.lang.String getRefClassName()
           
 java.lang.String getText()
          Gets the current content of the Aglet's message line.
 boolean isActive()
          Checks if it's valid or not.
 boolean isRemote()
          Checks if it's remote or not.
 boolean isState(int s)
          Check the state
 boolean isValid()
          Checks if it's valid or not.
protected  void kill()
           
 void referenced()
           
 void resume()
          Resume the aglet
 FutureReply sendFutureMessage(Message msg)
          Sends a future message in asynchronous way.
 java.lang.Object sendMessage(Message msg)
          Sends a message in synchronous way.
 void sendOnewayMessage(Message msg)
          Sends an oneway message
protected  void setAglet(Aglet a)
           
protected  void setProtections(java.security.PermissionCollection newprotections)
          Sets the protections: permission collection about who can send what kind of messages to the aglet
 void setRef(VirtualRef vref, java.io.ObjectInputStream s)
           
protected  void setText(java.lang.String text)
          Sets/Shows a text.
protected  void snapshot()
          Checkpointing the snapshot of the aglet.
protected  void subscribeMessage(java.lang.String kind)
           
protected  void suspend(long duration)
          Suspend aglet for the specified amount of time.
 java.lang.String toString()
           
 void unreferenced()
           
protected  void unsubscribeAllMessages()
           
protected  boolean unsubscribeMessage(java.lang.String kind)
           
 void writeInfo(java.io.ObjectOutputStream s)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

activate

public void activate()
              throws java.io.IOException,
                     InvalidAgletException,
                     AgletNotFoundException,
                     ShuttingDownException
Description copied from interface: AgletRef
Activate the aglet
Specified by:
activate in interface AgletRef

checkValidation

public void checkValidation()
                     throws InvalidAgletException
Specified by:
checkValidation in interface AgletRef

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Clones the aglet ref. Note that the cloned aglet will get activated. If you like to get cloned aglet which is not activated, throw ThreadDeath exception in the onClone method.
Overrides:
clone in class AgletStub
Returns:
the new aglet ref what holds cloned aglet.
Throws:
java.lang.CloneNotSupportedException - if the cloning fails.
InvalidAgletException - if the aglet is invalid.

deactivate

protected void deactivate(long duration)
                   throws java.io.IOException
Deactivate aglet till the specified date. The deactivated aglet are stored in the aglet spool.
Overrides:
deactivate in class AgletStub
Parameters:
duration - the duration to sleep in milliseconds.
Throws:
AgletEception - if can not deactivate the aglet.

delegateMessage

public void delegateMessage(Message msg)
                     throws InvalidAgletException
Delegates a message to the ref.
Specified by:
delegateMessage in interface AgletRef
Parameters:
msg - a message to delegate
Throws:
InvalidAgletException - if the aglet is not valid any longer.

dispatch

protected void dispatch(Ticket ticket)
                 throws java.io.IOException,
                        RequestRefusedException
Overrides:
dispatch in class AgletStub

dispatch

protected void dispatch(java.net.URL url)
                 throws java.io.IOException,
                        RequestRefusedException
Overrides:
dispatch in class AgletStub

dispatchEvent

public void dispatchEvent(AgletEvent ev)

dispose

protected void dispose()
Disposes the aglet.
Overrides:
dispose in class AgletStub
Throws:
InvalidAgletException - if the aglet is invalid.

getAddress

public java.lang.String getAddress()
                            throws InvalidAgletException
Gets the address.
Specified by:
getAddress in interface AgletRef
Returns:
the current context address

getAglet

public Aglet getAglet()
               throws InvalidAgletException
Gets the aglet. If the aglet is access protected it will require the right key to get access.
Specified by:
getAglet in interface AgletRef
Returns:
the aglet
Throws:
java.lang.SecurityException - if the current execution is not allowed.

getAgletContext

protected AgletContext getAgletContext()
Overrides:
getAgletContext in class AgletStub

getAgletInfo

public AgletInfo getAgletInfo()
Gets the information of the aglet
Specified by:
getAgletInfo in interface AgletRef
Overrides:
getAgletInfo in class AgletStub
Returns:
an AgletInfo object

getCertificate

public java.security.cert.Certificate getCertificate()
                                              throws InvalidAgletException
Gets the Certificate of the aglet's class.
Returns:
a Certificate

getMessageManager

protected MessageManager getMessageManager()
Description copied from class: AgletStub
Gets the aglet's message manager object.
Overrides:
getMessageManager in class AgletStub
Following copied from class: com.ibm.aglet.AgletStub
Returns:
the method manager
Throws:
InvalidAgletException - if the aglet is not valid.
See Also:
aglet.MessageManager

getName

public Name getName()

getProtections

protected java.security.PermissionCollection getProtections()
Gets the protections: permission collection about who can send what kind of messages to the aglet
Overrides:
getProtections in class AgletStub
Returns:
collection of protections about who can send what kind of messages to the aglet

getRef

public Ref getRef(VirtualRef vref)
Specified by:
getRef in interface Ref

getRefClassName

public java.lang.String getRefClassName()
Specified by:
getRefClassName in interface Ref

getText

public java.lang.String getText()
Gets the current content of the Aglet's message line.
Overrides:
getText in class AgletStub
Returns:
the message line.

isActive

public boolean isActive()
Checks if it's valid or not.
Specified by:
isActive in interface AgletRef

isRemote

public boolean isRemote()
Checks if it's remote or not.
Specified by:
isRemote in interface AgletRef

isState

public boolean isState(int s)
Check the state
Specified by:
isState in interface AgletRef

isValid

public boolean isValid()
Checks if it's valid or not.
Specified by:
isValid in interface AgletRef

kill

protected void kill()

referenced

public void referenced()
Specified by:
referenced in interface Ref

resume

public void resume()
            throws AgletNotFoundException,
                   InvalidAgletException,
                   ShuttingDownException
Description copied from interface: AgletRef
Resume the aglet
Specified by:
resume in interface AgletRef

sendFutureMessage

public FutureReply sendFutureMessage(Message msg)
                              throws InvalidAgletException
Description copied from interface: AgletRef
Sends a future message in asynchronous way.
Specified by:
sendFutureMessage in interface AgletRef
Following copied from interface: com.ibm.aglets.AgletRef
Parameters:
msg - the message to send

sendMessage

public java.lang.Object sendMessage(Message msg)
                             throws MessageException,
                                    InvalidAgletException,
                                    NotHandledException
Description copied from interface: AgletRef
Sends a message in synchronous way.
Specified by:
sendMessage in interface AgletRef
Following copied from interface: com.ibm.aglets.AgletRef
Parameters:
msg - the message to send

sendOnewayMessage

public void sendOnewayMessage(Message msg)
                       throws InvalidAgletException
Description copied from interface: AgletRef
Sends an oneway message
Specified by:
sendOnewayMessage in interface AgletRef
Following copied from interface: com.ibm.aglets.AgletRef
Parameters:
msg - the message to send

setAglet

protected void setAglet(Aglet a)
Overrides:
setAglet in class AgletStub

setProtections

protected void setProtections(java.security.PermissionCollection newprotections)
Sets the protections: permission collection about who can send what kind of messages to the aglet
Overrides:
setProtections in class AgletStub
Parameters:
protections - collection of protections about who can send what kind of messages to the aglet

setRef

public void setRef(VirtualRef vref,
                   java.io.ObjectInputStream s)
            throws java.io.IOException,
                   java.lang.ClassNotFoundException
Specified by:
setRef in interface Ref

setText

protected void setText(java.lang.String text)
Sets/Shows a text.
Overrides:
setText in class AgletStub
Parameters:
text -  

snapshot

protected void snapshot()
                 throws java.io.IOException
Checkpointing the snapshot of the aglet.
Overrides:
snapshot in class AgletStub
Throws:
java.io.IOException -  

subscribeMessage

protected void subscribeMessage(java.lang.String kind)
Overrides:
subscribeMessage in class AgletStub

suspend

protected void suspend(long duration)
                throws InvalidAgletException
Suspend aglet for the specified amount of time. The suspended aglet will remain in the memory.
Overrides:
suspend in class AgletStub
Parameters:
duration - the duration to sleep in milliseconds.
Throws:
InvalidAgletEception - if can not suspend the aglet.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unreferenced

public void unreferenced()
Specified by:
unreferenced in interface Ref

unsubscribeAllMessages

protected void unsubscribeAllMessages()
Overrides:
unsubscribeAllMessages in class AgletStub

unsubscribeMessage

protected boolean unsubscribeMessage(java.lang.String kind)
Overrides:
unsubscribeMessage in class AgletStub

writeInfo

public void writeInfo(java.io.ObjectOutputStream s)
               throws java.io.IOException
Specified by:
writeInfo in interface Ref