[jboss-cvs] JBossAS SVN: r84721 - projects/jboss-felix/trunk/modules/integration/deployer/src/main/java/org/jboss/osgi/deployer.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 25 06:37:28 EST 2009
Author: alesj
Date: 2009-02-25 06:37:28 -0500 (Wed, 25 Feb 2009)
New Revision: 84721
Modified:
projects/jboss-felix/trunk/modules/integration/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java
Log:
Simple refactoring.
Modified: projects/jboss-felix/trunk/modules/integration/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java
===================================================================
--- projects/jboss-felix/trunk/modules/integration/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java 2009-02-25 11:34:48 UTC (rev 84720)
+++ projects/jboss-felix/trunk/modules/integration/deployer/src/main/java/org/jboss/osgi/deployer/OSGiDeployer.java 2009-02-25 11:37:28 UTC (rev 84721)
@@ -27,83 +27,84 @@
import java.util.List;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
/**
* This is the OSGi Deployer
- *
+ *
* @author Thomas.Diesler at jboss.org
+ * @author Ales.Justin at jboss.org
* @since 03-Feb-2009
*/
-public class OSGiDeployer extends AbstractRealDeployer
+public class OSGiDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
{
- // provide logging
- private static final Logger log = Logger.getLogger(OSGiDeployer.class);
+ private BundleContext bundleContext;
+ private List<URI> skipBundles;
- private BundleContext bundleContext;
- private List<URI> skipBundles;
+ public OSGiDeployer()
+ {
+ super(OSGiMetaData.class);
+ }
- public OSGiDeployer()
- {
- setInput(OSGiMetaData.class);
- }
+ public void setBundleContext(BundleContext bundleContext)
+ {
+ this.bundleContext = bundleContext;
+ }
- public void setBundleContext(BundleContext bundleContext)
- {
- this.bundleContext = bundleContext;
- }
+ public void setSkipBundles(List<URI> skipBundles)
+ {
+ this.skipBundles = skipBundles;
+ }
- public void setSkipBundles(List<URI> skipBundles)
- {
- this.skipBundles = skipBundles;
- }
+ public void start()
+ {
+ if (bundleContext == null)
+ throw new IllegalArgumentException("No system bundle context.");
+ }
- @Override
- protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
- {
- OSGiMetaData metadata = unit.getAttachment(OSGiMetaData.class);
- log.info("Install Bundle: " + metadata.getSymbolicName());
-
- URI bundleUri = metadata.getBundleLocation();
- if (bundleUri == null)
- throw new IllegalStateException("Cannot obtain bundle location for: " + metadata);
-
- try
- {
- if (skipBundles.contains(bundleUri) == false)
- {
- Bundle bundle = bundleContext.installBundle(bundleUri.toString());
- bundle.start();
-
- unit.addAttachment(Bundle.class, bundle);
- }
- }
- catch (BundleException ex)
- {
- throw new DeploymentException("Cannot install bundle: " + metadata, ex);
- }
- }
+ public void deploy(DeploymentUnit unit, OSGiMetaData metadata) throws DeploymentException
+ {
+ log.info("Install Bundle: " + metadata.getSymbolicName());
- @Override
- protected void internalUndeploy(DeploymentUnit unit)
- {
- Bundle bundle = unit.getAttachment(Bundle.class);
- if (bundle != null)
- {
- log.info("Uninstall Bundle: " + bundle.getSymbolicName());
+ URI bundleUri = metadata.getBundleLocation();
+ if (bundleUri == null)
+ throw new IllegalStateException("Cannot obtain bundle location for: " + metadata);
+
try
{
- bundle.uninstall();
+ if (skipBundles != null && skipBundles.contains(bundleUri) == false)
+ {
+ Bundle bundle = bundleContext.installBundle(bundleUri.toString());
+ bundle.start();
+
+ unit.addAttachment(Bundle.class, bundle);
+ }
}
catch (BundleException ex)
{
- log.error(ex);
+ throw new DeploymentException("Cannot install bundle: " + metadata, ex);
}
- }
- }
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, OSGiMetaData osGiMetaData)
+ {
+ Bundle bundle = unit.getAttachment(Bundle.class);
+ if (bundle != null)
+ {
+ log.info("Uninstall Bundle: " + bundle.getSymbolicName());
+ try
+ {
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.error(ex);
+ }
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list