GigaSpaces XAP 9.0 API

org.openspaces.core.space.filter
Class FilterOperationDelegate

java.lang.Object
  extended by org.openspaces.core.space.filter.FilterOperationDelegate
All Implemented Interfaces:
ISpaceFilter

public class FilterOperationDelegate
extends Object
implements ISpaceFilter

An ISpaceFilter implementation that acts as an adapter delegating the execution of the filter lifecycle methods and specific operation to pluggable reflection based methods.

Holds a Method representing an init callback, and one representing close callback. Both can be null for cases where no delegation is required.

Holds a map of FilterOperationDelegateInvoker per operation code. Once process is called, a FilterOperationDelegateInvoker is required based on the operation code, and if found, the invocation is delegated to it.

Author:
kimchy
See Also:
FilterOperationDelegateInvoker

Constructor Summary
FilterOperationDelegate(Object delegate, Map<Integer,org.openspaces.core.space.filter.FilterOperationDelegateInvoker> invokerLookup)
          Constructs a new filter operation delegate.
 
Method Summary
 void close()
          If closeMethod is supplied, will invoke it.
 void init(IJSpace space, String filterId, String url, int priority)
          If initMethod is supplied, will invoke it.
 void process(SpaceContext context, ISpaceFilterEntry[] entries, int operationCode)
          Fetch a FilterOperationDelegateInvoker based on the operation code.
 void process(SpaceContext context, ISpaceFilterEntry entry, int operationCode)
          Fetch a FilterOperationDelegateInvoker based on the operation code.
 void setCloseMethod(Method closeMethod)
          Sets an optional close method callback.
 void setInitMethod(Method initMethod)
          Sets an optional init method callback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterOperationDelegate

public FilterOperationDelegate(Object delegate,
                               Map<Integer,org.openspaces.core.space.filter.FilterOperationDelegateInvoker> invokerLookup)
Constructs a new filter operation delegate. Providing the delegate to perform the invocation on and a map of operation per FilterOperationDelegateInvoker.

Method Detail

setInitMethod

public void setInitMethod(Method initMethod)
Sets an optional init method callback.


setCloseMethod

public void setCloseMethod(Method closeMethod)
Sets an optional close method callback.


init

public void init(IJSpace space,
                 String filterId,
                 String url,
                 int priority)
          throws RuntimeException
If initMethod is supplied, will invoke it. The method signature can have no parameters or can have a single IJSpace.

Specified by:
init in interface ISpaceFilter
Parameters:
space - an embedded proxy to the space that contain this filter.
filterId - the name of this filter.
url - The URL that was passed when this filter was created.
priority - defines the order in which filters are activated.
Throws:
RuntimeException - if this exception is raised, the filter will be discarded by the engine for the current engine execution ,unless defined otherwise in space configuration.

process

public void process(SpaceContext context,
                    ISpaceFilterEntry entry,
                    int operationCode)
             throws RuntimeException
Fetch a FilterOperationDelegateInvoker based on the operation code. If found, delegates to its process method.

Specified by:
process in interface ISpaceFilter
Parameters:
context - the Context passed by the caller, contains security context. some of the filters (like ON_INIT) will always receive a null context.
entry - the event that occurred.
operationCode - the operation that defines when this filter is activated. The operation codes are defined in FilterOperationCodes.
Throws:
RuntimeException - if this exception is raised for BEFORE filters, it aborts the execution of the operation.

process

public void process(SpaceContext context,
                    ISpaceFilterEntry[] entries,
                    int operationCode)
             throws RuntimeException
Fetch a FilterOperationDelegateInvoker based on the operation code. If found, delegates to its process method.

Specified by:
process in interface ISpaceFilter
Parameters:
context - the Context passed by the caller, contains security context. some of the filters (like ON_INIT) will always receive a null context.
entries - an array of two elements:

On AFTER_UPDATE: the first element represents the old entry while the second is the new entry.

On BEFORE_NOTIFY_TRIGGER and AFTER_NOTIFY_TRIGGER: the first element represents the entry while the second is the template.

operationCode - the operation that defines when this filter is activated. The operation codes are defined in FilterOperationCodes.
Throws:
RuntimeException - if this exception is raised for BEFORE filters,

close

public void close()
           throws RuntimeException
If closeMethod is supplied, will invoke it. The method signature should have no parameters.

Specified by:
close in interface ISpaceFilter
Throws:
RuntimeException - if this exception is raised it will be logged. This should be used as away to report a filter internal error.

GigaSpaces XAP 9.0 API

Copyright © GigaSpaces.