1 22 package org.jboss.deployment; 23 24 import org.jboss.logging.Logger; 25 import org.jboss.metadata.IconMetaData; 26 import org.jboss.metadata.SecurityRoleMetaData; 27 import org.jboss.metadata.SecurityRoleRefMetaData; 28 import org.jboss.xb.binding.ObjectModelFactory; 29 import org.jboss.xb.binding.UnmarshallingContext; 30 import org.xml.sax.Attributes ; 31 32 38 public class J2eeApplicationObjectFactory implements ObjectModelFactory 39 { 40 private static Logger log = Logger.getLogger(J2eeApplicationObjectFactory.class); 41 42 public J2eeApplicationMetaData newRoot(Object root, UnmarshallingContext navigator, 43 String namespaceURI, String localName, Attributes attrs) 44 { 45 J2eeApplicationMetaData metaData = null; 46 if (root != null) 47 metaData = (J2eeApplicationMetaData) root; 48 else 49 metaData = new J2eeApplicationMetaData(); 50 return metaData; 51 } 52 53 public Object completeRoot(Object root, UnmarshallingContext ctx, 54 String uri, String name) 55 { 56 return root; 57 } 58 59 69 public Object newChild(J2eeApplicationMetaData dd, UnmarshallingContext navigator, 70 String namespaceURI, String localName, Attributes attrs) 71 { 72 Object child = null; 73 log.debug("newChild, " + localName); 74 75 String version = attrs.getValue(namespaceURI, "version"); 77 if( version != null ) 78 dd.setVersion(version); 79 80 if (localName.equals("icon")) 82 child = new IconMetaData(); 83 else if(localName.equals("module")) 84 child = new J2eeModuleMetaData(); 85 else if( localName.equals("security-role")) 86 child = new SecurityRoleMetaData(); 87 else if (log.isTraceEnabled()) 88 { 89 log.trace("Ignoring: " + localName); 90 } 91 return child; 92 } 93 94 104 public Object newChild(J2eeModuleMetaData module, UnmarshallingContext navigator, 105 String namespaceURI, String localName, Attributes attrs) 106 { 107 Object child = null; 108 if (localName.equals("web")) 109 { 110 child = new WebModuleMetaData(module); 111 } 112 else if (localName.equals("security-role-ref")) 113 { 114 child = new SecurityRoleRefMetaData(); 115 } 116 return child; 117 } 118 119 public void addChild(J2eeApplicationMetaData parent, J2eeModuleMetaData module, 120 UnmarshallingContext navigator, String namespaceURI, String localName) 121 { 122 parent.addModule(module); 123 } 124 public void addChild(J2eeApplicationMetaData parent, SecurityRoleMetaData role, 125 UnmarshallingContext navigator, String namespaceURI, String localName) 126 { 127 parent.addSecurityRole(role); 128 } 129 130 138 public void setValue(J2eeApplicationMetaData dd, 139 UnmarshallingContext navigator, String namespaceURI, String localName, 140 String value) 141 { 142 if( localName.equals("display-name") ) 143 dd.setDisplayName(value); 144 else if( localName.equals("description") ) 145 dd.setDescription(value); 146 else if( localName.equals("library-directory") ) 147 dd.setLibraryDirectory(value); 148 } 149 150 public void setValue(IconMetaData icon, 151 UnmarshallingContext navigator, String namespaceURI, String localName, 152 String value) 153 { 154 if( localName.equals("small-icon") ) 155 icon.setSmallIcon(value); 156 if( localName.equals("large-icon") ) 157 icon.setLargeIcon(value); 158 } 159 public void setValue(J2eeModuleMetaData module, 160 UnmarshallingContext navigator, String namespaceURI, String localName, 161 String value) 162 { 163 if( localName.equals("ejb") ) 164 { 165 module.setType(J2eeModuleMetaData.EJB); 166 module.setFileName(value); 167 } 168 else if( localName.equals("java") ) 169 { 170 module.setType(J2eeModuleMetaData.CLIENT); 171 module.setFileName(value); 172 } 173 else if( localName.equals("connector") ) 174 { 175 module.setType(J2eeModuleMetaData.CONNECTOR); 176 module.setFileName(value); 177 } 178 else if( localName.equals("service") ) 179 { 180 module.setType(J2eeModuleMetaData.SERVICE); 181 module.setFileName(value); 182 } 183 else if( localName.equals("har") ) 184 { 185 module.setType(J2eeModuleMetaData.HAR); 186 module.setFileName(value); 187 } 188 else if( localName.equals("alt-dd") ) 189 module.setAlternativeDD(value); 190 } 191 public void setValue(WebModuleMetaData module, 192 UnmarshallingContext navigator, String namespaceURI, String localName, 193 String value) 194 { 195 if( localName.equals("web-uri") ) 196 { 197 module.setFileName(value); 198 } 199 else if( localName.equals("context-root") ) 200 { 201 module.setWebContext(value); 202 } 203 else if( localName.equals("alt-dd") ) 204 module.setAlternativeDD(value); 205 } 206 207 public void setValue(SecurityRoleMetaData role, 208 UnmarshallingContext navigator, String namespaceURI, String localName, 209 String value) 210 { 211 if( localName.equals("description") ) 212 { 213 role.setDescription(value); 214 } 215 else if( localName.equals("role-name") ) 216 { 217 role.setRoleName(value); 218 } 219 } 220 221 } 222 | Popular Tags |