KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > connectors > util > ConnectionPoolReconfigHelper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.connectors.util;
25
26 import com.sun.enterprise.connectors.*;
27 import com.sun.enterprise.deployment.runtime.connector.*;
28 import com.sun.enterprise.deployment.*;
29 import com.sun.enterprise.connectors.util.SecurityMapUtils;
30 import com.sun.logging.*;
31 import java.util.logging.Logger JavaDoc;
32 import java.util.logging.Level JavaDoc;
33 import java.util.Set JavaDoc;
34 import com.sun.enterprise.connectors.authentication.RuntimeSecurityMap;
35 import com.sun.enterprise.connectors.authentication.ConnectorSecurityMap;
36 /**
37  */

38
39 public class ConnectionPoolReconfigHelper {
40
41     private static Logger JavaDoc _logger = LogDomains.getLogger( LogDomains.RSR_LOGGER );
42     
43
44     public enum ReconfigAction { RECREATE_POOL, UPDATE_MCF_AND_ATTRIBUTES, NO_OP };
45
46     public static ReconfigAction compare( ConnectorConnectionPool oldPool,
47             ConnectorConnectionPool newPool, Set JavaDoc excludedProps )
48         throws ConnectorRuntimeException
49     {
50
51         if ( isEqualConnectorConnectionPool( oldPool, newPool , excludedProps )
52         == ReconfigAction.NO_OP ) {
53     
54         return ReconfigAction.UPDATE_MCF_AND_ATTRIBUTES;
55     }
56         
57     return ReconfigAction.RECREATE_POOL;
58
59     }
60
61     /*
62      * Compare the Original ConnectorConnectionPool with the passed one
63      * If MCF properties are changed, indicate that pool recreation is
64      * required
65      * We only check the MCF properties since a pool restart is required
66      * for changes in MCF props. For pool specific properties we can get
67      * away without restart
68      * If the new pool and old pool have identical MCF properties returns
69      * true
70      */

71     private static ReconfigAction isEqualConnectorConnectionPool( ConnectorConnectionPool
72             oldCcp, ConnectorConnectionPool newCcp, Set JavaDoc excludedProps )
73     {
74         boolean poolsEqual = true;
75         
76     //for all the following properties, we need to recreate pool if they
77
//have changed
78
if (newCcp.getTransactionSupport() != oldCcp.getTransactionSupport() ) {
79         return ReconfigAction.RECREATE_POOL;
80     }
81
82     if (newCcp.isAssociateWithThread() != oldCcp.isAssociateWithThread() ) {
83         return ReconfigAction.RECREATE_POOL;
84     }
85
86     if (newCcp.isLazyConnectionAssoc() != oldCcp.isLazyConnectionAssoc() ) {
87         return ReconfigAction.RECREATE_POOL;
88     }
89
90     
91         ConnectorDescriptorInfo oldCdi = oldCcp.getConnectorDescriptorInfo();
92         ConnectorDescriptorInfo newCdi = newCcp.getConnectorDescriptorInfo();
93
94     if (! oldCdi.getResourceAdapterClassName().equals(
95             newCdi.getResourceAdapterClassName()) ) {
96         
97         logFine(
98             "isEqualConnectorConnectionPool: getResourceAdapterClassName:: " +
99              oldCdi.getResourceAdapterClassName() + " -- " +
100          newCdi.getResourceAdapterClassName());
101         return ReconfigAction.RECREATE_POOL;
102     }
103
104     if (! oldCdi.getConnectionDefinitionName().equals(
105             newCdi.getConnectionDefinitionName()) ) {
106         
107         logFine(
108             "isEqualConnectorConnectionPool: getConnectionDefinitionName:: "+
109             oldCdi.getConnectionDefinitionName() + " -- " +
110         newCdi.getConnectionDefinitionName());
111         
112         return ReconfigAction.RECREATE_POOL;
113     }
114
115     ConnectorSecurityMap[] newSecurityMaps = newCcp.getSecurityMaps();
116     RuntimeSecurityMap newRuntimeSecurityMap =
117         SecurityMapUtils.processSecurityMaps(newSecurityMaps);
118     ConnectorSecurityMap[] oldSecurityMaps = oldCcp.getSecurityMaps();
119     RuntimeSecurityMap oldRuntimeSecurityMap =
120         SecurityMapUtils.processSecurityMaps(oldSecurityMaps);
121     if (!( oldRuntimeSecurityMap.equals(newRuntimeSecurityMap) )){
122         logFine("isEqualConnectorConnectionPool: CCP.getSecurityMaps:: " +
123                 "New set of Security Maps is not equal to the existing" +
124                 " set of security Maps.");
125         return ReconfigAction.RECREATE_POOL;
126     }
127     
128     Set JavaDoc newMCFConfigProps = newCdi.getMCFConfigProperties();
129     Set JavaDoc oldMCFConfigProps = oldCdi.getMCFConfigProperties();
130         return oldCdi.compareMCFConfigProperties( newCdi, excludedProps );
131     }
132     
133     private static void logFine( String JavaDoc msg ) {
134         if (msg != null && _logger.isLoggable(Level.FINE)) {
135         _logger.fine( msg );
136     }
137     }
138 }
139
Popular Tags