public class EventType extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
private class |
EventType.SendTask
Subclass of
RetryTask used by EventType
to send events. |
Modifier and Type | Field and Description |
---|---|
private long |
evID
Our event ID
|
private EventTypeGenerator |
generator
Event type generator that created us.
|
private MarshalledObject |
handback
Handback object associated with current listener.
|
private long |
lastSeqNum
Last event sequence number we used
|
private RemoteEventListener |
listener
Transient cache of listener in unmarshalled form
|
private static Logger |
logger
Logger for logging messages for this class
|
private MarshalledObject |
marshalledListener
Listener registered for events of this type.
|
private SendMonitor |
monitor
Object we check with to ensure leases have not expired and notify
when we get a definite exception during an event send attempt.
|
private ProxyPreparer |
recoveredListenerPreparer
The proxy preparer to use to prepare a newly unmarshalled listener, or
null if this instance was created using an already prepared listener,
which is how instances are created initially.
|
private long |
registrationNumber
Sequence number of the current listener/handback pair, incremented
every time a new listener is set (even if the objects
are equivalent)
|
private static long |
serialVersionUID |
Constructor and Description |
---|
EventType(EventTypeGenerator generator,
SendMonitor monitor,
long evID,
RemoteEventListener listener,
MarshalledObject handback)
Simple constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
bumpSequenceNumber()
Increment the sequence number and return the result.
|
private void |
clearListener()
Utility method to null out listener
|
boolean |
clearListenerIfSequenceMatch(long oldSequenceNumber)
Atomically clear the current registration if its sequence
number matches the passed in sequence number.
|
long |
getEventID()
Return the
long that was uniquely associated with this
object when it was created. |
long |
getLastSequenceNumber()
Return the sequence number of the last event that was scheduled
to be sent.
|
private RemoteEventListener |
getListener()
Convince method to get the listener.
|
boolean |
haveListener()
Returns
true if there is a listener registered for this
event type. |
void |
restoreTransientState(EventTypeGenerator generator,
SendMonitor monitor,
ProxyPreparer recoveredListenerPreparer)
Restore the transient state of this object after recovering it
from a serialization stream.
|
long |
sendEvent(EventFactory factory)
Schedule the sending of an event.
|
void |
setLastSequenceNumber(long seqNum)
Set the object's notion of the last sequence number.
|
void |
setListener(RemoteEventListener listener,
MarshalledObject handback)
(Re)set the listener for this type of event.
|
private static final long serialVersionUID
private static final Logger logger
private MarshalledObject marshalledListener
EventType
object can
be recovered even if the listener's codebase is not available.
If this field is null
, listener
and
handback
will be also.private transient RemoteEventListener listener
private transient ProxyPreparer recoveredListenerPreparer
private MarshalledObject handback
private long registrationNumber
private long lastSeqNum
private long evID
private transient SendMonitor monitor
null
generator will be also.private transient EventTypeGenerator generator
null
monitor will be also.EventType(EventTypeGenerator generator, SendMonitor monitor, long evID, RemoteEventListener listener, MarshalledObject handback) throws IOException
generator
- EventTypeGenerator that is creating this event typemonitor
- Object which is to monitor the sending of events
of this typeevID
- event ID of this event typelistener
- the listener events of this type should go tohandback
- the object that should be passed to listener
as part of the eventIOException
- if the listener cannot be serializedprivate void clearListener()
public void setListener(RemoteEventListener listener, MarshalledObject handback) throws IOException
null
will cancel the sending of all pending
events.listener
- the listener events of this type should go tohandback
- the object that should be passed to listener
as part of the eventIOException
- if listener cannot be serializedpublic boolean haveListener()
true
if there is a listener registered for this
event type.private RemoteEventListener getListener()
null
if the listener can't be
unpacked or prepared, or there is no listenerpublic boolean clearListenerIfSequenceMatch(long oldSequenceNumber)
setListener(null, null)
.
Can be used by code that needs to remove event registrations in response to exceptions thrown during event delivery without risking clobbering new registrations.
oldSequenceNumber
- sequence number of the
registration that had a problemtrue
if the state of the object was
changed and false
otherwisesetListener(net.jini.core.event.RemoteEventListener, java.rmi.MarshalledObject)
public void setLastSequenceNumber(long seqNum)
Note: this method is not synchronized.
seqNum
- value for the last sequence numberpublic long getLastSequenceNumber()
EventRegistration
objects and the like.public long getEventID()
long
that was uniquely associated with this
object when it was created.public long sendEvent(EventFactory factory)
null
this call will have no affect aside from
incrementing the sequence number.factory
- an object that will be used to create the
Event
object when necessaryIllegalStateException
- if this method is called
after the object has be deserialized and before
restoreTransientState
has been calledrestoreTransientState(com.sun.jini.norm.event.EventTypeGenerator, com.sun.jini.norm.event.SendMonitor, net.jini.security.ProxyPreparer)
public long bumpSequenceNumber()
public void restoreTransientState(EventTypeGenerator generator, SendMonitor monitor, ProxyPreparer recoveredListenerPreparer)
null
.
Note: this method is not synchronized.
generator
- the EventTypeGenerator
that was used
to create this EventType object originallymonitor
- the object that monitors the progress of events
set by this objectrecoveredListenerPreparer
- the proxy preparer to use to prepare
listeners recovered from persistent storageCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.