catch ( NamingException ne )
{
LOG.error( "Subscribe failed due to internal error: " + ne );
throw new BaseFaultException( NAMESPACE_SET, "Subscribe failed due to internal server error." );
}
Subscription subscription = null;
try
{
subscription = subscriptionHome.create( SubscriptionResource.class,
new XmlBeansEndpointReference( request.getConsumerReference() ), producerEPR, initialTerminationTime,
subPolicy, precondition, selector, getResourceKey(),
( (AbstractResourceContext) getResourceContext() ).getResourceHomeLocation(), topicExpr, useNotify, (WsnNamespaceVersionHolder) getNamespaceSet() );
}
catch ( Exception e )
{
LOG.error( "Subscribe failed due to internal error: " + e );
if ( LOG.isDebugEnabled() )
{
e.printStackTrace( );
}
throw new SubscribeCreationFailedFaultException( NAMESPACE_SET );
}
SubscriptionTopicListener subscriptionTopicListener = new SubscriptionTopicListener( subscription );
for ( int i = 0; i < topics.length; i++ )
{
topics[i].addTopicListener( subscriptionTopicListener );
}
SubscribeResponseDocument subscribeResponseDoc = SubscribeResponseDocument.Factory.newInstance();
SubscribeResponseDocument.SubscribeResponse subscribeResponse = subscribeResponseDoc.addNewSubscribeResponse();
subscriptionEPR = (EndpointReferenceType) ( (XmlObjectWrapper) subscription.getEndpointReference() ).getXmlObject();
subscribeResponse.setSubscriptionReference( subscriptionEPR );
return subscribeResponseDoc;
}