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 javax.xml.parsers.DocumentBuilderFactory;
020
021 import org.w3c.dom.Document;
022 import org.w3c.dom.Element;
023 import org.w3c.dom.Text;
024
025 import org.oasis_open.docs.wsn.b_2.CreatePullPoint;
026 import org.springframework.beans.factory.FactoryBean;
027
028 /**
029 *
030 * @author gnodet
031 * @version $Revision: 376451 $
032 * @org.apache.xbean.XBean element="create-pull-point"
033 */
034 public class CreatePullPointFactoryBean implements FactoryBean {
035
036 private String address;
037
038 /**
039 * @return Returns the address.
040 */
041 public String getAddress() {
042 return address;
043 }
044
045 /**
046 * @param address The address to set.
047 */
048 public void setAddress(String address) {
049 this.address = address;
050 }
051
052 public Object getObject() throws Exception {
053 CreatePullPoint createPullPoint = new CreatePullPoint();
054 if (address != null) {
055 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
056 factory.setNamespaceAware(true);
057 Document doc = factory.newDocumentBuilder().newDocument();
058 Element el = doc.createElementNS("http://servicemix.apache.org/wsn2005/1.0", "address");
059 Text txt = doc.createTextNode(address);
060 el.appendChild(txt);
061 doc.appendChild(el);
062 createPullPoint.getAny().add(el);
063 }
064 return createPullPoint;
065 }
066
067 public Class getObjectType() {
068 return CreatePullPoint.class;
069 }
070
071 public boolean isSingleton() {
072 return false;
073 }
074
075 }