|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.rbnb.plugins.PlugInTemplate
public abstract class PlugInTemplate
An abstract base class that simplifies PlugIn development.
Most plug-in implementations will only need to overload the
processRequest(ChannelMap, PlugInChannelMap ) method in order to
have a fully functional plug-in.
Other overloadable functions:
createForwardMap(PlugInChannelMap) -- create the
ChannelMap used to forward requests for data to process, getForwardData(Sink, ChannelMap, PlugInChannelMap)
-- makes the forwarded request using the given sink and map.processRegistrationRequest(ChannelMap, PlugInChannelMap)
-- handles registration requests in case channel names or mime
types need to be changed, or server XML meta-data needs to
be generated.
| Constructor Summary | |
|---|---|
protected |
PlugInTemplate()
Create a FilterPlugIn with default parameters. |
protected |
PlugInTemplate(String host,
String name)
Create a FilterPlugIn specifying the RBNB host and the client name. |
| Method Summary | |
|---|---|
void |
addChannelToRegister(String channel)
Add a channel to be registered with the server for this PlugIn. |
protected static String[] |
argHelper(String[] args,
PlugInTemplate pit)
Helper function to parse PlugInTemplate specific command-line options. |
protected ChannelMap |
createForwardMap(PlugInChannelMap picm)
Callback to create a ChannelMap to be used to request data from the server to match an incoming request. |
protected ChannelMap |
getForwardData(Sink sink,
ChannelMap mappedChannels,
PlugInChannelMap picm)
Callback to make the request to the server for matching data. |
boolean |
getForwardRequestData()
If true, the data from incoming requests is forwarded to the sink to get matching data for processing. |
boolean |
getForwardRequests()
If true, incoming requests are automatically forwarded to the sink to get matching data for processing. |
String |
getHost()
The RBNB hostname:port. |
String |
getName()
The client name used for this PlugIn in the RBNB. |
String |
getPassword()
Password used in connecting to the RBNB. |
Properties |
getRequestOptions()
Gives a Properties object, which represents the options set by the Sink for this PlugIn when the request was made. |
Sink |
getRequestSink()
For sinks where the default request forwarding approach is inappropriate, this method may be used to get a handle to a Sink to make requests. |
long |
getTimeout()
Timeout (in ms) used in calls to Fetch(). |
boolean |
getUseOneSink()
If true, one sink is used to get all forwarding data. |
String |
getUser()
Username used in connecting to the RBNB. |
Class |
getUserRequestClass()
Returns the class whose instances are created to help answer requests. |
Object |
getUserRequestObject()
If the user request class has been set, and we are inside a callback such as processRequest(ChannelMap, PlugInChannelMap),
then this method returns an
instance of the user request class. |
boolean |
isRunning()
Returns true if this PlugIn is currently answering requests. |
protected void |
processRegistrationRequest(ChannelMap fwdReg,
PlugInChannelMap out)
Callback to handle requests for dynamic registration. |
protected abstract void |
processRequest(ChannelMap fwdData,
PlugInChannelMap out)
Override this callback to perform the plug-in processing. |
void |
setForwardRequestData(boolean forwardRequestData)
|
void |
setForwardRequests(boolean forwardRequests)
|
void |
setHost(String host)
|
void |
setName(String name)
|
void |
setPassword(String pass)
|
void |
setTimeout(long timeout)
|
void |
setUseOneSink(boolean oneSink)
|
void |
setUser(String user)
|
void |
setUserRequestClass(Class userClass)
Set the class used to help answer requests. |
protected static void |
showHelper()
A helper routine which displays the options supported by argHelper. |
void |
start()
Starts the PlugIn in another thread, returning execution to the current thread. |
void |
stop()
Stops the PlugIn thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected PlugInTemplate()
protected PlugInTemplate(String host,
String name)
| Method Detail |
|---|
public final void start()
throws SAPIException
this
are notified.
SAPIException - if a connection error occurs.public final void stop()
Any threads waiting on this are notified.
public final boolean isRunning()
public final String getHost()
public final void setHost(String host)
public final String getName()
Class.getName()public final void setName(String name)
public final String getUser()
public final void setUser(String user)
public final String getPassword()
public final void setPassword(String pass)
public final void addChannelToRegister(String channel)
IllegalArgumentException - if the channel is invalid.public final long getTimeout()
PlugIn.Fetch(long),
Sink.Fetch(long)public final void setTimeout(long timeout)
public final boolean getUseOneSink()
The default is false.
public final void setUseOneSink(boolean oneSink)
public final boolean getForwardRequests()
Other plug-ins generate their own data internally, or want to handle forwarding themselves; they should set this field to false.
The default is true.
public final void setForwardRequests(boolean forwardRequests)
public final boolean getForwardRequestData()
The default is true.
public final void setForwardRequestData(boolean forwardRequestData)
public final Class getUserRequestClass()
setUserRequestClass(Class)public final void setUserRequestClass(Class userClass)
getUserRequestObject().
The class should have either a single argument constructor which takes an instance of PlugInTemplate, or failing that a no-argument constructor.
This object is typically used to store references to objects
which are expensive to create and non-reentrant,
to give a performance improvement
over creating them each time
processRequest(ChannelMap, PlugInChannelMap) is called.
public final Object getUserRequestObject()
processRequest(ChannelMap, PlugInChannelMap),
then this method returns an
instance of the user request class.
public final Sink getRequestSink()
throws SAPIException
NOTE: If the useOneSink property is true, you should synchronize on the Sink object returned by this method.
SAPIException - if the sink is new and needs to be connected,
but failed.public final Properties getRequestOptions()
protected ChannelMap createForwardMap(PlugInChannelMap picm)
throws SAPIException
Override this method to provide an alternative mapping between channel names. It must be reentrant. The default simply copies the names over, with some special processing for registration requests.
Developers overriding this method are encouraged to respect the value of the forwardRequestData field.
Note this method will never be called if
getForwardRequests() is false.
SAPIException
protected abstract void processRequest(ChannelMap fwdData,
PlugInChannelMap out)
throws SAPIException
fwdData - Matching data from the server, if forwardRequests
is true; otherwise an empty ChannelMap which may be used as desired.out - PlugIn output.
SAPIExceptionsetForwardRequests(boolean),
getUserRequestClass(),
getRequestSink()
protected void processRegistrationRequest(ChannelMap fwdReg,
PlugInChannelMap out)
throws SAPIException
SAPIException
protected ChannelMap getForwardData(Sink sink,
ChannelMap mappedChannels,
PlugInChannelMap picm)
throws SAPIException
Note that this method is not called if the
getForwardRequests() property is false.
SAPIExceptionprotected static void showHelper()
protected static String[] argHelper(String[] args,
PlugInTemplate pit)
IllegalArgumentException - if the arguments supported do not
follow the conventions specified in showHelper().
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||