KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > validation > tests > ConnectorConnectionPoolTest


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.config.serverbeans.validation.tests;
25
26 import java.util.logging.Level JavaDoc;
27
28 import com.sun.enterprise.config.ConfigContextEvent;
29 import com.sun.enterprise.config.ConfigException;
30 import com.sun.enterprise.config.serverbeans.ConnectorConnectionPool;
31 import com.sun.enterprise.config.serverbeans.ServerBeansFactory;
32 import com.sun.enterprise.config.serverbeans.ServerTags;
33 import com.sun.enterprise.config.serverbeans.validation.GenericValidator;
34 import com.sun.enterprise.config.serverbeans.validation.Result;
35 import com.sun.enterprise.config.serverbeans.validation.ValidationDescriptor;
36 import com.sun.enterprise.connectors.ConnectorRuntime;
37 import java.util.Set JavaDoc;
38 import java.util.logging.Level JavaDoc;
39
40 /**
41     Custom Test for Connector Connection Pool Test which calls the Generic Validation before performing custom tests
42
43     @author Srinivas Krishnan
44     @version 2.0
45 */

46
47 public class ConnectorConnectionPoolTest extends GenericValidator {
48     
49     int maxPoolSize = 0;
50     
51     public ConnectorConnectionPoolTest(ValidationDescriptor desc) {
52         super(desc);
53     }
54     
55     public Result validate(ConfigContextEvent cce) {
56         Result result = super.validate(cce); // Before doing custom validation do basic validation
57
String JavaDoc choice = cce.getChoice();
58
59         if(choice.equals(StaticTest.UPDATE)) {
60             validateAttribute(cce.getName(), (String JavaDoc) cce.getObject(), result);
61         }
62         return result;
63     }
64
65
66
67         
68     
69     public void validateAttribute(String JavaDoc name, String JavaDoc value, Result result) {
70         if(value == null || value.equals(""))
71             return;
72         if(name.equals(ServerTags.CONNECTION_DEFINITION_NAME)) {
73         }
74     }
75     
76     public void validateAttribute(String JavaDoc name, String JavaDoc value, String JavaDoc rarName, Result result) {
77         try {
78             String JavaDoc connDefnNames[] = ConnectorRuntime.getRuntime().getConnectionDefinitionNames(rarName);
79             boolean available = false;
80             for(int i=0;i<connDefnNames.length;i++) {
81                 if(value.equals(connDefnNames[i])) {
82                     available = true;
83                     break;
84                 }
85             }
86             if(!available)
87                     result.failed(smh.getLocalString(getClass().getName() + ".connDefnNotAvl",
88                         "Attribute(conndefn={0}) : Invalid Connection Definition Name", new Object JavaDoc[]{value}));
89         } catch(Exception JavaDoc e) {
90             _logger.log(Level.FINE, "domainxmlverifier.exception", e);
91         }
92     }
93
94     private final ConnectorConnectionPool getConnectorConnectionPool(final ConfigContextEvent cce) throws ConfigException{
95         return (ConnectorConnectionPool) cce.getValidationTarget();
96     }
97     
98 }
99
Popular Tags