001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.servicemix.wsn.spring;
018
019 import org.apache.servicemix.wsn.client.AbstractWSAClient;
020 import org.oasis_open.docs.wsn.b_2.TopicExpressionType;
021 import org.oasis_open.docs.wsn.br_2.RegisterPublisher;
022 import org.springframework.beans.factory.FactoryBean;
023
024 /**
025 *
026 * @author gnodet
027 * @version $Revision: 376451 $
028 * @org.apache.xbean.XBean element="register-publisher"
029 */
030 public class RegisterPublisherFactoryBean implements FactoryBean {
031
032 private String publisher;
033
034 private String topic;
035
036 private boolean demand;
037
038 /**
039 * @return Returns the demand.
040 */
041 public boolean isDemand() {
042 return demand;
043 }
044
045 /**
046 * @param demand The demand to set.
047 */
048 public void setDemand(boolean demand) {
049 this.demand = demand;
050 }
051
052 /**
053 * @return Returns the publisher.
054 */
055 public String getPublisher() {
056 return publisher;
057 }
058
059 /**
060 * @param publisher The publisher to set.
061 */
062 public void setPublisher(String publisher) {
063 this.publisher = publisher;
064 }
065
066 /**
067 * @return Returns the topic.
068 */
069 public String getTopic() {
070 return topic;
071 }
072
073 /**
074 * @param topic The topic to set.
075 */
076 public void setTopic(String topic) {
077 this.topic = topic;
078 }
079
080 /* (non-Javadoc)
081 * @see org.springframework.beans.factory.FactoryBean#getObject()
082 */
083 public Object getObject() throws Exception {
084 RegisterPublisher registerPublisher = new RegisterPublisher();
085 registerPublisher.setPublisherReference(AbstractWSAClient.createWSA(publisher));
086 if (topic != null) {
087 TopicExpressionType topicExp = new TopicExpressionType();
088 topicExp.getContent().add(topic);
089 registerPublisher.getTopic().add(topicExp);
090 }
091 registerPublisher.setDemand(Boolean.valueOf(demand));
092 return registerPublisher;
093 }
094
095 /* (non-Javadoc)
096 * @see org.springframework.beans.factory.FactoryBean#getObjectType()
097 */
098 public Class getObjectType() {
099 return RegisterPublisher.class;
100 }
101
102 /* (non-Javadoc)
103 * @see org.springframework.beans.factory.FactoryBean#isSingleton()
104 */
105 public boolean isSingleton() {
106 return false;
107 }
108
109 }