KickJava   Java API By Example, From Geeks To Geeks.

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


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 Applications fields
35  * Author : srini@sun.com
36  */

37
38
39 // 8.0 XML Verifier
40
//import com.sun.enterprise.tools.verifier.Result;
41
import com.sun.enterprise.config.serverbeans.Server;
42 import com.sun.enterprise.config.serverbeans.*;
43 import com.sun.enterprise.config.serverbeans.Resources;
44 import com.sun.enterprise.config.serverbeans.Applications;
45 import com.sun.enterprise.config.ConfigContext;
46 import com.sun.enterprise.config.ConfigException;
47 import com.sun.enterprise.config.serverbeans.*;
48 import com.sun.enterprise.config.ConfigContextEvent;
49
50 import com.sun.enterprise.admin.verifier.*;
51
52 // Logging
53
import java.util.logging.Logger JavaDoc;
54 import java.util.logging.Level JavaDoc;
55 import com.sun.logging.LogDomains;
56
57
58 public class ApplicationsTest extends ServerXmlTest implements ServerCheck {
59     
60      // Logging
61
static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
62     
63     public ApplicationsTest() {
64     }
65  
66     // check method invoked by the command line verifier
67
public Result check(ConfigContext context) {
68             Result result;
69             result = super.getInitializedResult();
70             // 8.0 XML Verifier
71
/*try {
72                 Server server = (Server)context.getRootConfigBean();
73                 Applications app = server.getApplications();
74                 String pollInterval = app.getDynamicReloadPollIntervalInSeconds();
75                 try {
76                     if(Integer.parseInt(pollInterval) < 0)
77                         //result.failed("Reload Poll Interval cannot be negative number");
78                         result.failed(smh.getLocalString(getClass().getName() + ".reloadNegative","Reload Poll Interval cannot be negative number"));
79                     else
80                         result.passed("Passed *** ");
81                 } catch(NumberFormatException e) {
82                     //result.failed("Reload Poll Interval : invalid number");
83                     result.failed(smh.getLocalString(getClass().getName()+".reloadInvalid","Reload Poll Interval : invalid number"));
84                 }
85             }
86             catch(Exception ex) {
87                 // Logging
88                 _logger.log(Level.FINE, "serverxmlverifier.exception", ex);
89                 result.failed("Exception : " + ex.getMessage());
90             }*/

91             return result;
92     }
93     
94     // check method called from the admin GUI and iasadmin
95
public Result check(ConfigContextEvent ccce) {
96                 Object JavaDoc value = ccce.getObject();
97                 ConfigContext context = ccce.getConfigContext();
98                 Result result = new Result();
99                 result.passed("Passed ** ");
100                 String JavaDoc beanName = ccce.getBeanName();
101                 if(beanName!=null) {
102                     String JavaDoc name = ccce.getName();
103                     if(name != null && value != null)
104                         result = validateAttribute(name, (String JavaDoc)value);
105                     return result;
106                 }
107                 
108                 return result;
109     }
110     
111     public Result validateAttribute(String JavaDoc name, String JavaDoc value) {
112             boolean failed = false;
113             Result result = new Result();
114             result.passed("Passed **");
115             if(name.equals(ServerTags.DYNAMIC_RELOAD_POLL_INTERVAL_IN_SECONDS)) {
116                 try {
117                     if(Integer.parseInt(value) < 0) {
118                         //result.failed("Reload poll Interval cannot be negative number");
119
result.failed(smh.getLocalString(getClass().getName()+ ".reloadNegative","Reload Poll Interval cannot be negative number"));
120                         failed = true;
121                     }
122                     else
123                         result.passed("passed ***");
124                 } catch(NumberFormatException JavaDoc e) {
125                     //result.failed("Reload Poll Interval : invalid number");
126
result.failed(smh.getLocalString(getClass().getName()+".reloadInvalid","Reload Poll Interval : invalid number"));
127                     failed = true;
128                 }
129             }
130             if(failed)
131                 result.setStatus(Result.FAILED);
132             return result;
133     }
134     
135 }
136
Popular Tags