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 org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor; 020 import org.apache.geronimo.connector.outbound.ConnectionInfo; 021 022 import java.util.Collections; 023 import java.util.HashMap; 024 import java.util.Map; 025 import java.util.Set; 026 027 /** 028 * @version $Rev: 585608 $ $Date: 2007-10-17 19:56:54 +0200 (Wed, 17 Oct 2007) $ 029 */ 030 public class SharedConnectorInstanceContext implements ConnectorInstanceContext { 031 032 private Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerMap = new HashMap<ConnectionTrackingInterceptor, Set<ConnectionInfo>>(); 033 034 private final Set<String> unshareableResources; 035 private final Set<String> applicationManagedSecurityResources; 036 037 private boolean hide = false; 038 039 public SharedConnectorInstanceContext(Set<String> unshareableResources, Set<String> applicationManagedSecurityResources, boolean share) { 040 this.unshareableResources = unshareableResources; 041 this.applicationManagedSecurityResources = applicationManagedSecurityResources; 042 if (!share) { 043 connectionManagerMap = new HashMap<ConnectionTrackingInterceptor, Set<ConnectionInfo>>(); 044 } 045 } 046 047 public void share(SharedConnectorInstanceContext context) { 048 connectionManagerMap = context.connectionManagerMap; 049 } 050 051 public void hide() { 052 this.hide = true; 053 } 054 055 public Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> getConnectionManagerMap() { 056 if (hide) { 057 return Collections.emptyMap(); 058 } 059 return connectionManagerMap; 060 } 061 062 public Set<String> getUnshareableResources() { 063 return unshareableResources; 064 } 065 066 public Set<String> getApplicationManagedSecurityResources() { 067 return applicationManagedSecurityResources; 068 } 069 }