KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployers > plugins > structure > vfs > explicit > StructureMetaDataObjectFactory


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
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.deployers.plugins.structure.vfs.explicit;
23
24 import java.util.ArrayList JavaDoc;
25
26 import org.jboss.deployers.plugins.structure.ClassPathInfoImpl;
27 import org.jboss.deployers.plugins.structure.ContextInfoImpl;
28 import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
29 import org.jboss.deployers.spi.structure.vfs.ClassPathInfo;
30 import org.jboss.xb.binding.ObjectModelFactory;
31 import org.jboss.xb.binding.UnmarshallingContext;
32 import org.xml.sax.Attributes JavaDoc;
33
34 /**
35  * An ObjectModelFactory for the jboss-structure.xml descriptor.
36  *
37  * @author Scott.Stark@jboss.org
38  * @version $Revision:$
39  */

40 public class StructureMetaDataObjectFactory implements ObjectModelFactory
41 {
42    public StructureMetaDataImpl newRoot(Object JavaDoc root, UnmarshallingContext navigator,
43          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
44    {
45       StructureMetaDataImpl metaData = null;
46       if (root != null)
47          metaData = (StructureMetaDataImpl) root;
48       else
49          metaData = new StructureMetaDataImpl();
50
51       return metaData;
52    }
53
54    public Object JavaDoc completeRoot(Object JavaDoc root, UnmarshallingContext ctx,
55          String JavaDoc uri, String JavaDoc name)
56    {
57       return root;
58    }
59
60    public Object JavaDoc newChild(StructureMetaDataImpl parent, UnmarshallingContext navigator,
61          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
62    {
63       Object JavaDoc child = null;
64       if(localName.equals("context"))
65       {
66          child = new ContextInfoImpl();
67       }
68       return child;
69    }
70    public Object JavaDoc newChild(ContextInfoImpl parent, UnmarshallingContext navigator,
71          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
72    {
73       Object JavaDoc child = null;
74       if (localName.equals("classpath"))
75          child = new ArrayList JavaDoc<ClassPathInfoImpl>();
76       else if( localName.equals("path") )
77       {
78          String JavaDoc path = attrs.getValue("name");
79          parent.setVfsPath(path);
80       }
81       else if( localName.equals("metaDataPath") )
82       {
83          String JavaDoc path = attrs.getValue("name");
84          parent.setMetaDataPath(path);
85       }
86       return child;
87    }
88    public Object JavaDoc newChild(ArrayList JavaDoc<ClassPathInfo> parent, UnmarshallingContext navigator,
89          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
90    {
91       Object JavaDoc child = null;
92       if( localName.equals("path") )
93       {
94          String JavaDoc name = attrs.getValue("name");
95          String JavaDoc suffixes = attrs.getValue("suffixes");
96          ClassPathInfoImpl path = new ClassPathInfoImpl(name);
97          path.setOption("suffixes", suffixes);
98          parent.add(path);
99       }
100       return child;
101    }
102
103    public void addChild(StructureMetaDataImpl parent, ContextInfoImpl context,
104          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
105    {
106       parent.addContext(context);
107    }
108    public void addChild(ContextInfoImpl context, ArrayList JavaDoc<ClassPathInfo> classpath,
109          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
110    {
111       context.setClassPath(classpath);
112    }
113 }
114
Popular Tags