PageRenderTime 30ms CodeModel.GetById 4ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/osgi/service/src/main/java/org/jboss/as/osgi/deployment/BundleInstallProcessor.java

#
Java | 58 lines | 23 code | 6 blank | 29 comment | 4 complexity | 5a916ce52f29c697f456ab3935b0d09e MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2010, Red Hat, Inc., and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.osgi.deployment;
  23. import org.jboss.as.server.deployment.DeploymentPhaseContext;
  24. import org.jboss.as.server.deployment.DeploymentUnit;
  25. import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
  26. import org.jboss.as.server.deployment.DeploymentUnitProcessor;
  27. import org.jboss.osgi.deployment.deployer.Deployment;
  28. /**
  29. * Processes deployments that have OSGi metadata attached.
  30. *
  31. * If so, it creates an {@link BundleInstallService}.
  32. *
  33. * @author Thomas.Diesler@jboss.com
  34. * @since 20-Sep-2010
  35. */
  36. public class BundleInstallProcessor implements DeploymentUnitProcessor {
  37. @Override
  38. public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  39. final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
  40. final Deployment deployment = OSGiDeploymentAttachment.getDeployment(depUnit);
  41. if (deployment != null) {
  42. BundleInstallService.addService(phaseContext, deployment);
  43. }
  44. }
  45. @Override
  46. public void undeploy(final DeploymentUnit depUnit) {
  47. final Deployment deployment = OSGiDeploymentAttachment.getDeployment(depUnit);
  48. if (deployment != null) {
  49. BundleInstallService.removeService(depUnit);
  50. }
  51. }
  52. }