PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/jboss-as-7.1.1.Final/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/EjbDependencyDeploymentUnitProcessor.java

#
Java | 114 lines | 39 code | 20 blank | 55 comment | 3 complexity | 05bdc3e55ed78ca58fd762aeb2b2d1dd MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright (c) 2011, 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.ejb3.deployment.processors;
  23. import org.jboss.as.ee.structure.DeploymentType;
  24. import org.jboss.as.ee.structure.DeploymentTypeMarker;
  25. import org.jboss.as.server.deployment.Attachments;
  26. import org.jboss.as.server.deployment.DeploymentPhaseContext;
  27. import org.jboss.as.server.deployment.DeploymentUnit;
  28. import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
  29. import org.jboss.as.server.deployment.DeploymentUnitProcessor;
  30. import org.jboss.as.server.deployment.module.ModuleDependency;
  31. import org.jboss.as.server.deployment.module.ModuleSpecification;
  32. import org.jboss.modules.Module;
  33. import org.jboss.modules.ModuleIdentifier;
  34. import org.jboss.modules.ModuleLoader;
  35. import static org.jboss.as.ejb3.deployment.EjbDeploymentMarker.isEjbDeployment;
  36. /**
  37. * Responsible for adding appropriate Java EE {@link org.jboss.as.server.deployment.module.ModuleDependency module dependencies}
  38. * <p/>
  39. * Author : Jaikiran Pai
  40. */
  41. public class EjbDependencyDeploymentUnitProcessor implements DeploymentUnitProcessor {
  42. // TODO: This should be centralized some place
  43. /**
  44. * Module id for Java EE module
  45. */
  46. private static final ModuleIdentifier JAVAEE_MODULE_IDENTIFIER = ModuleIdentifier.create("javaee.api");
  47. /**
  48. * Needed for timer handle persistence
  49. * TODO: restrict visibility
  50. */
  51. private static final ModuleIdentifier EJB_SUBSYSTEM = ModuleIdentifier.create("org.jboss.as.ejb3");
  52. private static final ModuleIdentifier EJB_CLIENT = ModuleIdentifier.create("org.jboss.ejb-client");
  53. private static final ModuleIdentifier EJB_IIOP_CLIENT = ModuleIdentifier.create("org.jboss.iiop-client");
  54. private static final ModuleIdentifier JACORB = ModuleIdentifier.create("org.jboss.as.jacorb");
  55. /**
  56. * Adds Java EE module as a dependency to any deployment unit which is a EJB deployment
  57. *
  58. * @param phaseContext the deployment unit context
  59. * @throws DeploymentUnitProcessingException
  60. *
  61. */
  62. @Override
  63. public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  64. // get hold of the deployment unit
  65. DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
  66. final ModuleLoader moduleLoader = Module.getBootModuleLoader();
  67. final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
  68. //we always give them the EJB client
  69. moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, EJB_CLIENT, false, false, false, false));
  70. moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, EJB_IIOP_CLIENT, false, false, false, false));
  71. //we always have to add this, as even non-ejb deployments may still lookup IIOP ejb's
  72. moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, EJB_SUBSYSTEM, false, false, false, false));
  73. /*
  74. if (JacORBDeploymentMarker.isJacORBDeployment(deploymentUnit)) {
  75. //needed for dynamic IIOP stubs
  76. moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JACORB, false, false, false, false));
  77. }
  78. */
  79. // fetch the EjbJarMetaData
  80. //TODO: remove the app client bit after the next EJB release
  81. if (!isEjbDeployment(deploymentUnit) && !DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
  82. // nothing to do
  83. return;
  84. }
  85. // FIXME: still not the best way to do it
  86. //this must be the first dep listed in the module
  87. if (Boolean.getBoolean("org.jboss.as.ejb3.EMBEDDED"))
  88. moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.CLASSPATH, false, false, false, false));
  89. moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAVAEE_MODULE_IDENTIFIER, false, false, false, false));
  90. }
  91. @Override
  92. public void undeploy(DeploymentUnit context) {
  93. }
  94. }