Hi Daniel

The SubscriptionManager itself is included in the WS-specs with Muse,
you just need to add the links in your resource.wsdl (the
muse-template.wsdl on the Muse website should already have all the
needed WSDL code needed).

Now to access the Notification Producer capability within your code a
bit of manual work (see below) has to be done (it's not added in by the
wsdl2java), the example below is for a WSDM resource, more work will be
needed for a WSRF resource as some things are provided by the Muse
framework behind the scenes for a WSDM resource.

To keep the email short and viewable I'll refrain from including the
wsdl for the example below.

Sincerely

Lenni


*** in the MyCapability.java of the resource you wish to have the WSN
producer ***

/**
         * External capabilities are instantiated and can be used
         */
        public void initializeCompleted() throws SoapFault {
                super.initializeCompleted();
                runtimeNotification =
(NotificationProducer)getResource().getCapability(WsnConstants.PRODUCER_
URI);
                // add list of Topics if needed
                runtimeNotification.addTopic(_TOPIC_NAME);
        }

// the function called to send a notification, you can add any
parameters //you wish, and it can be private so only functions within
you MyCapability.jav can access it or public to allow others to use it
public Element runtimeEventOperation(){
        factory = new SimpleWefFactory();
        event = factory.createEvent(); 
        
        Component reporter = factory.createComponent();
        ComponentAddress reporterAddress =
factory.createComponentAddress(getResource().getEndpointReference().toXM
L());
        reporter.setAddress(reporterAddress);
        reporter.setName(WefConstants.REPORTER_COMP_QNAME);
        Component source = factory.createComponent();
        ComponentAddress sourceAddress =
factory.createComponentAddress(getResource().getEndpointReference().toXM
L());
        source.setAddress(sourceAddress);
        source.setName(WefConstants.SOURCE_COMP_QNAME);         
        Situation situation = factory.createSituation();
 
situation.setCategoryType(WefConstants.AVAILABILITY_SITUATION_QNAME);
        situation.setPriority(Situation.HIGH_PRIORITY);
        situation.setSeverity(Situation.UNKNOWN_SEVERITY);
        situation.setMessage("Something important has happened in the
"+getServerName()+"!");
        event.setReporter(reporter);
        event.setSource(source);
        event.setSituation(situation);
                try{
                        getLog().info("Sending message to
consumers...");
                        
                        runtimeNotification.publish(_TOPIC_NAME,
toPublish);
                }catch (Throwable error){
                        error.printStackTrace();
                }
                return toPublish;
}


-----Original Message-----
From: Daniel Beer [mailto:[EMAIL PROTECTED] 
Sent: 27 November 2007 22:55
To: [email protected]
Subject: Adding Notification Producer Capabilities to existing
webservice

Hi all,

we have already running a muse 2.2.0 webservice and want to add
notification producer capabilities to it. I somewhat copied & pasted my
existing wsdl into the wsn-producer sample WsResource.wsdl. After some
try
and error (NPE and "only one service allowed") I am now able to generate
my artifacts with

$MUSE_HOME/bin/wsdl2java.sh -j2ee mini -overwrite -wsdl foobar.wsdl

but the generated artifacts don't contain any notification specific
declarations. MyCapability still only extends AbstractCapability, but if
I
generate the artifacts of wsn-producer sample MyCapability extends
AbstractWsResourceCapability.

In addition I'm a bit confused about the WsResource.rmd and
SubscriptionManager.wsdl files, where do they come from and do I have to
edit them?

Any help appreciated,

TIA,
Daniel

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


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

Reply via email to