/*=============================================================================*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*=============================================================================*/
package org.apache.ws.notification.base.v2004_06.impl;
import org.apache.ws.XmlObjectWrapper;
import org.apache.ws.addressing.EndpointReference;
import org.apache.ws.notification.base.impl.AbstractSubscription;
import org.apache.ws.notification.base.impl.XmlBeansTopicExpression;
import org.apache.ws.notification.base.v2004_06.porttype.SubscriptionManagerPortType;
import org.apache.ws.notification.topics.expression.TopicExpression;
import org.apache.ws.pubsub.SubscriptionEndConsumer;
import org.apache.ws.resource.lifetime.callback.CurrentTimeCallback;
import org.apache.ws.resource.lifetime.v2004_06.porttype.ScheduledResourceTerminationPortType;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.ResourcePropertySet;
import org.apache.ws.resource.properties.ResourcePropertySetMetaData;
import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySetMetaData;
import org.apache.ws.resource.properties.query.impl.XmlBeansQueryExpression;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.ConsumerReferenceDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.CreationTimeDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.PreconditionDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.SelectorDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.SubscriptionManagerRPDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.SubscriptionPolicyDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.UseNotifyDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.CurrentTimeDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.TerminationTimeDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryExpressionType;
import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
import javax.xml.namespace.QName;
/**
* The resource for the builtin SubscriptionManager service.
*/
public class SubscriptionResource
extends AbstractSubscription
{
private static final QName[] READ_ONLY_PROP_NAMES =
{
ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME,
ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME,
SubscriptionManagerPortType.PROP_QNAME_CREATION_TIME
};
/**
* Creates a new {@link SubscriptionResource} object.
*
* @param consumerReference DOCUMENT_ME
* @param producerReference DOCUMENT_ME
* @param producerId DOCUMENT_ME
* @param producerHomeLocation DOCUMENT_ME
* @param topicExpression DOCUMENT_ME
*/
public SubscriptionResource( EndpointReference consumerReference,
EndpointReference producerReference,
Object producerId,
String producerHomeLocation,
TopicExpression topicExpression )
{
super( consumerReference, producerReference, producerHomeLocation, producerId, topicExpression );
}
/**
* Get the subscriptionEnd consumer associated with this subscription.
*
* @return the subscriptionEnd consumer
*/
public SubscriptionEndConsumer getSubscriptionEndConsumer( )
{
return null; //todo *SJC* pubsub stuff
}
/**
* DOCUMENT_ME
*/
public void init( )
{
SubscriptionManagerRPDocument propsDoc = SubscriptionManagerRPDocument.Factory.newInstance( );
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 );
CurrentTimeDocument currTimeDoc = CurrentTimeDocument.Factory.newInstance( );
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( ) );
prop.add( termTimeDoc );
// wsntw:SubscriptionManager props
prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_CONSUMER_REFERENCE );
ConsumerReferenceDocument consumerRefDoc = ConsumerReferenceDocument.Factory.newInstance( );
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.add( creationTimeDoc );
prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_TOPIC_EXPRESSION );
TopicExpressionDocument topicExprDoc = TopicExpressionDocument.Factory.newInstance( );
topicExprDoc.setTopicExpression( (TopicExpressionType) ( (XmlBeansTopicExpression) m_topicExpression )
.getXmlObject( ) );
prop.add( topicExprDoc );
prop = m_propSet.get( SubscriptionManagerPortType.PROP_QNAME_USE_NOTIFY );
UseNotifyDocument useNotifyDoc = UseNotifyDocument.Factory.newInstance( );
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 );
}
}
}