You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pubscribe-dev@ws.apache.org by ip...@apache.org on 2005/05/18 16:16:42 UTC

svn commit: r170756 - /incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java /incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionResource.java

Author: ips
Date: Wed May 18 07:16:40 2005
New Revision: 170756

URL: http://svn.apache.org/viewcvs?rev=170756&view=rev
Log:
fixed some potential NPEs

Modified:
    incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionResource.java

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java?rev=170756&r1=170755&r2=170756&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java Wed May 18 07:16:40 2005
@@ -121,7 +121,7 @@
         }
         catch ( Exception e )
         {
-            throw new ResourceException( "Failed to create Subscription resource." );
+            throw new ResourceException( "Failed to create Subscription resource.", e );
         }
     }
 

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionResource.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionResource.java?rev=170756&r1=170755&r2=170756&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionResource.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionResource.java Wed May 18 07:16:40 2005
@@ -24,6 +24,7 @@
 import org.apache.ws.pubsub.SubscriptionEndConsumer;
 import org.apache.ws.resource.ResourceKey;
 import org.apache.ws.resource.lifetime.v2004_06.porttype.ScheduledResourceTerminationPortType;
+import org.apache.ws.resource.lifetime.callback.CurrentTimeCallback;
 import org.apache.ws.resource.properties.ResourceProperty;
 import org.apache.ws.resource.properties.ResourcePropertySet;
 import org.apache.ws.resource.properties.ResourcePropertySetMetaData;
@@ -49,8 +50,7 @@
 /**
  * TODO
  */
-public class SubscriptionResource extends AbstractSubscription
-{
+public class SubscriptionResource extends AbstractSubscription {
 
     private static final QName[] READ_ONLY_PROP_NAMES =
             {
@@ -59,58 +59,67 @@
                 SubscriptionManagerPortType.PROP_QNAME_CREATION_TIME
             };
 
-    public SubscriptionResource( EndpointReference consumerReference, EndpointReference producerReference,
-                                 ResourceKey producerKey, String producerHomeLocation,
-                                 TopicExpression topicExpression )
-    {
-        super( consumerReference, producerReference,
-                producerKey, producerHomeLocation, topicExpression );
+    public SubscriptionResource(EndpointReference consumerReference, EndpointReference producerReference,
+                                ResourceKey producerKey, String producerHomeLocation,
+                                TopicExpression topicExpression) {
+        super(consumerReference, producerReference,
+                producerKey, producerHomeLocation, topicExpression);
     }
 
-    public void init()
-    {
+    public void init() {
         SubscriptionManagerRPDocument propsDoc = SubscriptionManagerRPDocument.Factory.newInstance();
-        ResourcePropertySetMetaData propSetMetaData = new XmlBeansResourcePropertySetMetaData( propsDoc.schemaType(),
-                READ_ONLY_PROP_NAMES );
-        m_propSet = new XmlBeansResourcePropertySet( propsDoc, propSetMetaData );
+        ResourcePropertySetMetaData propSetMetaData = new XmlBeansResourcePropertySetMetaData(propsDoc.schemaType(),
+                READ_ONLY_PROP_NAMES);
+        m_propSet = new XmlBeansResourcePropertySet(propsDoc, propSetMetaData);
 
         // wsrlw:ScheduledResourceTermination props
-        ResourceProperty prop = m_propSet.get( ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME );
+        ResourceProperty prop = m_propSet.get(ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME);
         CurrentTimeDocument currTimeDoc = CurrentTimeDocument.Factory.newInstance();
-        currTimeDoc.setCurrentTime( getCurrentTime() );
-        prop.add( currTimeDoc );
-        //prop.setCallback( new CurrentTimeCallback() );
-        prop = m_propSet.get( ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME );
+        currTimeDoc.setCurrentTime(getCurrentTime());
+        prop.setCallback( new CurrentTimeCallback() );
+        prop.add(currTimeDoc);        
+        prop = m_propSet.get(ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME);
         TerminationTimeDocument termTimeDoc = TerminationTimeDocument.Factory.newInstance();
-        termTimeDoc.setTerminationTime( getTerminationTime() );
+        termTimeDoc.setTerminationTime(getTerminationTime());
+        prop.add(termTimeDoc);
         // wsntw:SubscriptionManager props
-        prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_CONSUMER_REFERENCE );
+        prop = m_propSet.get(SubscriptionManagerPortType.PROP_QNAME_CONSUMER_REFERENCE);
         ConsumerReferenceDocument consumerRefDoc = ConsumerReferenceDocument.Factory.newInstance();
-        consumerRefDoc.setConsumerReference(
-                (EndpointReferenceType) ( (XmlObjectWrapper) m_consumerReference ).getXmlObject() );
-        prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_CREATION_TIME );
+        consumerRefDoc.setConsumerReference((EndpointReferenceType) ((XmlObjectWrapper) m_consumerReference).getXmlObject());
+        prop.add(consumerRefDoc);
+        prop = m_propSet.get(SubscriptionManagerPortType.PROP_QNAME_CREATION_TIME);
         CreationTimeDocument creationTimeDoc = CreationTimeDocument.Factory.newInstance();
-        creationTimeDoc.setCreationTime( m_creationTime );
-        prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_PRECONDITION );
-        PreconditionDocument preconditionDoc = PreconditionDocument.Factory.newInstance();
-        preconditionDoc.setPrecondition(
-                (QueryExpressionType) ( (XmlBeansQueryExpression) m_precondition ).getXmlObject() );
-        prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_SELECTOR );
-        SelectorDocument selectorDoc = SelectorDocument.Factory.newInstance();
-        selectorDoc.setSelector( (QueryExpressionType) ( (XmlBeansQueryExpression) m_selector ).getXmlObject() );
-        prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_SUBSCRIPTION_POLICY );
-        SubscriptionPolicyDocument subPolicyDoc = SubscriptionPolicyDocument.Factory.newInstance();
-        subPolicyDoc.setSubscriptionPolicy( null );
-        prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_TOPIC_EXPRESSION );
+        creationTimeDoc.setCreationTime(m_creationTime);
+        prop.add(creationTimeDoc);
+        prop = m_propSet.get(SubscriptionManagerPortType.PROP_QNAME_TOPIC_EXPRESSION);
         TopicExpressionDocument topicExprDoc = TopicExpressionDocument.Factory.newInstance();
