Yes it needs that too!

I was saving that for destroy() :-)

Paul

On 7/26/07, Davanum Srinivas <[EMAIL PROTECTED]> wrote:
> Paul,
>
> How about a mechanism for synapse to tell GMondPuller to shut itself
> down as Synapse instance itslef is being shutdown?
>
> thanks,
> dims
>
> On 7/26/07, Paul Fremantle <[EMAIL PROTECTED]> wrote:
> > Here is a simple example of what I'd like to be able to do
> >
> > As you can see it would make it dead simple to add a new adapter. In
> > this case, all you need to do to get XML from gmond is to open a
> > socket to it.
> >
> > The changes we'd need to make this work are:
> >
> > 1) create a synapse interface Initializable which could be implemented
> > both by mediators and also by stuff like adapters that need to be run
> > but aren't mediators
> > 2) Add a way of specifying things that need to be started in the Synapse 
> > config:
> >
> > e.g.
> > <startup>
> >    <init class="org.fremantle.GMondPuller"/>
> > </startup>
> >
> > 2) need to be able to get at the thread pool from the
> > SynapseEnvironment (this could just be a link into the Axis2 thread
> > pool)
> > 3) Fix createMessageContext!
> > 4) I think that is it.
> >
> > public class GMondPuller implements Initializable, Runnable {
> >
> >         private String hostName = null;
> >         private int port = 0;
> >         private long interval = 1000;
> >         private SynapseEnvironment synapseEnvironment = null;
> >
> >         public void init(SynapseConfiguration sc, SynapseEnvironment se) {
> >                 synapseEnvironment = se;
> >                 synapseEnvironment.getThreadPool().execute(this);
> >         }
> >
> >         public void run() {
> >
> >                 if (hostName == null || port == 0 || synapseEnvironment == 
> > null)
> >                         return;
> >                 try {
> >                         while (true) {
> >                                 java.net.Socket socket = new 
> > Socket(hostName, port);
> >                                 StAXOMBuilder builder = new 
> > StAXOMBuilder(socket
> >                                                 .getInputStream());
> >                                 MessageContext mc =
> >                                      
> > synapseEnvironment.createMessageContext();
> >                                 
> > mc.getEnvelope().getBody().addChild(builder.getDocumentElement());
> >                                 synapseEnvironment.injectMessage(mc);
> >                                 Thread.sleep(interval);
> >                         }
> >                 } catch (Exception e) {
> >                         log.debug(e);
> >                 }
> >
> >         }
> >
> >         public void setHostName(String hostName) {
> >                 this.hostName = hostName;
> >         }
> >
> >         public String getHostName() {
> >                 return hostName;
> >         }
> >
> >         public void setPort(int port) {
> >                 this.port = port;
> >         }
> >
> >         public int getPort() {
> >                 return port;
> >         }
> >
> >         public void setInterval(long interval) {
> >                 this.interval = interval;
> >         }
> >
> >         public long getInterval() {
> >                 return interval;
> >         }
> > }
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Davanum Srinivas :: http://davanum.wordpress.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair

blog: http://pzf.fremantle.org
[EMAIL PROTECTED]

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to