[jboss-cvs] JBossAS SVN: r61979 - in projects: microcontainer/trunk/osgi-int/src/main/org/jboss and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 2 06:18:26 EDT 2007
Author: alesj
Date: 2007-04-02 06:18:26 -0400 (Mon, 02 Apr 2007)
New Revision: 61979
Added:
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/AbstractServiceAction.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/ActivateAction.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/BindAction.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/EnableAction.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/InstallAction.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContext.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContextActions.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/BundleActivatorDeployer.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeclarativeDeployer.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeploymentResolver.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeploymentVisitor.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiServiceDeployer.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiStructure.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/SecurityActions.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/ServiceDeploymentDeployer.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerHandler.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerInterceptor.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBinding.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBindingHelper.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaInitializer.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ReferenceHandler.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ServiceHandler.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractBundleEvent.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractDelegateListener.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractFrameworkEvent.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractServiceEvent.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleContextImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleEventAdapter.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleListenerImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/EventAdapter.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FilterImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkEventAdapter.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkListenerImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/OSGiKernelEventFilter.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceEventAdapter.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceFactoryImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceListenerImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceReferenceImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceRegistrationImpl.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractAttributeMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractDependencyMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractHolderMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractListenerMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractMetaDataVisitorNode.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractReferenceMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceDeployment.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/AttributeMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/DependencyMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/HolderMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ListenerMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/OSGiMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ReferenceMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceDeployment.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitor.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitorNode.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceValueMetaData.java
projects/microcontainer/trunk/osgi-int/src/resources/
projects/microcontainer/trunk/osgi-int/src/resources/schema/
projects/microcontainer/trunk/osgi-int/src/resources/schema/osgi-beans_1_0.xsd
Modified:
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/annotations/OsgiService.java
Log:
Initial OSGi code - work in progress.
Need to include tests for MC like features, other OSGi test should probably came from existing OSGi testsuites (Felix, Equinox, ...).
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/AbstractServiceAction.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/AbstractServiceAction.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/AbstractServiceAction.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,45 @@
+/*
+* 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.plugins.dependency;
+
+import org.jboss.dependency.plugins.action.SimpleControllerContextAction;
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * Abstract service controller context
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractServiceAction extends SimpleControllerContextAction<OSGiServiceReferenceContext>
+{
+
+ protected boolean validateContext(ControllerContext context)
+ {
+ return true;
+ }
+
+ protected OSGiServiceReferenceContext contextCast(ControllerContext context)
+ {
+ return OSGiServiceReferenceContext.class.cast(context);
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/ActivateAction.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/ActivateAction.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/ActivateAction.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.dependency;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ActivateAction extends AbstractServiceAction
+{
+ protected void installAction(OSGiServiceReferenceContext context) throws Throwable
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ protected void uninstallAction(OSGiServiceReferenceContext context)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/BindAction.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/BindAction.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/BindAction.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.dependency;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BindAction extends AbstractServiceAction
+{
+ protected void installAction(OSGiServiceReferenceContext context) throws Throwable
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ protected void uninstallAction(OSGiServiceReferenceContext context)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/EnableAction.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/EnableAction.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/EnableAction.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.dependency;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class EnableAction extends AbstractServiceAction
+{
+ protected void installAction(OSGiServiceReferenceContext context) throws Throwable
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ protected void uninstallAction(OSGiServiceReferenceContext context)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/InstallAction.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/InstallAction.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/InstallAction.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.dependency;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstallAction extends AbstractServiceAction
+{
+ protected void installAction(OSGiServiceReferenceContext context) throws Throwable
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ protected void uninstallAction(OSGiServiceReferenceContext context)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContext.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContext.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContext.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,207 @@
+/*
+* 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.plugins.dependency;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
+
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.osgi.spi.metadata.ServiceMetaData;
+import org.jboss.osgi.spi.metadata.ServiceMetaDataVisitor;
+import org.jboss.osgi.spi.metadata.ServiceMetaDataVisitorNode;
+import org.osgi.framework.BundleContext;
+
+/**
+ * OSGi service controller context
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiServiceReferenceContext extends AbstractControllerContext implements InvokeDispatchContext
+{
+ /** The meta data */
+ private ServiceMetaData serviceMetaData;
+
+ /** The Bundle Context */
+ private BundleContext bundleContext;
+
+ public OSGiServiceReferenceContext(ServiceMetaData metaData, BundleContext bundleContext)
+ {
+ super(metaData.getId(), OSGiServiceReferenceContextActions.getInstance());
+ this.bundleContext = bundleContext;
+ }
+
+ public Object get(String name) throws Throwable
+ {
+ return null; // todo
+ }
+
+ public void set(String name, Object value) throws Throwable
+ {
+ }
+
+ public Object invoke(String name, Object parameters[], String[] signature) throws Throwable
+ {
+ return null; // todo
+ }
+
+ public ClassLoader getClassLoader() throws Throwable
+ {
+ return null; // todo get Bundle CL
+ }
+
+ /**
+ * Get the serviceMetaData.
+ *
+ * @return the serviceMetaData.
+ */
+ public ServiceMetaData getServiceMetaData()
+ {
+ return serviceMetaData;
+ }
+
+ /**
+ * Set the serviceMetaData.
+ *
+ * @param serviceMetaData the serviceMetaData.
+ */
+ public void setServiceMetaData(ServiceMetaData serviceMetaData)
+ {
+ this.serviceMetaData = serviceMetaData;
+ }
+
+ /**
+ * Get Bundle Context
+ *
+ * @return the bundle context
+ */
+ public BundleContext getBundleContext()
+ {
+ return bundleContext;
+ }
+
+ /**
+ * Get the service proxy
+ *
+ * @return the service proxy
+ * @throws Exception for any error
+ */
+ public Object getServiceProxy() throws Exception
+ {
+ return null; // todo
+ }
+
+ public void setController(Controller controller)
+ {
+ super.setController(controller);
+ if (controller != null)
+ {
+ preprocessMetaData();
+ }
+ }
+
+ /**
+ * Preprocess the metadata for this context
+ */
+ protected void preprocessMetaData()
+ {
+ if (serviceMetaData == null)
+ return;
+ PreprocessMetaDataVisitor visitor = new PreprocessMetaDataVisitor();
+ AccessController.doPrivileged(visitor);
+ }
+
+ /**
+ * A visitor for the metadata that looks for dependencies.
+ */
+ protected class PreprocessMetaDataVisitor implements ServiceMetaDataVisitor, PrivilegedAction<Object>
+ {
+ /** The current context for when the dependencies are required */
+ private ControllerState contextState = ControllerState.INSTANTIATED;
+
+ /**
+ * Visit the bean metadata node, this is the starting point
+ */
+ public Object run()
+ {
+ serviceMetaData.visit(this);
+ return null;
+ }
+
+ /**
+ * Visit a node
+ *
+ * @param node the node
+ */
+ public void visit(ServiceMetaDataVisitorNode node)
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Visit node " + node);
+
+ // Visit the children of this node
+ Iterator<? extends ServiceMetaDataVisitorNode> children = node.getChildren();
+ if (children != null)
+ {
+ ControllerState restoreState = contextState;
+ while (children.hasNext())
+ {
+ ServiceMetaDataVisitorNode child = children.next();
+ try
+ {
+ child.visit(this);
+ }
+ finally
+ {
+ contextState = restoreState;
+ }
+ }
+ }
+ }
+
+ public OSGiServiceReferenceContext getControllerContext()
+ {
+ return OSGiServiceReferenceContext.this;
+ }
+
+ public ControllerState getContextState()
+ {
+ return contextState;
+ }
+
+ public void addDependency(DependencyItem dependency)
+ {
+ getDependencyInfo().addIDependOn(dependency);
+ }
+
+ public void setContextState(ControllerState contextState)
+ {
+ this.contextState = contextState;
+ }
+ }
+
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContextActions.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContextActions.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/dependency/OSGiServiceReferenceContextActions.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,60 @@
+/*
+* 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.plugins.dependency;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.dependency.plugins.AbstractControllerContextActions;
+import org.jboss.dependency.plugins.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * OSGi service controller context actions
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiServiceReferenceContextActions extends AbstractControllerContextActions
+{
+ /* The single instance */
+ private static OSGiServiceReferenceContextActions instance;
+
+ public OSGiServiceReferenceContextActions(Map<ControllerState, ControllerContextAction> actions)
+ {
+ super(actions);
+ }
+
+ public static OSGiServiceReferenceContextActions getInstance()
+ {
+ if (instance == null)
+ {
+ Map<ControllerState, ControllerContextAction> actions = new HashMap<ControllerState, ControllerContextAction>();
+ actions.put(ControllerState.PRE_INSTALL, new EnableAction());
+ actions.put(ControllerState.CONFIGURED, new BindAction());
+ actions.put(ControllerState.START, new ActivateAction());
+ actions.put(ControllerState.INSTALLED, new InstallAction());
+ instance = new OSGiServiceReferenceContextActions(actions);
+ }
+ return instance;
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/BundleActivatorDeployer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/BundleActivatorDeployer.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/BundleActivatorDeployer.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,90 @@
+/*
+* 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.plugins.deployers;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.plugins.deployers.helpers.AbstractRealDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Create OSGi meta data from manifest.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BundleActivatorDeployer extends AbstractRealDeployer<OSGiMetaData>
+{
+ private final KernelController controller;
+
+ public BundleActivatorDeployer(Kernel kernel)
+ {
+ if (kernel == null)
+ throw new IllegalArgumentException("Null kernel");
+ controller = kernel.getController();
+ setDeploymentVisitor(new BundleActivatorDeploymentVisitor());
+ }
+
+ protected String createBundleActivatorBeanName(OSGiMetaData metaData)
+ {
+ return metaData.getBundleSymbolicName() + "Activator";
+ }
+
+ private class BundleActivatorDeploymentVisitor extends OSGiMetaDataDeploymentVisitor
+ {
+ public void deploy(DeploymentUnit unit, OSGiMetaData deployment) throws DeploymentException
+ {
+ String bundleActivator = deployment.getBundleActivator();
+ if (bundleActivator != null)
+ {
+ String name = createBundleActivatorBeanName(deployment);
+ BundleContext bundleContext = null; // todo
+ BeanMetaDataBuilder builder = new BeanMetaDataBuilder(name, bundleActivator)
+ .addStartParameter(BundleContext.class.getName(), bundleContext)
+ .addStopParameter(BundleContext.class.getName(), bundleContext);
+ BeanMetaData beanMetaData = builder.getBeanMetaData();
+ try
+ {
+ controller.install(beanMetaData);
+ }
+ catch (Throwable throwable)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Unable to install BundleActivator.", throwable);
+ }
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit, OSGiMetaData deployment)
+ {
+ String bundleActivator = deployment.getBundleActivator();
+ if (bundleActivator != null)
+ {
+ String name = createBundleActivatorBeanName(deployment);
+ controller.uninstall(name);
+ }
+ }
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeclarativeDeployer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeclarativeDeployer.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeclarativeDeployer.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,56 @@
+/*
+* 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.plugins.deployers;
+
+import org.jboss.deployers.plugins.deployers.helpers.SchemaResolverDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.osgi.spi.metadata.ServiceDeployment;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * OSGi declarative components deployer
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiDeclarativeDeployer extends SchemaResolverDeployer<ServiceDeployment>
+{
+ public OSGiDeclarativeDeployer()
+ {
+ super(ServiceDeployment.class);
+ }
+
+ protected void init(DeploymentUnit unit, ServiceDeployment metaData, VirtualFile file) throws Exception
+ {
+ String name = file.toURI().toString();
+ metaData.setName(name);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ createMetaData(unit, null, "-osgi.xml");
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeploymentResolver.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeploymentResolver.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiDeploymentResolver.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,50 @@
+/*
+* 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.plugins.deployers;
+
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.deployers.plugins.deployers.helpers.DeploymentResolver;
+import org.jboss.kernel.Kernel;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+
+/**
+ * Handle DeploymentControllerContext regarding OSGi meta data.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiDeploymentResolver extends DeploymentResolver<OSGiMetaData>
+{
+ public OSGiDeploymentResolver(Kernel kernel)
+ {
+ super(OSGiMetaData.class, kernel);
+ }
+
+ protected void addDependencies(OSGiMetaData deployment, DependencyInfo dependencyInfo)
+ {
+ //todo
+ }
+
+ protected void removeDependencies(OSGiMetaData deployment, DependencyInfo dependencyInfo)
+ {
+ //todo
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.osgi.plugins.deployers;
+
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.plugins.deployers.helpers.ManifestDeployer;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+
+/**
+ * Create OSGi meta data from manifest.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiMetaDataDeployer extends ManifestDeployer<OSGiMetaData>
+{
+ public OSGiMetaDataDeployer(Class<OSGiMetaData> deploymentType)
+ {
+ super(deploymentType);
+ }
+
+ protected OSGiMetaData createMetaData(Manifest manifest) throws Exception
+ {
+ return null; //todo
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeploymentVisitor.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeploymentVisitor.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeploymentVisitor.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,40 @@
+/*
+* 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.plugins.deployers;
+
+import org.jboss.deployers.plugins.deployers.helpers.SimpleDeploymentVisitor;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+
+/**
+ * OSGi meta data deployment visitor.
+ * Used with real OSGi deployer.
+ *
+ * @see BundleActivatorDeployer
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class OSGiMetaDataDeploymentVisitor implements SimpleDeploymentVisitor<OSGiMetaData>
+{
+ public Class<OSGiMetaData> getVisitorType()
+ {
+ return OSGiMetaData.class;
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiServiceDeployer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiServiceDeployer.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiServiceDeployer.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,72 @@
+/*
+* 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.plugins.deployers;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.osgi.plugins.dependency.OSGiServiceReferenceContext;
+import org.jboss.osgi.plugins.facade.BundleContextImpl;
+import org.jboss.osgi.spi.metadata.ServiceMetaData;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Create OSGi meta data from manifest.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiServiceDeployer extends AbstractSimpleRealDeployer<ServiceMetaData>
+{
+ /** The kernel controller */
+ private final KernelController controller;
+
+ public OSGiServiceDeployer(Kernel kernel)
+ {
+ super(ServiceMetaData.class);
+ if (kernel == null)
+ throw new IllegalArgumentException("Null kernel");
+ controller = kernel.getController();
+ }
+
+ public void deploy(DeploymentUnit unit, ServiceMetaData deployment) throws DeploymentException
+ {
+ // todo - get deployment context in non-depricated way
+ BundleContext bundleContext = new BundleContextImpl(unit.getDeploymentContext());
+ ControllerContext context = new OSGiServiceReferenceContext(deployment, bundleContext);
+ try
+ {
+ controller.install(context);
+ }
+ catch (Throwable t)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + deployment.getId(), t);
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit, ServiceMetaData deployment)
+ {
+ controller.uninstall(deployment.getId());
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiStructure.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiStructure.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiStructure.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,49 @@
+/*
+* 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.plugins.deployers;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * OSGi structure deployer.
+ * Reads manifest for OSGi classpath.
+ *
+ * @see org.jboss.deployers.plugins.structure.vfs.jar.JARStructure
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiStructure extends AbstractStructureDeployer
+{
+ public OSGiStructure()
+ {
+ /* one after jar */
+ setRelativeOrder(10001);
+ }
+
+ public boolean determineStructure(VirtualFile root, StructureMetaData metaData, StructuredDeployers deployers)
+ {
+ // todo - see JarStructure
+ return false;
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/SecurityActions.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/SecurityActions.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/SecurityActions.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,90 @@
+/*
+* 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.plugins.deployers;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SecurityActions
+{
+ /**
+ * Actions for File access
+ */
+ interface FileActions
+ {
+ FileActions PRIVILEGED = new FileActions()
+ {
+ public Boolean isLeaf(final VirtualFile f) throws IOException
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>()
+ {
+ public Boolean run() throws Exception
+ {
+ return f.isLeaf();
+ }
+ });
+ }
+ catch(PrivilegedActionException e)
+ {
+ Exception ex = e.getException();
+ if( ex instanceof IOException )
+ throw (IOException) ex;
+ else if( ex instanceof RuntimeException )
+ throw (RuntimeException) ex;
+ else
+ throw new UndeclaredThrowableException(ex);
+ }
+ }
+ };
+
+ FileActions NON_PRIVILEGED = new FileActions()
+ {
+ public Boolean isLeaf(VirtualFile f) throws IOException
+ {
+ return f.isLeaf();
+ }
+
+ };
+
+ public Boolean isLeaf(VirtualFile f) throws IOException;
+ }
+
+ static boolean isLeaf(VirtualFile f) throws IOException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if( sm != null )
+ return FileActions.PRIVILEGED.isLeaf(f);
+ else
+ return FileActions.NON_PRIVILEGED.isLeaf(f);
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/ServiceDeploymentDeployer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/ServiceDeploymentDeployer.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/ServiceDeploymentDeployer.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,103 @@
+/*
+* 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.plugins.deployers;
+
+import java.util.List;
+
+import org.jboss.deployers.plugins.deployers.helpers.AbstractComponentDeployer;
+import org.jboss.deployers.plugins.deployers.helpers.SimpleDeploymentVisitor;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.osgi.spi.metadata.ServiceDeployment;
+import org.jboss.osgi.spi.metadata.ServiceMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServiceDeploymentDeployer extends AbstractComponentDeployer<ServiceDeployment, ServiceMetaData>
+{
+ /**
+ * Create a new ServiceDeploymentDeployer.
+ */
+ public ServiceDeploymentDeployer()
+ {
+ setDeploymentVisitor(new ServiceDeploymentVisitor());
+ setComponentVisitor(new ServiceMetaDataVisitor());
+ }
+
+ protected static void addServiceComponent(DeploymentUnit unit, ServiceMetaData service)
+ {
+ DeploymentUnit component = unit.addComponent(service.getId());
+ component.addAttachment(ServiceMetaData.class.getName(), service);
+ }
+
+ protected static void removeServiceComponent(DeploymentUnit unit, ServiceMetaData service)
+ {
+ unit.removeComponent(service.getId());
+ }
+
+ /**
+ * ServiceDeploymentVisitor.
+ */
+ public static class ServiceDeploymentVisitor implements SimpleDeploymentVisitor<ServiceDeployment>
+ {
+ public Class<ServiceDeployment> getVisitorType()
+ {
+ return ServiceDeployment.class;
+ }
+
+ public void deploy(DeploymentUnit unit, ServiceDeployment deployment) throws DeploymentException
+ {
+ List<ServiceMetaData> services = deployment.getServices();
+ for (ServiceMetaData service : services)
+ addServiceComponent(unit, service);
+ }
+
+ public void undeploy(DeploymentUnit unit, ServiceDeployment deployment)
+ {
+ List<ServiceMetaData> services = deployment.getServices();
+ for (ServiceMetaData service : services)
+ removeServiceComponent(unit, service);
+ }
+ }
+
+ /**
+ * ServiceMetaDataVisitor.
+ */
+ public static class ServiceMetaDataVisitor implements SimpleDeploymentVisitor<ServiceMetaData>
+ {
+ public Class<ServiceMetaData> getVisitorType()
+ {
+ return ServiceMetaData.class;
+ }
+
+ public void deploy(DeploymentUnit unit, ServiceMetaData deployment) throws DeploymentException
+ {
+ addServiceComponent(unit, deployment);
+ }
+
+ public void undeploy(DeploymentUnit unit, ServiceMetaData deployment)
+ {
+ removeServiceComponent(unit, deployment);
+ }
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerHandler.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerHandler.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerHandler.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,70 @@
+/*
+* 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.plugins.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.osgi.plugins.metadata.AbstractListenerMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * Listener handler.
+ *
+ * @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/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerInterceptor.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ListenerInterceptor.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,54 @@
+/*
+* 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.plugins.deployment.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.namespace.QName;
+
+import org.jboss.osgi.plugins.metadata.AbstractListenerMetaData;
+import org.jboss.osgi.plugins.metadata.AbstractReferenceMetaData;
+import org.jboss.osgi.spi.metadata.ListenerMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * Listener interceptor.
+ *
+ * @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/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBinding.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBinding.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+
+/**
+ * OSGi schema.
+ *
+ * @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/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBindingHelper.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaBindingHelper.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,60 @@
+/*
+* 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.plugins.deployment.xml;
+
+import org.jboss.kernel.plugins.deployment.xml.BeanPropertyInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.BeanSchemaBinding20;
+import org.jboss.kernel.plugins.deployment.xml.ValueMetaDataElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+
+/**
+ * OSGi schema binding.
+ *
+ * @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/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaInitializer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaInitializer.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/OSGiSchemaInitializer.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.deployment.xml;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+
+/**
+ * OSGi schema initializer.
+ *
+ * @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/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ReferenceHandler.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ReferenceHandler.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ReferenceHandler.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,89 @@
+/*
+* 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.plugins.deployment.xml;
+
+import java.util.Collections;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.osgi.plugins.metadata.AbstractDependencyMetaData;
+import org.jboss.osgi.plugins.metadata.AbstractReferenceMetaData;
+import org.jboss.osgi.spi.metadata.DependencyMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * Reference handler.
+ *
+ * @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/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ServiceHandler.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ServiceHandler.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployment/xml/ServiceHandler.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,86 @@
+/*
+* 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.plugins.deployment.xml;
+
+import java.util.Collections;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.osgi.plugins.metadata.AbstractDependencyMetaData;
+import org.jboss.osgi.plugins.metadata.AbstractServiceMetaData;
+import org.jboss.osgi.spi.metadata.DependencyMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * Service handler.
+ *
+ * @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;
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractBundleEvent.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractBundleEvent.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractBundleEvent.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,45 @@
+/*
+* 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.plugins.facade;
+
+import org.jboss.kernel.plugins.event.AbstractEvent;
+import org.osgi.framework.BundleEvent;
+
+/**
+ * BundleEvent implementation on top of KernelEvent.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractBundleEvent extends AbstractEvent implements BundleEventAdapter
+{
+ // todo - bundle event type, Bundle
+ public AbstractBundleEvent(Object source, String type, long sequence, long timestamp, Object context)
+ {
+ super(source, type, sequence, timestamp, context);
+ }
+
+ public BundleEvent getEvent()
+ {
+ int bundleType = 0;
+ return new BundleEvent(bundleType, null);
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractDelegateListener.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractDelegateListener.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractDelegateListener.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.osgi.plugins.facade;
+
+import org.jboss.kernel.spi.event.KernelEventListener;
+
+/**
+ * Delegate implementation on top of existing KernelEventListener.
+ *
+ * @param <T> Listener type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractDelegateListener<T> implements KernelEventListener
+{
+ protected T delegate;
+
+ public AbstractDelegateListener(T delegate)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Listener is null!");
+ this.delegate = delegate;
+ }
+
+ /**
+ * Common add / remove validate.
+ */
+ protected void validate()
+ {
+ }
+
+ /**
+ * Validate if we are allowed to add this listener
+ */
+ protected void addValidate()
+ {
+ validate();
+ }
+
+ /**
+ * Validate if we ar eallowed to remove this listener
+ */
+ protected void removeValidate()
+ {
+ validate();
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractFrameworkEvent.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractFrameworkEvent.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractFrameworkEvent.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,45 @@
+/*
+* 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.plugins.facade;
+
+import org.jboss.kernel.plugins.event.AbstractEvent;
+import org.osgi.framework.FrameworkEvent;
+
+/**
+ * BundleEvent implementation on top of KernelEvent.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractFrameworkEvent extends AbstractEvent implements FrameworkEventAdapter
+{
+ // todo - framework event type, Bundle
+ public AbstractFrameworkEvent(Object source, String type, long sequence, long timestamp, Object context)
+ {
+ super(source, type, sequence, timestamp, context);
+ }
+
+ public FrameworkEvent getEvent()
+ {
+ int frameworkType = 0;
+ return new FrameworkEvent(frameworkType, null, null);
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractServiceEvent.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractServiceEvent.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/AbstractServiceEvent.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,54 @@
+/*
+* 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.plugins.facade;
+
+import org.jboss.kernel.plugins.event.AbstractEvent;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.osgi.framework.ServiceEvent;
+
+/**
+ * ServiceEvent implementation on top of KernelEvent.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractServiceEvent extends AbstractEvent implements ServiceEventAdapter
+{
+ // todo - service modified type, ServiceReference
+ public AbstractServiceEvent(Object source, String type, long sequence, long timestamp, Object context)
+ {
+ super(source, type, sequence, timestamp, context);
+ }
+
+ public ServiceEvent getEvent()
+ {
+ int serviceType = 0;
+ if (KernelRegistry.KERNEL_REGISTRY_REGISTERED.equals(type))
+ {
+ serviceType = ServiceEvent.REGISTERED;
+ }
+ else if (KernelRegistry.KERNEL_REGISTRY_UNREGISTERED.equals(type))
+ {
+ serviceType = ServiceEvent.UNREGISTERING;
+ }
+ return new ServiceEvent(serviceType, null);
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleContextImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleContextImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleContextImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,311 @@
+/*
+* 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.plugins.facade;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.kernel.spi.event.KernelEventEmitter;
+import org.jboss.kernel.spi.event.KernelEventFilter;
+import org.jboss.logging.Logger;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Bundle context implementation on top of existing DeploymentContext.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BundleContextImpl implements BundleContext
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(BundleContextImpl.class);
+
+ protected DeploymentContext context;
+ protected Bundle bundle;
+ protected KernelEventEmitter eventEmitter;
+
+ protected Map<EventListener, AbstractDelegateListener> listeners = Collections.synchronizedMap(new HashMap<EventListener, AbstractDelegateListener>());
+ protected Map<ServiceListener, KernelEventFilter> filters = Collections.synchronizedMap(new HashMap<ServiceListener, KernelEventFilter>());
+
+ public BundleContextImpl(DeploymentContext context)
+ {
+ this.context = context;
+ }
+
+ protected boolean isBundleContextValid()
+ {
+ return true;
+ }
+
+ protected void validateBundle() throws IllegalStateException
+ {
+ if (isBundleContextValid() == false)
+ throw new IllegalStateException("BundleContext is no longer valid.");
+ }
+
+ public String getProperty(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Bundle getBundle()
+ {
+ if (bundle == null)
+ {
+ bundle = new BundleImpl(context);
+ }
+ return bundle;
+ }
+
+ public Bundle installBundle(String string) throws BundleException
+ {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ public Bundle installBundle(String string, InputStream inputStream) throws BundleException
+ {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ public Bundle getBundle(long id)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Bundle[] getBundles()
+ {
+ return new Bundle[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addServiceListener(ServiceListener serviceListener, String filter) throws InvalidSyntaxException
+ {
+ // todo - conditional add
+ validateBundle();
+ // remove the existing first
+ if (listeners.containsKey(serviceListener))
+ {
+ removeServiceListener(serviceListener);
+ }
+ // create new one
+ ServiceListenerImpl listener = new ServiceListenerImpl(serviceListener);
+ listener.addValidate();
+ OSGiKernelEventFilter eventFilter = null;
+ if (filter != null)
+ {
+ eventFilter = new OSGiKernelEventFilter(filter);
+ filters.put(serviceListener, eventFilter);
+ }
+ try
+ {
+ eventEmitter.registerListener(listener, eventFilter, this);
+ listeners.put(serviceListener, listener);
+ }
+ catch (Throwable throwable)
+ {
+ filters.remove(serviceListener);
+ // todo - throw what?
+ throw new IllegalArgumentException(throwable);
+ }
+ }
+
+ public void addServiceListener(ServiceListener serviceListener)
+ {
+ try
+ {
+ addServiceListener(serviceListener, null);
+ }
+ catch (InvalidSyntaxException ignored)
+ {
+ }
+ }
+
+ public void removeServiceListener(ServiceListener serviceListener)
+ {
+ AbstractDelegateListener listener = listeners.get(serviceListener);
+ if (listener != null)
+ {
+ listener.removeValidate();
+ KernelEventFilter filter = filters.get(serviceListener);
+ try
+ {
+ eventEmitter.unregisterListener(listener, filter, this);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Exception while unregistering Service listener.", t);
+ }
+ finally
+ {
+ listeners.remove(serviceListener);
+ if (filter != null)
+ {
+ filters.remove(serviceListener);
+ }
+ }
+ }
+ }
+
+ public void addBundleListener(BundleListener bundleListener)
+ {
+ validateBundle();
+ if (listeners.containsKey(bundleListener) == false)
+ {
+ BundleListenerImpl listener = new BundleListenerImpl(bundleListener);
+ listener.addValidate();
+ try
+ {
+ eventEmitter.registerListener(listener, null, this);
+ listeners.put(bundleListener, listener);
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalArgumentException(t);
+ }
+ }
+ }
+
+ public void removeBundleListener(BundleListener bundleListener)
+ {
+ validateBundle();
+ AbstractDelegateListener listener = listeners.get(bundleListener);
+ if (listener != null)
+ {
+ listener.removeValidate();
+ try
+ {
+ eventEmitter.unregisterListener(listener, null, this);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Exception while unregistering Bundle listener.", t);
+ }
+ finally
+ {
+ listeners.remove(bundleListener);
+ }
+ }
+ }
+
+ public void addFrameworkListener(FrameworkListener frameworkListener)
+ {
+ validateBundle();
+ if (listeners.containsKey(frameworkListener) == false)
+ {
+ FrameworkListenerImpl listener = new FrameworkListenerImpl(frameworkListener);
+ listener.addValidate();
+ try
+ {
+ eventEmitter.registerListener(listener, null, this);
+ listeners.put(frameworkListener, listener);
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalArgumentException(t);
+ }
+ }
+ }
+
+ public void removeFrameworkListener(FrameworkListener frameworkListener)
+ {
+ validateBundle();
+ AbstractDelegateListener listener = listeners.get(frameworkListener);
+ if (listener != null)
+ {
+ listener.removeValidate();
+ try
+ {
+ eventEmitter.unregisterListener(listener, null, this);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Exception while unregistering Framework listener.", t);
+ }
+ finally
+ {
+ listeners.remove(frameworkListener);
+ }
+ }
+ }
+
+ public ServiceRegistration registerService(String[] strings, Object object, Dictionary dictionary)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ServiceRegistration registerService(String string, Object object, Dictionary dictionary)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ServiceReference[] getServiceReferences(String string, String string1) throws InvalidSyntaxException
+ {
+ return new ServiceReference[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ServiceReference[] getAllServiceReferences(String string, String string1) throws InvalidSyntaxException
+ {
+ return new ServiceReference[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ServiceReference getServiceReference(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Object getService(ServiceReference serviceReference)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean ungetService(ServiceReference serviceReference)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public File getDataFile(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Filter createFilter(String filter) throws InvalidSyntaxException
+ {
+ validateBundle();
+ return FrameworkUtil.createFilter(filter);
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleEventAdapter.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleEventAdapter.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleEventAdapter.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,33 @@
+/*
+* 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.plugins.facade;
+
+import org.osgi.framework.BundleEvent;
+
+/**
+ * BundleEvent contract.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface BundleEventAdapter extends EventAdapter<BundleEvent>
+{
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,153 @@
+/*
+* 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.plugins.facade;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Bundle implementation on top of existing DeploymentContext.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BundleImpl implements Bundle
+{
+ protected DeploymentContext context;
+
+ public BundleImpl(DeploymentContext context)
+ {
+ this.context = context;
+ }
+
+ public int getState()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void start() throws BundleException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void stop() throws BundleException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void update() throws BundleException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void update(InputStream inputStream) throws BundleException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void uninstall() throws BundleException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Dictionary getHeaders()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public long getBundleId()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getLocation()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ServiceReference[] getRegisteredServices()
+ {
+ return new ServiceReference[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ServiceReference[] getServicesInUse()
+ {
+ return new ServiceReference[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean hasPermission(Object object)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public URL getResource(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Dictionary getHeaders(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getSymbolicName()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Class loadClass(String string) throws ClassNotFoundException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Enumeration getResources(String string) throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Enumeration getEntryPaths(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public URL getEntry(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public long getLastModified()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Enumeration findEntries(String string, String string1, boolean b)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleListenerImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleListenerImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleListenerImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,72 @@
+/*
+* 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.plugins.facade;
+
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.SynchronousBundleListener;
+
+/**
+ * BundleListenerImpl implementation on top of KernelEventListener.
+ * Handles both SynchronousBundleListener and simple BundleListener.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BundleListenerImpl extends AbstractDelegateListener<BundleListener>
+{
+ private boolean isSynchronous;
+
+ public BundleListenerImpl(BundleListener delegate)
+ {
+ super(delegate);
+ isSynchronous = (delegate instanceof SynchronousBundleListener);
+ }
+
+ /**
+ * Is the listener synchronous.
+ *
+ * @return synchhronous
+ */
+ public boolean isSynchronous()
+ {
+ return isSynchronous;
+ }
+
+ protected void validate()
+ {
+ if (isSynchronous())
+ {
+ // todo - check appropriate AdminPermission[context bundle,LISTENER]
+ }
+ }
+
+ // todo - synchrounous stuff
+ public void onEvent(KernelEvent event, Object handback)
+ {
+ if (event instanceof BundleEventAdapter)
+ {
+ BundleEventAdapter adapter = (BundleEventAdapter)event;
+ delegate.bundleChanged(adapter.getEvent());
+ }
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/EventAdapter.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/EventAdapter.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/EventAdapter.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,33 @@
+/*
+* 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.plugins.facade;
+
+/**
+ * Event adapter contract.
+ *
+ * @param <E> event type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface EventAdapter<E>
+{
+ E getEvent();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FilterImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FilterImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FilterImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,67 @@
+/*
+* 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.plugins.facade;
+
+import java.util.Dictionary;
+
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.jboss.kernel.spi.event.KernelEventFilter;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * OSGi Filter contract on top of KernelEventFilter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FilterImpl implements KernelEventFilter, Filter
+{
+ protected String filter;
+ protected OSGiKernelEventFilter eventFilter;
+
+ public FilterImpl(String filter) throws InvalidSyntaxException
+ {
+ this.filter = filter;
+ this.eventFilter = new OSGiKernelEventFilter(filter);
+ }
+
+ public boolean wantEvent(KernelEvent event, Object handback)
+ {
+ return eventFilter.wantEvent(event, handback);
+ }
+
+ public boolean match(ServiceReference serviceReference)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean match(Dictionary dictionary)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean matchCase(Dictionary dictionary)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkEventAdapter.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkEventAdapter.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkEventAdapter.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,33 @@
+/*
+* 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.plugins.facade;
+
+import org.osgi.framework.FrameworkEvent;
+
+/**
+ * FrameworkEvent contract.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface FrameworkEventAdapter extends EventAdapter<FrameworkEvent>
+{
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkListenerImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkListenerImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/FrameworkListenerImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,47 @@
+/*
+* 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.plugins.facade;
+
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.osgi.framework.FrameworkListener;
+
+/**
+ * FrameworkListener implementation on top of existing KernelEventListener.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FrameworkListenerImpl extends AbstractDelegateListener<FrameworkListener>
+{
+ public FrameworkListenerImpl(FrameworkListener delegate)
+ {
+ super(delegate);
+ }
+
+ public void onEvent(KernelEvent event, Object handback)
+ {
+ if (event instanceof FrameworkEventAdapter)
+ {
+ FrameworkEventAdapter adapter = (FrameworkEventAdapter)event;
+ delegate.frameworkEvent(adapter.getEvent());
+ }
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/OSGiKernelEventFilter.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/OSGiKernelEventFilter.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/OSGiKernelEventFilter.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.facade;
+
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.jboss.kernel.spi.event.KernelEventFilter;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * OSGi Filter contract on top of KernelEventFilter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiKernelEventFilter implements KernelEventFilter
+{
+ protected String filter;
+
+ public OSGiKernelEventFilter(String filter) throws InvalidSyntaxException
+ {
+ this.filter = filter;
+ validateFilterString();
+ }
+
+ protected void validateFilterString()
+ {
+ // todo
+ }
+
+ public boolean wantEvent(KernelEvent event, Object handback)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceEventAdapter.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceEventAdapter.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceEventAdapter.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,33 @@
+/*
+* 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.plugins.facade;
+
+import org.osgi.framework.ServiceEvent;
+
+/**
+ * ServiceEvent contract.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ServiceEventAdapter extends EventAdapter<ServiceEvent>
+{
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceFactoryImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceFactoryImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceFactoryImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,44 @@
+/*
+* 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.plugins.facade;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Servicefactory implementation on top of Controller
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServiceFactoryImpl implements ServiceFactory
+{
+ public Object getService(Bundle bundle, ServiceRegistration serviceRegistration)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration serviceRegistration, Object object)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceListenerImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceListenerImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceListenerImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,63 @@
+/*
+* 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.plugins.facade;
+
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.osgi.framework.AllServiceListener;
+import org.osgi.framework.ServiceListener;
+
+/**
+ * ServiceListenerImpl implementation on top of existing KernelEventListener.
+ * Handles both AllServiceListener and simple ServiceListener.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServiceListenerImpl extends AbstractDelegateListener<ServiceListener>
+{
+ private boolean isAll;
+
+ public ServiceListenerImpl(ServiceListener delegate)
+ {
+ super(delegate);
+ isAll = (delegate instanceof AllServiceListener);
+ }
+
+ /**
+ * Is AllServiceListener.
+ *
+ * @return is all service listener
+ */
+ public boolean isAll()
+ {
+ return isAll;
+ }
+
+ public void onEvent(KernelEvent event, Object handback)
+ {
+ // todo - all stuff, permissions
+ if (event instanceof ServiceEventAdapter)
+ {
+ ServiceEventAdapter adapter = (ServiceEventAdapter)event;
+ delegate.serviceChanged(adapter.getEvent());
+ }
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceReferenceImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceReferenceImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceReferenceImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.facade;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * ServiceReference implementation.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServiceReferenceImpl implements ServiceReference
+{
+ public Object getProperty(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String[] getPropertyKeys()
+ {
+ return new String[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Bundle getBundle()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Bundle[] getUsingBundles()
+ {
+ return new Bundle[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isAssignableTo(Bundle bundle, String string)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceRegistrationImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceRegistrationImpl.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/ServiceRegistrationImpl.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,50 @@
+/*
+* 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.plugins.facade;
+
+import java.util.Dictionary;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * ServiceRegistration implementation.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServiceRegistrationImpl implements ServiceRegistration
+{
+ public ServiceReference getReference()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setProperties(Dictionary dictionary)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void unregister()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractAttributeMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractAttributeMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractAttributeMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,100 @@
+/*
+* 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.plugins.metadata;
+
+import java.io.Serializable;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.osgi.spi.metadata.AttributeMetaData;
+import org.jboss.osgi.spi.metadata.ServiceValueMetaData;
+import org.jboss.util.UnreachableStatementException;
+import org.osgi.framework.BundleContext;
+
+/**
+ * ServiceAttributeMetaData.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractAttributeMetaData extends AbstractMetaDataVisitorNode implements AttributeMetaData, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ /** The attribute name */
+ private String name;
+
+ /** The value */
+ private ServiceValueMetaData value;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Set the name.
+ *
+ * @param name the name.
+ */
+ public void setName(String name)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ this.name = name;
+ }
+
+ public ServiceValueMetaData getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param value the value.
+ */
+ public void setValue(ServiceValueMetaData value)
+ {
+ if (value == null)
+ throw new IllegalArgumentException("Null value");
+ this.value = value;
+ }
+
+ /**
+ * Get the value
+ *
+ * @param bundleContext the bundle context
+ * @return the value
+ * @throws Exception for any error
+ */
+ public Object getValue(BundleContext bundleContext) throws Exception
+ {
+ try
+ {
+ return value.getValue(bundleContext);
+ }
+ catch (Throwable t)
+ {
+ DeploymentException.rethrowAsDeploymentException("Error configuring attribute " + name, t);
+ throw new UnreachableStatementException();
+ }
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractDependencyMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractDependencyMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractDependencyMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,117 @@
+/*
+* 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.plugins.metadata;
+
+import java.io.Serializable;
+
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.osgi.plugins.dependency.OSGiServiceReferenceContext;
+import org.jboss.osgi.spi.metadata.DependencyMetaData;
+import org.jboss.osgi.spi.metadata.ServiceMetaDataVisitor;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * A dependency.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractDependencyMetaData extends AbstractMetaDataVisitorNode
+ implements DependencyMetaData, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ /** The dependency, may transient? */
+ protected Object dependency;
+
+ /**
+ * Create a new dependency
+ */
+ public AbstractDependencyMetaData()
+ {
+ }
+
+ /**
+ * Create a new dependency
+ *
+ * @param dependency the dependency
+ */
+ public AbstractDependencyMetaData(Object dependency)
+ {
+ this.dependency = dependency;
+ }
+
+ /**
+ * Set the dependency
+ *
+ * @param dependency the dependency
+ */
+ public void setDependency(Object dependency)
+ {
+ this.dependency = dependency;
+ flushJBossObjectCache();
+ }
+
+ public Object getDependency()
+ {
+ return dependency;
+ }
+
+ public void visit(ServiceMetaDataVisitor visitor)
+ {
+ OSGiServiceReferenceContext context = visitor.getControllerContext();
+ DependencyItem item = new LifecycleDependencyItem(context.getName(), ControllerState.CREATE);
+ visitor.addDependency(item);
+ item = new LifecycleDependencyItem(context.getName(), ControllerState.START);
+ visitor.addDependency(item);
+
+ visitor.visit(this);
+ }
+
+ public void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("dependency=").append(dependency);
+ }
+
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(dependency);
+ }
+
+ /**
+ * A LifecycleDependencyItem.
+ */
+ public class LifecycleDependencyItem extends AbstractDependencyItem
+ {
+ /**
+ * Create a new LifecycleDependencyItem.
+ *
+ * @param name the name
+ * @param state the state
+ */
+ public LifecycleDependencyItem(Object name, ControllerState state)
+ {
+ super(name, dependency, state, state);
+ }
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractHolderMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractHolderMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractHolderMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.plugins.metadata;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.osgi.spi.metadata.DependencyMetaData;
+import org.jboss.osgi.spi.metadata.HolderMetaData;
+
+/**
+ * Common OSGi reference or service impl.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractHolderMetaData extends AbstractMetaDataVisitorNode
+ implements HolderMetaData, Serializable
+{
+ private static final long serialVersionUID = 1l;
+
+ private String id;
+ private String anInterface;
+ private Set<DependencyMetaData> depends;
+ private ClassLoaderMetaData classLoaderMetaData;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getInterface()
+ {
+ return anInterface;
+ }
+
+ public Set<DependencyMetaData> getDepends()
+ {
+ return depends;
+ }
+
+ public ClassLoaderMetaData getContextClassLoader()
+ {
+ return classLoaderMetaData;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public void setInterface(String anInterface)
+ {
+ this.anInterface = anInterface;
+ }
+
+ public void setDepends(Set<DependencyMetaData> depends)
+ {
+ this.depends = depends;
+ }
+
+ public void setClassLoaderMetaData(ClassLoaderMetaData classLoaderMetaData)
+ {
+ this.classLoaderMetaData = classLoaderMetaData;
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractListenerMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractListenerMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractListenerMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,72 @@
+/*
+* 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.plugins.metadata;
+
+import java.io.Serializable;
+
+import org.jboss.osgi.spi.metadata.ListenerMetaData;
+
+/**
+ * Simple listener meta data.
+ * Referencing ref bean as a reference listener.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractListenerMetaData implements ListenerMetaData, Serializable
+{
+ private static final long serialVersionUID = 1l;
+
+ private String ref;
+ private String bindMethod;
+ private String unbindMethod;
+
+ public String getRef()
+ {
+ return ref;
+ }
+
+ public String getBindMethod()
+ {
+ return bindMethod;
+ }
+
+ public String getUnbindMethod()
+ {
+ return unbindMethod;
+ }
+
+ public void setRef(String ref)
+ {
+ this.ref = ref;
+ }
+
+ public void setBindMethod(String bindMethod)
+ {
+ this.bindMethod = bindMethod;
+ }
+
+ public void setUnbindMethod(String unbindMethod)
+ {
+ this.unbindMethod = unbindMethod;
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractMetaDataVisitorNode.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractMetaDataVisitorNode.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractMetaDataVisitorNode.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,62 @@
+/*
+* 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.plugins.metadata;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.jboss.osgi.spi.metadata.ServiceMetaDataVisitor;
+import org.jboss.osgi.spi.metadata.ServiceMetaDataVisitorNode;
+import org.jboss.util.JBossObject;
+import org.jboss.util.collection.CollectionsFactory;
+
+/**
+ * AbstractMetaDataVisitorNode.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractMetaDataVisitorNode extends JBossObject implements ServiceMetaDataVisitorNode
+{
+ public Iterator<? extends ServiceMetaDataVisitorNode> getChildren()
+ {
+ Set<ServiceMetaDataVisitorNode> children = CollectionsFactory.createLazySet();
+ addChildren(children);
+ if (children.size() == 0)
+ return null;
+ else
+ return children.iterator();
+ }
+
+ public void visit(ServiceMetaDataVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ /**
+ * Add to the children
+ *
+ * @param children the children
+ */
+ protected void addChildren(Set<ServiceMetaDataVisitorNode> children)
+ {
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,45 @@
+/*
+* 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.plugins.metadata;
+
+import org.jboss.deployers.plugins.metadata.AbstractManifestMetaData;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+
+/**
+ * Abstract OSGi meta data.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractOSGiMetaData extends AbstractManifestMetaData implements OSGiMetaData
+{
+ private static final long serialVersionUID = 1L;
+
+ public String getBundleSymbolicName()
+ {
+ return null;
+ }
+
+ public String getBundleActivator()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractReferenceMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractReferenceMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractReferenceMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,123 @@
+/*
+* 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.plugins.metadata;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.osgi.spi.metadata.ListenerMetaData;
+import org.jboss.osgi.spi.metadata.ReferenceMetaData;
+import org.jboss.osgi.spi.metadata.ServiceMetaDataVisitor;
+import org.osgi.framework.BundleContext;
+
+/**
+ * OSGi reference meta data.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractReferenceMetaData extends AbstractHolderMetaData implements ReferenceMetaData
+{
+ private static final long serialVersionUID = 1l;
+
+ private String filter;
+ private Cardinality cardinality = Cardinality.ONE_TO_ONE;
+ private Integer timeout;
+ private List<ListenerMetaData> listeners;
+ private Set<PropertyMetaData> properties;
+
+ public Object getUnderlyingValue()
+ {
+ return getId();
+ }
+
+ public Object getValue(BundleContext bundleContext) throws Throwable
+ {
+ // todo - add dynamic behaviour
+ return GeneratedAOPProxyFactory.createProxy(null, null);
+ }
+
+ public void visit(ServiceMetaDataVisitor visitor)
+ {
+ // todo - add dependency
+ super.visit(visitor);
+ }
+
+ public String getFilter()
+ {
+ return filter;
+ }
+
+ public Cardinality getCardinality()
+ {
+ return cardinality;
+ }
+
+ public Integer getTimeout()
+ {
+ return timeout;
+ }
+
+ public List<ListenerMetaData> getListeners()
+ {
+ return listeners;
+ }
+
+ public Set<PropertyMetaData> getProperties()
+ {
+ return properties;
+ }
+
+ public Class getType(MetaDataVisitor visitor, MetaDataVisitorNode previous) throws Throwable
+ {
+ return null;
+ }
+
+ public void setFilter(String filter)
+ {
+ this.filter = filter;
+ }
+
+ public void setCardinality(Cardinality cardinality)
+ {
+ this.cardinality = cardinality;
+ }
+
+ public void setTimeout(Integer timeout)
+ {
+ this.timeout = timeout;
+ }
+
+ public void setListeners(List<ListenerMetaData> listeners)
+ {
+ this.listeners = listeners;
+ }
+
+ public void setProperties(Set<PropertyMetaData> properties)
+ {
+ this.properties = properties;
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceDeployment.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceDeployment.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceDeployment.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,77 @@
+/*
+* 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.plugins.metadata;
+
+import java.util.List;
+
+import org.jboss.osgi.spi.metadata.ServiceDeployment;
+import org.jboss.osgi.spi.metadata.ServiceMetaData;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * An abstract service deployment
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractServiceDeployment extends JBossObject implements ServiceDeployment
+{
+ /** The name of the deployment */
+ protected String name;
+
+ /* The services list */
+ protected List<ServiceMetaData> services;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ flushJBossObjectCache();
+ }
+
+ public List<ServiceMetaData> getServices()
+ {
+ return services;
+ }
+
+ public void setServices(List<ServiceMetaData> services)
+ {
+ this.services = services;
+ }
+
+ public void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("name=").append(name);
+ if (services != null)
+ buffer.append(" services=").append(services);
+ }
+
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(name);
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractServiceMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,110 @@
+/*
+* 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.plugins.metadata;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.osgi.spi.metadata.AttributeMetaData;
+import org.jboss.osgi.spi.metadata.ServiceMetaData;
+import org.jboss.osgi.spi.metadata.ServiceMetaDataVisitor;
+
+/**
+ * OSGi service meta data.
+ * Register ref bean as an OSGi service with interface or interfaces.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractServiceMetaData extends AbstractHolderMetaData implements ServiceMetaData
+{
+ private static final long serialVersionUID = 1l;
+
+ private Set<String> interfaces;
+ private Map<String, String> serviceProperties;
+ private String ref;
+ private boolean lazyInit;
+
+ /** The references */
+ private List<AttributeMetaData> attributes = Collections.emptyList();
+
+ /** The dependencies */
+ // todo
+
+ public void visit(ServiceMetaDataVisitor visitor)
+ {
+ // todo - add children, depend on ref bean from MC
+ super.visit(visitor);
+ }
+
+ public List<AttributeMetaData> getAttributes()
+ {
+ return attributes;
+ }
+
+ public Set<String> getInterfaces()
+ {
+ return interfaces;
+ }
+
+ public Map<String, String> getServiceProperties()
+ {
+ return serviceProperties;
+ }
+
+ public String getRef()
+ {
+ return ref;
+ }
+
+ public boolean getLazyInit()
+ {
+ return lazyInit;
+ }
+
+ public void setAttributes(List<AttributeMetaData> attributes)
+ {
+ this.attributes = attributes;
+ }
+
+ public void setInterfaces(Set<String> interfaces)
+ {
+ this.interfaces = interfaces;
+ }
+
+ public void setServiceProperties(Map<String, String> serviceProperties)
+ {
+ this.serviceProperties = serviceProperties;
+ }
+
+ public void setRef(String ref)
+ {
+ this.ref = ref;
+ }
+
+ public void setLazyInit(boolean lazyInit)
+ {
+ this.lazyInit = lazyInit;
+ }
+
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/AttributeMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/AttributeMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/AttributeMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,44 @@
+/*
+* 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.spi.metadata;
+
+/**
+ * ServiceAttributeMetaData.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface AttributeMetaData
+{
+ /**
+ * Get the name.
+ *
+ * @return the name.
+ */
+ String getName();
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ ServiceValueMetaData getValue();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/DependencyMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/DependencyMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/DependencyMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,37 @@
+/*
+* 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.spi.metadata;
+
+/**
+ * Metadata about what a osgi service's dependency.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface DependencyMetaData
+{
+ /**
+ * What is the dependency
+ *
+ * @return the dependency
+ */
+ Object getDependency();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/HolderMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/HolderMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/HolderMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,42 @@
+/*
+* 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.spi.metadata;
+
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+
+/**
+ * Common OSGi meta data attributes.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface HolderMetaData
+{
+ String getId();
+
+ String getInterface();
+
+ Set<DependencyMetaData> getDepends();
+
+ ClassLoaderMetaData getContextClassLoader();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ListenerMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ListenerMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ListenerMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,36 @@
+/*
+* 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.spi.metadata;
+
+/**
+ * Simple listener meta data - referencing bean as listener.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ListenerMetaData
+{
+ String getRef();
+
+ String getBindMethod();
+
+ String getUnbindMethod();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/OSGiMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/OSGiMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/OSGiMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,44 @@
+/*
+* 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.spi.metadata;
+
+import org.jboss.deployers.spi.metadata.ManifestMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface OSGiMetaData extends ManifestMetaData
+{
+ /**
+ * Get bundle symbolic name.
+ *
+ * @return bundle's symbolic name
+ */
+ String getBundleSymbolicName();
+
+ /**
+ * Get bundle activator class name.
+ *
+ * @return bundle activator classname or null if no such attribute
+ */
+ String getBundleActivator();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ReferenceMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ReferenceMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ReferenceMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.osgi.spi.metadata;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+
+/**
+ * OSGi reference meta data.
+ * Extends ValueMetaData - can be used as a value via proxy.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ReferenceMetaData extends HolderMetaData, ServiceValueMetaData
+{
+ String getFilter();
+
+// Cardinality getCardinality();
+
+ Integer getTimeout();
+
+ List<ListenerMetaData> getListeners();
+
+ Set<PropertyMetaData> getProperties();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceDeployment.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceDeployment.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceDeployment.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.spi.metadata;
+
+import java.util.List;
+
+/**
+ * An osgi service deployment
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ServiceDeployment
+{
+ /**
+ * Get the name of the deployment
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Set the name of the deployment
+ *
+ * @param name the name
+ */
+ void setName(String name);
+
+ /**
+ * Get the services in the deployment
+ * @return List<ServiceMetaData>
+ */
+ List<ServiceMetaData> getServices();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,44 @@
+/*
+* 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.spi.metadata;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * OSGi service meta data.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ServiceMetaData extends HolderMetaData, ServiceMetaDataVisitorNode
+{
+ List<AttributeMetaData> getAttributes();
+
+ Set<String> getInterfaces();
+
+ Map<String, String> getServiceProperties();
+
+ String getRef();
+
+ boolean getLazyInit();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitor.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitor.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitor.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,69 @@
+/*
+* 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.spi.metadata;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.osgi.plugins.dependency.OSGiServiceReferenceContext;
+
+/**
+ * ServiceMetaDataVisitor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ServiceMetaDataVisitor
+{
+ /**
+ * Get the controller context
+ *
+ * @return the context
+ */
+ OSGiServiceReferenceContext getControllerContext();
+
+ /**
+ * Get the context state
+ *
+ * @return the context state
+ */
+ ControllerState getContextState();
+
+ /**
+ * Set the context state
+ *
+ * @param contextState the context state
+ */
+ void setContextState(ControllerState contextState);
+
+ /**
+ * Add a dependency
+ *
+ * @param dependency the dependency
+ */
+ void addDependency(DependencyItem dependency);
+
+ /**
+ * Visit the node
+ *
+ * @param node the node
+ */
+ void visit(ServiceMetaDataVisitorNode node);
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitorNode.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitorNode.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceMetaDataVisitorNode.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -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.osgi.spi.metadata;
+
+import java.util.Iterator;
+
+/**
+ * ServiceMetaDataVisitorNode.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ServiceMetaDataVisitorNode
+{
+ /**
+ * Visit the node
+ *
+ * @param vistor the visitor
+ */
+ public void visit(ServiceMetaDataVisitor vistor);
+
+ /**
+ * Return the child nodes
+ *
+ * @return Iterator<MetaDataVisitorNode> or null if there aren't any
+ */
+ public Iterator<? extends ServiceMetaDataVisitorNode> getChildren();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceValueMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceValueMetaData.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/spi/metadata/ServiceValueMetaData.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,41 @@
+/*
+* 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.spi.metadata;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * ServiceValueMetaData.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ServiceValueMetaData extends ServiceMetaDataVisitorNode
+{
+ /**
+ * Get the value
+ *
+ * @param bundleContext the bundle context
+ * @return the value
+ * @throws Throwable for any error
+ */
+ Object getValue(BundleContext bundleContext) throws Throwable;
+}
Added: projects/microcontainer/trunk/osgi-int/src/resources/schema/osgi-beans_1_0.xsd
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/resources/schema/osgi-beans_1_0.xsd (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/resources/schema/osgi-beans_1_0.xsd 2007-04-02 10:18:26 UTC (rev 61979)
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for the osgi xml deployer -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:osgi-beans:1.0"
+ xmlns="urn:jboss:osgi-beans:1.0"
+ xmlns:mc="urn:jboss:bean-deployer:2.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:import namespace="urn:jboss:bean-deployer:2.0"/>
+
+ <!-- reference -->
+ <xsd:element name="reference" type="referenceType"/>
+
+ <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="listenerType" minOccurs="0"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" use="required" type="xsd:string"/>
+ <xsd:attribute name="interface" use="required" type="xsd:string"/>
+ <xsd:attribute name="filter" use="optional" type="xsd:string"/>
+ <xsd:attribute name="cardinality" use="optional" type="Tcardinality" default="1..1"/>
+ <xsd:attribute name="timeout" use="optional" type="xsd:int" default="0"/>
+ <xsd:attribute name="depends-on" type="xsd:string" use="optional"/>
+ <xsd:attribute name="context-classloader" type="TreferenceClassLoaderOptions" default="client"/>
+ </xsd:complexContent>
+
+ </xsd:complexType>
+
+ <xsd:simpleType name="Tcardinality">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="0..1"/>
+ <xsd:enumeration value="0..n"/>
+ <xsd:enumeration value="1..1"/>
+ <xsd:enumeration value="1..n"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="TreferenceClassLoaderOptions">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="client"/>
+ <xsd:enumeration value="service-provider"/>
+ <xsd:enumeration value="unmanaged"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <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="serviceType"/>
+
+ <xsd:complexType name="serviceType">
+ <xsd:complexContent>
+ <xsd:sequence minOccurs="0" maxOccurs="1">
+ <xsd:element name="interfaces" type="mc:setType" minOccurs="0"/>
+ <xsd:element name="service-properties" type="mc:mapType" minOccurs="0"/>
+ <!-- this next entry is to allow a nested bean element -->
+ <!--<xsd:any namespace="##other" minOccurs="0" maxOccurs="1" processContents="skip"/>-->
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:string" use="optional"/>
+ <xsd:attribute name="ref" type="xsd:string" use="required"/>
+ <xsd:attribute name="interface" type="xsd:string" use="optional"/>
+ <xsd:attribute name="lazy-init" type="xsd:boolean" use="optional" default="false"/>
+ <xsd:attribute name="depends-on" type="xsd:string" use="optional"/>
+ <xsd:attribute name="context-classloader" type="TserviceClassLoaderOptions" default="unmanaged"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:simpleType name="TserviceClassLoaderOptions">
+
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="service-provider"/>
+ <xsd:enumeration value="unmanaged"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
Modified: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/annotations/OsgiService.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/annotations/OsgiService.java 2007-04-02 10:15:34 UTC (rev 61978)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/metadata/spi/annotations/OsgiService.java 2007-04-02 10:18:26 UTC (rev 61979)
@@ -19,7 +19,7 @@
* 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.metadata.spi.annotations;
+package org.jboss.osgi.spi.metadata.annotations;
/**
* Annotation marking bean as OSGi service.
More information about the jboss-cvs-commits
mailing list