-        topicExprDoc.setTopicExpression( (TopicExpressionType) ( (XmlBeansTopicExpression) m_selector ).getXmlObject() );
-        prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_USE_NOTIFY );
+        topicExprDoc.setTopicExpression((TopicExpressionType) ((XmlBeansTopicExpression) m_selector).getXmlObject());
+        prop.add(topicExprDoc);
+        prop = m_propSet.get(SubscriptionManagerPortType.PROP_QNAME_USE_NOTIFY);
         UseNotifyDocument useNotifyDoc = UseNotifyDocument.Factory.newInstance();
-        useNotifyDoc.setUseNotify( m_useNotify );
+        useNotifyDoc.setUseNotify(m_useNotify);
+        prop.add(useNotifyDoc);
+        if (m_precondition != null) {
+            prop = m_propSet.get(SubscriptionManagerPortType.PROP_QNAME_PRECONDITION);
+            PreconditionDocument preconditionDoc = PreconditionDocument.Factory.newInstance();
+            preconditionDoc.setPrecondition((QueryExpressionType) ((XmlBeansQueryExpression) m_precondition).getXmlObject());
+            prop.add(preconditionDoc);
+        }
+        if (m_selector != null) {
+            prop = m_propSet.get(SubscriptionManagerPortType.PROP_QNAME_SELECTOR);
+            SelectorDocument selectorDoc = SelectorDocument.Factory.newInstance();
+            selectorDoc.setSelector((QueryExpressionType) ((XmlBeansQueryExpression) m_selector).getXmlObject());
+            prop.add(selectorDoc);
+        }
+        if (m_policy != null) {
+            prop = m_propSet.get(SubscriptionManagerPortType.PROP_QNAME_SUBSCRIPTION_POLICY);
+            SubscriptionPolicyDocument subPolicyDoc = SubscriptionPolicyDocument.Factory.newInstance();
+            subPolicyDoc.setSubscriptionPolicy(null);
+            prop.add(subPolicyDoc);
+        }
     }
 
-    public void setResourcePropertySet( ResourcePropertySet resourcePropertySet )
-    {
+    public void setResourcePropertySet(ResourcePropertySet resourcePropertySet) {
         //todo
     }
 
@@ -119,8 +128,7 @@
      *
      * @return the subscriptionEnd consumer
      */
-    public SubscriptionEndConsumer getSubscriptionEndConsumer()
-    {
+    public SubscriptionEndConsumer getSubscriptionEndConsumer() {
         return null;   //todo
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: hermes-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: hermes-dev-help@ws.apache.org