KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > wsn > spring > CreatePullPointFactoryBean


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 JavaDoc;
20
21 import org.oasis_open.docs.wsn.b_2.CreatePullPoint;
22 import org.springframework.beans.factory.FactoryBean;
23 import org.w3c.dom.Document JavaDoc;
24 import org.w3c.dom.Element JavaDoc;
25 import org.w3c.dom.Text JavaDoc;
26
27 /**
28  *
29  * @author gnodet
30  * @version $Revision: 376451 $
31  * @org.apache.xbean.XBean element="create-pull-point"
32  */

33 public class CreatePullPointFactoryBean implements FactoryBean {
34
35     private String JavaDoc address;
36     
37     /**
38      * @return Returns the address.
39      */

40     public String JavaDoc getAddress() {
41         return address;
42     }
43
44     /**
45      * @param address The address to set.
46      */

47     public void setAddress(String JavaDoc address) {
48         this.address = address;
49     }
50
51     public Object JavaDoc getObject() throws Exception JavaDoc {
52         CreatePullPoint createPullPoint = new CreatePullPoint();
53         if (address != null) {
54             DocumentBuilderFactory JavaDoc factory = DocumentBuilderFactory.newInstance();
55             factory.setNamespaceAware(true);
56             Document JavaDoc doc = factory.newDocumentBuilder().newDocument();
57             Element JavaDoc el = doc.createElementNS("http://servicemix.apache.org/wsn2005/1.0", "address");
58             Text JavaDoc txt = doc.createTextNode(address);
59             el.appendChild(txt);
60             doc.appendChild(el);
61             createPullPoint.getAny().add(el);
62         }
63         return createPullPoint;
64     }
65
66     public Class JavaDoc getObjectType() {
67         return CreatePullPoint.class;
68     }
69
70     public boolean isSingleton() {
71         return false;
72     }
73
74 }
75
Popular Tags