001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.j2ee.deployment;
018    
019    import java.io.File;
020    import java.util.Collection;
021    import java.util.HashMap;
022    import java.util.Map;
023    
024    import org.apache.geronimo.common.DeploymentException;
025    import org.apache.geronimo.deployment.DeploymentContext;
026    import org.apache.geronimo.gbean.AbstractName;
027    import org.apache.geronimo.gbean.AbstractNameQuery;
028    import org.apache.geronimo.kernel.Naming;
029    import org.apache.geronimo.kernel.config.ConfigurationManager;
030    import org.apache.geronimo.kernel.config.ConfigurationModuleType;
031    import org.apache.geronimo.kernel.repository.Environment;
032    
033    /**
034     * @version $Rev:386276 $ $Date: 2007-05-05 07:12:52 -0400 (Sat, 05 May 2007) $
035     */
036    public class EARContext extends DeploymentContext {
037    
038        private final AbstractNameQuery serverName;
039        private final AbstractNameQuery transactionManagerObjectName;
040        private final AbstractNameQuery connectionTrackerObjectName;
041        private final AbstractNameQuery transactedTimerName;
042        private final AbstractNameQuery nonTransactedTimerName;
043        private final AbstractNameQuery corbaGBeanObjectName;
044    
045        private final Map contextIDToPermissionsMap = new HashMap();
046        private AbstractName jaccManagerName;
047        private Object securityConfiguration;
048    
049        private final Map  messageDestinations;
050    
051        private final Map<Object,Object> generalData = new HashMap<Object,Object>();
052    
053        public EARContext(File baseDir,
054                File inPlaceConfigurationDir,
055                Environment environment,
056                ConfigurationModuleType moduleType,
057                Naming naming,
058                ConfigurationManager configurationManager, 
059                Collection repositories,
060                AbstractNameQuery serverName,
061                AbstractName baseName,
062                AbstractNameQuery transactionManagerObjectName,
063                AbstractNameQuery connectionTrackerObjectName,
064                AbstractNameQuery transactedTimerName,
065                AbstractNameQuery nonTransactedTimerName,
066                AbstractNameQuery corbaGBeanObjectName
067        ) throws DeploymentException {
068            super(baseDir, inPlaceConfigurationDir, environment, baseName, moduleType, naming, configurationManager, repositories);
069    
070            this.serverName = serverName;
071            this.transactionManagerObjectName = transactionManagerObjectName;
072            this.connectionTrackerObjectName = connectionTrackerObjectName;
073            this.transactedTimerName = transactedTimerName;
074            this.nonTransactedTimerName = nonTransactedTimerName;
075            this.corbaGBeanObjectName = corbaGBeanObjectName;
076            this.messageDestinations = new HashMap();
077        }
078    
079        public EARContext(File baseDir,
080                File inPlaceConfigurationDir,
081                Environment environment,
082                ConfigurationModuleType moduleType,
083                Naming naming,
084                ConfigurationManager configurationManager,
085                AbstractNameQuery serverName,
086                AbstractName baseName,
087                AbstractNameQuery transactionManagerObjectName,
088                AbstractNameQuery connectionTrackerObjectName,
089                AbstractNameQuery transactedTimerName,
090                AbstractNameQuery nonTransactedTimerName,
091                AbstractNameQuery corbaGBeanObjectName,
092                Map messageDestinations) throws DeploymentException {
093            super(baseDir, inPlaceConfigurationDir, environment, baseName, moduleType, naming, configurationManager);
094    
095            this.serverName = serverName;
096    
097            this.transactionManagerObjectName = transactionManagerObjectName;
098            this.connectionTrackerObjectName = connectionTrackerObjectName;
099            this.transactedTimerName = transactedTimerName;
100            this.nonTransactedTimerName = nonTransactedTimerName;
101            this.corbaGBeanObjectName = corbaGBeanObjectName;
102            this.messageDestinations = messageDestinations;
103        }
104    
105        public EARContext(File baseDir, File inPlaceConfigurationDir, Environment environment, ConfigurationModuleType moduleType, AbstractName baseName, EARContext parent) throws DeploymentException {
106            super(baseDir, inPlaceConfigurationDir, environment, baseName, moduleType, parent.getNaming(), parent.getConfigurationManager());
107            this.serverName = parent.getServerName();
108    
109            this.transactionManagerObjectName = parent.getTransactionManagerName();
110            this.connectionTrackerObjectName = parent.getConnectionTrackerName();
111            this.transactedTimerName = parent.getTransactedTimerName();
112            this.nonTransactedTimerName = parent.getNonTransactedTimerName();
113            this.corbaGBeanObjectName = parent.getCORBAGBeanName();
114            this.messageDestinations  = new HashMap();
115        }
116    
117        public AbstractNameQuery getServerName() {
118            return serverName;
119        }
120    
121        public AbstractNameQuery getTransactionManagerName() {
122            return transactionManagerObjectName;
123        }
124    
125        public AbstractNameQuery getConnectionTrackerName() {
126            return connectionTrackerObjectName;
127        }
128    
129        public AbstractNameQuery getTransactedTimerName() {
130            return transactedTimerName;
131        }
132    
133        public AbstractNameQuery getNonTransactedTimerName() {
134            return nonTransactedTimerName;
135        }
136    
137        public AbstractNameQuery getCORBAGBeanName() {
138            return corbaGBeanObjectName;
139        }
140    
141        public Map getContextIDToPermissionsMap() {
142            return contextIDToPermissionsMap;
143        }
144    
145        public void addSecurityContext(String contextID, Object componentPermissions) throws DeploymentException {
146            Object old = contextIDToPermissionsMap.put(contextID, componentPermissions);
147            if (old != null) {
148                throw new DeploymentException("Duplicate contextID registered! " + contextID);
149            }
150        }
151    
152        public void setJaccManagerName(AbstractName jaccManagerName) {
153            this.jaccManagerName = jaccManagerName;
154        }
155    
156        public AbstractName getJaccManagerName() {
157            return jaccManagerName;
158        }
159    
160        public void setSecurityConfiguration(Object securityConfiguration) throws DeploymentException {
161            if (this.securityConfiguration != null) {
162                throw new DeploymentException("Only one security configuration allowed per application");
163            }
164            this.securityConfiguration = securityConfiguration;
165        }
166    
167        public Object getSecurityConfiguration() {
168            return securityConfiguration;
169        }
170    
171        public void registerMessageDestionations(String moduleName, Map nameMap) throws DeploymentException {
172            messageDestinations.put(moduleName, nameMap);
173        }
174    
175        public Map getMessageDestinations() {
176            return messageDestinations;
177        }
178    
179        public Map<Object,Object> getGeneralData() {
180            return generalData;
181        }
182    }