[jboss-cvs] JBossAS SVN: r79414 - trunk/tomcat/src/main/org/jboss/web/tomcat/metadata.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 13 13:02:47 EDT 2008
Author: remy.maucherat at jboss.com
Date: 2008-10-13 13:02:47 -0400 (Mon, 13 Oct 2008)
New Revision: 79414
Added:
trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextXMLObjectModelFactory.java
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerXMLObjectModelFactory.java
Log:
- Add context.xml factory.
Added: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextXMLObjectModelFactory.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextXMLObjectModelFactory.java (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ContextXMLObjectModelFactory.java 2008-10-13 17:02:47 UTC (rev 79414)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.metadata;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.xb.binding.GenericObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * A context.xml ObjectModelFactory.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ContextXMLObjectModelFactory implements GenericObjectModelFactory
+{
+
+ public Object newRoot(Object root, UnmarshallingContext ctx, String namespaceURI, String localName, Attributes attrs)
+ {
+ ContextMetaData metaData = new ContextMetaData();
+ return metaData;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String namespaceURI, String localName)
+ {
+ return root;
+ }
+
+ public void addChild(Object parent, Object child, UnmarshallingContext ctx, String namespaceURI, String localName)
+ {
+ if(parent instanceof ContextMetaData)
+ {
+ ContextMetaData metaData = (ContextMetaData) parent;
+ if(child instanceof ListenerMetaData)
+ {
+ if(metaData.getListeners() == null)
+ metaData.setListeners(new ArrayList<ListenerMetaData>());
+ metaData.getListeners().add((ListenerMetaData) child);
+ }
+ else if(child instanceof ValveMetaData)
+ {
+ if(metaData.getValves() == null)
+ metaData.setValves(new ArrayList<ValveMetaData>());
+ metaData.getValves().add((ValveMetaData) child);
+ }
+ else if(child instanceof RealmMetaData)
+ {
+ metaData.setRealm((RealmMetaData) child);
+ }
+ else if(child instanceof LoaderMetaData)
+ {
+ metaData.setLoader((LoaderMetaData) child);
+ }
+ else if(child instanceof ManagerMetaData)
+ {
+ metaData.setManager((ManagerMetaData) child);
+ }
+ else if(child instanceof ResourcesMetaData)
+ {
+ metaData.setResources((ResourcesMetaData) child);
+ }
+ else if(child instanceof SessionCookieMetaData)
+ {
+ metaData.setSessionCookie((SessionCookieMetaData) child);
+ }
+ else if(child instanceof ParameterMetaData)
+ {
+ if(metaData.getParameters() == null)
+ metaData.setParameters(new ArrayList<ParameterMetaData>());
+ metaData.getParameters().add((ParameterMetaData) child);
+ }
+ }
+
+ // ...
+ }
+
+ public Object newChild(Object parent, UnmarshallingContext ctx, String namespaceURI, String localName,
+ Attributes attrs)
+ {
+ Set<String> excludeAttributes = new HashSet<String>();
+ Object child = null;
+
+ // TODO child.setName(attrs.getValue("name"));
+
+ if(parent instanceof ContextMetaData)
+ {
+ // <Valve/>
+ if("Valve".equals(localName))
+ child = new ValveMetaData();
+ // <Listener/>
+ else if("Listener".equals(localName))
+ child = new ListenerMetaData();
+ // <Parameter/>
+ else if("Parameter".equals(localName))
+ child = new ParameterMetaData();
+ // <SessionCookie/>
+ else if("SessionCookie".equals(localName))
+ {
+ child = new SessionCookieMetaData();
+ // FIXME: attributes
+ }
+ // <Resources/>
+ else if("Resources".equals(localName))
+ child = new ResourcesMetaData();
+ // <Loader/>
+ else if("Loader".equals(localName))
+ child = new LoaderMetaData();
+ // <Manager/>
+ else if("Manager".equals(localName))
+ child = new ManagerMetaData();
+ }
+
+ // Handle attributes for AnyXmlMetaData
+ if(child instanceof AnyXmlMetaData)
+ {
+ AnyXmlMetaData metaData = (AnyXmlMetaData) child;
+ if( metaData.getAttributes() == null)
+ metaData.setAttributes(new HashMap<String, Object>());
+
+ // ClassName
+ String className = getAttribute("className", excludeAttributes, attrs);
+ metaData.setClassName(className);
+
+ if(attrs != null)
+ {
+ for(int i = 0; i <attrs.getLength(); i++)
+ {
+ String key = attrs.getLocalName(i);
+ if(excludeAttributes.contains(key))
+ continue;
+ //
+ String value = attrs.getValue(i);
+ metaData.getAttributes().put(key, value);
+ }
+ }
+ return metaData;
+ }
+
+ return child;
+ }
+
+ public void setValue(Object o, UnmarshallingContext ctx, String namespaceURI, String localName, String value)
+ {
+ if(o instanceof ContextMetaData)
+ {
+ ContextMetaData metaData = (ContextMetaData) o;
+ // <InstanceListener/>
+ if("InstanceListener".equals(localName))
+ {
+ if(metaData.getInstanceListeners() == null)
+ metaData.setInstanceListeners(new ArrayList<String>());
+ metaData.getInstanceListeners().add(value);
+ }
+ }
+ }
+
+ protected String getAttribute(String name, Set<String> excludeList, Attributes attrs)
+ {
+ if(attrs == null) return null;
+
+ if(excludeList != null)
+ excludeList.add(name);
+
+ return attrs.getValue(name);
+ }
+
+}
+
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerXMLObjectModelFactory.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerXMLObjectModelFactory.java 2008-10-13 16:43:31 UTC (rev 79413)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/metadata/ServerXMLObjectModelFactory.java 2008-10-13 17:02:47 UTC (rev 79414)
@@ -140,7 +140,6 @@
{
metaData.setRealm((RealmMetaData) child);
}
- // FIXME: Alias !
}
// ...
@@ -152,8 +151,6 @@
Set<String> excludeAttributes = new HashSet<String>();
Object child = null;
- // TODO child.setName(attrs.getValue("name"));
-
// <Server/>
if(parent instanceof ServerMetaData)
{
@@ -219,8 +216,6 @@
// <Listener/>
else if("Listener".equals(localName))
child = new ListenerMetaData();
- // <Alias/>
- // FIXME !
}
// Handle attributes for AnyXmlMetaData
More information about the jboss-cvs-commits
mailing list