1 22 package org.jboss.deployers.plugins.structure.vfs.explicit; 23 24 import java.util.ArrayList ; 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 ; 33 34 40 public class StructureMetaDataObjectFactory implements ObjectModelFactory 41 { 42 public StructureMetaDataImpl newRoot(Object root, UnmarshallingContext navigator, 43 String namespaceURI, String localName, Attributes 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 completeRoot(Object root, UnmarshallingContext ctx, 55 String uri, String name) 56 { 57 return root; 58 } 59 60 public Object newChild(StructureMetaDataImpl parent, UnmarshallingContext navigator, 61 String namespaceURI, String localName, Attributes attrs) 62 { 63 Object child = null; 64 if(localName.equals("context")) 65 { 66 child = new ContextInfoImpl(); 67 } 68 return child; 69 } 70 public Object newChild(ContextInfoImpl parent, UnmarshallingContext navigator, 71 String namespaceURI, String localName, Attributes attrs) 72 { 73 Object child = null; 74 if (localName.equals("classpath")) 75 child = new ArrayList <ClassPathInfoImpl>(); 76 else if( localName.equals("path") ) 77 { 78 String path = attrs.getValue("name"); 79 parent.setVfsPath(path); 80 } 81 else if( localName.equals("metaDataPath") ) 82 { 83 String path = attrs.getValue("name"); 84 parent.setMetaDataPath(path); 85 } 86 return child; 87 } 88 public Object newChild(ArrayList <ClassPathInfo> parent, UnmarshallingContext navigator, 89 String namespaceURI, String localName, Attributes attrs) 90 { 91 Object child = null; 92 if( localName.equals("path") ) 93 { 94 String name = attrs.getValue("name"); 95 String 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 namespaceURI, String localName) 105 { 106 parent.addContext(context); 107 } 108 public void addChild(ContextInfoImpl context, ArrayList <ClassPathInfo> classpath, 109 UnmarshallingContext navigator, String namespaceURI, String localName) 110 { 111 context.setClassPath(classpath); 112 } 113 } 114 | Popular Tags |