KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > resource > deployment > JBossRAObjectModelFactory


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.resource.deployment;
23
24 import org.jboss.logging.Logger;
25 import org.jboss.resource.metadata.ConfigPropertyMetaData;
26 import org.jboss.resource.metadata.JBossRAMetaData;
27 import org.jboss.xb.binding.ObjectModelFactory;
28 import org.jboss.xb.binding.UnmarshallingContext;
29 import org.xml.sax.Attributes JavaDoc;
30
31 /**
32  * A JBossRAObjectModelFactory.
33  *
34  * @author <a HREF="weston.price@jboss.com">Weston Price</a>
35  * @version $Revision: 46109 $
36  */

37 public class JBossRAObjectModelFactory implements ObjectModelFactory
38 {
39
40    private boolean trace;
41    
42    private Logger log = Logger.getLogger(JBossRAObjectModelFactory.class);
43    
44    public Object JavaDoc completeRoot(Object JavaDoc root, UnmarshallingContext arg1, String JavaDoc arg2, String JavaDoc arg3)
45    {
46       return root;
47    }
48
49    public Object JavaDoc newRoot(Object JavaDoc root, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc atts)
50    {
51       
52       if(localName == null || !localName.equals("jboss-ra"))
53       {
54          throw new IllegalArgumentException JavaDoc("Error invalid root element for jboss-ra.xml" + localName);
55          
56       }
57       
58       JBossRAMetaData ramd = new JBossRAMetaData();
59       return ramd;
60    }
61    
62    public Object JavaDoc newChild(JBossRAMetaData ramd, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
63    {
64       
65       if(localName.equals("ra-config-property"))
66       {
67          ConfigPropertyMetaData cpmd = new ConfigPropertyMetaData();
68          ramd.addProperty(cpmd);
69          return cpmd;
70          
71       }
72       else
73       {
74          return null;
75          
76       }
77       
78    }
79    
80    public void setValue(ConfigPropertyMetaData cpmd, UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
81    {
82       if (trace)
83          log.trace("config property setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value);
84     
85       else if (localName.equals("ra-config-property-name"))
86          cpmd.setName(value);
87       else if (localName.equals("ra-config-property-type"))
88          cpmd.setType(value);
89       else if (localName.equals("ra-config-property-value"))
90          cpmd.setValue(value);
91       else
92          throw new IllegalArgumentException JavaDoc("Unknown config property setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value);
93    }
94
95
96 }
97
Popular Tags