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