org.jboss.cache.marshall
Class TreeCacheMarshaller

java.lang.Object
  extended by org.jboss.cache.marshall.TreeCacheMarshaller
All Implemented Interfaces:
org.jgroups.blocks.RpcDispatcher.Marshaller

public class TreeCacheMarshaller
extends java.lang.Object
implements org.jgroups.blocks.RpcDispatcher.Marshaller

Marshaller implementation that does aplication specific marshalling in the JGroups RpcDispatcher level. Application that runs on specific class loader will only need to register beforehand with TreeCache the class loader needed under the specific fqn region. Note again that this marshalling policy is region based. Anything that falls under that region will use the registered class loader. We also handle the region conflict during registeration time as well. For fqn that does not belong to any region, the default (system) class loader will be used.

Version:
$Id: TreeCacheMarshaller.java,v 1.19 2006/06/06 10:17:14 msurtani Exp $
Author:
Ben Wang Date: Aug 9, 2005

Field Summary
protected  boolean defaultInactive_
           
protected  RegionManager manager_
           
 
Constructor Summary
TreeCacheMarshaller()
           
TreeCacheMarshaller(RegionManager manager, boolean defaultInactive)
           
 
Method Summary
 void activate(java.lang.String fqn)
          Activates unmarshalling of replication messages for the region rooted in the given Fqn.
protected  java.lang.String extractFqn(JBCMethodCall method_call)
           
protected  java.lang.String extractFqnFromListOfMethodCall(JBCMethodCall call)
          This is "replicate" call with a list of MethodCall argument.
protected  java.lang.String extractFqnFromMethodCall(JBCMethodCall call)
          This is "replicate" call with a single MethodCall argument.
 java.lang.ClassLoader getClassLoader(java.lang.String fqn)
          Gets the classloader previously registered for fqn by a call to registerClassLoader(String, ClassLoader).
 RegionManager getManager()
           
protected  Region getRegion(java.lang.String fqnString)
           
 void inactivate(java.lang.String fqn)
          Disables unmarshalling of replication messages for the region rooted in the given Fqn.
 boolean isDefaultInactive()
           
 boolean isInactive(java.lang.String fqn)
          Gets whether unmarshalling has been disabled for the region rooted in the given Fqn.
 java.lang.Object objectFromByteBuffer(byte[] bytes)
          This is the un-marshalling step.
 byte[] objectToByteBuffer(java.lang.Object o)
          Idea is to write specific fqn information in the header such that during unm-marshalling we know which class loader to use.
 void registerClassLoader(java.lang.String fqn, java.lang.ClassLoader cl)
          Register the specific classloader under the fqn region.
 void setDefaultInactive(boolean defaultInactive)
           
 void setManager(RegionManager manager)
           
 void unregisterClassLoader(java.lang.String fqn)
          Un-register the class loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager_

protected RegionManager manager_

defaultInactive_

protected boolean defaultInactive_
Constructor Detail

TreeCacheMarshaller

public TreeCacheMarshaller()

TreeCacheMarshaller

public TreeCacheMarshaller(RegionManager manager,
                           boolean defaultInactive)
Method Detail

getManager

public RegionManager getManager()

setManager

public void setManager(RegionManager manager)

isDefaultInactive

public boolean isDefaultInactive()

setDefaultInactive

public void setDefaultInactive(boolean defaultInactive)

registerClassLoader

public void registerClassLoader(java.lang.String fqn,
                                java.lang.ClassLoader cl)
                         throws RegionNameConflictException
Register the specific classloader under the fqn region.

Parameters:
fqn -
cl -
Throws:
RegionNameConflictException - thrown if there is a conflict in region definition.

unregisterClassLoader

public void unregisterClassLoader(java.lang.String fqn)
                           throws RegionNotFoundException
Un-register the class loader. Caller will need to call this when the application is out of scope. Otherwise, the class loader will not get gc.

Parameters:
fqn -
Throws:
RegionNotFoundException

getClassLoader

public java.lang.ClassLoader getClassLoader(java.lang.String fqn)
                                     throws RegionNotFoundException
Gets the classloader previously registered for fqn by a call to registerClassLoader(String, ClassLoader).

Parameters:
fqn - the fqn
Returns:
the classloader associated with the cache region rooted by fqn, or null if no classloader has been associated with the region.
Throws:
RegionNotFoundException

activate

public void activate(java.lang.String fqn)
              throws RegionNameConflictException
Activates unmarshalling of replication messages for the region rooted in the given Fqn.

Parameters:
fqn -
Throws:
RegionNameConflictException

inactivate

public void inactivate(java.lang.String fqn)
                throws RegionNameConflictException
Disables unmarshalling of replication messages for the region rooted in the given Fqn.

Parameters:
fqn -
Throws:
RegionNameConflictException - if there is a conflict in region definition.

isInactive

public boolean isInactive(java.lang.String fqn)
Gets whether unmarshalling has been disabled for the region rooted in the given Fqn.

Parameters:
fqn -
Returns:
true if unmarshalling is disabled; false otherwise.
See Also:
activate(java.lang.String), inactivate(java.lang.String)

objectToByteBuffer

public byte[] objectToByteBuffer(java.lang.Object o)
                          throws java.lang.Exception
Idea is to write specific fqn information in the header such that during unm-marshalling we know which class loader to use.

Specified by:
objectToByteBuffer in interface org.jgroups.blocks.RpcDispatcher.Marshaller
Parameters:
o -
Returns:
Throws:
java.lang.Exception

objectFromByteBuffer

public java.lang.Object objectFromByteBuffer(byte[] bytes)
                                      throws java.lang.Exception
This is the un-marshalling step. We will read in the fqn and thus obtain the user-specified classloader first.

Specified by:
objectFromByteBuffer in interface org.jgroups.blocks.RpcDispatcher.Marshaller
Parameters:
bytes -
Returns:
Throws:
java.lang.Exception

extractFqnFromMethodCall

protected java.lang.String extractFqnFromMethodCall(JBCMethodCall call)
This is "replicate" call with a single MethodCall argument.

Parameters:
call -

extractFqnFromListOfMethodCall

protected java.lang.String extractFqnFromListOfMethodCall(JBCMethodCall call)
This is "replicate" call with a list of MethodCall argument.

Parameters:
call -

extractFqn

protected java.lang.String extractFqn(JBCMethodCall method_call)

getRegion

protected Region getRegion(java.lang.String fqnString)


Copyright 1998-2005 JBoss Inc . All Rights Reserved.