You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-user@ws.apache.org by le...@bt.com on 2007/11/28 12:29:29 UTC

RE: Adding Notification Producer Capabilities to existing web service

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:daniel.beer@iais.fraunhofer.de] 
Sent: 27 November 2007 22:55
To: muse-user@ws.apache.org
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: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org


RE: Adding Notification Producer Capabilities to existing web service

Posted by Daniel Beer <da...@iais.fraunhofer.de>.
Hi Lenni,

thanks for your hints. I pasted and adopted your snippet to my code, but I
can't get it running. I specified values for ServerName and
MessageInterval but I get these errors:

java.lang.RuntimeException: [ID = 'PropertyNotFound'] The schema has no
property with the name '{NAMESPACE_URI}ServerName'. Use the hasProperty
method to determine if a property exists.

java.lang.RuntimeException: [ID = 'PropertyNotFound'] The schema has no
property with the name '{NAMESPACE_URI}MessageInterval'. Use the
hasProperty method to determine if a property exists.

java.lang.IllegalStateException: [ID = 'NoCapabilityForProperty'] There is
no capability that defines the property
{http://ws.apache.org/muse/test/wsrf}MessageInterval. If you have a
capability that is supposed to define this property, make sure the name is
returned as part of WsResourceCapability.getPropertyNames().

org.apache.muse.ws.notification.faults.InvalidTopicExpressionFault: [ID =
'TopicExists'] There is already a topic named 'TopologyChange' in the
topic space for 'NAMESPACE_URI'.


Additionally I wonder how and where to call your runtimeEventOperation
method as MyCapability delegates calls to a RequestHandler:

    public Element createStuff(final Element createStuffElement) throws
Exception {
        return RequestHandler.getInstance().handle(createStuffElement);
    }
and what is toPublish in your snippet?


Thanks for your help,
Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org


Extending default EPR handling in Muse

Posted by Scandelli Francesco <Fr...@italtel.it>.
Hi all

I'd like to use Muse in order to expose a great number of manageable
resources MUWS whose states/behaviours depend on a series of underlying
heterogeneous data sources/agents.

The point is that I'd like to avoid having one object per each
manageable resource in order to reduce the footprint (I read an article
by D.Jamiolo which addresses this problem:
http://www-128.ibm.com/developerworks/autonomic/library/ac-muse.html)
and I'd like also to remove the list of EPRs that Muse keeps in memory.
This way Muse would serve any request to a certain resource by first
addressing the right resource type through the URL part of the requested
EPR, and then it would delegate the request to the proper capability
which would contextualize the request using the second part of the EPR
(the WS-A parameters) in a total resource type specific way. Of course
it could happen that the requested EPR has not correspondence in the
underlying data sources/agents and in this case Muse should return an
error like "resource not found". 

Do you think it's possible to obtain such a Muse behaviour? If yes, how?
By writing my own implementation of org.apache.muse.core.ResourceManager
interface?

Thanks
Francesco


Internet Email Confidentiality Footer
-----------------------------------------------------------------------------------------------------
La presente comunicazione, con le informazioni in essa contenute e ogni documento o file allegato, e' rivolta unicamente alla/e persona/e cui e' indirizzata ed alle altre da questa autorizzata/e a riceverla. Se non siete i destinatari/autorizzati siete avvisati che qualsiasi azione, copia, comunicazione, divulgazione o simili basate sul contenuto di tali informazioni e' vietata e potrebbe essere contro la legge (art. 616 C.P., D.Lgs n. 196/2003 Codice in materia di protezione dei dati personali). Se avete ricevuto questa comunicazione per errore, vi preghiamo di darne immediata notizia al mittente e di distruggere il messaggio originale e ogni file allegato senza farne copia alcuna o riprodurne in alcun modo il contenuto. 

This e-mail and its attachments are intended for the addressee(s) only and are confidential and/or may contain legally privileged information. If you have received this message by mistake or are not one of the addressees above, you may take no action based on it, and you may not copy or show it to anyone; please reply to this e-mail and point out the error which has occurred. 
-----------------------------------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org