| Home >> All >> org >> everestWeather >> wsdm >> samples >> x2005 >> x04 >> [ schema Javadoc ] |
Source code: org/everestWeather/wsdm/samples/x2005/x04/schema/WeatherstationHome.java
1 package org.everestWeather.wsdm.samples.x2005.x04.schema; 2 3 import org.apache.ws.resource.Resource; 4 import org.apache.ws.resource.ResourceContext; 5 import org.apache.ws.resource.ResourceContextException; 6 import org.apache.ws.resource.ResourceException; 7 import org.apache.ws.resource.ResourceKey; 8 import org.apache.ws.resource.ResourceUnknownException; 9 import org.apache.ws.resource.example.InteropConstants; 10 import org.apache.ws.resource.impl.AbstractResourceHome; 11 import org.apache.ws.addressing.EndpointReference; 12 13 import javax.xml.namespace.QName; 14 import java.io.Serializable; 15 16 /** 17 * Home for Weatherstation WS-Resources. 18 */ 19 public class WeatherstationHome 20 extends AbstractResourceHome 21 implements Serializable 22 { 23 /** 24 * The service endpoint name as registered with the SOAP Platform. This is useful for building EPR's. * 25 */ 26 public static final QName SERVICE_NAME = javax.xml.namespace.QName.valueOf("{http://everest-weather.org/wsdm/samples/2005/04/schema}weatherstation"); 27 28 /** 29 * The management PortType associated with this resource. This is useful for building EPR's.* 30 */ 31 public static final QName PORT_TYPE = javax.xml.namespace.QName.valueOf("{http://everest-weather.org/wsdm/samples/2005/04/schema}WeatherStationPortType"); 32 33 /** 34 * The WSDL Port name associated with the resource. This is useful for building EPR's. * 35 */ 36 public static final String PORT_NAME = "weatherstation"; 37 38 /** 39 * The name of the resource key for this resource. * 40 */ 41 public static final QName RESOURCE_KEY_NAME = javax.xml.namespace.QName.valueOf("{${resourcekey.NamespaceURI}}${resourcekey.LocalPart}"); 42 43 /** 44 * A NamespaceVerionHolder which maintains the QNames of Spec Wsdls 45 */ 46 public static final org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl SPEC_NAMESPACE_SET = new org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl(); 47 /** 48 * A constant for the JNDI Lookup name for this home. * 49 */ 50 public static final String HOME_LOCATION = 51 org.apache.ws.resource.JndiConstants.CONTEXT_NAME_SERVICES + "/" + SERVICE_NAME.getLocalPart() + "/" + org.apache.ws.resource.JndiConstants.ATOMIC_NAME_HOME; 52 53 54 /** 55 * TODO 56 * 57 * @param resourceContext DOCUMENT_ME 58 * @return DOCUMENT_ME 59 * @throws ResourceException DOCUMENT_ME 60 * @throws ResourceContextException DOCUMENT_ME 61 * @throws ResourceUnknownException DOCUMENT_ME 62 */ 63 public Resource getInstance(ResourceContext resourceContext) 64 throws ResourceException, 65 ResourceContextException, 66 ResourceUnknownException 67 { 68 ResourceKey key = resourceContext.getResourceKey(); 69 WeatherstationResource resource = null; 70 try 71 { 72 resource = (WeatherstationResource)find(key); 73 } 74 catch (ResourceException re) 75 { 76 Object id = key.getValue(); 77 /** 78 * Determine if the passed-in key is, in fact, something we expect. 79 */ 80 if (id.equals(InteropConstants.WEATHERSTATION_KEY1) || id.equals(InteropConstants.WEATHERSTATION_KEY2)) 81 { 82 try 83 { 84 resource = (WeatherstationResource)createInstance(key); 85 FCCIDDocument fccidDocument = FCCIDDocument.Factory.newInstance(); 86 //set the same value for both instances 87 fccidDocument.setFCCID(InteropConstants.FCCID); 88 ((WeatherstationResource) resource).setFCCID(fccidDocument); 89 EndpointReference epr = getEndpointReference(resourceContext.getBaseURL( ) + "/" + getServiceName().getLocalPart() , key, SPEC_NAMESPACE_SET.getAddressingNamespace()); 90 resource.setEndpointReference(epr); 91 92 } 93 catch (Exception e) 94 { 95 throw new ResourceException(e); 96 } 97 add(key, resource); 98 } 99 else 100 { 101 throw new ResourceUnknownException(id, 102 resourceContext.getServiceName()); 103 } 104 } 105 return resource; 106 107 } 108 109 public QName getServiceName() 110 { 111 return SERVICE_NAME; 112 } 113 114 public QName getPortType() 115 { 116 return PORT_TYPE; 117 } 118 119 public String getServicePortName() 120 { 121 return PORT_NAME; 122 } 123 124 public QName getResourceKeyNameQName() 125 { 126 return RESOURCE_KEY_NAME; 127 } 128 }