KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
35  * Test case to check the validity of the JavaConfig fields
36  *
37  * @author Venky TV
38  * @version $Revision: 1.3 $
39  */

40
41
42 import java.io.File JavaDoc;
43
44 // 8.0 XML Verifier
45
//import com.sun.enterprise.tools.verifier.Result;
46
import com.sun.enterprise.config.serverbeans.Server;
47 import com.sun.enterprise.config.serverbeans.*;
48 import com.sun.enterprise.config.serverbeans.Resources;
49 import com.sun.enterprise.config.serverbeans.Applications;
50 //import com.sun.enterprise.config.serverbeans.Mime;
51
import com.sun.enterprise.config.ConfigContext;
52 import com.sun.enterprise.config.ConfigException;
53 import com.sun.enterprise.config.serverbeans.*;
54 import com.sun.enterprise.config.ConfigContextEvent;
55
56 import com.sun.enterprise.admin.verifier.*;
57 // Logging
58
import java.util.logging.Logger JavaDoc;
59 import java.util.logging.Level JavaDoc;
60 import com.sun.logging.LogDomains;
61
62 public class JavaConfigTest extends ServerXmlTest implements ServerCheck {
63     
64      // Logging
65
static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
66     
67     public JavaConfigTest() {
68     }
69
70     // check method invoked by the command line verifier
71
// Does nothing right now
72
public Result check(ConfigContext context) {
73             Result result;
74             result = super.getInitializedResult();
75             return result;
76     }
77
78     // check method called from the admin GUI and iasadmin
79
public Result check(ConfigContextEvent ccce) {
80         Object JavaDoc value = ccce.getObject();
81         ConfigContext context = ccce.getConfigContext();
82         Result result = new Result();
83         result.passed("Passed ** ");
84         String JavaDoc beanName = ccce.getBeanName();
85         if(beanName!=null) {
86             String JavaDoc name = ccce.getName();
87             result = validateAttribute(name, (String JavaDoc)value);
88         }
89         return result;
90     }
91
92     public Result validateAttribute(String JavaDoc name, String JavaDoc value) {
93         Result result = new Result();
94         result.passed("Passed **");
95
96         if( name != null && name.equals( ServerTags.JAVA_HOME ) ) {
97
98             if( value == null ) {
99                 result.failed( "Java Home value is null" );
100                 return( result );
101             }
102
103             /* Check if <java-home>/jre is a valid directory */
104             String JavaDoc jreDir = value + File.separator + "jre";
105             try {
106                 File JavaDoc f = new File JavaDoc( jreDir );
107                 if( ! f.isDirectory() ) {
108                     result.failed( "Invalid Java Home: "
109                             + "Could not find the jre directory under "
110                             + value );
111                     return( result );
112                 }
113             }
114             catch( Exception JavaDoc e ) {
115                 result.failed( e.getMessage() );
116                 return( result );
117             }
118
119         }
120         return( result );
121     }
122 }
123
Popular Tags