[jboss-cvs] JBossAS SVN: r59354 - in projects/osgi/trunk: core deployment/src/main/org/jboss/osgi/deployment deployment/src/main/org/jboss/osgi/deployment/xml deployment/src/main/org/jboss/osgi/metadata/plugins deployment/src/main/org/jboss/osgi/metadata/spi deployment/src/resources/schema
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 4 10:58:40 EST 2007
Author: alesj
Date: 2007-01-04 10:58:27 -0500 (Thu, 04 Jan 2007)
New Revision: 59354
Added:
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerHandler.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerInterceptor.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBinding.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBindingHelper.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaInitializer.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ReferenceHandler.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ServiceHandler.java
Modified:
projects/osgi/trunk/core/core.iml
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/plugins/AbstractReferenceMetaData.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/Cardinality.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/ClassLoaderOptions.java
projects/osgi/trunk/deployment/src/resources/schema/osgi-beans_1_0.xsd
Log:
initial xb binding
Modified: projects/osgi/trunk/core/core.iml
===================================================================
--- projects/osgi/trunk/core/core.iml 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/core/core.iml 2007-01-04 15:58:27 UTC (rev 59354)
@@ -66,6 +66,26 @@
</SOURCES>
</library>
</orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../thirdparty/jboss/common-core/lib/jboss-common-core.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/../thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
</module>
Added: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerHandler.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerHandler.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerHandler.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -0,0 +1,68 @@
+/*
+* 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.osgi.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.osgi.metadata.plugins.AbstractListenerMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ListenerHandler extends DefaultElementHandler
+{
+ public static final ListenerHandler HANDLER = new ListenerHandler();
+
+ public Object startElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ return new AbstractListenerMetaData();
+ }
+
+ public void attributes(Object object, QName qName, ElementBinding eb, Attributes attrs, NamespaceContext ns)
+ {
+ AbstractListenerMetaData listenerMetaData = (AbstractListenerMetaData) object;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ String value = attrs.getValue(i);
+ if ("ref".equals(localName))
+ listenerMetaData.setRef(value);
+ else if ("bind-method".equals(localName))
+ listenerMetaData.setBindMethod(value);
+ else if ("unbind-method".equals(localName))
+ listenerMetaData.setUnbindMethod(value);
+ }
+ }
+
+ public Object endElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ AbstractListenerMetaData lmd = (AbstractListenerMetaData) object;
+ if (lmd.getRef() == null)
+ throw new IllegalArgumentException("Ref attribute must be set: " + this);
+ return lmd;
+ }
+
+}
Added: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerInterceptor.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerInterceptor.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ListenerInterceptor.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -0,0 +1,52 @@
+/*
+* 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.osgi.deployment.xml;
+
+import java.util.List;
+import java.util.ArrayList;
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.osgi.metadata.plugins.AbstractReferenceMetaData;
+import org.jboss.osgi.metadata.plugins.AbstractListenerMetaData;
+import org.jboss.osgi.metadata.spi.ListenerMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ListenerInterceptor extends DefaultElementInterceptor
+{
+ public static final ListenerInterceptor INTERCEPTOR = new ListenerInterceptor();
+
+ public void add(Object parent, Object child, QName qName)
+ {
+ AbstractReferenceMetaData rmd = (AbstractReferenceMetaData) parent;
+ AbstractListenerMetaData lmd = (AbstractListenerMetaData) child;
+ List<ListenerMetaData> listeners = rmd.getListeners();
+ if (listeners == null) {
+ listeners = new ArrayList<ListenerMetaData>();
+ rmd.setListeners(listeners);
+ }
+ listeners.add(lmd);
+ }
+
+}
Added: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBinding.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBinding.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBinding.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -0,0 +1,85 @@
+/*
+* 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.osgi.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiSchemaBinding
+{
+ /**
+ * The namespace
+ */
+ public static final String OSGI_DEPLOYER_NS = "urn:jboss:osgi-beans:1.0";
+
+ /**
+ * The service binding
+ */
+ public static final QName serviceTypeQName = new QName(OSGI_DEPLOYER_NS, "serviceType");
+
+ /**
+ * The service element name
+ */
+ public static final QName serviceQName = new QName(OSGI_DEPLOYER_NS, "service");
+
+ /**
+ * The reference binding
+ */
+ public static final QName referenceTypeQName = new QName(OSGI_DEPLOYER_NS, "referenceType");
+
+ /**
+ * The reference element name
+ */
+ public static final QName referenceQName = new QName(OSGI_DEPLOYER_NS, "reference");
+
+ /**
+ * The listener binding
+ */
+ public static final QName listenerTypeQName = new QName(OSGI_DEPLOYER_NS, "listenerType");
+
+ /**
+ * The listener element name
+ */
+ public static final QName listenerQName = new QName(OSGI_DEPLOYER_NS, "listener");
+
+ public static void init(SchemaBinding schemaBinding)
+ {
+ // service binding
+ TypeBinding serviceType = schemaBinding.getType(serviceTypeQName);
+ OSGiSchemaBindingHelper.initServiceHandler(serviceType);
+
+ // reference binding
+ TypeBinding referenceType = schemaBinding.getType(referenceTypeQName);
+ OSGiSchemaBindingHelper.initReferenceHandler(referenceType);
+
+ // listener binding
+ TypeBinding listenerType = schemaBinding.getType(listenerTypeQName);
+ OSGiSchemaBindingHelper.initListenerHandler(listenerType);
+
+ }
+
+}
Added: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBindingHelper.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBindingHelper.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaBindingHelper.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -0,0 +1,58 @@
+/*
+* 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.osgi.deployment.xml;
+
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.kernel.plugins.deployment.xml.BeanSchemaBinding20;
+import org.jboss.kernel.plugins.deployment.xml.BeanPropertyInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.ValueMetaDataElementInterceptor;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiSchemaBindingHelper
+{
+
+ public static void initServiceHandler(TypeBinding serviceType)
+ {
+ serviceType.setHandler(ServiceHandler.HANDLER);
+ // handle interfaces
+ serviceType.pushInterceptor(BeanSchemaBinding20.setQName, ValueMetaDataElementInterceptor.VALUES);
+ // handle service-properties
+ serviceType.pushInterceptor(BeanSchemaBinding20.mapQName, ValueMetaDataElementInterceptor.VALUES);
+ }
+
+ public static void initReferenceHandler(TypeBinding referenceType)
+ {
+ referenceType.setHandler(ReferenceHandler.HANDLER);
+ // handle properties
+ referenceType.pushInterceptor(BeanSchemaBinding20.propertyQName, BeanPropertyInterceptor.INTERCEPTOR);
+ // handle listener
+ referenceType.pushInterceptor(OSGiSchemaBinding.listenerQName, ListenerInterceptor.INTERCEPTOR);
+ }
+
+ public static void initListenerHandler(TypeBinding listenerType)
+ {
+ listenerType.setHandler(ListenerHandler.HANDLER);
+ }
+
+}
Added: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaInitializer.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaInitializer.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/OSGiSchemaInitializer.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -0,0 +1,39 @@
+/*
+* 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.osgi.deployment.xml;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiSchemaInitializer implements SchemaBindingInitializer
+{
+
+ public SchemaBinding init(SchemaBinding schema)
+ {
+ OSGiSchemaBinding.init(schema);
+ return schema;
+ }
+
+}
Added: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ReferenceHandler.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ReferenceHandler.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ReferenceHandler.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -0,0 +1,87 @@
+/*
+* 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.osgi.deployment.xml;
+
+import java.util.Collections;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.osgi.metadata.plugins.AbstractReferenceMetaData;
+import org.jboss.osgi.metadata.spi.Cardinality;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ReferenceHandler extends DefaultElementHandler
+{
+ public static final ReferenceHandler HANDLER = new ReferenceHandler();
+
+ public Object startElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ return new AbstractReferenceMetaData();
+ }
+
+ public void attributes(Object object, QName qName, ElementBinding eb, Attributes attrs, NamespaceContext ns)
+ {
+ AbstractReferenceMetaData referenceMetaData = (AbstractReferenceMetaData) object;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ String value = attrs.getValue(i);
+ if ("id".equals(localName))
+ referenceMetaData.setId(value);
+ else if ("interface".equals(localName))
+ referenceMetaData.setInterface(value);
+ else if ("filter".equals(localName))
+ referenceMetaData.setFilter(value);
+ else if ("cardinality".equals(localName))
+ referenceMetaData.setCardinality(Cardinality.toCardinality(value));
+ else if ("timeout".equals(localName))
+ referenceMetaData.setTimeout(Integer.valueOf(value));
+ else if ("depends-on".equals(localName))
+ {
+ DependencyMetaData dmd = new AbstractDependencyMetaData(value);
+ referenceMetaData.setDepends(Collections.singleton(dmd));
+ }
+ else if ("context-classloader".equals(localName))
+ {
+ ClassLoaderMetaData clmd = null; // todo
+ referenceMetaData.setClassLoaderMetaData(clmd);
+ }
+ }
+ }
+
+ public Object endElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ AbstractReferenceMetaData rmd = (AbstractReferenceMetaData) object;
+ if (rmd.getInterface() == null)
+ throw new IllegalArgumentException("Interface attribute must be set: " + this);
+ return rmd;
+ }
+
+}
Added: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ServiceHandler.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ServiceHandler.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployment/xml/ServiceHandler.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -0,0 +1,84 @@
+/*
+* 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.osgi.deployment.xml;
+
+import java.util.Collections;
+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.jboss.osgi.metadata.plugins.AbstractServiceMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServiceHandler extends DefaultElementHandler
+{
+ public static final ServiceHandler HANDLER = new ServiceHandler();
+
+ public Object startElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ return new AbstractServiceMetaData();
+ }
+
+ public void attributes(Object object, QName qName, ElementBinding eb, Attributes attrs, NamespaceContext ns)
+ {
+ AbstractServiceMetaData serviceMetaData = (AbstractServiceMetaData) object;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ String value = attrs.getValue(i);
+ if ("id".equals(localName))
+ serviceMetaData.setId(value);
+ else if ("ref".equals(localName))
+ serviceMetaData.setRef(value);
+ else if ("interface".equals(localName))
+ serviceMetaData.setInterface(value);
+ else if ("lazy-init".equals(localName))
+ serviceMetaData.setLazyInit(Boolean.valueOf(value));
+ else if ("depends-on".equals(localName))
+ {
+ DependencyMetaData dmd = new AbstractDependencyMetaData(value);
+ serviceMetaData.setDepends(Collections.singleton(dmd));
+ }
+ else if ("context-classloader".equals(localName))
+ {
+ ClassLoaderMetaData clmd = null; // todo
+ serviceMetaData.setClassLoaderMetaData(clmd);
+ }
+ }
+ }
+
+ public Object endElement(Object object, QName qName, ElementBinding elementBinding)
+ {
+ AbstractServiceMetaData smd = (AbstractServiceMetaData) object;
+ if (smd.getInterface() != null && smd.getInterfaces() != null && smd.getInterfaces().isEmpty() == false)
+ throw new IllegalArgumentException("Cannot set both interface definitions: " + this);
+ return smd;
+ }
+
+}
Modified: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/plugins/AbstractReferenceMetaData.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/plugins/AbstractReferenceMetaData.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/plugins/AbstractReferenceMetaData.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -40,7 +40,7 @@
implements ReferenceMetaData
{
private String filter;
- private Cardinality cardinality;
+ private Cardinality cardinality = Cardinality.ONE_TO_ONE;
private Integer timeout;
private List<ListenerMetaData> listeners;
private Set<PropertyMetaData> properties;
Modified: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/Cardinality.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/Cardinality.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/Cardinality.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -40,6 +40,18 @@
this.type = type;
}
+ public static Cardinality toCardinality(String value)
+ {
+ for(Cardinality c : values())
+ {
+ if (c.getType().equals(value))
+ {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException("Illegal Cardinality value: " + value);
+ }
+
public String getType()
{
return type;
Modified: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/ClassLoaderOptions.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/ClassLoaderOptions.java 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/ClassLoaderOptions.java 2007-01-04 15:58:27 UTC (rev 59354)
@@ -42,6 +42,18 @@
this.serviceSupported = serviceSupported;
}
+ public static ClassLoaderOptions toClassLoaderOptions(String value)
+ {
+ for(ClassLoaderOptions clo : values())
+ {
+ if (clo.getType().equals(value))
+ {
+ return clo;
+ }
+ }
+ throw new IllegalArgumentException("Illegal type value: " + value);
+ }
+
public String getType()
{
return type;
Modified: projects/osgi/trunk/deployment/src/resources/schema/osgi-beans_1_0.xsd
===================================================================
--- projects/osgi/trunk/deployment/src/resources/schema/osgi-beans_1_0.xsd 2007-01-04 15:43:18 UTC (rev 59353)
+++ projects/osgi/trunk/deployment/src/resources/schema/osgi-beans_1_0.xsd 2007-01-04 15:58:27 UTC (rev 59354)
@@ -11,13 +11,13 @@
<xsd:import namespace="urn:jboss:bean-deployer:2.0"/>
<!-- reference -->
- <xsd:element name="reference" type="Treference"/>
+ <xsd:element name="reference" type="referenceType"/>
- <xsd:complexType name="Treference">
+ <xsd:complexType name="referenceType">
<xsd:complexContent>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="property" type="mc:propertyType" minOccurs="0"/>
- <xsd:element name="listener" type="Tlistener" minOccurs="0"/>
+ <xsd:element name="listener" type="listenerType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:string"/>
<xsd:attribute name="interface" use="required" type="xsd:string"/>
@@ -47,16 +47,16 @@
</xsd:restriction>
</xsd:simpleType>
- <xsd:complexType name="Tlistener">
+ <xsd:complexType name="listenerType">
<xsd:attribute name="ref" type="xsd:string" use="required"/>
<xsd:attribute name="bind-method" type="xsd:string" use="optional"/>
<xsd:attribute name="unbind-method" type="xsd:string" use="optional"/>
</xsd:complexType>
<!-- service -->
- <xsd:element name="service" type="Tservice"/>
+ <xsd:element name="service" type="serviceType"/>
- <xsd:complexType name="Tservice">
+ <xsd:complexType name="serviceType">
<xsd:complexContent>
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element name="interfaces" type="mc:setType" minOccurs="0"/>
More information about the jboss-cvs-commits
mailing list