Author: scamp
Date: Fri Jun 17 12:32:13 2005
New Revision: 191185

URL: http://svn.apache.org/viewcvs?rev=191185&view=rev
Log:
updated for setting different names

Modified:
    
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationHome.java
    
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationResource.java

Modified: 
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationHome.java
URL: 
http://svn.apache.org/viewcvs/incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationHome.java?rev=191185&r1=191184&r2=191185&view=diff
==============================================================================
--- 
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationHome.java
 (original)
+++ 
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationHome.java
 Fri Jun 17 12:32:13 2005
@@ -1,8 +1,6 @@
 package org.wsdmdemo.service.weatherStation;
 
 import org.apache.ws.addressing.EndpointReference;
-import org.apache.ws.addressing.XmlBeansEndpointReference;
-import org.apache.ws.addressing.v2004_08_10.AddressingConstants;
 import org.apache.ws.resource.Resource;
 import org.apache.ws.resource.ResourceContext;
 import org.apache.ws.resource.ResourceContextException;
@@ -10,10 +8,7 @@
 import org.apache.ws.resource.ResourceKey;
 import org.apache.ws.resource.ResourceUnknownException;
 import org.apache.ws.resource.impl.AbstractResourceHome;
-import org.apache.xmlbeans.XmlObject;
 import org.wsdmdemo.service.InteropConstants;
-import org.wsdmdemo.service.InteropRequestUtils;
-import org.wsdmdemo.service.weatherStationDir.AddWeatherStationDocument;
 
 import javax.xml.namespace.QName;
 import java.io.Serializable;
@@ -73,39 +68,6 @@
     public synchronized void init() throws Exception
     {
         super.init();
-        /*try
-        {
-            //bootstrap the weather stations  todo not sure we need to do this
-            SimpleTypeResourceKey ws1Key = new 
SimpleTypeResourceKey(RESOURCE_KEY_NAME, InteropConstants.WS1_KEY);
-            WeatherStationResource ws1 = (WeatherStationResource) 
createInstance(ws1Key);
-            SimpleTypeResourceKey ws2Key = new 
SimpleTypeResourceKey(RESOURCE_KEY_NAME, InteropConstants.WS2_KEY);
-            WeatherStationResource ws2 = (WeatherStationResource) 
createInstance(ws2Key);
-
-            //todo how to get resource ctx in constructor for base url..may 
not be possible
-            EndpointReference ws1Epr = 
getEndpointReference(InteropConstants.BASE_ADDRESS + "/" + 
getServiceName().getLocalPart(), ws1Key, 
SPEC_NAMESPACE_SET.getAddressingNamespace());
-            ws1.setEndpointReference(ws1Epr);
-            add(ws1Key, ws1);
-
-            EndpointReference ws2Epr = 
getEndpointReference(InteropConstants.BASE_ADDRESS + "/" + 
getServiceName().getLocalPart(), ws2Key, 
SPEC_NAMESPACE_SET.getAddressingNamespace());
-            ws2.setEndpointReference(ws2Epr);
-            add(ws2Key, ws2);
-
-            //register with the directory service
-            registerWeatherStation(ws1Epr);
-            registerWeatherStation(ws2Epr);
-        }
-        catch (ResourceException e)
-        {
-            e.printStackTrace();
-        }*/
-    }
-
-    private void registerWeatherStation(EndpointReference epr)
-    {
-        AddWeatherStationDocument addWeatherStationDocument = 
AddWeatherStationDocument.Factory.newInstance();
-        
org.wsdmdemo.service.weatherStationDir.AddWeatherStationDocument.AddWeatherStation
 addWeatherStation = addWeatherStationDocument.addNewAddWeatherStation();
-        
addWeatherStation.setEndpointReference((org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType)
 ((XmlBeansEndpointReference) 
epr).getXmlObject(AddressingConstants.NSURI_ADDRESSING_SCHEMA));
-        XmlObject xmlObject = 
InteropRequestUtils.sendRequest(addWeatherStationDocument, 
"http://wsdmdemo.org/service/weather-station-dir/AddWeatherStation";, 
InteropConstants.SYSPROP_WS_DIR_SERVICE_URL);
     }
 
     /**
@@ -134,9 +96,19 @@
             Object id = key.getValue();
             if (InteropConstants.WS1_KEY.equals(id) || 
InteropConstants.WS2_KEY.equals(id))
             {
+                String name = null;
+                if(InteropConstants.WS1_KEY.equals(id))
+                {
+                    name = "Space Co.";
+                }
+                else
+                {
+                    name = "NASA";
+                }
                 try
                 {
                     WeatherStationResource myresource = 
(WeatherStationResource) createInstance(key); //this will create the resource 
IF it is has default constructor. It also calls init() on the resource.
+                    myresource.setName(name);
                     //the next line will create an EPR
                     EndpointReference epr = 
getEndpointReference(resourceContext.getBaseURL() + "/" + 
getServiceName().getLocalPart(), key, 
SPEC_NAMESPACE_SET.getAddressingNamespace());
                     myresource.setEndpointReference(epr); //make sure to set 
the EPR on your new instance

Modified: 
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationResource.java
URL: 
http://svn.apache.org/viewcvs/incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationResource.java?rev=191185&r1=191184&r2=191185&view=diff
==============================================================================
--- 
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationResource.java
 (original)
+++ 
incubator/muse/trunk/src/ieeedemo/src/java/org/wsdmdemo/service/weatherStation/WeatherStationResource.java
 Fri Jun 17 12:32:13 2005
@@ -10,6 +10,7 @@
 import org.apache.ws.notification.topics.TopicSpace;
 import org.apache.ws.notification.topics.impl.TopicSpaceImpl;
 import org.apache.ws.resource.faults.FaultException;
+import org.apache.ws.resource.properties.ResourceProperty;
 import 
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.OperationalStatusDocument;
 import org.wsdmdemo.service.InteropConstants;
 import org.wsdmdemo.service.weatherStation.callbacks.HumidityCallback;
@@ -131,14 +132,6 @@
             prop_price.setPrice(InteropConstants.PRICE);
             resourceProperty.add(prop_price);
 
-
-            // init the {http://wsdmdemo.org/service/weather-station}Name 
Resource Property
-            resourceProperty = 
resourcePropertySet.get(WeatherStationPropertyQNames.NAME);
-            org.wsdmdemo.service.weatherStation.NameDocument prop_name = 
org.wsdmdemo.service.weatherStation.NameDocument.Factory.newInstance();
-            prop_name.setName("NASA");
-            resourceProperty.add(prop_name);
-
-
             // init the 
{http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd}OperationalStatus
 Resource Property
             resourceProperty = 
resourcePropertySet.get(WeatherStationPropertyQNames.OPERATIONALSTATUS);
             
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.OperationalStatusDocument 
prop_operationalstatus = 
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.OperationalStatusDocument.Factory.newInstance();
@@ -183,5 +176,19 @@
          * @param propSet
          */
         
org.apache.ws.notification.topics.util.TopicUtils.initNotificationProducerProperties(getTopicSpaceSet(),
 getResourcePropertySet());
+    }
+
+    /**
+     * Sets the name property of this resource.
+     * i.e. Nasa
+     *
+     * @param name
+     */
+    public void setName(String name)
+    {
+         ResourceProperty resourceProperty = 
getResourcePropertySet().get(WeatherStationPropertyQNames.NAME);
+         org.wsdmdemo.service.weatherStation.NameDocument prop_name = 
org.wsdmdemo.service.weatherStation.NameDocument.Factory.newInstance();
+         prop_name.setName(name);
+         resourceProperty.add(prop_name);
     }
 }



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

Reply via email to