[jboss-cvs] JBossAS SVN: r59055 - in projects/microcontainer/trunk: kernel/src/main/org/jboss/beans/metadata/plugins kernel/src/main/org/jboss/kernel/plugins/deployment/xml spring-int/src/main/org/jboss/spring/deployment/xml
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 14 12:14:31 EST 2006
Author: alesj
Date: 2006-12-14 12:14:20 -0500 (Thu, 14 Dec 2006)
New Revision: 59055
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertiesMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropHandler.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropertiesHandler.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java
Log:
string properties MD support
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java 2006-12-14 17:02:50 UTC (rev 59054)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java 2006-12-14 17:14:20 UTC (rev 59055)
@@ -30,7 +30,6 @@
import org.jboss.joinpoint.spi.Joinpoint;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.util.JBossStringBuilder;
/**
* Map metadata.
@@ -96,9 +95,14 @@
this.valueType = valueType;
}
+ protected Class<? extends Map> expectedMapClass()
+ {
+ return Map.class;
+ }
+
public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
{
- Map<Object, Object> result = getMapInstance(info, cl, Map.class);
+ Map<Object, Object> result = getMapInstance(info, cl, expectedMapClass());
if (result == null)
result = getDefaultMapInstance();
@@ -162,8 +166,7 @@
public void putAll(Map<? extends MetaDataVisitorNode, ? extends MetaDataVisitorNode> t)
{
- putAll(t);
-
+ map.putAll(t);
}
public MetaDataVisitorNode remove(Object key)
@@ -213,11 +216,6 @@
return super.getType(visitor, previous);
}
- public void toString(JBossStringBuilder buffer)
- {
- super.toString(buffer);
- }
-
/**
* Create the default map instance
*
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertiesMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertiesMetaData.java 2006-12-14 17:02:50 UTC (rev 59054)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertiesMetaData.java 2006-12-14 17:14:20 UTC (rev 59055)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.beans.metadata.plugins;
+
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Properties metadata.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractPropertiesMetaData extends AbstractMapMetaData
+{
+
+ protected Map<Object, Object> getDefaultMapInstance() throws Throwable
+ {
+ return new Properties();
+ }
+
+ protected Class<? extends Map> expectedMapClass()
+ {
+ return Properties.class;
+ }
+
+ public String getKeyType()
+ {
+ return String.class.getName();
+ }
+
+ public void setKeyType(String keyType)
+ {
+ throw new IllegalArgumentException("Illegal call to set properties key type!");
+ }
+
+ public String getValueType()
+ {
+ return String.class.getName();
+ }
+
+ public void setValueType(String valueType)
+ {
+ throw new IllegalArgumentException("Illegal call to set properties value type!");
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropHandler.java 2006-12-14 17:02:50 UTC (rev 59054)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropHandler.java 2006-12-14 17:14:20 UTC (rev 59055)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
+
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * PropertyHandler.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 43026 $
+ */
+public class PropHandler extends DefaultElementHandler
+{
+ /** The handler */
+ public static final PropHandler HANDLER = new PropHandler();
+
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new MapEntry();
+ }
+
+ public void attributes(Object object, QName qName, ElementBinding eb, Attributes attrs, NamespaceContext nc)
+ {
+ MapEntry entry = (MapEntry) object;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("key".equals(localName))
+ entry.key = attrs.getValue(i);
+ }
+ }
+
+ public Object endElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ MapEntry entry = (MapEntry) object;
+ if (entry.key == null)
+ throw new IllegalArgumentException("Missing key attribute: " + elementBinding);
+ return entry;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropertiesHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropertiesHandler.java 2006-12-14 17:02:50 UTC (rev 59054)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PropertiesHandler.java 2006-12-14 17:14:20 UTC (rev 59055)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractPropertiesMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+
+/**
+ * PropertyHandler.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 43026 $
+ */
+public class PropertiesHandler extends DefaultElementHandler
+{
+ /** The handler */
+ public static final PropertiesHandler HANDLER = new PropertiesHandler();
+
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractPropertiesMetaData();
+ }
+
+}
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java 2006-12-14 17:02:50 UTC (rev 59054)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java 2006-12-14 17:14:20 UTC (rev 59055)
@@ -128,6 +128,26 @@
public static final QName mapQName = new QName(SPRING_DEPLOYER_NS, "map");
/**
+ * The props binding
+ */
+ public static final QName propsTypeQName = new QName(SPRING_DEPLOYER_NS, "propsType");
+
+ /**
+ * The props element name
+ */
+ public static final QName propsQName = new QName(SPRING_DEPLOYER_NS, "props");
+
+ /**
+ * The props binding
+ */
+ public static final QName propTypeQName = new QName(SPRING_DEPLOYER_NS, "propType");
+
+ /**
+ * The prop element name
+ */
+ public static final QName propQName = new QName(SPRING_DEPLOYER_NS, "prop");
+
+ /**
* The entry binding
*/
public static final QName entryTypeQName = new QName(SPRING_DEPLOYER_NS, "entryType");
@@ -216,6 +236,14 @@
// key type
TypeBinding keyType = schemaBinding.getType(entryTypeQName);
SpringSchemaBindingHelper.initKeyHandler(keyType);
+
+ // props
+ TypeBinding propsType = schemaBinding.getType(propsTypeQName);
+ SpringSchemaBindingHelper.initPropsHandler(propsType);
+
+ // prop
+ TypeBinding propType = schemaBinding.getType(propTypeQName);
+ SpringSchemaBindingHelper.initPropHandler(propType);
}
}
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java 2006-12-14 17:02:50 UTC (rev 59054)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java 2006-12-14 17:14:20 UTC (rev 59055)
@@ -93,6 +93,13 @@
typeBinding.pushInterceptor(SpringSchemaBinding.entryQName, MapEntryInterceptor.INTERCEPTOR);
}
+ public static void initPropsHandler(TypeBinding typeBinding)
+ {
+ typeBinding.setHandler(PropertiesHandler.HANDLER);
+ // props
+ typeBinding.pushInterceptor(SpringSchemaBinding.propQName, MapEntryInterceptor.INTERCEPTOR);
+ }
+
public static void initEntryHandler(TypeBinding typeBinding)
{
typeBinding.setHandler(EntryHandler.HANDLER);
@@ -122,6 +129,13 @@
typeBinding.pushInterceptor(SpringSchemaBinding.nullQName, EntryValueInterceptor.INTERCEPTOR);
}
+ public static void initPropHandler(TypeBinding typeBinding)
+ {
+ typeBinding.setHandler(PropHandler.HANDLER);
+ // property takes characters
+ typeBinding.setSimpleType(PropertyCharactersHandler.HANDLER);
+ }
+
public static void initKeyHandler(TypeBinding typeBinding)
{
typeBinding.setHandler(SpringMapKeyHandler.HANDLER);
More information about the jboss-cvs-commits
mailing list