com.ibm.aglets
Class AgletProxyImpl

java.lang.Object
  extended bycom.ibm.awb.weakref.VirtualRef
      extended bycom.ibm.aglets.AgletProxyImpl
All Implemented Interfaces:
AgletProxy, java.io.Serializable

final class AgletProxyImpl
extends VirtualRef
implements AgletProxy

Version:
1.00 96/11/25
Author:
Mitsuru Oshima, ONO Kouichi

Nested Class Summary
 
Nested classes inherited from class com.ibm.awb.weakref.VirtualRef
VirtualRef.NullRef
 
Field Summary
(package private) static long serialVersionUID
           
 
Fields inherited from class com.ibm.awb.weakref.VirtualRef
 
Constructor Summary
(package private) AgletProxyImpl(AgletRef ref)
           
 
Method Summary
 void activate()
          Activates the aglet.
 java.lang.Object clone()
          Clones the aglet proxy.
 void deactivate(long duration)
          Deactivate aglet till the specified date.
 void delegateMessage(Message msg)
          Delegates a message
 AgletProxy dispatch(Ticket ticket)
          Dispatches the aglet to the location specified by the ticket as the argument.
 AgletProxy dispatch(java.net.URL url)
          Dispatches the aglet to the location specified by the argument address.
 void dispose()
          Disposes the aglet.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getAddress()
          Gets the aglet's class name.
 Aglet getAglet()
          Gets the aglet.
 java.lang.String getAgletClassName()
          Gets the aglet's class name.
 AgletID getAgletID()
          Gets the aglet's id
 AgletInfo getAgletInfo()
          Gets the information of the aglet
(package private)  AgletRef getAgletRef()
           
 java.net.URL getCodeBase()
          Gets the URL of the aglet's class.
 int hashCode()
           
 boolean isActive()
          Checks if the aglet is active or deactivated.
 boolean isRemote()
          Checks if it's remote
 boolean isState(int state)
          Checks if the aglet is in the state give by type.
 boolean isValid()
          Checks if it's valid.
 void resume()
           
 FutureReply sendAsyncMessage(Message msg)
          Sends a message in asynchronous way.
 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 a oneway message
 void suspend(long duration)
          Suspend the aglet.
 java.lang.String toString()
           
 
Methods inherited from class com.ibm.awb.weakref.VirtualRef
finalize, getCurrentRef, getRef, setRef
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

AgletProxyImpl

AgletProxyImpl(AgletRef ref)
Method Detail

activate

public void activate()
              throws java.io.IOException,
                     AgletException
Description copied from interface: AgletProxy
Activates the aglet. This is a forced activation of a deactivated/resumed aglet.

Specified by:
activate in interface AgletProxy
Throws:
AgletException - if the aglet is not valid.
java.io.IOException - if the activation failed.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the aglet proxy. 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.

Specified by:
clone in interface AgletProxy
Returns:
the new aglet proxy what holds cloned aglet.
Throws:
java.lang.CloneNotSupportedException - if the cloning fails.
InvalidAgletException - if the aglet is invalid.

deactivate

public void deactivate(long duration)
                throws java.io.IOException,
                       InvalidAgletException
Deactivate aglet till the specified date. The deactivated aglet are stored in the aglet spool.

Specified by:
deactivate in interface AgletProxy
Parameters:
duration - duration of the aglet deactivating in milliseconds. If this is 0, it will be activeted at the next startup time.
Throws:
AgletEception - if can not deactivate the aglet.
InvalidAgletException - if the aglet is not valid.
java.io.IOException

delegateMessage

public void delegateMessage(Message msg)
                     throws InvalidAgletException
Delegates a message

Specified by:
delegateMessage in interface AgletProxy
Parameters:
msg - a message to delegate
Throws:
InvalidAgletException - if the aglet proxy is not valid.
See Also:
Aglet.handleMessage(com.ibm.aglet.Message)

dispatch

public AgletProxy dispatch(Ticket ticket)
                    throws java.io.IOException,
                           AgletException
Description copied from interface: AgletProxy
Dispatches the aglet to the location specified by the ticket as the argument.

Specified by:
dispatch in interface AgletProxy
Returns:
the AgletProxy of the dispatched (remote) aglet.
Throws:
java.io.IOException
AgletException

dispatch

public AgletProxy dispatch(java.net.URL url)
                    throws java.io.IOException,
                           AgletException
Description copied from interface: AgletProxy
Dispatches the aglet to the location specified by the argument address.

Specified by:
dispatch in interface AgletProxy
Parameters:
url - the address of the destination context.
Returns:
the AgletProxy of the dispatched (remote) aglet.
Throws:
java.io.IOException
AgletException

dispose

