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.connector.outbound.connectiontracking;
018    
019    import java.util.Collections;
020    import java.util.HashMap;
021    import java.util.Map;
022    import java.util.Set;
023    
024    /**
025     * @version $Rev: 550546 $ $Date: 2007-06-25 12:52:11 -0400 (Mon, 25 Jun 2007) $
026     */
027    public class SharedConnectorInstanceContext implements ConnectorInstanceContext {
028    
029        private Map connectionManagerMap = new HashMap();
030    
031        private final Set unshareableResources;
032        private final Set applicationManagedSecurityResources;
033    
034        private boolean hide = false;
035    
036        public SharedConnectorInstanceContext(Set unshareableResources, Set applicationManagedSecurityResources, boolean share) {
037            this.unshareableResources = unshareableResources;
038            this.applicationManagedSecurityResources = applicationManagedSecurityResources;
039            if (!share) {
040                connectionManagerMap = new HashMap();
041            }
042        }
043    
044        public void share(SharedConnectorInstanceContext context) {
045            connectionManagerMap = context.connectionManagerMap;
046        }
047    
048        public void hide() {
049            this.hide = true;
050        }
051    
052        public Map getConnectionManagerMap() {
053            if (hide) {
054                return Collections.EMPTY_MAP;
055            }
056            return connectionManagerMap;
057        }
058    
059        public Set getUnshareableResources() {
060            return unshareableResources;
061        }
062    
063        public Set getApplicationManagedSecurityResources() {
064            return applicationManagedSecurityResources;
065        }
066    }