groovyx.gpars.serial
Class SerialHandle

java.lang.Object
  extended by org.codehaus.groovy.util.ManagedReference<WithSerialId>
      extended by groovyx.gpars.serial.SerialHandle
All Implemented Interfaces:
org.codehaus.groovy.util.Finalizable
Direct Known Subclasses:
SerialHandle.LocalSerialHandle, SerialHandle.RemoteSerialHandle

public class SerialHandle
extends org.codehaus.groovy.util.ManagedReference<WithSerialId>

Weak reference to object, which was serialized to remote hosts. Also keep ids of all hosts, where the object was serialized.

While subscribed by remote nodes it keeps object alive by holding strong reference (anchor) to it

Author:
Alex Tkachman

Nested Class Summary
private static class SerialHandle.LocalSerialHandle
           
private static class SerialHandle.RemoteSerialHandle
           
 
Field Summary
private  WithSerialId anchor
           
private static org.codehaus.groovy.util.ReferenceBundle bundle
           
protected  SerialContext context
          local host
private static org.codehaus.groovy.util.ReferenceManager manager
           
private static java.lang.ref.ReferenceQueue<WithSerialId> queue
           
protected  java.util.UUID serialId
          serial id of the object
private  java.lang.Object subscribers
          remote hosts subscribed to this objects
 
Constructor Summary
private SerialHandle(WithSerialId value, java.util.UUID id)
          Construct handle for object with given id to it
 
Method Summary
static SerialHandle create(WithSerialId obj, java.util.UUID id)
           
 void finalizeReference()
           
 java.util.UUID getSerialId()
          Serial id of the object
 java.lang.Object getSubscribers()
          Getter for subscribers
 void subscribe(SerialContext context)
          Subscribes host as interested in the object
 void unsubscribe(SerialContext context)
           
 
Methods inherited from class org.codehaus.groovy.util.ManagedReference
clear, get
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

private static final java.lang.ref.ReferenceQueue<WithSerialId> queue

manager

private static final org.codehaus.groovy.util.ReferenceManager manager

bundle

private static final org.codehaus.groovy.util.ReferenceBundle bundle

serialId

protected final java.util.UUID serialId
serial id of the object


context

protected final SerialContext context
local host


subscribers

private volatile java.lang.Object subscribers
remote hosts subscribed to this objects


anchor

private volatile WithSerialId anchor
Constructor Detail

SerialHandle

private SerialHandle(WithSerialId value,
                     java.util.UUID id)
Construct handle for object with given id to it

Parameters:
value - The value to associate with the id
id - The id, if null a new id will be generated
Method Detail

getSerialId

public java.util.UUID getSerialId()
Serial id of the object

Returns:
The serial id

finalizeReference

public void finalizeReference()
Specified by:
finalizeReference in interface org.codehaus.groovy.util.Finalizable
Overrides:
finalizeReference in class org.codehaus.groovy.util.ManagedReference<WithSerialId>

getSubscribers

public java.lang.Object getSubscribers()
Getter for subscribers

Returns:
The current subscribers

subscribe

public void subscribe(SerialContext context)
Subscribes host as interested in the object

Parameters:
context - The subscription context to use

unsubscribe

public void unsubscribe(SerialContext context)

create

public static SerialHandle create(WithSerialId obj,
                                  java.util.UUID id)

Copyright © 2008–2012 Václav Pech. All Rights Reserved.