xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.filewriter
Class FileWriter

java.lang.Object
  extended by org.xmlBlaster.contrib.GlobalInfo
      extended by org.xmlBlaster.contrib.filewriter.FileWriter
All Implemented Interfaces:
I_Callback, I_Info, I_Plugin

public class FileWriter
extends GlobalInfo
implements I_Callback

XmlBlaster plugin wrapper code. A plugin registration example (xmlBlasterPlugins.xml):

    <plugin create='true' id='FileWriter'
           className='org.xmlBlaster.contrib.filewriter.Receiver'>
      <attribute id='mom.topicName'>fileWriterTopic</attribute>
      <attribute id='connectQos'><![CDATA[
           <qos>
              <securityService type='htpasswd' version='1.0'>
                <user>FileWriter</user>
                <passwd>secret</passwd>
              </securityService>
              <session name='client/FileWriter/session/1' timeout='0' maxSessions='1'
                          clearSessions='true' reconnectSameClientOnly='false'/>
           </qos>
           ]]>
      </attribute>
      <attribute id='directoryName'>${user.home}${file.separator}FileDumps</attribute>
      <action do='LOAD' onStartupRunlevel='6' sequence='6'
                 onFail='resource.configuration.pluginFailed'/>
      <action do='STOP' onShutdownRunlevel='5' sequence='6'/>
   </plugin>
 

Author:
Michele Laghi

Field Summary
private  I_XmlBlasterAccess access
           
private  FileWriterCallback callback
           
private  ConnectQos connectQos
           
private  Global global
           
private  boolean isShutdown
          used to identify if it has shut down (to get a new global)
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
private  boolean momAdministered
           
private  java.lang.String name
          only used as a default login name and logging
private  I_PluginConfig pluginConfig
           
private  java.lang.String subscribeKey
           
private  java.lang.String subscribeQos
           
 
Fields inherited from class org.xmlBlaster.contrib.GlobalInfo
LOWER_CASE, ORIGINAL_ENGINE_GLOBAL, pluginInfo, UNTOUCHED, UPPER_CASE
 
Fields inherited from interface org.xmlBlaster.contrib.I_Info
ID, JMX_PREFIX
 
Constructor Summary
FileWriter()
           
FileWriter(Global globOrig, java.lang.String name, I_PluginConfig config)
           
 
Method Summary
 void doInit(Global glob, PluginInfo info)
           
 java.lang.String getType()
          The plugin name as configured im xmlBlasterPlugins.xml
 java.lang.String getVersion()
          The plugin version as configured in xmlBlasterPlugins.xml
private  void initConnection()
          Connects to the xmlBlaster.
private  void prepareInit(Global globOrig, I_PluginConfig config)
           
 void shutdown()
          If an exception occurs it means it could not publish the entry
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.
 
Methods inherited from class org.xmlBlaster.contrib.GlobalInfo
dump, get, getBoolean, getGlobal, getInt, getKeys, getLong, getObject, getObjectKeys, getOriginalGlobal, getRaw, getStrippedString, init, loadPlugin, put, putObject, putRaw, replaceAllEntries, setStrippedHostname
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

global

private Global global

log

private static java.util.logging.Logger log

access

private I_XmlBlasterAccess access

connectQos

private ConnectQos connectQos

subscribeKey

private java.lang.String subscribeKey

subscribeQos

private java.lang.String subscribeQos

callback

private FileWriterCallback callback

isShutdown

private boolean isShutdown
used to identify if it has shut down (to get a new global)


name

private java.lang.String name
only used as a default login name and logging


pluginConfig

private I_PluginConfig pluginConfig

momAdministered

private boolean momAdministered
Constructor Detail

FileWriter

public FileWriter()

FileWriter

public FileWriter(Global globOrig,
                  java.lang.String name,
                  I_PluginConfig config)
           throws XmlBlasterException
Throws:
XmlBlasterException
Method Detail

prepareInit

private void prepareInit(Global globOrig,
                         I_PluginConfig config)
                  throws XmlBlasterException
Throws:
XmlBlasterException

initConnection

private void initConnection()
                     throws XmlBlasterException
Connects to the xmlBlaster.

Throws:
XmlBlasterException

shutdown

public void shutdown()
              throws XmlBlasterException
If an exception occurs it means it could not publish the entry

Specified by:
shutdown in interface I_Plugin
Overrides:
shutdown in class GlobalInfo
Throws:
XmlBlasterException
See Also:
I_Plugin.shutdown()

getType

public java.lang.String getType()
Description copied from class: GlobalInfo
The plugin name as configured im xmlBlasterPlugins.xml

Specified by:
getType in interface I_Plugin
Overrides:
getType in class GlobalInfo
See Also:
I_Plugin.getType()

getVersion

public java.lang.String getVersion()
Description copied from class: GlobalInfo
The plugin version as configured in xmlBlasterPlugins.xml

Specified by:
getVersion in interface I_Plugin
Overrides:
getVersion in class GlobalInfo
See Also:
I_Plugin.getVersion()

doInit

public void doInit(Global glob,
                   PluginInfo info)
            throws XmlBlasterException
Specified by:
doInit in class GlobalInfo
Parameters:
glob - The global passed by the RunLevelManager, this is not the object owned by the plugin. It is the original global.
Throws:
XmlBlasterException

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
Description copied from interface: I_Callback
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.

So you should implement in your client code the I_Callback interface - suppling the update() method where you can do with the message whatever you want.

The raw protocol driver specific update() method (e.g. CORBA-BlasterCallback.update()) is unpacked and for each arrived message this update is called.

Specified by:
update in interface I_Callback
Parameters:
cbSessionId - The session ID specified by the client which registered the callback. You can specify a cbSessionId during connection (with ConnectQos) and this is bounced back here so you can authenticate the message.
updateKey - The arrived key containing the topic name
content - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.