public void dispose()
             throws InvalidAgletException
Disposes the aglet.

Specified by:
dispose in interface AgletProxy
Throws:
InvalidAgletException - if the aglet is invalid.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class VirtualRef

getAddress

public java.lang.String getAddress()
                            throws InvalidAgletException
Gets the aglet's class name.

Specified by:
getAddress in interface AgletProxy
Returns:
the address.
Throws:
InvalidAgletException

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 AgletProxy
Returns:
the aglet
Throws:
java.lang.SecurityException - if the current execution is not allowed.
InvalidAgletException - if the aglet is not valid.

getAgletClassName

public java.lang.String getAgletClassName()
                                   throws InvalidAgletException
Gets the aglet's class name.

Specified by:
getAgletClassName in interface AgletProxy
Returns:
the class name.
Throws:
InvalidAgletException - if the aglet is not valid.

getAgletID

public AgletID getAgletID()
                   throws InvalidAgletException
Gets the aglet's id

Specified by:
getAgletID in interface AgletProxy
Returns:
the aglet's id
Throws:
InvalidAgletException - if the aglet is not valid.

getAgletInfo

public AgletInfo getAgletInfo()
                       throws InvalidAgletException
Gets the information of the aglet

Specified by:
getAgletInfo in interface AgletProxy
Returns:
the AgletInfo of the aglet
Throws:
InvalidAgletException - if the aglet is not valid.
See Also:
AgletInfo

getAgletRef

AgletRef getAgletRef()

getCodeBase

public java.net.URL getCodeBase()
                         throws InvalidAgletException
Gets the URL of the aglet's class. Null is returned if the class is in the set of common classes.

Returns:
the class URL.
Throws:
InvalidAgletException

hashCode

public int hashCode()

isActive

public boolean isActive()
Description copied from interface: AgletProxy
Checks if the aglet is active or deactivated.

Specified by:
isActive in interface AgletProxy
Returns:
true if the aglet is active.

isRemote

public boolean isRemote()
Checks if it's remote

Specified by:
isRemote in interface AgletProxy
Returns:
true if the aglet resides at the remote site.

isState

public boolean isState(int state)
Description copied from interface: AgletProxy
Checks if the aglet is in the state give by type.

Specified by:
isState in interface AgletProxy
Parameters:
state - an integer value specifying the aglet's state
Returns:
true if the aglet is in the same state as the type give as an argument.
See Also:
Aglet.ACTIVE, Aglet.INACTIVE

isValid

public boolean isValid()
Checks if it's valid.

Specified by:
isValid in interface AgletProxy
Returns:
true if the aglet proxy is valid. false if not.

resume

public void resume()
            throws AgletException
Throws:
AgletException

sendAsyncMessage

public FutureReply sendAsyncMessage(Message msg)
                             throws InvalidAgletException
Sends a message in asynchronous way.

Specified by:
sendAsyncMessage in interface AgletProxy
Parameters:
msg - the message to send
Returns:
a future object that will give you the reply of the message.
Throws:
InvalidAgletException - if the aglet is not valid any longer.

sendFutureMessage

public FutureReply sendFutureMessage(Message msg)
                              throws InvalidAgletException
Sends a future message in asynchronous way.

Specified by:
sendFutureMessage in interface AgletProxy
Parameters:
msg - the message to send
Returns:
a future object that will give you the reply of the message.
Throws:
InvalidAgletException - if the aglet is not valid any longer.

sendMessage

public java.lang.Object sendMessage(Message msg)
                             throws MessageException,
                                    InvalidAgletException,
                                    NotHandledException
Sends a message in synchronous way.

Specified by:
sendMessage in interface AgletProxy
Parameters:
msg - the message to send
Returns:
the result object if any. null if not.
Throws:
NotHandledException - if the aglet didn't handle the the message.
InvalidAgletException - if the aglet is not valid any longer.
MessageException - a exception which the handleMessage method raised.

sendOnewayMessage

public void sendOnewayMessage(Message msg)
                       throws InvalidAgletException
Sends a oneway message

Specified by:
sendOnewayMessage in interface AgletProxy
Parameters:
msg - the message to send
Throws:
InvalidAgletException - if the aglet is not valid any longer.

suspend

public void suspend(long duration)
             throws InvalidAgletException
Suspend the aglet. That is, objects of the suspended aglet will remain in the memory.

Specified by:
suspend in interface AgletProxy
Parameters:
duration - duration of the aglet deactivating in milliseconds. If this is 0, it will be activeted at the next startup time.
Throws:
AgletEception - if can not suspend the aglet.
java.lang.IllegalArgumentException - if the minutes parameter is negative.
InvalidAgletException

toString

public java.lang.String toString()