com.sun.jini.outrigger
Class StorableReference

java.lang.Object
  extended by com.sun.jini.outrigger.StorableReference
All Implemented Interfaces:
Externalizable, Serializable

 class StorableReference
extends Object
implements Externalizable

This class holds a proxy for some remote resource. When persisted the proxy is marshalled in its own MarshalledObject so this object can be unmarshalled even if the proxy can't be (say because it codebase is unavailable). The get(net.jini.security.ProxyPreparer) method can be used to retrieve the proxy on demand.

Author:
Sun Microsystems, Inc.

Field Summary
private  MarshalledObject bytes
          The proxy in marshalled form
private static boolean DEBUG
           
private  Object obj
          A cached copy of the unmarshalled proxy
private  boolean prepared
          True if the obj has been prepared
private static long serialVersionUID
           
 
Constructor Summary
StorableReference()
          Used by the object output stream.
StorableReference(Object obj)
          Create a StorableReference that will hold obj.
 
Method Summary
 Object get(ProxyPreparer preparer)
          Return the proxy.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bytes

private MarshalledObject bytes
The proxy in marshalled form


obj

private transient Object obj
A cached copy of the unmarshalled proxy


prepared

private transient boolean prepared
True if the obj has been prepared


DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

serialVersionUID

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

StorableReference

public StorableReference(Object obj)
Create a StorableReference that will hold obj.


StorableReference

public StorableReference()
Used by the object output stream.

Method Detail

get

public Object get(ProxyPreparer preparer)
           throws IOException,
                  ClassNotFoundException
Return the proxy. If necessary deserialize the proxy and optionally prepare it. Will only deserialize the reference if it has not already been deserialized. Will only prepare the object if preparer is non-null and no previous call to get has succeeded. If this method throws an exception, preparation has not succeeded. If a previous call to this method has succeed, all future calls will succeed and return the same object as the first successful call.

Parameters:
preparer - the ProxyPreparer to be used to prepare the reference. May be null.
Returns:
the remote reference contained in this object
Throws:
IOException - if the unmarshalling fails. Will also throw RemoteException if preparer.prepareProxy does.
ClassNotFoundException - if unmarshalling fails with one.
SecurityException - if preparer does.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.