|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.replicator.filter.JavaScriptFilter
public class JavaScriptFilter
This filter allows to develop JavaScript filters without coding any Java at
all.
User's script will be precompiled once and then called on every filtered
event.
Script must define the following function:
function filter(event) - called on every filtered
ReplDBMSEvent.
filter(event) function's return value is handled as follows:
a. null and ReplDBMSEvent - passed through to the JavaScriptFilter's caller,
b. Undefined (no return statement in the JS) - ignored,
c. Everything else - logged into INFO stream.
Further functions may be defined, but are optional:
function prepare() - called when this filter is being prepared.
function release() - called when this filter is being released.
Any of these functions are free to return a value. If they do, value is
logged into trep.log INFO stream.
Also there are the following variables exported via JavaScript reflection for
user's usage:
properties -
TungstenProperties of the
current replicator instance;
filterProperties -
TungstenProperties subset with
the current filter's properties (eg. "script");
logger - this classes Logger. Eg. of usage:
logger.info("I'm a script!");
thread - current Thread. Eg. of usage: thread.sleep(1000);
Note: if you wish to call more than one JS file, use multiple instances of
this filter with different names defined in replicator.properties
| Constructor Summary | |
|---|---|
JavaScriptFilter()
|
|
| Method Summary | |
|---|---|
void |
configure(PluginContext context)
Complete plug-in configuration. |
ReplDBMSEvent |
filter(ReplDBMSEvent event)
Calls filter(event) function in user's script. |
void |
prepare(PluginContext context)
Reads and compiles user's script. |
void |
release(PluginContext context)
Calls script's release() function if it exists. |
void |
setConfigPrefix(java.lang.String configPrefix)
Set filter's configuration prefix. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JavaScriptFilter()
| Method Detail |
|---|
public void setConfigPrefix(java.lang.String configPrefix)
TungstenProperties filterProperties = properties.subset(configPrefix
+ ".", true);
setConfigPrefix in interface FilterManualPropertiesconfigPrefix - Configuration prefix.FilterManualProperties.setConfigPrefix(java.lang.String)
public ReplDBMSEvent filter(ReplDBMSEvent event)
throws ReplicatorException,
java.lang.InterruptedException
filter in interface Filterevent - An event to be filtered
ReplicatorException - Thrown if there is a processing error
java.lang.InterruptedException - Must be thrown if the filter is interrupted
or the replicator may hangFilter.filter(com.continuent.tungsten.replicator.event.ReplDBMSEvent)
public void configure(PluginContext context)
throws ReplicatorException
configure in interface ReplicatorPluginReplicatorException - Thrown if configuration is incomplete or
failsReplicatorPlugin.configure(com.continuent.tungsten.replicator.plugin.PluginContext)
public void prepare(PluginContext context)
throws ReplicatorException
prepare in interface ReplicatorPluginReplicatorException - Thrown if resource allocation failsReplicatorPlugin.prepare(com.continuent.tungsten.replicator.plugin.PluginContext)
public void release(PluginContext context)
throws ReplicatorException
release in interface ReplicatorPluginReplicatorException - Thrown if resource deallocation failsReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||