1 17 package org.apache.servicemix.wsn.spring; 18 19 import javax.xml.bind.JAXBElement; 20 21 import org.apache.servicemix.wsn.AbstractSubscription; 22 import org.apache.servicemix.wsn.client.AbstractWSAClient; 23 import org.oasis_open.docs.wsn.b_2.FilterType; 24 import org.oasis_open.docs.wsn.b_2.QueryExpressionType; 25 import org.oasis_open.docs.wsn.b_2.Subscribe; 26 import org.oasis_open.docs.wsn.b_2.TopicExpressionType; 27 import org.oasis_open.docs.wsn.b_2.UseRaw; 28 import org.springframework.beans.factory.FactoryBean; 29 30 36 public class SubscribeFactoryBean implements FactoryBean { 37 38 private String consumer; 39 private String topic; 40 private String xpath; 41 private boolean raw; 42 43 46 public String getConsumer() { 47 return consumer; 48 } 49 50 53 public void setConsumer(String consumer) { 54 this.consumer = consumer; 55 } 56 57 60 public String getTopic() { 61 return topic; 62 } 63 64 67 public void setTopic(String topic) { 68 this.topic = topic; 69 } 70 71 74 public String getXpath() { 75 return xpath; 76 } 77 78 81 public void setXpath(String xpath) { 82 this.xpath = xpath; 83 } 84 85 88 public boolean isRaw() { 89 return raw; 90 } 91 92 95 public void setRaw(boolean raw) { 96 this.raw = raw; 97 } 98 99 102 public Object getObject() throws Exception { 103 Subscribe subscribe = new Subscribe(); 104 subscribe.setConsumerReference(AbstractWSAClient.createWSA(consumer)); 105 subscribe.setFilter(new FilterType()); 106 if (topic != null) { 107 TopicExpressionType topicExp = new TopicExpressionType(); 108 topicExp.getContent().add(topic); 109 subscribe.getFilter().getAny().add(new JAXBElement<TopicExpressionType>(AbstractSubscription.QNAME_TOPIC_EXPRESSION, TopicExpressionType.class, topicExp)); 110 } 111 if (xpath != null) { 112 QueryExpressionType xpathExp = new QueryExpressionType(); 113 xpathExp.setDialect(AbstractSubscription.XPATH1_URI); 114 xpathExp.getContent().add(xpath); 115 subscribe.getFilter().getAny().add(new JAXBElement<QueryExpressionType>(AbstractSubscription.QNAME_MESSAGE_CONTENT, QueryExpressionType.class, xpathExp)); 116 } 117 if (raw) { 118 subscribe.setSubscriptionPolicy(new Subscribe.SubscriptionPolicy()); 119 subscribe.getSubscriptionPolicy().getAny().add(new UseRaw()); 120 } 121 return subscribe; 122 } 123 124 127 public Class getObjectType() { 128 return Subscribe.class; 129 } 130 131 134 public boolean isSingleton() { 135 return false; 136 } 137 138 } 139 | Popular Tags |