Hi Lei,
Are you trying to access the NotificationProducer from code external to
muse or just another capability that isn't part of your resource?
If its from another capability or resource you can use :
public Resource getDefaultResource(String resourceName) {
Resource resource = null;
try {
resource = manager.getResource(new
EndpointReference(
new
URI(museIsoLayer.getRouter().getEnvironment().getDefaultURI()+resourceNa
me)));
} catch (URISyntaxException e) {
// handle the case wherethe uri is bad
}
// got a resource?
if (resource == null) {
// throw some kind of exception etc
}
return resource;
}
where
manager = ( (SimpleResourceRouter) museIsoLayer.getRouter()
).getResourceManager();
or
manager = getResource().getResourceManager();
and the resourceName is the resource name present in your muse.xml and
that you only have one instance of that resource.
If the code is to be accessed from outside of Muse resources or
capabilities then you must provide a hook to the ResourceManager. You
can pass the instance via a custom capability into the code that needs
it.
cheers,
Chris
-----Original Message-----
From: Huang, Lei [USA] [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 24, 2008 10:50 PM
To: [email protected]
Subject: referencing NotificationProducer from user defined classes
hi everyone,
I'm currently developing some business logic for a notification producer
and able to get a reference to the muse NotificationProducer class
through resource manager with this statement:
final NotificationProducer wsn = (NotificationProducer)
getResource().getCapability(WsnConstants.PRODUCER_URI);
My question is how do I get the muse NotificationProducer reference in
other than MyCapability class. If I use NotificationProducerClient
object, it doesn't provide me with APIs such as addTopic(), publish()
and etc. Please advise. Thanks in advance for everyone's help.
Lei
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]