package org.wsdmdemo.service.weatherStation;
import org.apache.ws.Soap1_1Constants;
import org.apache.ws.muws.v1_0.MuwsConstants;
import org.apache.ws.muws.v1_0.capability.IdentityCapability;
import org.apache.ws.muws.v1_0.capability.ManageabilityCharacteristicsCapability;
import org.apache.ws.muws.v1_0.capability.OperationalStatusCapability;
import org.apache.ws.muws.v1_0.topics.ManagementEventTopic;
import org.apache.ws.muws.v1_0.topics.impl.XmlBeansManagementEventTopicImpl;
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;
import org.wsdmdemo.service.weatherStation.callbacks.TemperatureCallback;
import org.wsdmdemo.service.weatherStation.callbacks.VisibilityCallback;
import org.wsdmdemo.service.weatherStationDir.WeatherStationDirPropertyQNames;
import java.util.Calendar;
/**
* **** NOTE: This file will not be overwritten during generation ****
* <p/>
* A WeatherStation WS-Resource.
* <p/>
* NOTE: This class is generated but IS meant to be modified.
*/
public class WeatherStationResource extends AbstractWeatherStationResource
{
/**
* A NamespaceVerionHolder which maintains the QNames of Spec Wsdls
*/
public static final org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl SPEC_NAMESPACE_SET = new org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl();
/**
* Initializes this resource's state (properties, etc.).
*/
public void init()
{
super.init();
/**
* The ResourcePropertySet which contains all the defined ResourceProperties
*/
org.apache.ws.resource.properties.ResourcePropertySet resourcePropertySet = getResourcePropertySet();
org.apache.ws.resource.properties.ResourceProperty resourceProperty = null;
try
{
/** TOPICS **/
TopicSpace muwsTopicSpace = new TopicSpaceImpl(MuwsConstants.NSURI_MUWS_PART2_TOPICS);
getTopicSpaceSet().addTopicSpace(muwsTopicSpace);
//identity
ManagementEventTopic identityCapability = new XmlBeansManagementEventTopicImpl(IdentityCapability.TOPIC_NAME);
muwsTopicSpace.addTopic(identityCapability);
//manageability
ManagementEventTopic manageabilityCharacteristicsCapability = new XmlBeansManagementEventTopicImpl(ManageabilityCharacteristicsCapability.TOPIC_NAME);
muwsTopicSpace.addTopic(manageabilityCharacteristicsCapability);
//operational status
ManagementEventTopic operationalCapability = new XmlBeansManagementEventTopicImpl(OperationalStatusCapability.TOPIC_NAME);
muwsTopicSpace.addTopic(operationalCapability);
/** END TOPICS **/
/** CAPABILITIES **/
// init the {http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part1.xsd}ManageabilityCapability Resource Property
resourceProperty = resourcePropertySet.get(WeatherStationDirPropertyQNames.MANAGEABILITYCAPABILITY);
//identity
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManageabilityCapabilityDocument prop_manageabilitycapability = org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManageabilityCapabilityDocument.Factory.newInstance();
prop_manageabilitycapability.setManageabilityCapability(IdentityCapability.URI);
resourceProperty.add(prop_manageabilitycapability);
//operational status
prop_manageabilitycapability = org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManageabilityCapabilityDocument.Factory.newInstance();
prop_manageabilitycapability.setManageabilityCapability(OperationalStatusCapability.URI);
resourceProperty.add(prop_manageabilitycapability);
//manageability listener
resourceProperty.addChangeListener(manageabilityCharacteristicsCapability);
/** END CAPABILITIES **/
/** RESOURCE PROPERTIES **/
// init the {http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part1.xsd}ResourceId Resource Property
resourceProperty = resourcePropertySet.get(WeatherStationPropertyQNames.RESOURCEID);
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ResourceIdDocument prop_resourceid = org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ResourceIdDocument.Factory.newInstance();
prop_resourceid.setResourceId("urn:" + getID());
resourceProperty.add(prop_resourceid);
resourceProperty.addChangeListener(identityCapability);
//resetat value for metrics
Calendar resetAt = Calendar.getInstance();
// init the {http://wsdmdemo.org/service/weather-station}Visibility Resource Property
resourceProperty = resourcePropertySet.get(WeatherStationPropertyQNames.VISIBILITY);
org.wsdmdemo.service.weatherStation.VisibilityDocument prop_visibility = org.wsdmdemo.service.weatherStation.VisibilityDocument.Factory.newInstance();
org.wsdmdemo.service.weatherStation.VisibilityMetricType visibilityMetricType = prop_visibility.addNewVisibility();
visibilityMetricType.setResetAt(resetAt);
visibilityMetricType.setDoubleValue(InteropConstants.DEFAULT_VISIBILITY);
resourceProperty.add(prop_visibility);
resourceProperty.setCallback(new VisibilityCallback());
// init the {http://wsdmdemo.org/service/weather-station}Temperature Resource Property
resourceProperty = resourcePropertySet.get(WeatherStationPropertyQNames.TEMPERATURE);
org.wsdmdemo.service.weatherStation.TemperatureDocument prop_temperature = org.wsdmdemo.service.weatherStation.TemperatureDocument.Factory.newInstance();
org.wsdmdemo.service.weatherStation.TemperatureMetricType temperatureMetricType = prop_temperature.addNewTemperature();
temperatureMetricType.setDoubleValue(InteropConstants.DEFAULT_TEMP);
temperatureMetricType.setResetAt(resetAt);
resourceProperty.add(prop_temperature);
resourceProperty.setCallback(new TemperatureCallback());
// init the {http://wsdmdemo.org/service/weather-station}Humidity Resource Property
resourceProperty = resourcePropertySet.get(WeatherStationPropertyQNames.HUMIDITY);
org.wsdmdemo.service.weatherStation.HumidityDocument prop_humidity = org.wsdmdemo.service.weatherStation.HumidityDocument.Factory.newInstance();
org.wsdmdemo.service.weatherStation.HumidityMetricType humidityMetricType = prop_humidity.addNewHumidity();
humidityMetricType.setDoubleValue(InteropConstants.DEFAULT_HUMIDITY);
humidityMetricType.setResetAt(resetAt);
resourceProperty.add(prop_humidity);
resourceProperty.setCallback(new HumidityCallback());
// init the {http://wsdmdemo.org/service/weather-station}Price Resource Property
resourceProperty = resourcePropertySet.get(WeatherStationPropertyQNames.PRICE);
org.wsdmdemo.service.weatherStation.PriceDocument prop_price = org.wsdmdemo.service.weatherStation.PriceDocument.Factory.newInstance();
prop_price.setPrice(InteropConstants.PRICE);
resourceProperty.add(prop_price);
// 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();
prop_operationalstatus.setOperationalStatus(OperationalStatusDocument.OperationalStatus.AVAILABLE);
resourceProperty.add(prop_operationalstatus);
resourceProperty.addChangeListener(operationalCapability);
// init the {http://wsdmdemo.org/service/weather-station}Owner Resource Property
resourceProperty = resourcePropertySet.get(WeatherStationPropertyQNames.OWNER);
org.wsdmdemo.service.weatherStation.OwnerDocument prop_owner = org.wsdmdemo.service.weatherStation.OwnerDocument.Factory.newInstance();
prop_owner.setOwner(InteropConstants.OWNER);
resourceProperty.add(prop_owner);
/** END RESOURCE PROPERTIES **/
}
catch (Exception e)
{
throw new FaultException(Soap1_1Constants.FAULT_SERVER, "There was a problem in initializing resource properties. Cause: " + e.getLocalizedMessage());
}
// Resource Property {http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd}FixedTopicSet is implemented by the framework.
// Resource Property {http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd}Topic is implemented by the framework.
// Resource Property {http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd}TopicExpressionDialects is implemented by the framework.
/**
* Initializes the Topic, TopicExpressionDialects and FixedTopicSet resource properties
*
* </br>
* <strong>NOTE this MUST be called last in the Resource.init() method to ensure all topics get registered</strong>
* </br>
* FixedTopicSet will be set based on the value returned from the {@see TopicSpaceSet#isFixed()} method.
* </br>
* Topic will have all root topics in the TopicSpaceSet, set to Simple dialect AND all child topics set ot
* Concrete dialect.
* </br>
*
* TopicExpressionDialects will be set to the engine's known Topic Dialects acquired from the TopicExpressionEngine
*
* @param topicSpaceSet
* @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);
}
}