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