KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > verifier > tests > MdbContainerTest


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 /**
25  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31
32 package com.sun.enterprise.admin.verifier.tests;
33
34 /* Test case to check the validity of Mdb Container fields
35  * Author : srini@sun.com
36  */

37
38 // 8.0 XML Verifier
39
//import com.sun.enterprise.tools.verifier.Result;
40
import com.sun.enterprise.config.serverbeans.Server;
41 import com.sun.enterprise.config.serverbeans.*;
42 import com.sun.enterprise.config.ConfigContext;
43 import com.sun.enterprise.config.ConfigException;
44 import com.sun.enterprise.config.serverbeans.*;
45 import com.sun.enterprise.config.ConfigContextEvent;
46
47 import com.sun.enterprise.admin.verifier.*;
48 // Logging
49
import java.util.logging.Logger JavaDoc;
50 import java.util.logging.Level JavaDoc;
51 import com.sun.logging.LogDomains;
52
53
54
55 public class MdbContainerTest extends ServerXmlTest implements ServerCheck {
56     // Logging
57
static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
58     
59     public MdbContainerTest() {
60     }
61  
62     // check method invoked by the command line verifier
63
public Result check(ConfigContext context) {
64             Result result;
65             result = super.getInitializedResult();
66             // 8.0 XML Verifier
67
/*try {
68                 Server server = (Server)context.getRootConfigBean();
69                 MdbContainer mdb = server.getMdbContainer();
70                 try {
71                     String steadyPool = mdb.getSteadyPoolSize();
72                     if(Integer.parseInt(steadyPool) < 0)
73                         result.failed(smh.getLocalString(getClass().getName()+".steadyPoolNegative","Steady Pool size cannot be negative number"));
74                     else
75                         result.passed("Passed **");
76                 } catch(NumberFormatException e) {
77                     result.failed(smh.getLocalString(getClass().getName()+".steadyPoolInvalid","Steady Pool Size : invalid number"));
78                 }
79                 try {
80                     String maxPool = mdb.getMaxPoolSize();
81                     if(Integer.parseInt(maxPool) < 0)
82                         result.failed(smh.getLocalString(getClass().getName()+".maxPoolNegative","Max Pool size cannot be negative number"));
83                     else
84                         result.passed("Passed **");
85                 } catch(NumberFormatException e) {
86                     result.failed(smh.getLocalString(getClass().getName()+".maxPoolInvalid","Max Pool Size : invalid number"));
87                 }
88                 try {
89                     String poolResize = mdb.getPoolResizeQuantity();
90                     if(Integer.parseInt(poolResize) < 0)
91                         result.failed(smh.getLocalString(getClass().getName()+".resizeQtyNegative","Pool Resize Qty cannot be negative number"));
92                     else
93                         result.passed("Passed **");
94                 } catch(NumberFormatException e) {
95                     result.failed(smh.getLocalString(getClass().getName()+".resizeQtyInvalid","Pool Resize Qty : invalid number"));
96                 }
97                 try {
98                     String idleTimeout = mdb.getIdleTimeoutInSeconds();
99                     if(Integer.parseInt(idleTimeout) < 0)
100                         result.failed(smh.getLocalString(getClass().getName()+".idleTimeoutNegative","Idle Timeout in Seconds cannot be negative number"));
101                     else
102                         result.passed("Passed **");
103                 } catch(NumberFormatException e) {
104                     result.failed(smh.getLocalString(getClass().getName()+".idleTimeoutInvalid","Idle Timeout in Seconds : invalid number"));
105                 }
106             }
107             catch(Exception ex) {
108                 //<addition author="irfan@sun.com" [bug/rfe]-id="logging" >
109                 /*ex.printStackTrace();
110                 result.failed("Exception : " + ex.getMessage());*/

111                 /*_logger.log(Level.FINE, "serverxmlverifier.exception", ex);
112                 result.failed("Exception : " + ex.getMessage());
113                 //</addition>
114             }*/

115             return result;
116     }
117     
118     // check method called from the admin GUI and iasadmin
119
public Result check(ConfigContextEvent ccce) {
120                 Object JavaDoc value = ccce.getObject();
121                 ConfigContext context = ccce.getConfigContext();
122                 Result result = new Result();
123                 result.passed("Passed ** ");
124                 String JavaDoc beanName = ccce.getBeanName();
125                 if(beanName!=null) {
126                     String JavaDoc name = ccce.getName();
127                     if(name != null && value != null)
128                         result = validateAttribute(name, (String JavaDoc)value);
129                     return result;
130                 }
131                 
132                 return result;
133     }
134     
135     public Result validateAttribute(String JavaDoc name, String JavaDoc value) {
136             Result result = new Result();
137             boolean isFailed = false;
138             result.passed("Passed **");
139             if(name.equals(ServerTags.STEADY_POOL_SIZE)) {
140                 try {
141                     if(Integer.parseInt(value) < 0) {
142                         result.failed(smh.getLocalString(getClass().getName()+".steadyPoolNegative","Steady Pool size cannot be negative number"));
143                         isFailed = true;
144                     }
145                     else
146                         result.passed("Passed ***");
147                 } catch(NumberFormatException JavaDoc e) {
148                     result.failed(smh.getLocalString(getClass().getName()+".steadyPoolInvalid","Steady Pool Size : invalid number"));
149                     isFailed = true;
150                 }
151             }
152             if(name.equals(ServerTags.MAX_POOL_SIZE)) {
153                 try {
154                     if(Integer.parseInt(value) < 0) {
155                         result.failed(smh.getLocalString(getClass().getName()+".maxPoolNegative","Max Pool size cannot be negative number"));
156                         isFailed = true;
157                     }
158                     else
159                         result.passed("Passed ***");
160                 } catch(NumberFormatException JavaDoc e) {
161                     result.failed(smh.getLocalString(getClass().getName()+".maxPoolInvalid","Max Pool Size : invalid number"));
162                     isFailed = true;
163                 }
164             }
165             if(name.equals(ServerTags.POOL_RESIZE_QUANTITY)){
166                 try {
167                     if(Integer.parseInt(value) < 0) {
168                         result.failed(smh.getLocalString(getClass().getName()+".resizeQtyNegative","Pool Resize Qty cannot be negative number"));
169                         isFailed = true;
170                     }
171                     else
172                         result.passed("Passed ***");
173                 } catch(NumberFormatException JavaDoc e) {
174                     result.failed(smh.getLocalString(getClass().getName()+".resizeQtyInvalid","Pool Resize Qty : invalid number"));
175                     isFailed = true;
176                 }
177             }
178             if(name.equals(ServerTags.IDLE_TIMEOUT_IN_SECONDS)) {
179                 try {
180                     if(Integer.parseInt(value) < 0) {
181                         result.failed(smh.getLocalString(getClass().getName()+".idleTimeoutNegative","Idle Timeout in Seconds cannot be negative number"));
182                         isFailed = true;
183                     }
184                     else
185                         result.passed("Passed ***");
186                 } catch(NumberFormatException JavaDoc e) {
187                     result.failed(smh.getLocalString(getClass().getName()+".idleTimeoutInvalid","Idle Timeout in Seconds : invalid number"));
188                     isFailed = true;
189                 }
190             }
191             if(isFailed)
192                 result.setStatus(Result.FAILED);
193             return result;
194     }
195 }
196
Popular Tags