KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > diagnostics > PELocalTargetResolver


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 package com.sun.enterprise.diagnostics;
24
25 import java.io.File JavaDoc;
26 import java.util.logging.Level JavaDoc;
27
28 /**
29  *
30  * @author mu125243
31  */

32 public class PELocalTargetResolver extends TargetResolver {
33     
34     /** Creates a new instance of PELocalTargetResolver */
35     public PELocalTargetResolver(String JavaDoc target, String JavaDoc repositoryDir, boolean local) {
36         super(target,repositoryDir,local);
37     }
38     
39     /**
40      * Combination of targetDir and target in local mode is expected
41      * to be appserver's nodeagent's or server instance's directory structure
42      * @param targetDir targetDir in local mode
43      * @param target target name for which report generation is initiated
44      * @return true if directory structure seems inline with nodeagent / instance
45      * directory structure
46      * @throw DiagnosticException if targetDir and target are null
47      */

48     public boolean validateTarget() throws DiagnosticException {
49         if(repositoryDir != null && target != null){
50             logger.log(Level.FINEST, "validate_local_target" , new String JavaDoc[]{target, repositoryDir});
51             return isAInstance(repositoryDir,target);
52         } // if
53
throw new DiagnosticException("Targetdir and targetname are null");
54     }
55     
56     private boolean isAInstance(String JavaDoc repositoryDir, String JavaDoc target) {
57         if(repositoryDir != null && target != null){
58             String JavaDoc absoluteDir = repositoryDir + File.separator + target;
59             File JavaDoc applicationsDirObj = new File JavaDoc(absoluteDir +
60                     Constants.APPLICATIONS_DIR);
61             File JavaDoc generatedDirObj = new File JavaDoc(absoluteDir +
62                     Constants.GENERATED_DIR);
63             File JavaDoc configDirObj = new File JavaDoc(absoluteDir +
64                     Constants.CONFIG_DIR);
65             if(applicationsDirObj.exists() &&
66                     generatedDirObj.exists() &&
67                     configDirObj.exists())
68                 return true;
69             return false;
70         }//if
71
return false;
72     }
73     
74     protected void determineRepositoryDetails() {
75         repositoryName = target;
76     }
77
78     protected void setExecutionContext() {
79         context = ExecutionContext.LOCAL_EC;
80     
81     }
82     
83     protected void determineTargetType() {
84         if(type == null)
85             setTargetType(TargetType.DAS);
86     }
87     
88     protected void determineTargetDir() {
89         //do nothing
90
}
91     
92     protected void determineInstances(){
93         addInstance(TargetType.DAS.getType());
94     }
95
96 }
97
Popular Tags