ws-muse-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lenni Madsen" <l.mad...@mil.dk>
Subject SV: Dynamically register notification producers
Date Thu, 22 May 2008 10:44:27 GMT
Hi Jan

While I'm not sure the fits your question entirely, it does give a small
view of the EPR creating and the ability you've at modifying it
programmatically during creation of a resource instance.

public EndpointReference createWithEprOperation(String ResourceID, String
ResourceType) throws Exception    {
    	System.out.println("createWithEprOperation::start");
    	ResourceManager manager = getResource().getResourceManager();
		EndpointReference epr = null;
		try	{
			Resource next =
manager.createResource(ResourceType);
			epr = next.getEndpointReference();
			epr.removeParameter(new
QName("http://ws.apache.org/muse/addressing", "ResourceId", "muse-wsa"));
			epr.addParameter(new
QName("http://ws.apache.org/muse/addressing", "ResourceId", "muse-wsa"),
ResourceID);
			next.setEndpointReference(epr);
			// don't change the EPR after the following
// step
			next.initialize();
			manager.addResource(epr, next);
		} catch (Throwable error){
			error.printStackTrace();
		}
		System.out.println("createWithEprOperation::stop");
		return epr;
    }

Be sure to get it a thorough test as I pulled this from some unused code in
an old project, but it should be functional.

Of course this function comes from a generic factory, where the type of
resource you wish to instantiate is referenced by ResourceType. In my case I
had two different wsdl's in my project, one for the factory and one for the
Resource, but as long as the ResourceType stays unique it should scale.

/Lenni

-----Oprindelig meddelelse-----
Fra: Chris.Twiner@swisscom.com [mailto:Chris.Twiner@swisscom.com] 
Sendt: 22. maj 2008 08:46
Til: muse-user@ws.apache.org
Emne: RE: Dynamically register notification producers

createResource automatically provides an epr thats unique for you but you
will have no control over its content (by default).  It is also, by default,
not thread safe, so if you have multiple requests using createResource you
will have a problem (you can override this for a given resource with by
implementing ResourceIdFactory and configuring with java-id-factory-class).

Also it seems that you aren't, in this example, creating the resource based
on any criteria.  Will there be something set in the resource later before
subscriptions are made?  If not then I'm not sure what benefit there is to
creating multiple NotificationProducers when multiple subscriptions would
seem to suffice.

Although its very likely I've missed something in your requirements :-)

-----Original Message-----
From: Jan Torben Heuer [mailto:jan.heuer@uni-muenster.de] 
Sent: Wednesday, May 21, 2008 5:09 PM
To: muse-user@ws.apache.org
Subject: Re: Dynamically register notification producers

On Wednesday 21 May 2008 15:26:05 Chris.Twiner@swisscom.com wrote:

Hallo,


> The approach seems great, just don't forget you must have a different 
> endpoint for each created resource, using reference parameters.  The 
> link I sent covers that but it makes a lot of sense to play with it as 
> a learning

I had a look at how subscriptions work. But I cannot find a code exampe on
how a ERP is actually created. Can you give me a hint? For example the
SimpleNotificationProducer as a method #subscribe. But that method get the
ERP as parameter, so It was already created before.

What did I miss?


> public class MyAdvertisementCapability extends 
> AbstractWsResourceCapability implements AdvertisementCapability {
>
> // is called to create a new producer
> 	public EndpointReference addAdvertisement() throws SoapFault {
> 		ResourceManager manager =
getResource().getResourceManager();
>
> 		String endpoint = getAdvertiseContextPath();
> 		WsResource advertise = null;
>
> 		advertise = (WsResource) manager.createResource(endpoint);
>
> 	        EndpointReference epr = advertise.getEndpointReference();
>
>         	return epr;
> 	}
>
> 	@Override
> 	public void initialize() throws SoapFault {
> 		super.initialize();
>
> 		//
> 		// find pullpoint resource type so we can create instances
of it
> 		// in createPullPoint()
> 		//
> 		ResourceManager manager =
getResource().getResourceManager();
> 		advertisePath =
> manager.getResourceContextPath(AdvertisementCapability.class);
> 	}
> }

Jan

-- 
Jan Torben Heuer		Institute for Geoinformatics
jan.heuer@uni-muenster.de	Robert-Koch-Strasse 26-28
+49 251 83-31960		48151 M√ľnster, Germany

---------------------------------------------------------------------
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


Mime
View raw message