JBoss-OSGI SVN: r95101 - in projects/jboss-osgi/trunk: testsuite/example/src/test/resources and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-19 06:27:41 -0400 (Mon, 19 Oct 2009)
New Revision: 95101
Modified:
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
Log:
Fix syscp delegation for deployment
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-10-19 10:25:06 UTC (rev 95100)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-10-19 10:27:41 UTC (rev 95101)
@@ -18,7 +18,8 @@
org.osgi.framework.system.packages.extra=\
org.apache.log4j;version=1.2, \
org.jboss.logging, \
- org.jboss.osgi.deployment;version=1.0, \
+ org.jboss.osgi.deployment.common;version=1.0, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.logging;version=1.0, \
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-10-19 10:25:06 UTC (rev 95100)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-10-19 10:27:41 UTC (rev 95101)
@@ -20,7 +20,8 @@
org.jboss.logging, \
org.jboss.net.protocol, \
org.jboss.osgi.common.log;version=1.0, \
- org.jboss.osgi.deployment;version=1.0, \
+ org.jboss.osgi.deployment.common;version=1.0, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.framework;version=1.0, \
16 years, 2 months
JBoss-OSGI SVN: r95097 - in projects/jboss-osgi: trunk/reactor/deployment and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-19 05:04:35 -0400 (Mon, 19 Oct 2009)
New Revision: 95097
Modified:
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml
projects/jboss-osgi/trunk/reactor/deployment/pom.xml
Log:
Fix import/export metadata
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml 2009-10-19 08:13:35 UTC (rev 95096)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml 2009-10-19 09:04:35 UTC (rev 95097)
@@ -96,7 +96,9 @@
<Import-Package>
javax.management,
org.jboss.osgi.common.log;version=1.0,
- org.jboss.osgi.deployment;version=1.0,
+ org.jboss.osgi.deployment.common;version=1.0,
+ org.jboss.osgi.deployment.deployer;version=1.0,
+ org.jboss.osgi.deployment.scanner;version=1.0,
org.jboss.osgi.spi.service;version=1.0,
org.jboss.osgi.spi.util;version=1.0,
org.osgi.framework,
Modified: projects/jboss-osgi/trunk/reactor/deployment/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-19 08:13:35 UTC (rev 95096)
+++ projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-19 09:04:35 UTC (rev 95097)
@@ -69,7 +69,10 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.jboss.osgi.deployment.internal.DeploymentServicesActivator</Bundle-Activator>
<Export-Package>
- org.jboss.osgi.deployment;version=1.0,
+ org.jboss.osgi.deployment.common;version=1.0,
+ org.jboss.osgi.deployment.deployer;version=1.0,
+ org.jboss.osgi.deployment.interceptor;version=1.0,
+ org.jboss.osgi.deployment.scanner;version=1.0,
</Export-Package>
<Private-Package>
org.jboss.osgi.deployment.internal
16 years, 2 months
JBoss-OSGI SVN: r95096 - in projects/jboss-osgi: projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer and 11 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-19 04:13:35 -0400 (Mon, 19 Oct 2009)
New Revision: 95096
Added:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Attachments.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceCapability.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/scanner/
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/scanner/DeploymentScannerService.java
Removed:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java
Modified:
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerActivator.java
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/ScannerThread.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
Log:
Seperate notion of deployer from interceptor
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerActivator.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerActivator.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -23,7 +23,7 @@
//$Id$
-import org.jboss.osgi.deployment.DeploymentScannerService;
+import org.jboss.osgi.deployment.scanner.DeploymentScannerService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -34,9 +34,9 @@
import java.util.List;
import java.util.Map;
-import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeploymentScannerService;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.scanner.DeploymentScannerService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/ScannerThread.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/ScannerThread.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/ScannerThread.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -24,7 +24,7 @@
//$Id$
import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.deployment.DeploymentScannerService;
+import org.jboss.osgi.deployment.scanner.DeploymentScannerService;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -23,7 +23,7 @@
//$Id$
-import org.jboss.osgi.deployment.DeploymentServiceCapability;
+import org.jboss.osgi.deployment.deployer.DeployerServiceCapability;
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.capability.CompendiumCapability;
import org.jboss.osgi.spi.service.MicrocontainerService;
@@ -47,7 +47,7 @@
super(MicrocontainerService.class.getName());
addDependency(new CompendiumCapability());
- addDependency(new DeploymentServiceCapability());
+ addDependency(new DeployerServiceCapability());
addBundle("bundles/jboss-osgi-microcontainer.jar");
}
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -47,9 +47,9 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeployerServiceBase;
-import org.jboss.osgi.deployment.DeploymentRegistryService;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.deployer.DeployerServiceBase;
+import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.MicrocontainerService;
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -35,7 +35,7 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.jbossxb.XMLBindingService;
import org.jboss.osgi.microcontainer.integration.AbstractMicrocontainerService;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -26,7 +26,7 @@
import java.net.URL;
import org.jboss.logging.Logger;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.spi.framework.BundleContextWrapper;
import org.jboss.osgi.spi.util.BundleInfo;
import org.osgi.framework.Bundle;
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -31,7 +31,7 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.logging.Logger;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.osgi.framework.BundleContext;
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,160 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-// $Id$
-
-import java.util.Collection;
-
-/**
- * An interface for general Attachments
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 20-Apr-2007
- */
-public interface Attachments
-{
- /** Get attachment keys */
- Collection<Key> getAttachmentKeys();
-
- /** Add arbitrary attachment */
- <T> T addAttachment(Class<T> clazz, Object value);
-
- /** Add arbitrary attachment with name */
- <T> T addAttachment(Class<T> clazz, String name, Object value);
-
- /** Add arbitrary attachment with name */
- Object addAttachment(String name, Object value);
-
- /** Get an arbitrary attachment */
- <T> T getAttachment(Class<T> clazz);
-
- /** Get an arbitrary attachment */
- <T> T getAttachment(Class<T> clazz, String name);
-
- /** Get an arbitrary attachment */
- Object getAttachment(String name);
-
- /** Remove arbitrary attachments */
- <T> T removeAttachment(Class<T> clazz);
-
- /** Remove arbitrary attachments */
- <T> T removeAttachment(Class<T> clazz, String name);
-
- /** Remove arbitrary attachments */
- Object removeAttachment(String name);
-
- /**
- * A key for attachements
- */
- public static class Key
- {
- private Class<?> clazz;
- private String name;
-
- /**
- * Construct the key with optional class and name
- */
- public Key(Class<?> clazz, String name)
- {
- this.clazz = clazz;
- this.name = name;
- }
-
- public static Key valueOf(String key)
- {
- int index = key.indexOf(",");
- if (key.startsWith("[") && key.endsWith("]") && index > 0)
- {
- Class<?> classPart = null;
- String className = key.substring(1, index);
- String namePart = key.substring(index + 1, key.length() - 1);
- if (className.length() > 0 && !className.equals("null"))
- {
- try
- {
- classPart = Class.forName(className);
- }
- catch (ClassNotFoundException ex)
- {
- throw new IllegalArgumentException("Cannot find class '" + className + "' in: " + key);
- }
- }
- return new Key(classPart, namePart);
- }
- return null;
- }
-
- /**
- * Get the class part for this key
- *
- * @return maybe null
- */
- public Class<?> getClassPart()
- {
- return clazz;
- }
-
- /**
- * Get the name part for this key
- *
- * @return maybe null
- */
- public String getNamePart()
- {
- return name;
- }
-
- /**
- * Two keys are equal if their {@link #toString()} is equal
- */
- public boolean equals(Object obj)
- {
- if (!(obj instanceof Key))
- return false;
- if (obj == this)
- return true;
- return obj.toString().equals(toString());
- }
-
- /**
- * Two keys have the same hashCode if their {@link #toString()} is equal
- */
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- /**
- * Returns the String repesentation of this Key.
- * <p/>
- *
- * <pre>
- * "[" + clazz + "," + name + "]"
- * </pre>
- */
- public String toString()
- {
- return "[" + clazz + "," + name + "]";
- }
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import java.net.URL;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.BundleException;
-
-/**
- * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public interface DeployerService
-{
- /**
- * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
- */
- ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
-
- /**
- * Create a deployment from the given location.
- */
- Deployment createDeployment(String location) throws BundleException;
-
- /**
- * Deploy an array of bundles
- */
- void deploy(Deployment[] bundleDeps) throws BundleException;
-
- /**
- * Undeploy an array of bundles
- */
- void undeploy(Deployment[] bundleDeps) throws BundleException;
-
- /**
- * Deploy bundle from URL
- */
- void deploy(URL url) throws BundleException;
-
- /**
- * Undeploy bundle from URL.
- *
- * Note, due to the dynamic nature of OSGi services it is
- * possible that a {@link DeployerService} is asked to undeploy
- * a bundle URL which it did not deploy itself.
- *
- * In this case this method should return false, so that
- * another {@link DeployerService} can be tried.
- *
- * @return true if this service could undeploy the bundle
- */
- boolean undeploy(URL url) throws BundleException;
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.jboss.osgi.deployment.internal.DeploymentImpl;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-//$Id$
-
-/**
- * An abstract base implementation of the DeployerService.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 16-Oct-2009
- */
-public abstract class DeployerServiceBase implements DeployerService
-{
- public Deployment createDeployment(String location) throws BundleException
- {
- // Try location as URL
- URL url = null;
- try
- {
- url = new URL(location);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try location as File
- if (url == null)
- {
- try
- {
- File file = new File(location);
- if (file.exists())
- url = file.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- if (url == null)
- throw new IllegalArgumentException("Invalid bundle location: " + location);
-
- return createDeploymentInternal(url);
- }
-
- private Deployment createDeploymentInternal(URL url) throws BundleException
- {
- Manifest manifest;
- try
- {
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
- }
- catch (IOException ex)
- {
- throw new BundleException("Cannot get manifest from: " + url);
-
- }
-
- Attributes attribs = manifest.getMainAttributes();
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
-
- String version = attribs.getValue(Constants.BUNDLE_VERSION);
- return new DeploymentImpl(url, symbolicName, version);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public-
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-import java.net.URL;
-
-//$Id$
-
-/**
- * An abstraction of a bundle deployment
- *
- * @author thomas.diesler(a)jboss.com
- * @since 27-May-2009
- */
-public interface Deployment extends Attachments
-{
- /**
- * Get the bundle location
- */
- public URL getLocation();
-
- /**
- * Get the bundle symbolic name
- */
- public String getSymbolicName();
-
- /**
- * Get the bundle version
- */
- public String getVersion();
-
- /**
- * Get the start level associated with this deployment
- */
- public int getStartLevel();
-
- /**
- * Set the start level associated with this deployment
- */
- public void setStartLevel(int startLevel);
-
- /**
- * Get the autostart flag associated with this deployment
- */
- public boolean isAutoStart();
-
- /**
- * Set the autostart flag associated with this deployment
- */
- public void setAutoStart(boolean autoStart);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,120 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-// $Id$
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * Basic attachments.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 20-Apr-2007
- */
-public abstract class DeploymentBase implements Attachments
-{
- private Map<Key, Object> attachments = new HashMap<Key, Object>();
-
- /** Construct the execution context with no attachments */
- public DeploymentBase()
- {
-
- }
-
- /** Construct the execution context with given attachments */
- public DeploymentBase(Attachments att)
- {
- if (att != null)
- {
- for (Key key : att.getAttachmentKeys())
- {
- Object value = att.getAttachment(key.getClassPart(), key.getNamePart());
- this.attachments.put(key, value);
- }
- }
- }
-
- public Collection<Key> getAttachmentKeys()
- {
- return attachments.keySet();
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getAttachment(Class<T> clazz)
- {
- return (T)attachments.get(new Key(clazz, null));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getAttachment(Class<T> clazz, String name)
- {
- return (T)attachments.get(new Key(clazz, name));
- }
-
- public Object getAttachment(String name)
- {
- return attachments.get(new Key(null, name));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T addAttachment(Class<T> clazz, Object obj)
- {
- return (T)attachments.put(new Key(clazz, null), obj);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T addAttachment(Class<T> clazz, String name, Object obj)
- {
- return (T)attachments.put(new Key(clazz, name), obj);
- }
-
- public Object addAttachment(String name, Object obj)
- {
- return attachments.put(new Key(null, name), obj);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T removeAttachment(Class<T> clazz)
- {
- return (T)attachments.remove(new Key(clazz, null));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T removeAttachment(Class<T> clazz, String name)
- {
- return (T)attachments.remove(new Key(clazz, name));
- }
-
- public Object removeAttachment(String name)
- {
- return attachments.remove(new Key(null, name));
- }
-
- public String toString()
- {
- return attachments.toString();
- }
-}
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-
-/**
- * An OSGi deployer
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public interface DeploymentInterceptor
-{
- enum Phase {
- BEFORE_INSTALLED,
- AFTER_INSTALLED,
- BEFORE_RESOLVED,
- AFTER_RESOLVED,
- BEFORE_ACTIVE,
- AFTER_ACTIVE
- }
-
- void deploy(Deployment dep);
-
- void undeploy(Deployment dep);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-
-/**
- * The deployers service
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public interface DeploymentInterceptorService
-{
- void addInterceptor(DeploymentInterceptor deployer);
-
- void removeInterceptor(DeploymentInterceptor deployer);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id: DeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
-
-import java.net.URL;
-
-import org.osgi.framework.Version;
-
-/**
- * A Service to register/unregister bundle deployments.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2009
- */
-public interface DeploymentRegistryService
-{
- /**
- * Create a bundle deployment from the given bundle URL
- * @return null, if this service does not maintain the bundle deployment
- */
- Deployment getBundleDeployment(URL url);
-
- /**
- * Get the bundle deployment for the given bundle symbolicName and version
- * @return null, if this service does not maintain the bundle deployment
- */
- Deployment getBundleDeployment(String symbolicName, Version version);
-
- /**
- * Register a bundle deployment
- */
- void registerBundleDeployment(Deployment dep);
-
- /**
- * Unregister a bundle deployment
- */
- void unregisterBundleDeployment(Deployment dep);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import java.net.URL;
-
-
-/**
- * A service that scans a directory location for new/removed bundles.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 27-May-2009
- */
-public interface DeploymentScannerService
-{
- /**
- * The property that names the scan location: org.jboss.osgi.hotdeploy.scandir
- */
- String PROPERTY_SCAN_LOCATION = "org.jboss.osgi.hotdeploy.scandir";
-
- /**
- * The property to defines the scan interval: org.jboss.osgi.hotdeploy.interval
- */
- String PROPERTY_SCAN_INTERVAL = "org.jboss.osgi.hotdeploy.interval";
-
- /**
- * Get the scan location URL.
- *
- * This is can be specified by setting the {@link #PROPERTY_SCAN_LOCATION} property.
- */
- URL getScanLocation();
-
- /**
- * The number of scans since the service started
- */
- long getScanCount();
-
- /**
- * The number of milliseconds between scans
- * Defaults to 2000ms
- */
- long getScanInterval();
-
- /**
- * The timestamp of the last change
- */
- long getLastChange();
-
- /**
- * Run a directory scan
- */
- void scan();
-
- /**
- * Returns the array of bundles currently known to the deployemtn scanner.
- */
- Deployment[] getBundleDeployments();
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-
-/**
- * Adds the DeploymentService capability to the {@link OSGiRuntime}
- * under test.
- *
- * It is ignored if the {@link DeployerService} is already registered.
- *
- * Installed bundles: jboss-osgi-deployment.jar
- *
- * @author thomas.diesler(a)jboss.com
- * @since 16-Oct-2009
- */
-public class DeploymentServiceCapability extends Capability
-{
- public DeploymentServiceCapability()
- {
- super(DeployerService.class.getName());
-
- addBundle("bundles/jboss-osgi-deployment.jar");
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Attachments.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Attachments.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Attachments.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.common;
+
+// $Id$
+
+import java.util.Collection;
+
+/**
+ * An interface for general Attachments
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public interface Attachments
+{
+ /** Get attachment keys */
+ Collection<Key> getAttachmentKeys();
+
+ /** Add arbitrary attachment */
+ <T> T addAttachment(Class<T> clazz, Object value);
+
+ /** Add arbitrary attachment with name */
+ <T> T addAttachment(Class<T> clazz, String name, Object value);
+
+ /** Add arbitrary attachment with name */
+ Object addAttachment(String name, Object value);
+
+ /** Get an arbitrary attachment */
+ <T> T getAttachment(Class<T> clazz);
+
+ /** Get an arbitrary attachment */
+ <T> T getAttachment(Class<T> clazz, String name);
+
+ /** Get an arbitrary attachment */
+ Object getAttachment(String name);
+
+ /** Remove arbitrary attachments */
+ <T> T removeAttachment(Class<T> clazz);
+
+ /** Remove arbitrary attachments */
+ <T> T removeAttachment(Class<T> clazz, String name);
+
+ /** Remove arbitrary attachments */
+ Object removeAttachment(String name);
+
+ /**
+ * A key for attachements
+ */
+ public static class Key
+ {
+ private Class<?> clazz;
+ private String name;
+
+ /**
+ * Construct the key with optional class and name
+ */
+ public Key(Class<?> clazz, String name)
+ {
+ this.clazz = clazz;
+ this.name = name;
+ }
+
+ public static Key valueOf(String key)
+ {
+ int index = key.indexOf(",");
+ if (key.startsWith("[") && key.endsWith("]") && index > 0)
+ {
+ Class<?> classPart = null;
+ String className = key.substring(1, index);
+ String namePart = key.substring(index + 1, key.length() - 1);
+ if (className.length() > 0 && !className.equals("null"))
+ {
+ try
+ {
+ classPart = Class.forName(className);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalArgumentException("Cannot find class '" + className + "' in: " + key);
+ }
+ }
+ return new Key(classPart, namePart);
+ }
+ return null;
+ }
+
+ /**
+ * Get the class part for this key
+ *
+ * @return maybe null
+ */
+ public Class<?> getClassPart()
+ {
+ return clazz;
+ }
+
+ /**
+ * Get the name part for this key
+ *
+ * @return maybe null
+ */
+ public String getNamePart()
+ {
+ return name;
+ }
+
+ /**
+ * Two keys are equal if their {@link #toString()} is equal
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof Key))
+ return false;
+ if (obj == this)
+ return true;
+ return obj.toString().equals(toString());
+ }
+
+ /**
+ * Two keys have the same hashCode if their {@link #toString()} is equal
+ */
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ /**
+ * Returns the String repesentation of this Key.
+ * <p/>
+ *
+ * <pre>
+ * "[" + clazz + "," + name + "]"
+ * </pre>
+ */
+ public String toString()
+ {
+ return "[" + clazz + "," + name + "]";
+ }
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java (from rev 95093, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public-
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.common;
+
+import java.net.URL;
+
+
+//$Id$
+
+/**
+ * An abstraction of a bundle deployment
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public interface Deployment extends Attachments
+{
+ /**
+ * Get the bundle location
+ */
+ public URL getLocation();
+
+ /**
+ * Get the bundle symbolic name
+ */
+ public String getSymbolicName();
+
+ /**
+ * Get the bundle version
+ */
+ public String getVersion();
+
+ /**
+ * Get the start level associated with this deployment
+ */
+ public int getStartLevel();
+
+ /**
+ * Set the start level associated with this deployment
+ */
+ public void setStartLevel(int startLevel);
+
+ /**
+ * Get the autostart flag associated with this deployment
+ */
+ public boolean isAutoStart();
+
+ /**
+ * Set the autostart flag associated with this deployment
+ */
+ public void setAutoStart(boolean autoStart);
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.common;
+
+// $Id$
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+
+
+/**
+ * Basic attachments.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public abstract class DeploymentBase implements Attachments
+{
+ private Map<Key, Object> attachments = new HashMap<Key, Object>();
+
+ /** Construct the execution context with no attachments */
+ public DeploymentBase()
+ {
+
+ }
+
+ /** Construct the execution context with given attachments */
+ public DeploymentBase(Attachments att)
+ {
+ if (att != null)
+ {
+ for (Key key : att.getAttachmentKeys())
+ {
+ Object value = att.getAttachment(key.getClassPart(), key.getNamePart());
+ this.attachments.put(key, value);
+ }
+ }
+ }
+
+ public Collection<Key> getAttachmentKeys()
+ {
+ return attachments.keySet();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getAttachment(Class<T> clazz)
+ {
+ return (T)attachments.get(new Key(clazz, null));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getAttachment(Class<T> clazz, String name)
+ {
+ return (T)attachments.get(new Key(clazz, name));
+ }
+
+ public Object getAttachment(String name)
+ {
+ return attachments.get(new Key(null, name));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T addAttachment(Class<T> clazz, Object obj)
+ {
+ return (T)attachments.put(new Key(clazz, null), obj);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T addAttachment(Class<T> clazz, String name, Object obj)
+ {
+ return (T)attachments.put(new Key(clazz, name), obj);
+ }
+
+ public Object addAttachment(String name, Object obj)
+ {
+ return attachments.put(new Key(null, name), obj);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T removeAttachment(Class<T> clazz)
+ {
+ return (T)attachments.remove(new Key(clazz, null));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T removeAttachment(Class<T> clazz, String name)
+ {
+ return (T)attachments.remove(new Key(clazz, name));
+ }
+
+ public Object removeAttachment(String name)
+ {
+ return attachments.remove(new Key(null, name));
+ }
+
+ public String toString()
+ {
+ return attachments.toString();
+ }
+}
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java (from rev 95093, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.deployer;
+
+//$Id$
+
+import java.net.URL;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleException;
+
+/**
+ * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public interface DeployerService
+{
+ /**
+ * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
+ */
+ ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
+
+ /**
+ * Create a deployment from the given location.
+ */
+ Deployment createDeployment(String location) throws BundleException;
+
+ /**
+ * Deploy an array of bundles
+ */
+ void deploy(Deployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Undeploy an array of bundles
+ */
+ void undeploy(Deployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Deploy bundle from URL
+ */
+ void deploy(URL url) throws BundleException;
+
+ /**
+ * Undeploy bundle from URL.
+ *
+ * Note, due to the dynamic nature of OSGi services it is
+ * possible that a {@link DeployerService} is asked to undeploy
+ * a bundle URL which it did not deploy itself.
+ *
+ * In this case this method should return false, so that
+ * another {@link DeployerService} can be tried.
+ *
+ * @return true if this service could undeploy the bundle
+ */
+ boolean undeploy(URL url) throws BundleException;
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java (from rev 95093, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.deployer;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.internal.DeploymentImpl;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+//$Id$
+
+/**
+ * An abstract base implementation of the DeployerService.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 16-Oct-2009
+ */
+public abstract class DeployerServiceBase implements DeployerService
+{
+ public Deployment createDeployment(String location) throws BundleException
+ {
+ // Try location as URL
+ URL url = null;
+ try
+ {
+ url = new URL(location);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try location as File
+ if (url == null)
+ {
+ try
+ {
+ File file = new File(location);
+ if (file.exists())
+ url = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ if (url == null)
+ throw new IllegalArgumentException("Invalid bundle location: " + location);
+
+ return createDeploymentInternal(url);
+ }
+
+ private Deployment createDeploymentInternal(URL url) throws BundleException
+ {
+ Manifest manifest;
+ try
+ {
+ JarFile jarFile = new JarFile(url.getPath());
+ manifest = jarFile.getManifest();
+ jarFile.close();
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot get manifest from: " + url);
+
+ }
+
+ Attributes attribs = manifest.getMainAttributes();
+ String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ if (symbolicName == null)
+ throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
+
+ String version = attribs.getValue(Constants.BUNDLE_VERSION);
+ return new DeploymentImpl(url, symbolicName, version);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceCapability.java (from rev 95093, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceCapability.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceCapability.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.deployer;
+
+//$Id$
+
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+
+/**
+ * Adds the DeploymentService capability to the {@link OSGiRuntime}
+ * under test.
+ *
+ * It is ignored if the {@link DeployerService} is already registered.
+ *
+ * Installed bundles: jboss-osgi-deployment.jar
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 16-Oct-2009
+ */
+public class DeployerServiceCapability extends Capability
+{
+ public DeployerServiceCapability()
+ {
+ super(DeployerService.class.getName());
+
+ addBundle("bundles/jboss-osgi-deployment.jar");
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.deployer;
+
+//$Id: DeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
+
+import java.net.URL;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.osgi.framework.Version;
+
+/**
+ * A Service to register/unregister bundle deployments.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2009
+ */
+public interface DeploymentRegistryService
+{
+ /**
+ * Create a bundle deployment from the given bundle URL
+ * @return null, if this service does not maintain the bundle deployment
+ */
+ Deployment getBundleDeployment(URL url);
+
+ /**
+ * Get the bundle deployment for the given bundle symbolicName and version
+ * @return null, if this service does not maintain the bundle deployment
+ */
+ Deployment getBundleDeployment(String symbolicName, Version version);
+
+ /**
+ * Register a bundle deployment
+ */
+ void registerBundleDeployment(Deployment dep);
+
+ /**
+ * Unregister a bundle deployment
+ */
+ void unregisterBundleDeployment(Deployment dep);
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.interceptor;
+
+import org.jboss.osgi.deployment.common.Deployment;
+
+//$Id$
+
+
+/**
+ * An OSGi deployer
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public interface DeploymentInterceptor
+{
+ enum Phase {
+ BEFORE_INSTALLED,
+ AFTER_INSTALLED,
+ BEFORE_RESOLVED,
+ AFTER_RESOLVED,
+ BEFORE_ACTIVE,
+ AFTER_ACTIVE
+ }
+
+ void deploy(Deployment dep);
+
+ void undeploy(Deployment dep);
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.interceptor;
+
+
+//$Id$
+
+
+/**
+ * The deployers service
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public interface DeploymentInterceptorService
+{
+ void addInterceptor(DeploymentInterceptor deployer);
+
+ void removeInterceptor(DeploymentInterceptor deployer);
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -24,8 +24,8 @@
import java.io.Serializable;
import java.net.URL;
-import org.jboss.osgi.deployment.DeploymentBase;
-import org.jboss.osgi.deployment.Deployment;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.common.DeploymentBase;
//$Id$
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -27,9 +27,9 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeployerService;
-import org.jboss.osgi.deployment.DeploymentRegistryService;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -29,10 +29,10 @@
import javax.management.MBeanServer;
import javax.management.StandardMBean;
-import org.jboss.osgi.deployment.DeployerService;
-import org.jboss.osgi.deployment.DeploymentInterceptor;
-import org.jboss.osgi.deployment.DeploymentInterceptorService;
-import org.jboss.osgi.deployment.DeploymentRegistryService;
+import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
+import org.jboss.osgi.deployment.interceptor.DeploymentInterceptor;
+import org.jboss.osgi.deployment.interceptor.DeploymentInterceptorService;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -30,10 +30,10 @@
import java.util.Map;
import java.util.Map.Entry;
-import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeployerService;
-import org.jboss.osgi.deployment.DeployerServiceBase;
-import org.jboss.osgi.deployment.DeploymentRegistryService;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.deployer.DeployerServiceBase;
+import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
import org.jboss.osgi.spi.logging.ExportedPackageHelper;
import org.jboss.osgi.spi.management.ManagedBundleService;
import org.osgi.framework.Bundle;
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/scanner/DeploymentScannerService.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/scanner/DeploymentScannerService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/scanner/DeploymentScannerService.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.scanner;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.osgi.deployment.common.Deployment;
+
+
+/**
+ * A service that scans a directory location for new/removed bundles.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public interface DeploymentScannerService
+{
+ /**
+ * The property that names the scan location: org.jboss.osgi.hotdeploy.scandir
+ */
+ String PROPERTY_SCAN_LOCATION = "org.jboss.osgi.hotdeploy.scandir";
+
+ /**
+ * The property to defines the scan interval: org.jboss.osgi.hotdeploy.interval
+ */
+ String PROPERTY_SCAN_INTERVAL = "org.jboss.osgi.hotdeploy.interval";
+
+ /**
+ * Get the scan location URL.
+ *
+ * This is can be specified by setting the {@link #PROPERTY_SCAN_LOCATION} property.
+ */
+ URL getScanLocation();
+
+ /**
+ * The number of scans since the service started
+ */
+ long getScanCount();
+
+ /**
+ * The number of milliseconds between scans
+ * Defaults to 2000ms
+ */
+ long getScanInterval();
+
+ /**
+ * The timestamp of the last change
+ */
+ long getLastChange();
+
+ /**
+ * Run a directory scan
+ */
+ void scan();
+
+ /**
+ * Returns the array of bundles currently known to the deployemtn scanner.
+ */
+ Deployment[] getBundleDeployments();
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-19 07:51:36 UTC (rev 95095)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-19 08:13:35 UTC (rev 95096)
@@ -23,7 +23,7 @@
//$Id$
-import static org.jboss.osgi.deployment.DeployerService.MBEAN_DEPLOYER_SERVICE;
+import static org.jboss.osgi.deployment.deployer.DeployerService.MBEAN_DEPLOYER_SERVICE;
import static org.jboss.osgi.spi.management.ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK;
import static org.jboss.osgi.spi.management.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
import static org.jboss.test.osgi.service.microcontainer.bundleB.SomeBeanMBean.MBEAN_NAME;
@@ -36,7 +36,7 @@
import javax.management.ObjectName;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jndi.JNDICapability;
16 years, 2 months
JBoss-OSGI SVN: r95093 - in projects/jboss-osgi: projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration and 7 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-19 03:29:26 -0400 (Mon, 19 Oct 2009)
New Revision: 95093
Added:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java
Removed:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java
Modified:
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
projects/jboss-osgi/trunk/reactor/deployment/pom.xml
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Remove DeployerServiceDelegate
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -36,7 +36,7 @@
import org.jboss.osgi.deployment.Deployment;
import org.jboss.osgi.deployment.DeploymentScannerService;
-import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeployerService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -62,7 +62,7 @@
private long beforeStart;
private long lastChange;
- private DeploymentService deployer;
+ private DeployerService deployer;
private ScannerThread scannerThread;
private List<Deployment> lastScan = new ArrayList<Deployment>();
private Map<String, Deployment> deploymentCache = new HashMap<String, Deployment>();
@@ -72,8 +72,8 @@
this.context = context;
// Get the DeployerService
- ServiceReference sref = context.getServiceReference(DeploymentService.class.getName());
- deployer = (DeploymentService)context.getService(sref);
+ ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+ deployer = (DeployerService)context.getService(sref);
initScanner(context);
}
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -48,7 +48,7 @@
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeploymentServiceBase;
+import org.jboss.osgi.deployment.DeployerServiceBase;
import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
@@ -65,7 +65,7 @@
* @author thomas.diesler(a)jboss.com
* @since 23-Jan-2009
*/
-public abstract class AbstractMicrocontainerService extends DeploymentServiceBase implements MicrocontainerService
+public abstract class AbstractMicrocontainerService extends DeployerServiceBase implements MicrocontainerService
{
private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
private ServiceTracker registryTracker;
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -35,13 +35,14 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeployerService;
import org.jboss.osgi.jbossxb.XMLBindingService;
import org.jboss.osgi.microcontainer.integration.AbstractMicrocontainerService;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.jboss.virtual.VFS;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
@@ -49,7 +50,7 @@
import org.osgi.util.tracker.ServiceTracker;
/**
- * An implementation of the {@link DeploymentService} and {@link MicrocontainerService}
+ * An implementation of the {@link DeployerService} and {@link MicrocontainerService}
* which is installed as a bundle
*
* @author thomas.diesler(a)jboss.com
@@ -147,8 +148,9 @@
// Register the DeployerService
Properties props = new Properties();
props.setProperty("provider", "microcontainer");
+ props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
log.log(LogService.LOG_DEBUG, "Register DeployerService");
- context.registerService(DeploymentService.class.getName(), mcServiceImpl, props);
+ context.registerService(DeployerService.class.getName(), mcServiceImpl, props);
// Register the MicrocontainerServiceMBean
registerMicrocontainerServiceMBean(mbeanServer);
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -26,7 +26,7 @@
import java.net.URL;
import org.jboss.logging.Logger;
-import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeployerService;
import org.jboss.osgi.spi.framework.BundleContextWrapper;
import org.jboss.osgi.spi.util.BundleInfo;
import org.osgi.framework.Bundle;
@@ -63,10 +63,10 @@
Bundle bundle;
- ServiceReference sref = context.getServiceReference(DeploymentService.class.getName());
+ ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
if (sref != null)
{
- DeploymentService service = (DeploymentService)context.getService(sref);
+ DeployerService service = (DeployerService)context.getService(sref);
service.deploy(bundleURL);
bundle = getBundle(symbolicName, version, true);
}
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -31,13 +31,14 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.logging.Logger;
-import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeployerService;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
/**
- * An implementation of the {@link DeploymentService} and {@link MicrocontainerService}
+ * An implementation of the {@link DeployerService} and {@link MicrocontainerService}
* which is installed as MC bean in jbossas.
*
* @author thomas.diesler(a)jboss.com
@@ -102,7 +103,8 @@
// Register the DeployerService
Properties props = new Properties();
props.setProperty("provider", "microcontainer");
- bundleContext.registerService(DeploymentService.class.getName(), this, props);
+ props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ bundleContext.registerService(DeployerService.class.getName(), this, props);
log.debug("DeployerService registered");
// Register the MicrocontainerServiceMBean
Modified: projects/jboss-osgi/trunk/reactor/deployment/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-19 07:29:26 UTC (rev 95093)
@@ -67,7 +67,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.deployment.internal.DeployersActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.deployment.internal.DeploymentServicesActivator</Bundle-Activator>
<Export-Package>
org.jboss.osgi.deployment;version=1.0,
</Export-Package>
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+import java.net.URL;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleException;
+
+/**
+ * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public interface DeployerService
+{
+ /**
+ * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
+ */
+ ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
+
+ /**
+ * Create a deployment from the given location.
+ */
+ Deployment createDeployment(String location) throws BundleException;
+
+ /**
+ * Deploy an array of bundles
+ */
+ void deploy(Deployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Undeploy an array of bundles
+ */
+ void undeploy(Deployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Deploy bundle from URL
+ */
+ void deploy(URL url) throws BundleException;
+
+ /**
+ * Undeploy bundle from URL.
+ *
+ * Note, due to the dynamic nature of OSGi services it is
+ * possible that a {@link DeployerService} is asked to undeploy
+ * a bundle URL which it did not deploy itself.
+ *
+ * In this case this method should return false, so that
+ * another {@link DeployerService} can be tried.
+ *
+ * @return true if this service could undeploy the bundle
+ */
+ boolean undeploy(URL url) throws BundleException;
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerServiceBase.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.osgi.deployment.internal.DeploymentImpl;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+//$Id$
+
+/**
+ * An abstract base implementation of the DeployerService.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 16-Oct-2009
+ */
+public abstract class DeployerServiceBase implements DeployerService
+{
+ public Deployment createDeployment(String location) throws BundleException
+ {
+ // Try location as URL
+ URL url = null;
+ try
+ {
+ url = new URL(location);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try location as File
+ if (url == null)
+ {
+ try
+ {
+ File file = new File(location);
+ if (file.exists())
+ url = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ if (url == null)
+ throw new IllegalArgumentException("Invalid bundle location: " + location);
+
+ return createDeploymentInternal(url);
+ }
+
+ private Deployment createDeploymentInternal(URL url) throws BundleException
+ {
+ Manifest manifest;
+ try
+ {
+ JarFile jarFile = new JarFile(url.getPath());
+ manifest = jarFile.getManifest();
+ jarFile.close();
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot get manifest from: " + url);
+
+ }
+
+ Attributes attribs = manifest.getMainAttributes();
+ String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ if (symbolicName == null)
+ throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
+
+ String version = attribs.getValue(Constants.BUNDLE_VERSION);
+ return new DeploymentImpl(url, symbolicName, version);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -14,7 +14,7 @@
* 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
+ * 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.
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import java.net.URL;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.BundleException;
-
-/**
- * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public interface DeploymentService
-{
- /**
- * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
- */
- ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
-
- /**
- * Create a deployment from the given location.
- */
- Deployment createDeployment(String location) throws BundleException;
-
- /**
- * Deploy an array of bundles
- */
- void deploy(Deployment[] bundleDeps) throws BundleException;
-
- /**
- * Undeploy an array of bundles
- */
- void undeploy(Deployment[] bundleDeps) throws BundleException;
-
- /**
- * Deploy bundle from URL
- */
- void deploy(URL url) throws BundleException;
-
- /**
- * Undeploy bundle from URL.
- *
- * Note, due to the dynamic nature of OSGi services it is
- * possible that a {@link DeploymentService} is asked to undeploy
- * a bundle URL which it did not deploy itself.
- *
- * In this case this method should return false, so that
- * another {@link DeploymentService} can be tried.
- *
- * @return true if this service could undeploy the bundle
- */
- boolean undeploy(URL url) throws BundleException;
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.jboss.osgi.deployment.internal.DeploymentImpl;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-//$Id$
-
-/**
- * An abstract base implementation of the DeployerService.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 16-Oct-2009
- */
-public abstract class DeploymentServiceBase implements DeploymentService
-{
- public Deployment createDeployment(String location) throws BundleException
- {
- // Try location as URL
- URL url = null;
- try
- {
- url = new URL(location);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try location as File
- if (url == null)
- {
- try
- {
- File file = new File(location);
- if (file.exists())
- url = file.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- if (url == null)
- throw new IllegalArgumentException("Invalid bundle location: " + location);
-
- return createDeploymentInternal(url);
- }
-
- private Deployment createDeploymentInternal(URL url) throws BundleException
- {
- Manifest manifest;
- try
- {
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
- }
- catch (IOException ex)
- {
- throw new BundleException("Cannot get manifest from: " + url);
-
- }
-
- Attributes attribs = manifest.getMainAttributes();
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
-
- String version = attribs.getValue(Constants.BUNDLE_VERSION);
- return new DeploymentImpl(url, symbolicName, version);
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -30,7 +30,7 @@
* Adds the DeploymentService capability to the {@link OSGiRuntime}
* under test.
*
- * It is ignored if the {@link DeploymentService} is already registered.
+ * It is ignored if the {@link DeployerService} is already registered.
*
* Installed bundles: jboss-osgi-deployment.jar
*
@@ -41,7 +41,7 @@
{
public DeploymentServiceCapability()
{
- super(DeploymentService.class.getName());
+ super(DeployerService.class.getName());
addBundle("bundles/jboss-osgi-deployment.jar");
}
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -1,143 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment.internal;
-
-//$Id$
-
-import java.net.URL;
-
-import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeploymentService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-/**
- * A {@link DeploymentService} that delegates to the service that is tracked by the given {@link DeployerServiceTracker}
- *
- * This delegate is registered as an MBean
- *
- * @author thomas.diesler(a)jboss.com
- * @since 27-May-2009
- */
-public class DeployerServiceDelegate implements DeploymentService
-{
- private BundleContext context;
-
- public DeployerServiceDelegate(BundleContext context)
- {
- this.context = context;
- }
-
- public Deployment createDeployment(String location) throws BundleException
- {
- DeploymentService service = getDefaultDeployerService();
- return service.createDeployment(location);
- }
-
- public void deploy(Deployment[] bundles) throws BundleException
- {
- DeploymentService service = getDefaultDeployerService();
- service.deploy(bundles);
- }
-
- public void deploy(URL url) throws BundleException
- {
- DeploymentService service = getDefaultDeployerService();
- service.deploy(url);
- }
-
- public void undeploy(Deployment[] bundles) throws BundleException
- {
- for (Deployment info : bundles)
- undeploy(info.getLocation());
- }
-
- public boolean undeploy(URL url) throws BundleException
- {
- boolean undeployed = false;
-
- DeploymentService service = getMicrocontainerDeployerService();
- if (service != null)
- undeployed = service.undeploy(url);
-
- if (undeployed == false)
- {
- service = getSystemDeployerService();
- undeployed = service.undeploy(url);
- }
-
- return undeployed;
- }
-
- private DeploymentService getDefaultDeployerService()
- {
- // First try the MC provider
- DeploymentService service = getMicrocontainerDeployerService();
-
- // Fall back to the system provider
- if (service == null)
- service = getSystemDeployerService();
-
- return service;
- }
-
- private DeploymentService getMicrocontainerDeployerService()
- {
- DeploymentService service = null;
- try
- {
- String filter = "(provider=microcontainer)";
- String serviceName = DeploymentService.class.getName();
- ServiceReference[] srefs = context.getServiceReferences(serviceName, filter);
- if (srefs != null)
- service = (DeploymentService)context.getService(srefs[0]);
- }
- catch (InvalidSyntaxException ex)
- {
- throw new IllegalArgumentException(ex);
- }
- return service;
- }
-
- private DeploymentService getSystemDeployerService()
- {
- DeploymentService service = null;
- try
- {
- String filter = "(provider=system)";
- String serviceName = DeploymentService.class.getName();
- ServiceReference[] srefs = context.getServiceReferences(serviceName, filter);
- if (srefs != null)
- service = (DeploymentService)context.getService(srefs[0]);
- }
- catch (InvalidSyntaxException ex)
- {
- throw new IllegalArgumentException(ex);
- }
-
- if (service == null)
- throw new IllegalStateException("Cannot obtain system DeployerService");
- return service;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment.internal;
-
-//$Id$
-
-import java.util.Properties;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.StandardMBean;
-
-import org.jboss.osgi.deployment.DeploymentService;
-import org.jboss.osgi.deployment.DeploymentInterceptor;
-import org.jboss.osgi.deployment.DeploymentInterceptorService;
-import org.jboss.osgi.deployment.DeploymentRegistryService;
-import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The deployers activator
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public class DeployersActivator implements BundleActivator
-{
- // Provide logging
- private Logger log = LoggerFactory.getLogger(DeployersActivator.class);
-
- public void start(BundleContext context) throws Exception
- {
- // Register the system SystemDeployerService and DeployerServiceDelegate
- DeploymentService deployer = registerDeployerServices(context);
-
- // Track the MBeanServer and register the DeployerServiceDelegate
- trackMBeanServer(context, deployer);
-
- DeploymentInterceptorService service = new DeploymentInterceptorService()
- {
- public void removeInterceptor(DeploymentInterceptor deployer)
- {
- throw new NotImplementedException();
- }
-
- public void addInterceptor(DeploymentInterceptor deployer)
- {
- throw new NotImplementedException();
- }
- };
- context.registerService(DeploymentInterceptorService.class.getName(), service, null);
- }
-
- public void stop(BundleContext context) throws Exception
- {
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- if (sref != null)
- {
- MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
- unregisterDeployerServiceMBean(mbeanServer);
- }
- }
-
- protected DeploymentService registerDeployerServices(BundleContext context)
- {
- // Register the DeploymentRegistryService
- DeploymentRegistryService registry = new DeploymentRegistryServiceImpl(context);
- context.registerService(DeploymentRegistryService.class.getName(), registry, null);
-
- // Register the SystemDeployerService
- Properties props = new Properties();
- props.put("provider", "system");
- SystemDeployerService systemDeployer = new SystemDeployerService(context);
- context.registerService(DeploymentService.class.getName(), systemDeployer, props);
-
- // Register the DeployerServiceDelegate
- props = new Properties();
- props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
- DeploymentService deployerDelegate = new DeployerServiceDelegate(context);
- context.registerService(DeploymentService.class.getName(), deployerDelegate, props);
- return deployerDelegate;
- }
-
- private void trackMBeanServer(BundleContext context, final DeploymentService deployer)
- {
- ServiceTracker jmxTracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
- {
- @Override
- public Object addingService(ServiceReference reference)
- {
- MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
- registerDeployerServiceMBean(mbeanServer, deployer);
- return mbeanServer;
- }
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- MBeanServer mbeanServer = (MBeanServer)service;
- unregisterDeployerServiceMBean(mbeanServer);
- super.removedService(reference, service);
- }
- };
- jmxTracker.open();
- }
-
- private void registerDeployerServiceMBean(MBeanServer mbeanServer, DeploymentService delegate)
- {
- try
- {
- StandardMBean mbean = new StandardMBean(delegate, DeploymentService.class);
- mbeanServer.registerMBean(mbean, DeploymentService.MBEAN_DEPLOYER_SERVICE);
- }
- catch (JMException ex)
- {
- throw new IllegalStateException("Cannot register DeployerService MBean", ex);
- }
- }
-
- private void unregisterDeployerServiceMBean(MBeanServer mbeanServer)
- {
- try
- {
- if (mbeanServer.isRegistered(DeploymentService.MBEAN_DEPLOYER_SERVICE))
- mbeanServer.unregisterMBean(DeploymentService.MBEAN_DEPLOYER_SERVICE);
- }
- catch (JMException ex)
- {
- log.error("Cannot unregister DeployerService MBean", ex);
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -28,13 +28,13 @@
import java.util.Set;
import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeployerService;
import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
/**
- * A {@link DeploymentService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
*
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java (from rev 95091, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.internal;
+
+//$Id$
+
+import java.util.Properties;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.StandardMBean;
+
+import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.DeploymentInterceptor;
+import org.jboss.osgi.deployment.DeploymentInterceptorService;
+import org.jboss.osgi.deployment.DeploymentRegistryService;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The deployers activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public class DeploymentServicesActivator implements BundleActivator
+{
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(DeploymentServicesActivator.class);
+
+ public void start(BundleContext context) throws Exception
+ {
+ // Register the deployer related services
+ registerDeployerService(context);
+
+ DeploymentInterceptorService service = new DeploymentInterceptorService()
+ {
+ public void removeInterceptor(DeploymentInterceptor deployer)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void addInterceptor(DeploymentInterceptor deployer)
+ {
+ throw new NotImplementedException();
+ }
+ };
+ context.registerService(DeploymentInterceptorService.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ }
+
+ protected void registerDeployerService(BundleContext context)
+ {
+ // Register the DeploymentRegistryService
+ DeploymentRegistryService registry = new DeploymentRegistryServiceImpl(context);
+ context.registerService(DeploymentRegistryService.class.getName(), registry, null);
+
+ // Register the SystemDeployerService
+ Properties props = new Properties();
+ props.put("provider", "system");
+ SystemDeployerService deployerService = new SystemDeployerService(context);
+ context.registerService(DeployerService.class.getName(), deployerService, props);
+
+ // Track the MBeanServer and register the DeployerService
+ ServiceTracker jmxTracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
+ registerDeployerServiceMBean(context, mbeanServer);
+ return mbeanServer;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ MBeanServer mbeanServer = (MBeanServer)service;
+ unregisterDeployerServiceMBean(mbeanServer);
+ super.removedService(reference, service);
+ }
+ };
+ jmxTracker.open();
+
+ // Track the DeployerService and register it as an MBean
+ ServiceTracker serviceTracker = new ServiceTracker(context, DeployerService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ DeployerService service = (DeployerService)super.addingService(reference);
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ if (sref != null)
+ {
+ MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+ registerDeployerServiceMBean(context, mbeanServer);
+ }
+ return service;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ if (sref != null)
+ {
+ MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+ unregisterDeployerServiceMBean(mbeanServer);
+ }
+ super.removedService(reference, service);
+ }
+ };
+ serviceTracker.open();
+ }
+
+ private void registerDeployerServiceMBean(BundleContext context, MBeanServer mbeanServer)
+ {
+ try
+ {
+ // Get the DeployerService with the highest ranking
+ ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("Cannot obtain deployer service");
+
+ // Unregister the DeployerService with a potentialy lower ranking
+ if (mbeanServer.isRegistered(DeployerService.MBEAN_DEPLOYER_SERVICE))
+ mbeanServer.unregisterMBean(DeployerService.MBEAN_DEPLOYER_SERVICE);
+
+ // Register the DeployerService with the highest ranking
+ DeployerService service = (DeployerService)context.getService(sref);
+ StandardMBean mbean = new StandardMBean(service, DeployerService.class);
+ mbeanServer.registerMBean(mbean, DeployerService.MBEAN_DEPLOYER_SERVICE);
+ }
+ catch (JMException ex)
+ {
+ throw new IllegalStateException("Cannot register DeployerService MBean", ex);
+ }
+ }
+
+ private void unregisterDeployerServiceMBean(MBeanServer mbeanServer)
+ {
+ try
+ {
+ if (mbeanServer.isRegistered(DeployerService.MBEAN_DEPLOYER_SERVICE))
+ mbeanServer.unregisterMBean(DeployerService.MBEAN_DEPLOYER_SERVICE);
+ }
+ catch (JMException ex)
+ {
+ log.error("Cannot unregister DeployerService MBean", ex);
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -31,8 +31,8 @@
import java.util.Map.Entry;
import org.jboss.osgi.deployment.Deployment;
-import org.jboss.osgi.deployment.DeploymentService;
-import org.jboss.osgi.deployment.DeploymentServiceBase;
+import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.DeployerServiceBase;
import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.jboss.osgi.spi.logging.ExportedPackageHelper;
import org.jboss.osgi.spi.management.ManagedBundleService;
@@ -48,12 +48,12 @@
import org.slf4j.LoggerFactory;
/**
- * A {@link DeploymentService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
*
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
*/
-public class SystemDeployerService extends DeploymentServiceBase
+public class SystemDeployerService extends DeployerServiceBase
{
// Provide logging
private Logger log = LoggerFactory.getLogger(SystemDeployerService.class);
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-19 07:22:47 UTC (rev 95092)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-19 07:29:26 UTC (rev 95093)
@@ -23,7 +23,7 @@
//$Id$
-import static org.jboss.osgi.deployment.DeploymentService.MBEAN_DEPLOYER_SERVICE;
+import static org.jboss.osgi.deployment.DeployerService.MBEAN_DEPLOYER_SERVICE;
import static org.jboss.osgi.spi.management.ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK;
import static org.jboss.osgi.spi.management.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
import static org.jboss.test.osgi.service.microcontainer.bundleB.SomeBeanMBean.MBEAN_NAME;
@@ -36,7 +36,7 @@
import javax.management.ObjectName;
-import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeployerService;
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jndi.JNDICapability;
@@ -92,12 +92,12 @@
}
/**
- * Test whether a bundle can be deployed through the {@link DeploymentService}
+ * Test whether a bundle can be deployed through the {@link DeployerService}
*/
@Test
public void testBundleDeployment() throws Exception
{
- DeploymentService deployer = MBeanProxy.get(DeploymentService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
+ DeployerService deployer = MBeanProxy.get(DeployerService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
deployer.deploy(getTestArchiveURL("service/mcservice-bundleA.jar"));
ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
@@ -108,13 +108,13 @@
}
/**
- * Test whether a bundle that contains beans can be deployed through the {@link DeploymentService}
+ * Test whether a bundle that contains beans can be deployed through the {@link DeployerService}
*/
@Test
public void testBeansDeployment() throws Exception
{
MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
- DeploymentService deployer = MBeanProxy.get(DeploymentService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
+ DeployerService deployer = MBeanProxy.get(DeployerService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
deployer.deploy(getTestArchiveURL("service/mcservice-bundleB.jar"));
16 years, 2 months
JBoss-OSGI SVN: r95042 - in projects/jboss-osgi: trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-16 10:58:09 -0400 (Fri, 16 Oct 2009)
New Revision: 95042
Added:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java
Log:
Add support for deployment attachments
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-16 14:50:10 UTC (rev 95041)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-16 14:58:09 UTC (rev 95042)
@@ -126,7 +126,8 @@
try
{
MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
- mainDeployer.removeDeployment((String)dep.getMetadata());
+ VFSDeployment vfsdep = dep.getAttachment(VFSDeployment.class);
+ mainDeployer.removeDeployment(vfsdep.getName());
mainDeployer.process();
return true;
}
@@ -151,16 +152,16 @@
for (Deployment dep : depArr)
{
VirtualFile file = VFS.createNewRoot(dep.getLocation());
- VFSDeployment deployment = deploymentFactory.createVFSDeployment(file);
- dep.setMetadata(deployment.getName());
+ VFSDeployment vfsdep = deploymentFactory.createVFSDeployment(file);
+ dep.addAttachment(VFSDeployment.class, vfsdep);
registry.registerBundleDeployment(dep);
- depList.add(deployment);
+ depList.add(vfsdep);
- MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
+ MutableAttachments att = (MutableAttachments)vfsdep.getPredeterminedManagedObjects();
att.addAttachment(OSGiConstants.PROPERTY_START_LEVEL, new Integer(dep.getStartLevel()));
att.addAttachment(OSGiConstants.PROPERTY_AUTO_START, new Boolean(dep.isAutoStart()));
- mainDeployer.addDeployment(deployment);
+ mainDeployer.addDeployment(vfsdep);
}
// Process the deployments
@@ -194,7 +195,8 @@
for (Deployment dep : depArr)
{
registry.unregisterBundleDeployment(dep);
- mainDeployer.removeDeployment((String)dep.getMetadata());
+ VFSDeployment vfsdep = dep.getAttachment(VFSDeployment.class);
+ mainDeployer.removeDeployment(vfsdep.getName());
}
mainDeployer.process();
}
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java 2009-10-16 14:58:09 UTC (rev 95042)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+// $Id$
+
+import java.util.Collection;
+
+/**
+ * An interface for general Attachments
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public interface Attachments
+{
+ /** Get attachment keys */
+ Collection<Key> getAttachmentKeys();
+
+ /** Add arbitrary attachment */
+ <T> T addAttachment(Class<T> clazz, Object value);
+
+ /** Add arbitrary attachment with name */
+ <T> T addAttachment(Class<T> clazz, String name, Object value);
+
+ /** Add arbitrary attachment with name */
+ Object addAttachment(String name, Object value);
+
+ /** Get an arbitrary attachment */
+ <T> T getAttachment(Class<T> clazz);
+
+ /** Get an arbitrary attachment */
+ <T> T getAttachment(Class<T> clazz, String name);
+
+ /** Get an arbitrary attachment */
+ Object getAttachment(String name);
+
+ /** Remove arbitrary attachments */
+ <T> T removeAttachment(Class<T> clazz);
+
+ /** Remove arbitrary attachments */
+ <T> T removeAttachment(Class<T> clazz, String name);
+
+ /** Remove arbitrary attachments */
+ Object removeAttachment(String name);
+
+ /**
+ * A key for attachements
+ */
+ public static class Key
+ {
+ private Class<?> clazz;
+ private String name;
+
+ /**
+ * Construct the key with optional class and name
+ */
+ public Key(Class<?> clazz, String name)
+ {
+ this.clazz = clazz;
+ this.name = name;
+ }
+
+ public static Key valueOf(String key)
+ {
+ int index = key.indexOf(",");
+ if (key.startsWith("[") && key.endsWith("]") && index > 0)
+ {
+ Class<?> classPart = null;
+ String className = key.substring(1, index);
+ String namePart = key.substring(index + 1, key.length() - 1);
+ if (className.length() > 0 && !className.equals("null"))
+ {
+ try
+ {
+ classPart = Class.forName(className);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalArgumentException("Cannot find class '" + className + "' in: " + key);
+ }
+ }
+ return new Key(classPart, namePart);
+ }
+ return null;
+ }
+
+ /**
+ * Get the class part for this key
+ *
+ * @return maybe null
+ */
+ public Class<?> getClassPart()
+ {
+ return clazz;
+ }
+
+ /**
+ * Get the name part for this key
+ *
+ * @return maybe null
+ */
+ public String getNamePart()
+ {
+ return name;
+ }
+
+ /**
+ * Two keys are equal if their {@link #toString()} is equal
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof Key))
+ return false;
+ if (obj == this)
+ return true;
+ return obj.toString().equals(toString());
+ }
+
+ /**
+ * Two keys have the same hashCode if their {@link #toString()} is equal
+ */
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ /**
+ * Returns the String repesentation of this Key.
+ * <p/>
+ *
+ * <pre>
+ * "[" + clazz + "," + name + "]"
+ * </pre>
+ */
+ public String toString()
+ {
+ return "[" + clazz + "," + name + "]";
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Attachments.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-16 14:50:10 UTC (rev 95041)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-16 14:58:09 UTC (rev 95042)
@@ -21,7 +21,6 @@
*/
package org.jboss.osgi.deployment;
-import java.io.Serializable;
import java.net.URL;
//$Id$
@@ -32,123 +31,40 @@
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
*/
-public class Deployment implements Serializable
+public interface Deployment extends Attachments
{
- private static final long serialVersionUID = 1L;
-
- private URL location;
- private String symbolicName;
- private String version;
- private int startLevel;
- private boolean autoStart;
- private Object metadata;
-
- public Deployment(URL location, String symbolicName, String version)
- {
- if (location == null)
- throw new IllegalArgumentException("Location cannot be null");
- if (symbolicName == null)
- throw new IllegalArgumentException("Symbolic name cannot be null");
-
- if (version == null)
- version = "0.0.0";
-
- this.symbolicName = symbolicName;
- this.location = location;
- this.version = version;
- }
-
/**
* Get the bundle location
*/
- public URL getLocation()
- {
- return location;
- }
+ public URL getLocation();
/**
* Get the bundle symbolic name
*/
- public String getSymbolicName()
- {
- return symbolicName;
- }
+ public String getSymbolicName();
/**
* Get the bundle version
*/
- public String getVersion()
- {
- return version;
- }
+ public String getVersion();
/**
* Get the start level associated with this deployment
*/
- public int getStartLevel()
- {
- return startLevel;
- }
+ public int getStartLevel();
/**
* Set the start level associated with this deployment
*/
- public void setStartLevel(int startLevel)
- {
- this.startLevel = startLevel;
- }
+ public void setStartLevel(int startLevel);
/**
* Get the autostart flag associated with this deployment
*/
- public boolean isAutoStart()
- {
- return autoStart;
- }
+ public boolean isAutoStart();
/**
* Set the autostart flag associated with this deployment
*/
- public void setAutoStart(boolean autoStart)
- {
- this.autoStart = autoStart;
- }
-
- /**
- * Get extra meta data associated with this deployment
- */
- public Object getMetadata()
- {
- return metadata;
- }
-
- /**
- * Set extra meta data associated with this deployment
- */
- public void setMetadata(Object metadata)
- {
- this.metadata = metadata;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (!(obj instanceof Deployment))
- return false;
-
- Deployment other = (Deployment)obj;
- return symbolicName.equals(other.symbolicName) && version.equals(other.version);
- }
-
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- @Override
- public String toString()
- {
- return "[" + symbolicName + "-" + version + ",url=" + location + "]";
- }
+ public void setAutoStart(boolean autoStart);
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java 2009-10-16 14:58:09 UTC (rev 95042)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+// $Id$
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Basic attachments.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public abstract class DeploymentBase implements Attachments
+{
+ private Map<Key, Object> attachments = new HashMap<Key, Object>();
+
+ /** Construct the execution context with no attachments */
+ public DeploymentBase()
+ {
+
+ }
+
+ /** Construct the execution context with given attachments */
+ public DeploymentBase(Attachments att)
+ {
+ if (att != null)
+ {
+ for (Key key : att.getAttachmentKeys())
+ {
+ Object value = att.getAttachment(key.getClassPart(), key.getNamePart());
+ this.attachments.put(key, value);
+ }
+ }
+ }
+
+ public Collection<Key> getAttachmentKeys()
+ {
+ return attachments.keySet();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getAttachment(Class<T> clazz)
+ {
+ return (T)attachments.get(new Key(clazz, null));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getAttachment(Class<T> clazz, String name)
+ {
+ return (T)attachments.get(new Key(clazz, name));
+ }
+
+ public Object getAttachment(String name)
+ {
+ return attachments.get(new Key(null, name));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T addAttachment(Class<T> clazz, Object obj)
+ {
+ return (T)attachments.put(new Key(clazz, null), obj);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T addAttachment(Class<T> clazz, String name, Object obj)
+ {
+ return (T)attachments.put(new Key(clazz, name), obj);
+ }
+
+ public Object addAttachment(String name, Object obj)
+ {
+ return attachments.put(new Key(null, name), obj);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T removeAttachment(Class<T> clazz)
+ {
+ return (T)attachments.remove(new Key(clazz, null));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T removeAttachment(Class<T> clazz, String name)
+ {
+ return (T)attachments.remove(new Key(clazz, name));
+ }
+
+ public Object removeAttachment(String name)
+ {
+ return attachments.remove(new Key(null, name));
+ }
+
+ public String toString()
+ {
+ return attachments.toString();
+ }
+}
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentBase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java 2009-10-16 14:50:10 UTC (rev 95041)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java 2009-10-16 14:58:09 UTC (rev 95042)
@@ -29,6 +29,7 @@
import java.util.jar.JarFile;
import java.util.jar.Manifest;
+import org.jboss.osgi.deployment.internal.DeploymentImpl;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -97,6 +98,6 @@
throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
String version = attribs.getValue(Constants.BUNDLE_VERSION);
- return new Deployment(url, symbolicName, version);
+ return new DeploymentImpl(url, symbolicName, version);
}
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-16 14:58:09 UTC (rev 95042)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.internal;
+
+import java.io.Serializable;
+import java.net.URL;
+
+import org.jboss.osgi.deployment.DeploymentBase;
+import org.jboss.osgi.deployment.Deployment;
+
+//$Id$
+
+/**
+ * An abstraction of a bundle deployment
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class DeploymentImpl extends DeploymentBase implements Deployment, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private URL location;
+ private String symbolicName;
+ private String version;
+ private int startLevel;
+ private boolean autoStart;
+ private Object metadata;
+
+ public DeploymentImpl(URL location, String symbolicName, String version)
+ {
+ if (location == null)
+ throw new IllegalArgumentException("Location cannot be null");
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Symbolic name cannot be null");
+
+ if (version == null)
+ version = "0.0.0";
+
+ this.symbolicName = symbolicName;
+ this.location = location;
+ this.version = version;
+ }
+
+ /**
+ * Get the bundle location
+ */
+ public URL getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * Get the bundle symbolic name
+ */
+ public String getSymbolicName()
+ {
+ return symbolicName;
+ }
+
+ /**
+ * Get the bundle version
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * Get the start level associated with this deployment
+ */
+ public int getStartLevel()
+ {
+ return startLevel;
+ }
+
+ /**
+ * Set the start level associated with this deployment
+ */
+ public void setStartLevel(int startLevel)
+ {
+ this.startLevel = startLevel;
+ }
+
+ /**
+ * Get the autostart flag associated with this deployment
+ */
+ public boolean isAutoStart()
+ {
+ return autoStart;
+ }
+
+ /**
+ * Set the autostart flag associated with this deployment
+ */
+ public void setAutoStart(boolean autoStart)
+ {
+ this.autoStart = autoStart;
+ }
+
+ /**
+ * Get extra meta data associated with this deployment
+ */
+ public Object getMetadata()
+ {
+ return metadata;
+ }
+
+ /**
+ * Set extra meta data associated with this deployment
+ */
+ public void setMetadata(Object metadata)
+ {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof DeploymentImpl))
+ return false;
+
+ DeploymentImpl other = (DeploymentImpl)obj;
+ return symbolicName.equals(other.symbolicName) && version.equals(other.version);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + symbolicName + "-" + version + ",url=" + location + "]";
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
16 years, 2 months
JBoss-OSGI SVN: r95039 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-16 10:15:48 -0400 (Fri, 16 Oct 2009)
New Revision: 95039
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
Log:
Fix location passed to installBundle
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-10-16 14:04:09 UTC (rev 95038)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-10-16 14:15:48 UTC (rev 95039)
@@ -23,6 +23,7 @@
// $Id$
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -62,10 +63,10 @@
public OSGiBundle installBundle(String location) throws BundleException
{
- location = getTestHelper().getTestArchivePath(location);
+ URL url = getTestHelper().getTestArchiveURL(location);
BundleContext context = getBundleContext();
- Bundle auxBundle = context.installBundle(location);
+ Bundle auxBundle = context.installBundle(url.toExternalForm());
OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
return registerBundle(location, bundle);
16 years, 2 months
JBoss-OSGI SVN: r95036 - in projects/jboss-osgi/projects: bundles/hotdeploy/trunk and 12 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-16 09:37:48 -0400 (Fri, 16 Oct 2009)
New Revision: 95036
Added:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
Removed:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/MicrocontainerCapability.java
Modified:
projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/projects/parent/trunk/pom.xml
projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml
projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
projects/jboss-osgi/projects/spi/trunk/pom.xml
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Cleanup initial deployment API
Modified: projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2009-10-16 13:37:48 UTC (rev 95036)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.3</version>
+ <version>1.0.4-SNAPSHOT</version>
</parent>
<!-- SCM -->
@@ -40,7 +40,6 @@
<!-- Properties -->
<properties>
<version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
- <version.slf4j>1.5.8</version.slf4j>
<version.osgi>r4v42</version.osgi>
</properties>
@@ -54,12 +53,10 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/pom.xml 2009-10-16 13:37:48 UTC (rev 95036)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.3</version>
+ <version>1.0.4-SNAPSHOT</version>
</parent>
<!-- Subversion -->
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-16 13:37:48 UTC (rev 95036)
@@ -34,10 +34,9 @@
import java.util.List;
import java.util.Map;
-import org.jboss.osgi.deployment.BundleDeployment;
-import org.jboss.osgi.deployment.BundleDeploymentFactory;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.Deployment;
import org.jboss.osgi.deployment.DeploymentScannerService;
+import org.jboss.osgi.deployment.DeploymentService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -63,18 +62,18 @@
private long beforeStart;
private long lastChange;
- private DeployerService deployer;
+ private DeploymentService deployer;
private ScannerThread scannerThread;
- private List<BundleDeployment> lastScan = new ArrayList<BundleDeployment>();
- private Map<String, BundleDeployment> deploymentCache = new HashMap<String, BundleDeployment>();
+ private List<Deployment> lastScan = new ArrayList<Deployment>();
+ private Map<String, Deployment> deploymentCache = new HashMap<String, Deployment>();
public DeploymentScannerImpl(BundleContext context)
{
this.context = context;
// Get the DeployerService
- ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
- deployer = (DeployerService)context.getService(sref);
+ ServiceReference sref = context.getServiceReference(DeploymentService.class.getName());
+ deployer = (DeploymentService)context.getService(sref);
initScanner(context);
}
@@ -124,7 +123,7 @@
public void scan()
{
- List<BundleDeployment> currScan = Arrays.asList(getBundleDeployments());
+ List<Deployment> currScan = Arrays.asList(getBundleDeployments());
logBundleDeployments("Current Scan", currScan);
@@ -142,24 +141,24 @@
log.info("JBossOSGi Runtime started in " + diff + "sec");
}
- private void logBundleDeployments(String message, List<BundleDeployment> bundleDeps)
+ private void logBundleDeployments(String message, List<Deployment> bundleDeps)
{
if (log.isTraceEnabled())
{
log.trace(message);
- for (BundleDeployment dep : bundleDeps)
+ for (Deployment dep : bundleDeps)
{
log.trace(" " + dep);
}
}
}
- private int processOldDeployments(List<BundleDeployment> currScan)
+ private int processOldDeployments(List<Deployment> currScan)
{
- List<BundleDeployment> diff = new ArrayList<BundleDeployment>();
+ List<Deployment> diff = new ArrayList<Deployment>();
// Detect OLD bundles that are not in the current scan
- for (BundleDeployment dep : lastScan)
+ for (Deployment dep : lastScan)
{
if (currScan.contains(dep) == false)
{
@@ -185,7 +184,7 @@
// Undeploy the bundles through the DeployerService
try
{
- BundleDeployment[] depArr = diff.toArray(new BundleDeployment[diff.size()]);
+ Deployment[] depArr = diff.toArray(new Deployment[diff.size()]);
deployer.undeploy(depArr);
}
catch (Exception ex)
@@ -196,12 +195,12 @@
return diff.size();
}
- private int processNewDeployments(List<BundleDeployment> currScan)
+ private int processNewDeployments(List<Deployment> currScan)
{
- List<BundleDeployment> diff = new ArrayList<BundleDeployment>();
+ List<Deployment> diff = new ArrayList<Deployment>();
// Detect NEW bundles that are not in the last scan
- for (BundleDeployment dep : currScan)
+ for (Deployment dep : currScan)
{
if (lastScan.contains(dep) == false && getBundle(dep) == null)
{
@@ -216,7 +215,7 @@
{
try
{
- BundleDeployment[] depArr = diff.toArray(new BundleDeployment[diff.size()]);
+ Deployment[] depArr = diff.toArray(new Deployment[diff.size()]);
deployer.deploy(depArr);
}
catch (Exception ex)
@@ -228,9 +227,9 @@
return diff.size();
}
- public BundleDeployment[] getBundleDeployments()
+ public Deployment[] getBundleDeployments()
{
- List<BundleDeployment> bundles = new ArrayList<BundleDeployment>();
+ List<Deployment> bundles = new ArrayList<Deployment>();
File[] listFiles = scanLocation.listFiles();
if (listFiles == null)
@@ -241,13 +240,13 @@
for (File file : listFiles)
{
URL bundleURL = toURL(file);
- BundleDeployment dep = deploymentCache.get(bundleURL.toExternalForm());
+ Deployment dep = deploymentCache.get(bundleURL.toExternalForm());
if (dep == null)
{
try
{
// hot-deploy bundles are started automatically
- dep = BundleDeploymentFactory.createBundleDeployment(bundleURL);
+ dep = deployer.createDeployment(bundleURL.toExternalForm());
dep.setAutoStart(true);
deploymentCache.put(bundleURL.toExternalForm(), dep);
@@ -261,7 +260,7 @@
}
}
- BundleDeployment[] arr = new BundleDeployment[bundles.size()];
+ Deployment[] arr = new Deployment[bundles.size()];
return bundles.toArray(arr);
}
@@ -301,7 +300,7 @@
scanLocation = scanFile;
}
- private Bundle getBundle(BundleDeployment dep)
+ private Bundle getBundle(Deployment dep)
{
String symbolicName = dep.getSymbolicName();
Version version = Version.parseVersion(dep.getVersion());
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml 2009-10-16 13:37:48 UTC (rev 95036)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.3</version>
+ <version>1.0.4-SNAPSHOT</version>
</parent>
<!-- Properties -->
@@ -101,6 +101,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.jboss.osgi.microcontainer.internal.MicrocontainerServiceActivator</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+ <Export-Package>
+ org.jboss.osgi.microcontainer;version=${version}
+ </Export-Package>
<Private-Package>
org.jboss.osgi.microcontainer.integration,
org.jboss.osgi.microcontainer.internal
Copied: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java (from rev 95006, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/MicrocontainerCapability.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java 2009-10-16 13:37:48 UTC (rev 95036)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.microcontainer;
+
+//$Id$
+
+import org.jboss.osgi.deployment.DeploymentServiceCapability;
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.capability.CompendiumCapability;
+import org.jboss.osgi.spi.service.MicrocontainerService;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+
+/**
+ * Adds the Microcontainer capability to the {@link OSGiRuntime}
+ * under test.
+ *
+ * It is ignored if the {@link MicrocontainerService} is already registered.
+ *
+ * Installed bundles: jboss-osgi-microcontainer.jar
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class MicrocontainerCapability extends Capability
+{
+ public MicrocontainerCapability()
+ {
+ super(MicrocontainerService.class.getName());
+
+ addDependency(new CompendiumCapability());
+ addDependency(new DeploymentServiceCapability());
+
+ addBundle("bundles/jboss-osgi-microcontainer.jar");
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-16 13:37:48 UTC (rev 95036)
@@ -40,7 +40,6 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerContextActions;
import org.jboss.dependency.spi.ControllerState;
-import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.client.spi.main.MainDeployer;
import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
@@ -48,9 +47,8 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.osgi.deployment.BundleDeployment;
-import org.jboss.osgi.deployment.BundleDeploymentFactory;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.Deployment;
+import org.jboss.osgi.deployment.DeploymentServiceBase;
import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
@@ -67,7 +65,7 @@
* @author thomas.diesler(a)jboss.com
* @since 23-Jan-2009
*/
-public abstract class AbstractMicrocontainerService implements DeployerService, MicrocontainerService
+public abstract class AbstractMicrocontainerService extends DeploymentServiceBase implements MicrocontainerService
{
private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
private ServiceTracker registryTracker;
@@ -111,14 +109,14 @@
public void deploy(URL url) throws BundleException
{
- BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
- deploy(new BundleDeployment[] { dep });
+ Deployment dep = createDeployment(url.toExternalForm());
+ deploy(new Deployment[] { dep });
}
public boolean undeploy(URL url) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
- BundleDeployment dep = registry.getBundleDeployment(url);
+ Deployment dep = registry.getBundleDeployment(url);
if (dep == null)
{
logWarning("Package not deployed: " + url);
@@ -139,18 +137,18 @@
}
}
- public void deploy(BundleDeployment[] depArr) throws BundleException
+ public void deploy(Deployment[] depArr) throws BundleException
{
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
{
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- List<Deployment> depList = new ArrayList<Deployment>();
+ List<VFSDeployment> depList = new ArrayList<VFSDeployment>();
MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
DeploymentRegistryService registry = getDeploymentRegistry();
- for (BundleDeployment dep : depArr)
+ for (Deployment dep : depArr)
{
VirtualFile file = VFS.createNewRoot(dep.getLocation());
VFSDeployment deployment = deploymentFactory.createVFSDeployment(file);
@@ -169,7 +167,7 @@
mainDeployer.process();
// Check for completeness
- Deployment[] deploymentArr = depList.toArray(new Deployment[depList.size()]);
+ VFSDeployment[] deploymentArr = depList.toArray(new VFSDeployment[depList.size()]);
mainDeployer.checkComplete(deploymentArr);
}
catch (RuntimeException rte)
@@ -186,14 +184,14 @@
}
}
- public void undeploy(BundleDeployment[] depArr) throws BundleException
+ public void undeploy(Deployment[] depArr) throws BundleException
{
try
{
MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
DeploymentRegistryService registry = getDeploymentRegistry();
- for (BundleDeployment dep : depArr)
+ for (Deployment dep : depArr)
{
registry.unregisterBundleDeployment(dep);
mainDeployer.removeDeployment((String)dep.getMetadata());
@@ -264,7 +262,10 @@
registryTracker = new ServiceTracker(context, DeploymentRegistryService.class.getName(), null);
registryTracker.open();
}
- return (DeploymentRegistryService)registryTracker.getService();
+ DeploymentRegistryService service = (DeploymentRegistryService)registryTracker.getService();
+ if (service == null)
+ throw new IllegalStateException("Cannot obtain DeploymentRegistryService");
+ return service;
}
static class PreInstalledControllerContext extends AbstractControllerContext
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-10-16 13:37:48 UTC (rev 95036)
@@ -35,7 +35,7 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.DeploymentService;
import org.jboss.osgi.jbossxb.XMLBindingService;
import org.jboss.osgi.microcontainer.integration.AbstractMicrocontainerService;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
@@ -49,7 +49,7 @@
import org.osgi.util.tracker.ServiceTracker;
/**
- * An implementation of the {@link DeployerService} and {@link MicrocontainerService}
+ * An implementation of the {@link DeploymentService} and {@link MicrocontainerService}
* which is installed as a bundle
*
* @author thomas.diesler(a)jboss.com
@@ -148,7 +148,7 @@
Properties props = new Properties();
props.setProperty("provider", "microcontainer");
log.log(LogService.LOG_DEBUG, "Register DeployerService");
- context.registerService(DeployerService.class.getName(), mcServiceImpl, props);
+ context.registerService(DeploymentService.class.getName(), mcServiceImpl, props);
// Register the MicrocontainerServiceMBean
registerMicrocontainerServiceMBean(mbeanServer);
Modified: projects/jboss-osgi/projects/parent/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-10-16 13:37:48 UTC (rev 95036)
@@ -22,6 +22,7 @@
<properties>
<version.jboss.logging>2.0.5.GA</version.jboss.logging>
<version.junit>4.6</version.junit>
+ <version.slf4j>1.5.8</version.slf4j>
</properties>
<!-- DependencyManagement -->
@@ -33,13 +34,23 @@
<version>${version.jboss.logging}</version>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
</dependency>
</dependencies>
</dependencyManagement>
-
+
<!-- Build -->
<build>
<plugins>
@@ -173,15 +184,8 @@
<!-- DistributionManagement -->
<distributionManagement>
<!--
- Add this to your ~/.m2/settings.xml
- <servers>
- <server>
- <id>jbmuc.dyndns.org</id>
- <username>yourname</username>
- <privateKey>/home/yourname/.ssh/id_rsa</privateKey>
- <passphrase>yourpass</passphrase>
- </server>
- </servers>
+ Add this to your ~/.m2/settings.xml <servers> <server> <id>jbmuc.dyndns.org</id> <username>yourname</username> <privateKey>/home/yourname/.ssh/id_rsa</privateKey>
+ <passphrase>yourpass</passphrase> </server> </servers>
-->
<repository>
<id>repository.jboss.org</id>
@@ -201,9 +205,8 @@
<url>scp://jbmuc.dyndns.org/var/www/html/jboss-osgi-${version.jboss.osgi}</url>
</site>
<!--
- To copy the userguide run:
- scp -r docbook/target/docbook/publish/en-US/* jbmuc.dyndns.org:/var/www/html/jboss-osgi-${version.jboss.osgi}/userguide/
- -->
+ To copy the userguide run: scp -r docbook/target/docbook/publish/en-US/* jbmuc.dyndns.org:/var/www/html/jboss-osgi-${version.jboss.osgi}/userguide/
+ -->
</distributionManagement>
<!-- Reporting -->
@@ -221,7 +224,7 @@
<!-- Profiles -->
<profiles>
-
+
<!--
Name: no-jboss-bind-address
Desc: Set the default jboss.bind.address
@@ -237,7 +240,7 @@
<jboss.bind.address>localhost</jboss.bind.address>
</properties>
</profile>
-
+
</profiles>
-
+
</project>
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml 2009-10-16 13:37:48 UTC (rev 95036)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.3</version>
+ <version>1.0.4-SNAPSHOT</version>
</parent>
<!-- Subversion -->
@@ -60,8 +60,8 @@
<version>${version.felix.framework}</version>
</dependency>
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-16 13:37:48 UTC (rev 95036)
@@ -26,10 +26,9 @@
import java.net.URL;
import org.jboss.logging.Logger;
-import org.jboss.osgi.deployment.BundleDeployment;
-import org.jboss.osgi.deployment.BundleDeploymentFactory;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.DeploymentService;
import org.jboss.osgi.spi.framework.BundleContextWrapper;
+import org.jboss.osgi.spi.util.BundleInfo;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -57,17 +56,17 @@
@Override
public Bundle installBundle(String location) throws BundleException
{
- BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(location);
- URL bundleURL = dep.getLocation();
- String symbolicName = dep.getSymbolicName();
- Version version = Version.parseVersion(dep.getVersion());
+ BundleInfo info = BundleInfo.createBundleInfo(location);
+ URL bundleURL = info.getLocation();
+ String symbolicName = info.getSymbolicName();
+ Version version = Version.parseVersion(info.getVersion());
Bundle bundle;
- ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+ ServiceReference sref = context.getServiceReference(DeploymentService.class.getName());
if (sref != null)
{
- DeployerService service = (DeployerService)context.getService(sref);
+ DeploymentService service = (DeploymentService)context.getService(sref);
service.deploy(bundleURL);
bundle = getBundle(symbolicName, version, true);
}
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-10-16 13:37:48 UTC (rev 95036)
@@ -26,11 +26,11 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.2</version>
+ <version>1.0.4-SNAPSHOT</version>
</parent>
<properties>
- <version.jboss.osgi.microcontainer>1.0.1</version.jboss.osgi.microcontainer>
+ <version.jboss.osgi.microcontainer>1.0.3-SNAPSHOT</version.jboss.osgi.microcontainer>
<version.osgi>r4v42</version.osgi>
</properties>
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/MicrocontainerServiceBean.java 2009-10-16 13:37:48 UTC (rev 95036)
@@ -31,13 +31,13 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.logging.Logger;
+import org.jboss.osgi.deployment.DeploymentService;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
-import org.jboss.osgi.spi.service.DeployerService;
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.osgi.framework.BundleContext;
/**
- * An implementation of the {@link DeployerService} and {@link MicrocontainerService}
+ * An implementation of the {@link DeploymentService} and {@link MicrocontainerService}
* which is installed as MC bean in jbossas.
*
* @author thomas.diesler(a)jboss.com
@@ -102,7 +102,7 @@
// Register the DeployerService
Properties props = new Properties();
props.setProperty("provider", "microcontainer");
- bundleContext.registerService(DeployerService.class.getName(), this, props);
+ bundleContext.registerService(DeploymentService.class.getName(), this, props);
log.debug("DeployerService registered");
// Register the MicrocontainerServiceMBean
Modified: projects/jboss-osgi/projects/spi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-10-16 13:37:48 UTC (rev 95036)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.3</version>
+ <version>1.0.4-SNAPSHOT</version>
</parent>
<!-- Subversion -->
@@ -40,7 +40,6 @@
<properties>
<version.args4j>2.0.12</version.args4j>
<version.jboss.vfs>2.1.3.SP1</version.jboss.vfs>
- <version.slf4j>1.5.8</version.slf4j>
<version.osgi>r4v42</version.osgi>
</properties>
@@ -56,12 +55,11 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
- <version>${version.jboss.vfs}</version>
+ <version>${version.jboss.vfs}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/MicrocontainerCapability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/MicrocontainerCapability.java 2009-10-16 13:34:54 UTC (rev 95035)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/MicrocontainerCapability.java 2009-10-16 13:37:48 UTC (rev 95036)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, 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.capability;
-
-//$Id$
-
-import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-
-/**
- * Adds the Microcontainer capability to the {@link OSGiRuntime}
- * under test.
- *
- * It is ignored if the {@link MicrocontainerService} is already registered.
- *
- * Installed bundles: jboss-osgi-microcontainer.jar
- *
- * @author thomas.diesler(a)jboss.com
- * @since 05-May-2009
- */
-public class MicrocontainerCapability extends Capability
-{
- public MicrocontainerCapability()
- {
- super(MicrocontainerService.class.getName());
-
- addDependency(new CompendiumCapability());
-
- addBundle("bundles/jboss-osgi-microcontainer.jar");
- }
-}
\ No newline at end of file
16 years, 2 months
JBoss-OSGI SVN: r95035 - in projects/jboss-osgi/trunk: reactor/blueprint/impl and 15 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-16 09:34:54 -0400 (Fri, 16 Oct 2009)
New Revision: 95035
Added:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/microcontainer/
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
Removed:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployer.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersCapability.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
Modified:
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Cleanup initial deployment API
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.3</version>
+ <version>1.0.4-SNAPSHOT</version>
</parent>
<!-- Subversion -->
@@ -65,7 +65,7 @@
<version.jboss.osgi.runtime.deployers>1.0.2</version.jboss.osgi.runtime.deployers>
<version.jboss.osgi.runtime.equinox>3.5</version.jboss.osgi.runtime.equinox>
<version.jboss.osgi.runtime.felix>2.0.0-SNAPSHOT</version.jboss.osgi.runtime.felix>
- <version.jboss.osgi.runtime.jbossas>1.0.1</version.jboss.osgi.runtime.jbossas>
+ <version.jboss.osgi.runtime.jbossas>1.0.2-SNAPSHOT</version.jboss.osgi.runtime.jbossas>
<version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
<version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>
<version.jboss.osgi.xml.binding>2.0.1.SP1</version.jboss.osgi.xml.binding>
Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
@@ -73,6 +73,7 @@
org.jboss.kernel.spi*,
org.jboss.osgi.common.log;version=1.0,
org.jboss.osgi.jbossxb;version=2.0,
+ org.jboss.osgi.microcontainer;version=1.0,
org.jboss.osgi.spi;version=1.0,
org.jboss.osgi.spi.capability;version=1.0,
org.jboss.osgi.spi.service;version=1.0,
Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -24,8 +24,8 @@
//$Id$
import org.jboss.osgi.jbossxb.XMLBindingCapability;
+import org.jboss.osgi.microcontainer.MicrocontainerCapability;
import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.capability.MicrocontainerCapability;
import org.jboss.osgi.spi.testing.OSGiRuntime;
/**
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
@@ -92,8 +92,8 @@
<!-- Test Dependencies -->
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -240,6 +240,11 @@
<artifactId>jboss-osgi-framework</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -279,6 +284,11 @@
<artifactId>jboss-osgi-framework</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/scripts/assembly-bundles.xml 2009-10-16 13:34:54 UTC (rev 95035)
@@ -18,6 +18,7 @@
<include>*:jboss-osgi-blueprint:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
+ <include>*:jboss-osgi-deployment:jar</include>
<include>*:jboss-osgi-husky:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -1,154 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-import java.io.Serializable;
-import java.net.URL;
-
-//$Id$
-
-/**
- * An abstraction of a bundle deployment
- *
- * @author thomas.diesler(a)jboss.com
- * @since 27-May-2009
- */
-public class BundleDeployment implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private URL location;
- private String symbolicName;
- private String version;
- private int startLevel;
- private boolean autoStart;
- private Object metadata;
-
- public BundleDeployment(URL location, String symbolicName, String version)
- {
- if (location == null)
- throw new IllegalArgumentException("Location cannot be null");
- if (symbolicName == null)
- throw new IllegalArgumentException("Symbolic name cannot be null");
-
- if (version == null)
- version = "0.0.0";
-
- this.symbolicName = symbolicName;
- this.location = location;
- this.version = version;
- }
-
- /**
- * Get the bundle location
- */
- public URL getLocation()
- {
- return location;
- }
-
- /**
- * Get the bundle symbolic name
- */
- public String getSymbolicName()
- {
- return symbolicName;
- }
-
- /**
- * Get the bundle version
- */
- public String getVersion()
- {
- return version;
- }
-
- /**
- * Get the start level associated with this deployment
- */
- public int getStartLevel()
- {
- return startLevel;
- }
-
- /**
- * Set the start level associated with this deployment
- */
- public void setStartLevel(int startLevel)
- {
- this.startLevel = startLevel;
- }
-
- /**
- * Get the autostart flag associated with this deployment
- */
- public boolean isAutoStart()
- {
- return autoStart;
- }
-
- /**
- * Set the autostart flag associated with this deployment
- */
- public void setAutoStart(boolean autoStart)
- {
- this.autoStart = autoStart;
- }
-
- /**
- * Get extra meta data associated with this deployment
- */
- public Object getMetadata()
- {
- return metadata;
- }
-
- /**
- * Set extra meta data associated with this deployment
- */
- public void setMetadata(Object metadata)
- {
- this.metadata = metadata;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (!(obj instanceof BundleDeployment))
- return false;
-
- BundleDeployment other = (BundleDeployment)obj;
- return symbolicName.equals(other.symbolicName) && version.equals(other.version);
- }
-
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- @Override
- public String toString()
- {
- return "[" + symbolicName + "-" + version + ",url=" + location + "]";
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.jboss.osgi.deployment.BundleDeployment;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-/**
- * A factory for bundle deployments.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2009
- */
-public abstract class BundleDeploymentFactory
-{
- public static BundleDeployment createBundleDeployment(String location) throws BundleException
- {
- // Try location as URL
- URL url = null;
- try
- {
- url = new URL(location);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try location as File
- if (url == null)
- {
- try
- {
- File file = new File(location);
- if (file.exists())
- url = file.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- if (url == null)
- throw new IllegalArgumentException("Invalid bundle location: " + location);
-
- return createBundleDeployment(url);
- }
-
- public static BundleDeployment createBundleDeployment(URL url) throws BundleException
- {
- Manifest manifest;
- try
- {
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
- }
- catch (IOException ex)
- {
- throw new BundleException("Cannot get manifest from: " + url);
-
- }
-
- Attributes attribs = manifest.getMainAttributes();
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
-
- String version = attribs.getValue(Constants.BUNDLE_VERSION);
- return new BundleDeployment(url, symbolicName, version);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployer.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployer.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployer.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-
-/**
- * An OSGi deployer
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public interface Deployer
-{
- enum Phase {
- BEFORE_INSTALLED,
- AFTER_INSTALLED,
- BEFORE_RESOLVED,
- AFTER_RESOLVED,
- BEFORE_ACTIVE,
- AFTER_ACTIVE
- }
-
- void deploy(Deployment dep);
-
- void undeploy(Deployment dep);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import java.net.URL;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.BundleException;
-
-/**
- * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public interface DeployerService
-{
- /**
- * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
- */
- ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
-
- /**
- * Deploy an array of bundles
- */
- void deploy(BundleDeployment[] bundleDeps) throws BundleException;
-
- /**
- * Undeploy an array of bundles
- */
- void undeploy(BundleDeployment[] bundleDeps) throws BundleException;
-
- /**
- * Deploy bundle from URL
- */
- void deploy(URL url) throws BundleException;
-
- /**
- * Undeploy bundle from URL.
- *
- * Note, due to the dynamic nature of OSGi services it is
- * possible that a {@link DeployerService} is asked to undeploy
- * a bundle URL which it did not deploy itself.
- *
- * In this case this method should return false, so that
- * another {@link DeployerService} can be tried.
- *
- * @return true if this service could undeploy the bundle
- */
- boolean undeploy(URL url) throws BundleException;
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersCapability.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersCapability.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-
-/**
- * Adds the Deployers capability to the {@link OSGiRuntime}
- * under test.
- *
- * It is ignored if the {@link DeployersService} is already registered.
- *
- * Installed bundles: jboss-osgi-microcontainer.jar
- *
- * @author thomas.diesler(a)jboss.com
- * @since 05-May-2009
- */
-public class DeployersCapability extends Capability
-{
- public DeployersCapability()
- {
- super(DeployersService.class.getName());
-
- addBundle("bundles/jboss-osgi-deployers.jar");
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersService.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersService.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-
-/**
- * The deployers service
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public interface DeployersService
-{
- Deployment createDeployment(String location);
-
- void addDeployer(Deployer deployer);
-
- void removeDeployer(Deployer deployer);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.deployment;
-
-//$Id$
-
-import org.jboss.virtual.VirtualFile;
-
-/**
- * An OSGi deployment
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public interface Deployment
-{
- String getLocation();
-
- VirtualFile getRoot();
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java (from rev 95025, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployment.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+import java.io.Serializable;
+import java.net.URL;
+
+//$Id$
+
+/**
+ * An abstraction of a bundle deployment
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class Deployment implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private URL location;
+ private String symbolicName;
+ private String version;
+ private int startLevel;
+ private boolean autoStart;
+ private Object metadata;
+
+ public Deployment(URL location, String symbolicName, String version)
+ {
+ if (location == null)
+ throw new IllegalArgumentException("Location cannot be null");
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Symbolic name cannot be null");
+
+ if (version == null)
+ version = "0.0.0";
+
+ this.symbolicName = symbolicName;
+ this.location = location;
+ this.version = version;
+ }
+
+ /**
+ * Get the bundle location
+ */
+ public URL getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * Get the bundle symbolic name
+ */
+ public String getSymbolicName()
+ {
+ return symbolicName;
+ }
+
+ /**
+ * Get the bundle version
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * Get the start level associated with this deployment
+ */
+ public int getStartLevel()
+ {
+ return startLevel;
+ }
+
+ /**
+ * Set the start level associated with this deployment
+ */
+ public void setStartLevel(int startLevel)
+ {
+ this.startLevel = startLevel;
+ }
+
+ /**
+ * Get the autostart flag associated with this deployment
+ */
+ public boolean isAutoStart()
+ {
+ return autoStart;
+ }
+
+ /**
+ * Set the autostart flag associated with this deployment
+ */
+ public void setAutoStart(boolean autoStart)
+ {
+ this.autoStart = autoStart;
+ }
+
+ /**
+ * Get extra meta data associated with this deployment
+ */
+ public Object getMetadata()
+ {
+ return metadata;
+ }
+
+ /**
+ * Set extra meta data associated with this deployment
+ */
+ public void setMetadata(Object metadata)
+ {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof Deployment))
+ return false;
+
+ Deployment other = (Deployment)obj;
+ return symbolicName.equals(other.symbolicName) && version.equals(other.version);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + symbolicName + "-" + version + ",url=" + location + "]";
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java (from rev 95024, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/Deployer.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptor.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+
+/**
+ * An OSGi deployer
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public interface DeploymentInterceptor
+{
+ enum Phase {
+ BEFORE_INSTALLED,
+ AFTER_INSTALLED,
+ BEFORE_RESOLVED,
+ AFTER_RESOLVED,
+ BEFORE_ACTIVE,
+ AFTER_ACTIVE
+ }
+
+ void deploy(Deployment dep);
+
+ void undeploy(Deployment dep);
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java (from rev 95024, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentInterceptorService.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+
+/**
+ * The deployers service
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public interface DeploymentInterceptorService
+{
+ void addInterceptor(DeploymentInterceptor deployer);
+
+ void removeInterceptor(DeploymentInterceptor deployer);
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -39,21 +39,21 @@
* Create a bundle deployment from the given bundle URL
* @return null, if this service does not maintain the bundle deployment
*/
- BundleDeployment getBundleDeployment(URL url);
+ Deployment getBundleDeployment(URL url);
/**
* Get the bundle deployment for the given bundle symbolicName and version
* @return null, if this service does not maintain the bundle deployment
*/
- BundleDeployment getBundleDeployment(String symbolicName, Version version);
+ Deployment getBundleDeployment(String symbolicName, Version version);
/**
* Register a bundle deployment
*/
- void registerBundleDeployment(BundleDeployment dep);
+ void registerBundleDeployment(Deployment dep);
/**
* Unregister a bundle deployment
*/
- void unregisterBundleDeployment(BundleDeployment dep);
+ void unregisterBundleDeployment(Deployment dep);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -75,5 +75,5 @@
/**
* Returns the array of bundles currently known to the deployemtn scanner.
*/
- BundleDeployment[] getBundleDeployments();
+ Deployment[] getBundleDeployments();
}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java (from rev 95025, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentService.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+import java.net.URL;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleException;
+
+/**
+ * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public interface DeploymentService
+{
+ /**
+ * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
+ */
+ ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
+
+ /**
+ * Create a deployment from the given location.
+ */
+ Deployment createDeployment(String location) throws BundleException;
+
+ /**
+ * Deploy an array of bundles
+ */
+ void deploy(Deployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Undeploy an array of bundles
+ */
+ void undeploy(Deployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Deploy bundle from URL
+ */
+ void deploy(URL url) throws BundleException;
+
+ /**
+ * Undeploy bundle from URL.
+ *
+ * Note, due to the dynamic nature of OSGi services it is
+ * possible that a {@link DeploymentService} is asked to undeploy
+ * a bundle URL which it did not deploy itself.
+ *
+ * In this case this method should return false, so that
+ * another {@link DeploymentService} can be tried.
+ *
+ * @return true if this service could undeploy the bundle
+ */
+ boolean undeploy(URL url) throws BundleException;
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+//$Id$
+
+/**
+ * An abstract base implementation of the DeployerService.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 16-Oct-2009
+ */
+public abstract class DeploymentServiceBase implements DeploymentService
+{
+ public Deployment createDeployment(String location) throws BundleException
+ {
+ // Try location as URL
+ URL url = null;
+ try
+ {
+ url = new URL(location);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try location as File
+ if (url == null)
+ {
+ try
+ {
+ File file = new File(location);
+ if (file.exists())
+ url = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ if (url == null)
+ throw new IllegalArgumentException("Invalid bundle location: " + location);
+
+ return createDeploymentInternal(url);
+ }
+
+ private Deployment createDeploymentInternal(URL url) throws BundleException
+ {
+ Manifest manifest;
+ try
+ {
+ JarFile jarFile = new JarFile(url.getPath());
+ manifest = jarFile.getManifest();
+ jarFile.close();
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot get manifest from: " + url);
+
+ }
+
+ Attributes attribs = manifest.getMainAttributes();
+ String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ if (symbolicName == null)
+ throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
+
+ String version = attribs.getValue(Constants.BUNDLE_VERSION);
+ return new Deployment(url, symbolicName, version);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceBase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java (from rev 95024, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployersCapability.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentServiceCapability.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+
+/**
+ * Adds the DeploymentService capability to the {@link OSGiRuntime}
+ * under test.
+ *
+ * It is ignored if the {@link DeploymentService} is already registered.
+ *
+ * Installed bundles: jboss-osgi-deployment.jar
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 16-Oct-2009
+ */
+public class DeploymentServiceCapability extends Capability
+{
+ public DeploymentServiceCapability()
+ {
+ super(DeploymentService.class.getName());
+
+ addBundle("bundles/jboss-osgi-deployment.jar");
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -25,22 +25,22 @@
import java.net.URL;
-import org.jboss.osgi.deployment.BundleDeployment;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.Deployment;
+import org.jboss.osgi.deployment.DeploymentService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
/**
- * A {@link DeployerService} that delegates to the service that is tracked by the given {@link DeployerServiceTracker}
+ * A {@link DeploymentService} that delegates to the service that is tracked by the given {@link DeployerServiceTracker}
*
* This delegate is registered as an MBean
*
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
*/
-public class DeployerServiceDelegate implements DeployerService
+public class DeployerServiceDelegate implements DeploymentService
{
private BundleContext context;
@@ -49,21 +49,27 @@
this.context = context;
}
- public void deploy(BundleDeployment[] bundles) throws BundleException
+ public Deployment createDeployment(String location) throws BundleException
{
- DeployerService service = getDefaultDeployerService();
+ DeploymentService service = getDefaultDeployerService();
+ return service.createDeployment(location);
+ }
+
+ public void deploy(Deployment[] bundles) throws BundleException
+ {
+ DeploymentService service = getDefaultDeployerService();
service.deploy(bundles);
}
public void deploy(URL url) throws BundleException
{
- DeployerService service = getDefaultDeployerService();
+ DeploymentService service = getDefaultDeployerService();
service.deploy(url);
}
- public void undeploy(BundleDeployment[] bundles) throws BundleException
+ public void undeploy(Deployment[] bundles) throws BundleException
{
- for (BundleDeployment info : bundles)
+ for (Deployment info : bundles)
undeploy(info.getLocation());
}
@@ -71,7 +77,7 @@
{
boolean undeployed = false;
- DeployerService service = getMicrocontainerDeployerService();
+ DeploymentService service = getMicrocontainerDeployerService();
if (service != null)
undeployed = service.undeploy(url);
@@ -84,10 +90,10 @@
return undeployed;
}
- private DeployerService getDefaultDeployerService()
+ private DeploymentService getDefaultDeployerService()
{
// First try the MC provider
- DeployerService service = getMicrocontainerDeployerService();
+ DeploymentService service = getMicrocontainerDeployerService();
// Fall back to the system provider
if (service == null)
@@ -96,16 +102,16 @@
return service;
}
- private DeployerService getMicrocontainerDeployerService()
+ private DeploymentService getMicrocontainerDeployerService()
{
- DeployerService service = null;
+ DeploymentService service = null;
try
{
String filter = "(provider=microcontainer)";
- String serviceName = DeployerService.class.getName();
+ String serviceName = DeploymentService.class.getName();
ServiceReference[] srefs = context.getServiceReferences(serviceName, filter);
if (srefs != null)
- service = (DeployerService)context.getService(srefs[0]);
+ service = (DeploymentService)context.getService(srefs[0]);
}
catch (InvalidSyntaxException ex)
{
@@ -114,16 +120,16 @@
return service;
}
- private DeployerService getSystemDeployerService()
+ private DeploymentService getSystemDeployerService()
{
- DeployerService service = null;
+ DeploymentService service = null;
try
{
String filter = "(provider=system)";
- String serviceName = DeployerService.class.getName();
+ String serviceName = DeploymentService.class.getName();
ServiceReference[] srefs = context.getServiceReferences(serviceName, filter);
if (srefs != null)
- service = (DeployerService)context.getService(srefs[0]);
+ service = (DeploymentService)context.getService(srefs[0]);
}
catch (InvalidSyntaxException ex)
{
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -29,10 +29,9 @@
import javax.management.MBeanServer;
import javax.management.StandardMBean;
-import org.jboss.osgi.deployment.Deployer;
-import org.jboss.osgi.deployment.DeployerService;
-import org.jboss.osgi.deployment.DeployersService;
-import org.jboss.osgi.deployment.Deployment;
+import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeploymentInterceptor;
+import org.jboss.osgi.deployment.DeploymentInterceptorService;
import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.BundleActivator;
@@ -58,29 +57,24 @@
public void start(BundleContext context) throws Exception
{
// Register the system SystemDeployerService and DeployerServiceDelegate
- DeployerService deployer = registerDeployerServices(context);
+ DeploymentService deployer = registerDeployerServices(context);
// Track the MBeanServer and register the DeployerServiceDelegate
trackMBeanServer(context, deployer);
- DeployersService service = new DeployersService()
+ DeploymentInterceptorService service = new DeploymentInterceptorService()
{
- public void removeDeployer(Deployer deployer)
+ public void removeInterceptor(DeploymentInterceptor deployer)
{
throw new NotImplementedException();
}
- public Deployment createDeployment(String location)
+ public void addInterceptor(DeploymentInterceptor deployer)
{
throw new NotImplementedException();
}
-
- public void addDeployer(Deployer deployer)
- {
- throw new NotImplementedException();
- }
};
- context.registerService(DeployersService.class.getName(), service, null);
+ context.registerService(DeploymentInterceptorService.class.getName(), service, null);
}
public void stop(BundleContext context) throws Exception
@@ -93,7 +87,7 @@
}
}
- protected DeployerService registerDeployerServices(BundleContext context)
+ protected DeploymentService registerDeployerServices(BundleContext context)
{
// Register the DeploymentRegistryService
DeploymentRegistryService registry = new DeploymentRegistryServiceImpl(context);
@@ -103,17 +97,17 @@
Properties props = new Properties();
props.put("provider", "system");
SystemDeployerService systemDeployer = new SystemDeployerService(context);
- context.registerService(DeployerService.class.getName(), systemDeployer, props);
+ context.registerService(DeploymentService.class.getName(), systemDeployer, props);
// Register the DeployerServiceDelegate
props = new Properties();
props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
- DeployerService deployerDelegate = new DeployerServiceDelegate(context);
- context.registerService(DeployerService.class.getName(), deployerDelegate, props);
+ DeploymentService deployerDelegate = new DeployerServiceDelegate(context);
+ context.registerService(DeploymentService.class.getName(), deployerDelegate, props);
return deployerDelegate;
}
- private void trackMBeanServer(BundleContext context, final DeployerService deployer)
+ private void trackMBeanServer(BundleContext context, final DeploymentService deployer)
{
ServiceTracker jmxTracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
{
@@ -136,12 +130,12 @@
jmxTracker.open();
}
- private void registerDeployerServiceMBean(MBeanServer mbeanServer, DeployerService delegate)
+ private void registerDeployerServiceMBean(MBeanServer mbeanServer, DeploymentService delegate)
{
try
{
- StandardMBean mbean = new StandardMBean(delegate, DeployerService.class);
- mbeanServer.registerMBean(mbean, DeployerService.MBEAN_DEPLOYER_SERVICE);
+ StandardMBean mbean = new StandardMBean(delegate, DeploymentService.class);
+ mbeanServer.registerMBean(mbean, DeploymentService.MBEAN_DEPLOYER_SERVICE);
}
catch (JMException ex)
{
@@ -153,8 +147,8 @@
{
try
{
- if (mbeanServer.isRegistered(DeployerService.MBEAN_DEPLOYER_SERVICE))
- mbeanServer.unregisterMBean(DeployerService.MBEAN_DEPLOYER_SERVICE);
+ if (mbeanServer.isRegistered(DeploymentService.MBEAN_DEPLOYER_SERVICE))
+ mbeanServer.unregisterMBean(DeploymentService.MBEAN_DEPLOYER_SERVICE);
}
catch (JMException ex)
{
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -27,43 +27,43 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.osgi.deployment.BundleDeployment;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.Deployment;
+import org.jboss.osgi.deployment.DeploymentService;
import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
/**
- * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ * A {@link DeploymentService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
*
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
*/
public class DeploymentRegistryServiceImpl implements DeploymentRegistryService
{
- private Set<BundleDeployment> deployments = new HashSet<BundleDeployment>();
+ private Set<Deployment> deployments = new HashSet<Deployment>();
public DeploymentRegistryServiceImpl(BundleContext context)
{
}
- public void registerBundleDeployment(BundleDeployment dep)
+ public void registerBundleDeployment(Deployment dep)
{
deployments.add(dep);
}
- public void unregisterBundleDeployment(BundleDeployment dep)
+ public void unregisterBundleDeployment(Deployment dep)
{
deployments.remove(dep);
}
- public BundleDeployment getBundleDeployment(String symbolicName, Version version)
+ public Deployment getBundleDeployment(String symbolicName, Version version)
{
if (symbolicName == null)
throw new IllegalArgumentException("Cannot obtain bundle deployment for null symbolic name");
- BundleDeployment dep = null;
- for (BundleDeployment auxDep : deployments)
+ Deployment dep = null;
+ for (Deployment auxDep : deployments)
{
String auxName = auxDep.getSymbolicName();
String auxVersion = auxDep.getVersion();
@@ -77,13 +77,13 @@
return dep;
}
- public BundleDeployment getBundleDeployment(URL url)
+ public Deployment getBundleDeployment(URL url)
{
if (url == null)
throw new IllegalArgumentException("Cannot obtain bundle deployment for: null");
- BundleDeployment dep = null;
- for (BundleDeployment auxDep : deployments)
+ Deployment dep = null;
+ for (Deployment auxDep : deployments)
{
if (url.equals(auxDep.getLocation()))
{
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -30,9 +30,9 @@
import java.util.Map;
import java.util.Map.Entry;
-import org.jboss.osgi.deployment.BundleDeployment;
-import org.jboss.osgi.deployment.BundleDeploymentFactory;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.Deployment;
+import org.jboss.osgi.deployment.DeploymentService;
+import org.jboss.osgi.deployment.DeploymentServiceBase;
import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.jboss.osgi.spi.logging.ExportedPackageHelper;
import org.jboss.osgi.spi.management.ManagedBundleService;
@@ -48,12 +48,12 @@
import org.slf4j.LoggerFactory;
/**
- * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ * A {@link DeploymentService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
*
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
*/
-public class SystemDeployerService implements DeployerService
+public class SystemDeployerService extends DeploymentServiceBase
{
// Provide logging
private Logger log = LoggerFactory.getLogger(SystemDeployerService.class);
@@ -67,14 +67,14 @@
this.context = context;
}
- public void deploy(BundleDeployment[] depArr) throws BundleException
+ public void deploy(Deployment[] depArr) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
List<Bundle> resolvableBundles = new ArrayList<Bundle>();
- Map<BundleDeployment, Bundle> bundleMap = new HashMap<BundleDeployment, Bundle>();
+ Map<Deployment, Bundle> bundleMap = new HashMap<Deployment, Bundle>();
- for (BundleDeployment dep : depArr)
+ for (Deployment dep : depArr)
{
try
{
@@ -107,9 +107,9 @@
}
// Start the installed bundles
- for (Entry<BundleDeployment, Bundle> entry : bundleMap.entrySet())
+ for (Entry<Deployment, Bundle> entry : bundleMap.entrySet())
{
- BundleDeployment dep = entry.getKey();
+ Deployment dep = entry.getKey();
Bundle bundle = entry.getValue();
StartLevel startLevel = getStartLevel();
@@ -146,11 +146,11 @@
}
}
- public void undeploy(BundleDeployment[] depArr) throws BundleException
+ public void undeploy(Deployment[] depArr) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
- for (BundleDeployment dep : depArr)
+ for (Deployment dep : depArr)
{
Bundle bundle = getBundle(dep);
if (bundle != null)
@@ -170,17 +170,17 @@
public void deploy(URL url) throws BundleException
{
- BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
- deploy(new BundleDeployment[] { dep });
+ Deployment dep = createDeployment(url.toExternalForm());
+ deploy(new Deployment[] { dep });
}
public boolean undeploy(URL url) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
- BundleDeployment dep = registry.getBundleDeployment(url);
+ Deployment dep = registry.getBundleDeployment(url);
if (dep != null)
{
- undeploy(new BundleDeployment[] { dep });
+ undeploy(new Deployment[] { dep });
return true;
}
else
@@ -190,7 +190,7 @@
}
}
- private Bundle getBundle(BundleDeployment dep)
+ private Bundle getBundle(Deployment dep)
{
String symbolicName = dep.getSymbolicName();
Version version = Version.parseVersion(dep.getVersion());
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -85,6 +85,8 @@
allPackages.add("javax.xml.transform.sax");
allPackages.add("javax.xml.transform.stream");
+ allPackages.add("org.jboss.osgi.microcontainer");
+
allPackages.add("org.w3c.dom");
allPackages.add("org.w3c.dom.bootstrap");
allPackages.add("org.w3c.dom.ls");
@@ -96,7 +98,7 @@
allPackages.add("org.xml.sax");
allPackages.add("org.xml.sax.ext");
allPackages.add("org.xml.sax.helpers");
-
+
allPackages.add("org.osgi.framework");
allPackages.add("org.osgi.framework.launch");
allPackages.add("org.osgi.service.startlevel");
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.microcontainer;
+
+//$Id$
+
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.capability.CompendiumCapability;
+import org.jboss.osgi.spi.service.MicrocontainerService;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+
+/**
+ * Adds the Microcontainer capability to the {@link OSGiRuntime}
+ * under test.
+ *
+ * This implementation does nothing because the JBossMC based framework
+ * does support microcontainer natively.
+ *
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class MicrocontainerCapability extends Capability
+{
+ public MicrocontainerCapability()
+ {
+ super(MicrocontainerService.class.getName());
+
+ addDependency(new CompendiumCapability());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-10-16 13:34:54 UTC (rev 95035)
@@ -19,6 +19,7 @@
<include>*:jboss-osgi-blueprint:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
+ <include>*:jboss-osgi-deployment:jar</include>
<include>*:jboss-osgi-husky:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -29,7 +29,7 @@
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jndi.JNDICapability;
-import org.jboss.osgi.spi.capability.MicrocontainerCapability;
+import org.jboss.osgi.microcontainer.MicrocontainerCapability;
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.testing.OSGiBundle;
import org.jboss.osgi.spi.testing.OSGiRuntime;
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-10-16 13:34:54 UTC (rev 95035)
@@ -44,4 +44,4 @@
# Bundles that need to be started automatically
org.jboss.osgi.spi.framework.autoStart=\
file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
- file://${test.archive.directory}/bundles/jboss-osgi-common.jar
+ file://${test.archive.directory}/bundles/jboss-osgi-common.jar
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-10-16 13:34:54 UTC (rev 95035)
@@ -19,6 +19,7 @@
<include>*:jboss-osgi-blueprint:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
+ <include>*:jboss-osgi-deployment:jar</include>
<include>*:jboss-osgi-husky:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -28,7 +28,7 @@
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jndi.JNDICapability;
-import org.jboss.osgi.spi.capability.MicrocontainerCapability;
+import org.jboss.osgi.microcontainer.MicrocontainerCapability;
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.management.MBeanProxyException;
import org.jboss.osgi.spi.testing.OSGiBundle;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-16 13:34:54 UTC (rev 95035)
@@ -23,7 +23,7 @@
//$Id$
-import static org.jboss.osgi.deployment.DeployerService.MBEAN_DEPLOYER_SERVICE;
+import static org.jboss.osgi.deployment.DeploymentService.MBEAN_DEPLOYER_SERVICE;
import static org.jboss.osgi.spi.management.ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK;
import static org.jboss.osgi.spi.management.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
import static org.jboss.test.osgi.service.microcontainer.bundleB.SomeBeanMBean.MBEAN_NAME;
@@ -36,11 +36,11 @@
import javax.management.ObjectName;
-import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.DeploymentService;
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jndi.JNDICapability;
-import org.jboss.osgi.spi.capability.MicrocontainerCapability;
+import org.jboss.osgi.microcontainer.MicrocontainerCapability;
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
@@ -92,12 +92,12 @@
}
/**
- * Test whether a bundle can be deployed through the {@link DeployerService}
+ * Test whether a bundle can be deployed through the {@link DeploymentService}
*/
@Test
public void testBundleDeployment() throws Exception
{
- DeployerService deployer = MBeanProxy.get(DeployerService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
+ DeploymentService deployer = MBeanProxy.get(DeploymentService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
deployer.deploy(getTestArchiveURL("service/mcservice-bundleA.jar"));
ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
@@ -108,13 +108,13 @@
}
/**
- * Test whether a bundle that contains beans can be deployed through the {@link DeployerService}
+ * Test whether a bundle that contains beans can be deployed through the {@link DeploymentService}
*/
@Test
public void testBeansDeployment() throws Exception
{
MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
- DeployerService deployer = MBeanProxy.get(DeployerService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
+ DeploymentService deployer = MBeanProxy.get(DeploymentService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
deployer.deploy(getTestArchiveURL("service/mcservice-bundleB.jar"));
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-10-16 13:18:32 UTC (rev 95034)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-10-16 13:34:54 UTC (rev 95035)
@@ -160,8 +160,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
16 years, 2 months
JBoss-OSGI SVN: r95027 - in projects/jboss-osgi/trunk: testsuite/example/src/test/resources and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-16 07:03:04 -0400 (Fri, 16 Oct 2009)
New Revision: 95027
Modified:
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties
Log:
Add org.jboss.osgi.deployment to sys classpath
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-10-16 11:03:01 UTC (rev 95026)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-10-16 11:03:04 UTC (rev 95027)
@@ -18,6 +18,7 @@
org.osgi.framework.system.packages.extra=\
org.apache.log4j;version=1.2, \
org.jboss.logging, \
+ org.jboss.osgi.deployment;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.logging;version=1.0, \
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties 2009-10-16 11:03:01 UTC (rev 95026)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties 2009-10-16 11:03:04 UTC (rev 95027)
@@ -16,6 +16,7 @@
org.apache.log4j;version=1.2, \
org.jboss.logging, \
org.jboss.net.protocol, \
+ org.jboss.osgi.deployment;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.framework;version=1.0, \
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-10-16 11:03:01 UTC (rev 95026)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-10-16 11:03:04 UTC (rev 95027)
@@ -20,6 +20,7 @@
org.jboss.logging, \
org.jboss.net.protocol, \
org.jboss.osgi.common.log;version=1.0, \
+ org.jboss.osgi.deployment;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.framework;version=1.0, \
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties 2009-10-16 11:03:01 UTC (rev 95026)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties 2009-10-16 11:03:04 UTC (rev 95027)
@@ -17,6 +17,7 @@
org.apache.log4j;version=1.2, \
org.jboss.logging, \
org.jboss.net.protocol, \
+ org.jboss.osgi.deployment;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.logging;version=1.0, \
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties 2009-10-16 11:03:01 UTC (rev 95026)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties 2009-10-16 11:03:04 UTC (rev 95027)
@@ -16,6 +16,7 @@
org.apache.log4j;version=1.2, \
org.jboss.logging, \
org.jboss.net.protocol, \
+ org.jboss.osgi.deployment;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.logging;version=1.0, \
16 years, 2 months
JBoss-OSGI SVN: r95025 - in projects/jboss-osgi/trunk: reactor/deployment/src/main/java/org/jboss/osgi/deployment and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-16 06:40:49 -0400 (Fri, 16 Oct 2009)
New Revision: 95025
Added:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
Modified:
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Move deployment stuff from common to deployement project
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-10-16 10:37:53 UTC (rev 95024)
+++ projects/jboss-osgi/trunk/pom.xml 2009-10-16 10:40:49 UTC (rev 95025)
@@ -54,6 +54,7 @@
<version.jboss.osgi.blueprint>1.0.0.Alpha3</version.jboss.osgi.blueprint>
<version.jboss.osgi.common>1.0.3-SNAPSHOT</version.jboss.osgi.common>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
+ <version.jboss.osgi.deployment>1.0.0-SNAPSHOT</version.jboss.osgi.deployment>
<version.jboss.osgi.framework>1.0.0.Alpha2</version.jboss.osgi.framework>
<version.jboss.osgi.hotdeploy>1.0.3-SNAPSHOT</version.jboss.osgi.hotdeploy>
<version.jboss.osgi.husky>1.0.1</version.jboss.osgi.husky>
@@ -109,6 +110,11 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-deployment</artifactId>
+ <version>${version.jboss.osgi.deployment}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-common-core</artifactId>
<version>${version.jboss.osgi.common.core}</version>
</dependency>
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java (from rev 95006, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeployment.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+import java.io.Serializable;
+import java.net.URL;
+
+//$Id$
+
+/**
+ * An abstraction of a bundle deployment
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class BundleDeployment implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private URL location;
+ private String symbolicName;
+ private String version;
+ private int startLevel;
+ private boolean autoStart;
+ private Object metadata;
+
+ public BundleDeployment(URL location, String symbolicName, String version)
+ {
+ if (location == null)
+ throw new IllegalArgumentException("Location cannot be null");
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Symbolic name cannot be null");
+
+ if (version == null)
+ version = "0.0.0";
+
+ this.symbolicName = symbolicName;
+ this.location = location;
+ this.version = version;
+ }
+
+ /**
+ * Get the bundle location
+ */
+ public URL getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * Get the bundle symbolic name
+ */
+ public String getSymbolicName()
+ {
+ return symbolicName;
+ }
+
+ /**
+ * Get the bundle version
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * Get the start level associated with this deployment
+ */
+ public int getStartLevel()
+ {
+ return startLevel;
+ }
+
+ /**
+ * Set the start level associated with this deployment
+ */
+ public void setStartLevel(int startLevel)
+ {
+ this.startLevel = startLevel;
+ }
+
+ /**
+ * Get the autostart flag associated with this deployment
+ */
+ public boolean isAutoStart()
+ {
+ return autoStart;
+ }
+
+ /**
+ * Set the autostart flag associated with this deployment
+ */
+ public void setAutoStart(boolean autoStart)
+ {
+ this.autoStart = autoStart;
+ }
+
+ /**
+ * Get extra meta data associated with this deployment
+ */
+ public Object getMetadata()
+ {
+ return metadata;
+ }
+
+ /**
+ * Set extra meta data associated with this deployment
+ */
+ public void setMetadata(Object metadata)
+ {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof BundleDeployment))
+ return false;
+
+ BundleDeployment other = (BundleDeployment)obj;
+ return symbolicName.equals(other.symbolicName) && version.equals(other.version);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + symbolicName + "-" + version + ",url=" + location + "]";
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.osgi.deployment.BundleDeployment;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * A factory for bundle deployments.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2009
+ */
+public abstract class BundleDeploymentFactory
+{
+ public static BundleDeployment createBundleDeployment(String location) throws BundleException
+ {
+ // Try location as URL
+ URL url = null;
+ try
+ {
+ url = new URL(location);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try location as File
+ if (url == null)
+ {
+ try
+ {
+ File file = new File(location);
+ if (file.exists())
+ url = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ if (url == null)
+ throw new IllegalArgumentException("Invalid bundle location: " + location);
+
+ return createBundleDeployment(url);
+ }
+
+ public static BundleDeployment createBundleDeployment(URL url) throws BundleException
+ {
+ Manifest manifest;
+ try
+ {
+ JarFile jarFile = new JarFile(url.getPath());
+ manifest = jarFile.getManifest();
+ jarFile.close();
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot get manifest from: " + url);
+
+ }
+
+ Attributes attribs = manifest.getMainAttributes();
+ String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ if (symbolicName == null)
+ throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
+
+ String version = attribs.getValue(Constants.BUNDLE_VERSION);
+ return new BundleDeployment(url, symbolicName, version);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/BundleDeploymentFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java (from rev 95006, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeployerService.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+import java.net.URL;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleException;
+
+/**
+ * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public interface DeployerService
+{
+ /**
+ * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
+ */
+ ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
+
+ /**
+ * Deploy an array of bundles
+ */
+ void deploy(BundleDeployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Undeploy an array of bundles
+ */
+ void undeploy(BundleDeployment[] bundleDeps) throws BundleException;
+
+ /**
+ * Deploy bundle from URL
+ */
+ void deploy(URL url) throws BundleException;
+
+ /**
+ * Undeploy bundle from URL.
+ *
+ * Note, due to the dynamic nature of OSGi services it is
+ * possible that a {@link DeployerService} is asked to undeploy
+ * a bundle URL which it did not deploy itself.
+ *
+ * In this case this method should return false, so that
+ * another {@link DeployerService} can be tried.
+ *
+ * @return true if this service could undeploy the bundle
+ */
+ boolean undeploy(URL url) throws BundleException;
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java (from rev 95006, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentRegistryService.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id: DeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
+
+import java.net.URL;
+
+import org.osgi.framework.Version;
+
+/**
+ * A Service to register/unregister bundle deployments.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2009
+ */
+public interface DeploymentRegistryService
+{
+ /**
+ * Create a bundle deployment from the given bundle URL
+ * @return null, if this service does not maintain the bundle deployment
+ */
+ BundleDeployment getBundleDeployment(URL url);
+
+ /**
+ * Get the bundle deployment for the given bundle symbolicName and version
+ * @return null, if this service does not maintain the bundle deployment
+ */
+ BundleDeployment getBundleDeployment(String symbolicName, Version version);
+
+ /**
+ * Register a bundle deployment
+ */
+ void registerBundleDeployment(BundleDeployment dep);
+
+ /**
+ * Unregister a bundle deployment
+ */
+ void unregisterBundleDeployment(BundleDeployment dep);
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java (from rev 95006, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/DeploymentScannerService.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment;
+
+//$Id$
+
+import java.net.URL;
+
+
+/**
+ * A service that scans a directory location for new/removed bundles.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public interface DeploymentScannerService
+{
+ /**
+ * The property that names the scan location: org.jboss.osgi.hotdeploy.scandir
+ */
+ String PROPERTY_SCAN_LOCATION = "org.jboss.osgi.hotdeploy.scandir";
+
+ /**
+ * The property to defines the scan interval: org.jboss.osgi.hotdeploy.interval
+ */
+ String PROPERTY_SCAN_INTERVAL = "org.jboss.osgi.hotdeploy.interval";
+
+ /**
+ * Get the scan location URL.
+ *
+ * This is can be specified by setting the {@link #PROPERTY_SCAN_LOCATION} property.
+ */
+ URL getScanLocation();
+
+ /**
+ * The number of scans since the service started
+ */
+ long getScanCount();
+
+ /**
+ * The number of milliseconds between scans
+ * Defaults to 2000ms
+ */
+ long getScanInterval();
+
+ /**
+ * The timestamp of the last change
+ */
+ long getLastChange();
+
+ /**
+ * Run a directory scan
+ */
+ void scan();
+
+ /**
+ * Returns the array of bundles currently known to the deployemtn scanner.
+ */
+ BundleDeployment[] getBundleDeployments();
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java (from rev 95022, projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployerServiceDelegate.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.internal;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.osgi.deployment.BundleDeployment;
+import org.jboss.osgi.deployment.DeployerService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A {@link DeployerService} that delegates to the service that is tracked by the given {@link DeployerServiceTracker}
+ *
+ * This delegate is registered as an MBean
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class DeployerServiceDelegate implements DeployerService
+{
+ private BundleContext context;
+
+ public DeployerServiceDelegate(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void deploy(BundleDeployment[] bundles) throws BundleException
+ {
+ DeployerService service = getDefaultDeployerService();
+ service.deploy(bundles);
+ }
+
+ public void deploy(URL url) throws BundleException
+ {
+ DeployerService service = getDefaultDeployerService();
+ service.deploy(url);
+ }
+
+ public void undeploy(BundleDeployment[] bundles) throws BundleException
+ {
+ for (BundleDeployment info : bundles)
+ undeploy(info.getLocation());
+ }
+
+ public boolean undeploy(URL url) throws BundleException
+ {
+ boolean undeployed = false;
+
+ DeployerService service = getMicrocontainerDeployerService();
+ if (service != null)
+ undeployed = service.undeploy(url);
+
+ if (undeployed == false)
+ {
+ service = getSystemDeployerService();
+ undeployed = service.undeploy(url);
+ }
+
+ return undeployed;
+ }
+
+ private DeployerService getDefaultDeployerService()
+ {
+ // First try the MC provider
+ DeployerService service = getMicrocontainerDeployerService();
+
+ // Fall back to the system provider
+ if (service == null)
+ service = getSystemDeployerService();
+
+ return service;
+ }
+
+ private DeployerService getMicrocontainerDeployerService()
+ {
+ DeployerService service = null;
+ try
+ {
+ String filter = "(provider=microcontainer)";
+ String serviceName = DeployerService.class.getName();
+ ServiceReference[] srefs = context.getServiceReferences(serviceName, filter);
+ if (srefs != null)
+ service = (DeployerService)context.getService(srefs[0]);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ throw new IllegalArgumentException(ex);
+ }
+ return service;
+ }
+
+ private DeployerService getSystemDeployerService()
+ {
+ DeployerService service = null;
+ try
+ {
+ String filter = "(provider=system)";
+ String serviceName = DeployerService.class.getName();
+ ServiceReference[] srefs = context.getServiceReferences(serviceName, filter);
+ if (srefs != null)
+ service = (DeployerService)context.getService(srefs[0]);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ throw new IllegalArgumentException(ex);
+ }
+
+ if (service == null)
+ throw new IllegalStateException("Cannot obtain system DeployerService");
+ return service;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java 2009-10-16 10:37:53 UTC (rev 95024)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeployersActivator.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -23,12 +23,25 @@
//$Id$
+import java.util.Properties;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.StandardMBean;
+
import org.jboss.osgi.deployment.Deployer;
+import org.jboss.osgi.deployment.DeployerService;
import org.jboss.osgi.deployment.DeployersService;
import org.jboss.osgi.deployment.Deployment;
+import org.jboss.osgi.deployment.DeploymentRegistryService;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -39,8 +52,17 @@
*/
public class DeployersActivator implements BundleActivator
{
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(DeployersActivator.class);
+
public void start(BundleContext context) throws Exception
{
+ // Register the system SystemDeployerService and DeployerServiceDelegate
+ DeployerService deployer = registerDeployerServices(context);
+
+ // Track the MBeanServer and register the DeployerServiceDelegate
+ trackMBeanServer(context, deployer);
+
DeployersService service = new DeployersService()
{
public void removeDeployer(Deployer deployer)
@@ -63,7 +85,80 @@
public void stop(BundleContext context) throws Exception
{
- // TODO Auto-generated method stub
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ if (sref != null)
+ {
+ MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+ unregisterDeployerServiceMBean(mbeanServer);
+ }
+ }
+
+ protected DeployerService registerDeployerServices(BundleContext context)
+ {
+ // Register the DeploymentRegistryService
+ DeploymentRegistryService registry = new DeploymentRegistryServiceImpl(context);
+ context.registerService(DeploymentRegistryService.class.getName(), registry, null);
+ // Register the SystemDeployerService
+ Properties props = new Properties();
+ props.put("provider", "system");
+ SystemDeployerService systemDeployer = new SystemDeployerService(context);
+ context.registerService(DeployerService.class.getName(), systemDeployer, props);
+
+ // Register the DeployerServiceDelegate
+ props = new Properties();
+ props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ DeployerService deployerDelegate = new DeployerServiceDelegate(context);
+ context.registerService(DeployerService.class.getName(), deployerDelegate, props);
+ return deployerDelegate;
}
+
+ private void trackMBeanServer(BundleContext context, final DeployerService deployer)
+ {
+ ServiceTracker jmxTracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
+ registerDeployerServiceMBean(mbeanServer, deployer);
+ return mbeanServer;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ MBeanServer mbeanServer = (MBeanServer)service;
+ unregisterDeployerServiceMBean(mbeanServer);
+ super.removedService(reference, service);
+ }
+ };
+ jmxTracker.open();
+ }
+
+ private void registerDeployerServiceMBean(MBeanServer mbeanServer, DeployerService delegate)
+ {
+ try
+ {
+ StandardMBean mbean = new StandardMBean(delegate, DeployerService.class);
+ mbeanServer.registerMBean(mbean, DeployerService.MBEAN_DEPLOYER_SERVICE);
+ }
+ catch (JMException ex)
+ {
+ throw new IllegalStateException("Cannot register DeployerService MBean", ex);
+ }
+ }
+
+ private void unregisterDeployerServiceMBean(MBeanServer mbeanServer)
+ {
+ try
+ {
+ if (mbeanServer.isRegistered(DeployerService.MBEAN_DEPLOYER_SERVICE))
+ mbeanServer.unregisterMBean(DeployerService.MBEAN_DEPLOYER_SERVICE);
+ }
+ catch (JMException ex)
+ {
+ log.error("Cannot unregister DeployerService MBean", ex);
+ }
+ }
}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java (from rev 95022, projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.internal;
+
+//$Id: SystemDeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.osgi.deployment.BundleDeployment;
+import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.DeploymentRegistryService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
+
+/**
+ * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class DeploymentRegistryServiceImpl implements DeploymentRegistryService
+{
+ private Set<BundleDeployment> deployments = new HashSet<BundleDeployment>();
+
+ public DeploymentRegistryServiceImpl(BundleContext context)
+ {
+ }
+
+ public void registerBundleDeployment(BundleDeployment dep)
+ {
+ deployments.add(dep);
+ }
+
+ public void unregisterBundleDeployment(BundleDeployment dep)
+ {
+ deployments.remove(dep);
+ }
+
+ public BundleDeployment getBundleDeployment(String symbolicName, Version version)
+ {
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Cannot obtain bundle deployment for null symbolic name");
+
+ BundleDeployment dep = null;
+ for (BundleDeployment auxDep : deployments)
+ {
+ String auxName = auxDep.getSymbolicName();
+ String auxVersion = auxDep.getVersion();
+ if (symbolicName.equals(auxName) && version.equals(auxVersion))
+ {
+ dep = auxDep;
+ break;
+ }
+ }
+
+ return dep;
+ }
+
+ public BundleDeployment getBundleDeployment(URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("Cannot obtain bundle deployment for: null");
+
+ BundleDeployment dep = null;
+ for (BundleDeployment auxDep : deployments)
+ {
+ if (url.equals(auxDep.getLocation()))
+ {
+ dep = auxDep;
+ break;
+ }
+ }
+
+ return dep;
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java (from rev 95022, projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -0,0 +1,261 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.deployment.internal;
+
+//$Id$
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.osgi.deployment.BundleDeployment;
+import org.jboss.osgi.deployment.BundleDeploymentFactory;
+import org.jboss.osgi.deployment.DeployerService;
+import org.jboss.osgi.deployment.DeploymentRegistryService;
+import org.jboss.osgi.spi.logging.ExportedPackageHelper;
+import org.jboss.osgi.spi.management.ManagedBundleService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class SystemDeployerService implements DeployerService
+{
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(SystemDeployerService.class);
+
+ private BundleContext context;
+ private ServiceTracker registryTracker;
+ private ServiceTracker startLevelTracker;
+
+ public SystemDeployerService(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void deploy(BundleDeployment[] depArr) throws BundleException
+ {
+ DeploymentRegistryService registry = getDeploymentRegistry();
+
+ List<Bundle> resolvableBundles = new ArrayList<Bundle>();
+ Map<BundleDeployment, Bundle> bundleMap = new HashMap<BundleDeployment, Bundle>();
+
+ for (BundleDeployment dep : depArr)
+ {
+ try
+ {
+ String location = dep.getLocation().toExternalForm();
+ Bundle bundle = context.installBundle(location);
+ log.info("Installed: " + bundle);
+
+ registerManagedBundle(bundle);
+
+ bundleMap.put(dep, bundle);
+ if (dep.isAutoStart())
+ resolvableBundles.add(bundle);
+
+ registry.registerBundleDeployment(dep);
+ }
+ catch (BundleException ex)
+ {
+ log.error( "Cannot install bundle: " + dep, ex);
+ }
+ }
+
+ // Resolve the installed bundles through the PackageAdmin
+ ServiceReference packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());
+ if (packageAdminRef != null && resolvableBundles.isEmpty() == false)
+ {
+ PackageAdmin packageAdmin = (PackageAdmin)context.getService(packageAdminRef);
+ Bundle[] resolvableBundleArr = new Bundle[resolvableBundles.size()];
+ resolvableBundles.toArray(resolvableBundleArr);
+ packageAdmin.resolveBundles(resolvableBundleArr);
+ }
+
+ // Start the installed bundles
+ for (Entry<BundleDeployment, Bundle> entry : bundleMap.entrySet())
+ {
+ BundleDeployment dep = entry.getKey();
+ Bundle bundle = entry.getValue();
+
+ StartLevel startLevel = getStartLevel();
+ if (dep.getStartLevel() > 0)
+ {
+ startLevel.setBundleStartLevel(bundle, dep.getStartLevel());
+ }
+
+ if (dep.isAutoStart())
+ {
+ int state = bundle.getState();
+ if (state == Bundle.RESOLVED || packageAdminRef == null)
+ {
+ try
+ {
+ log.debug( "Start: " + bundle);
+
+ // Added support for Bundle.START_ACTIVATION_POLICY on start
+ // http://issues.apache.org/jira/browse/FELIX-1317
+ // bundle.start(Bundle.START_ACTIVATION_POLICY);
+
+ bundle.start();
+
+ log.info("Started: " + bundle);
+ ExportedPackageHelper packageHelper = new ExportedPackageHelper(context);
+ packageHelper.logExportedPackages(bundle);
+ }
+ catch (BundleException ex)
+ {
+ log.error( "Cannot start bundle: " + bundle, ex);
+ }
+ }
+ }
+ }
+ }
+
+ public void undeploy(BundleDeployment[] depArr) throws BundleException
+ {
+ DeploymentRegistryService registry = getDeploymentRegistry();
+
+ for (BundleDeployment dep : depArr)
+ {
+ Bundle bundle = getBundle(dep);
+ if (bundle != null)
+ {
+ registry.unregisterBundleDeployment(dep);
+
+ unregisterManagedBundle(bundle);
+ bundle.uninstall();
+ log.info("Uninstalled: " + bundle);
+ }
+ else
+ {
+ log.warn( "Cannot obtain bundle for: " + dep);
+ }
+ }
+ }
+
+ public void deploy(URL url) throws BundleException
+ {
+ BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
+ deploy(new BundleDeployment[] { dep });
+ }
+
+ public boolean undeploy(URL url) throws BundleException
+ {
+ DeploymentRegistryService registry = getDeploymentRegistry();
+ BundleDeployment dep = registry.getBundleDeployment(url);
+ if (dep != null)
+ {
+ undeploy(new BundleDeployment[] { dep });
+ return true;
+ }
+ else
+ {
+ log.warn( "Cannot find deployment for: " + url);
+ return false;
+ }
+ }
+
+ private Bundle getBundle(BundleDeployment dep)
+ {
+ String symbolicName = dep.getSymbolicName();
+ Version version = Version.parseVersion(dep.getVersion());
+
+ Bundle bundle = null;
+ for (Bundle aux : context.getBundles())
+ {
+ if (aux.getSymbolicName().equals(symbolicName))
+ {
+ Version auxVersion = aux.getVersion();
+ if (version.equals(auxVersion))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ }
+ return bundle;
+ }
+
+ private void registerManagedBundle(Bundle bundle)
+ {
+ ServiceReference sref = context.getServiceReference(ManagedBundleService.class.getName());
+ if (sref != null)
+ {
+ ManagedBundleService service = (ManagedBundleService)context.getService(sref);
+ service.register(bundle);
+ }
+ else
+ {
+ log.debug( "No ManagedBundleService. Cannot register managed bundle: " + bundle);
+ }
+ }
+
+ private void unregisterManagedBundle(Bundle bundle)
+ {
+ ServiceReference sref = context.getServiceReference(ManagedBundleService.class.getName());
+ if (sref != null)
+ {
+ ManagedBundleService service = (ManagedBundleService)context.getService(sref);
+ service.unregister(bundle);
+ }
+ else
+ {
+ log.debug( "No ManagedBundleService. Cannot unregister managed bundle: " + bundle);
+ }
+ }
+
+ private DeploymentRegistryService getDeploymentRegistry()
+ {
+ if (registryTracker == null)
+ {
+ registryTracker = new ServiceTracker(context, DeploymentRegistryService.class.getName(), null);
+ registryTracker.open();
+ }
+ return (DeploymentRegistryService)registryTracker.getService();
+ }
+
+ private StartLevel getStartLevel()
+ {
+ if (startLevelTracker == null)
+ {
+ startLevelTracker = new ServiceTracker(context, StartLevel.class.getName(), null);
+ startLevelTracker.open();
+ }
+ return (StartLevel)startLevelTracker.getService();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-16 10:37:53 UTC (rev 95024)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-10-16 10:40:49 UTC (rev 95025)
@@ -23,9 +23,9 @@
//$Id$
+import static org.jboss.osgi.deployment.DeployerService.MBEAN_DEPLOYER_SERVICE;
import static org.jboss.osgi.spi.management.ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK;
import static org.jboss.osgi.spi.management.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
-import static org.jboss.osgi.spi.service.DeployerService.MBEAN_DEPLOYER_SERVICE;
import static org.jboss.test.osgi.service.microcontainer.bundleB.SomeBeanMBean.MBEAN_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -36,6 +36,7 @@
import javax.management.ObjectName;
+import org.jboss.osgi.deployment.DeployerService;
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.jmx.JMXCapability;
import org.jboss.osgi.jndi.JNDICapability;
@@ -43,7 +44,6 @@
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
-import org.jboss.osgi.spi.service.DeployerService;
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiTest;
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-10-16 10:37:53 UTC (rev 95024)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-10-16 10:40:49 UTC (rev 95025)
@@ -115,6 +115,11 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-deployment</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-husky</artifactId>
<scope>provided</scope>
</dependency>
16 years, 2 months