ws-muse-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Twiner <chris.twi...@gmail.com>
Subject Re: WSRP property change notifications
Date Fri, 06 Mar 2009 15:19:21 GMT
No problem Jonas.

The only thing further I can suggest is that there is either no rmd
file, an empty rmd file or it is not linked to the wsdl.  If that
doesn't help at all perhaps you can send me the project (as far as
possible) with a test case directly and I'll have a look sometime next
week.

cheers,
Chris

On Fri, Mar 6, 2009 at 3:07 PM, Jonas Buys <jonas_buys@yahoo.com> wrote:
> Hello Chris!
>
> Thanks for your swift reply!  I pasted the code for MyCapability.java.  The value of
the _FrameDropping and _CPUload variables is correctly set in the initialize() and initializeCompleted()
methods.  I added a small comment where it goes wrong (just in front of the iterator creation).
>
> Thx!
>
> public class MyCapability extends AbstractManageabilityCapability implements IMyCapability
> {
>     private int _CPUload;
>     private int _oldCPUload;
>     private int _FrameDropping;
>     private boolean _playing;
>
>     private JMPlayer _mplayer;
>     private static final QName[] _PROPERTIES = new QName[]
>     {
>         new QName(NAMESPACE_URI, "CPUload", PREFIX),
>         new QName(NAMESPACE_URI, "FrameDropping", PREFIX)
>     };
>
>     public void initialize() throws SoapFault
>     {
>         //
>         //The following call is necessary to property initialize the resource
>         //
>         super.initialize();
>
>         //
>         // perform intitialization of the following non-primitive properties
>         //
>     _FrameDropping = 0;
>     _CPUload = _oldCPUload = HelloCPU.getCPULoad();
>     _playing = false;
>     }
>
>     public void initializeCompleted() throws SoapFault
>     {
>         super.initializeCompleted();
>
>         // every once in a while update CPU load
>         Thread cpumon = new Thread() {
>             public void run()
>             {
>                 while (true) {
>                     try {
>             setCPUload(HelloCPU.getCPULoad());
>                         Thread.currentThread().sleep(5000L);;
>                     } catch(InterruptedException exc) {
>                getLog().warning("\nCPU monitor thread interrupted\n");
>               }
>                 }
>             }
>         };
>         cpumon.start();
>
>         // alert on property change that occurred outside of WSRP requests
>         QName cpuElem = _PROPERTIES[0];
>     Element oldValue = XmlUtils.createElement(cpuElem, new Integer(_oldCPUload));
>     Element newValue = XmlUtils.createElement(cpuElem, new Integer(_CPUload));
>     ResourcePropertyCollection wsrp = getWsResource().getPropertyCollection();
> // --> the returned WSRP variable = NULL <--
>
>     Iterator i = wsrp.getChangeListeners(cpuElem);
>
>     while(i.hasNext()) {
>         PropertyChangeListener listener = (PropertyChangeListener)i.next();
>         listener.propertyChanged(oldValue, newValue);
>         }
>     }
>
>     public QName[] getPropertyNames()
>     {
>         return _PROPERTIES;
>     }
>
>     public int getCPUload()
>     {
>         return _CPUload;
>     }
>
>     public void setCPUload(int param0)
>     {
>     _oldCPUload = _CPUload;
>         _CPUload = param0;
>     }
>
>     public int getFrameDropping()
>     {
>         return _FrameDropping;
>     }
>
>     public void setFrameDropping(int param0)
>     {
>         _FrameDropping = param0;
>     }
>
>     public void start() throws Exception    {
>     _mplayer = new JMPlayer();
>     _mplayer.open(new File("D:/fortis.avi"));
>     //_mplayer.setFullscreen(1);
>         _playing = true;
>     }
>
>     public void pause() throws Exception {
>     if(_playing && (_mplayer != null)) {
>        _mplayer.togglePlay();
>            _playing = false;
>     }
>     }
>
>     public void resume() throws Exception    {
>     if(!_playing && (_mplayer != null)) {
>        _mplayer.togglePlay();
>            _playing = true;
>     }
>     }
>
>     public void stop() throws Exception    {
>         if(_mplayer != null) _mplayer.close();
>     }
> }
>
> --- On Fri, 3/6/09, Chris Twiner <chris.twiner@gmail.com> wrote:
> From: Chris Twiner <chris.twiner@gmail.com>
> Subject: Re: WSRP property change notifications
> To: muse-user@ws.apache.org, jonas_buys@yahoo.com
> Date: Friday, March 6, 2009, 2:48 PM
>
> Its great to hear about new users, there have been many in the last
> months, truly great.
>
> Could you please send the source code for the capability that contains
> the property and the code that triggers the value update?
>
> I wonder if the capability with the properties is not the same as the
> one that calls getPropertyCollection.
>
> On Fri, Mar 6, 2009 at 2:20 PM, Jonas Buys <jonas_buys@yahoo.com> wrote:
>> Hi,
>>
>> Please forgive be about my ignorance of MUSE, as I am just starting to use
> it, but so far I'm *very* fond of it!
>>
>> Unfortunately,
>> I am facing this rather peculiar issue.  I want to have WSRP change
>> notifications automatically published for an _internally changed_
>> metric variable.  To accomplish this task, I followed the procedure
>> described in
>>
> http://ws.apache.org/muse/docs/2.2.0/manual/how-to/publish-wsrp-notifications.html
> using the PropertyChangeListeners.
>>
>> BUT
>> - even though the resource property document is correctly populated
>> with my defined properties and their values - the wsrp variable results
>> in null:
>> ResourcePropertyCollection wsrp = getWsResource().getPropertyCollection();
>> (code inside myCapab.java's initializeCompleted method).
>> The WsResource appears to be set correctly, I did a toString() for
>>  that.
>>
>> Any help would be much appreciated!
>>
>> Cheers, Jonas
>>
>>
>>
>
>
>
>

Mime
View raw message