01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.wsn.spring;
18:
19: import javax.xml.parsers.DocumentBuilderFactory;
20:
21: import org.w3c.dom.Document;
22: import org.w3c.dom.Element;
23: import org.w3c.dom.Text;
24:
25: import org.oasis_open.docs.wsn.b_2.CreatePullPoint;
26: import org.springframework.beans.factory.FactoryBean;
27:
28: /**
29: *
30: * @author gnodet
31: * @version $Revision: 376451 $
32: * @org.apache.xbean.XBean element="create-pull-point"
33: */
34: public class CreatePullPointFactoryBean implements FactoryBean {
35:
36: private String address;
37:
38: /**
39: * @return Returns the address.
40: */
41: public String getAddress() {
42: return address;
43: }
44:
45: /**
46: * @param address The address to set.
47: */
48: public void setAddress(String address) {
49: this .address = address;
50: }
51:
52: public Object getObject() throws Exception {
53: CreatePullPoint createPullPoint = new CreatePullPoint();
54: if (address != null) {
55: DocumentBuilderFactory factory = DocumentBuilderFactory
56: .newInstance();
57: factory.setNamespaceAware(true);
58: Document doc = factory.newDocumentBuilder().newDocument();
59: Element el = doc.createElementNS(
60: "http://servicemix.apache.org/wsn2005/1.0",
61: "address");
62: Text txt = doc.createTextNode(address);
63: el.appendChild(txt);
64: doc.appendChild(el);
65: createPullPoint.getAny().add(el);
66: }
67: return createPullPoint;
68: }
69:
70: public Class getObjectType() {
71: return CreatePullPoint.class;
72: }
73:
74: public boolean isSingleton() {
75: return false;
76: }
77:
78: }
|