KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.sun.enterprise.config.ConfigContext;
26 import com.sun.enterprise.config.ConfigException;
27 import com.sun.enterprise.config.serverbeans.ServerHelper;
28 import com.sun.enterprise.server.ApplicationServer;
29 import com.sun.enterprise.server.ServerContext;
30 import java.io.File JavaDoc;
31 import java.util.logging.Level JavaDoc;
32
33 /**
34  *
35  * @author mu125243
36  */

37 public class PERemoteTargetResolver extends TargetResolver {
38     
39     private static final String JavaDoc REPOSITORY_CONFIG_CLASS_NAME =
40             "com.sun.enterprise.admin.servermgmt.DomainConfig";
41     private static final String JavaDoc GET_REP_ROOT_METHOD ="getRepositoryRoot";
42     private static final String JavaDoc GET_REP_NAME = "getRepositoryName";
43     
44     /** Creates a new instance of PERemoteTargetResolver */
45     public PERemoteTargetResolver(String JavaDoc target, String JavaDoc repositoryDir, boolean local) {
46         super(target,repositoryDir,local);
47     }
48     
49     
50     public boolean validateTarget() throws DiagnosticException {
51         ConfigContext configContext = getServerContext().getConfigContext();
52         try {
53             String JavaDoc domainName = ServerHelper.getAdministrativeDomainName(
54                     configContext,null);
55             
56             if(domainName != null)
57                 return domainName.equals(target);
58         } catch(ConfigException ce) {
59             throw new DiagnosticException("Couldn't determine domain name");
60         }
61         throw new DiagnosticException("Couldn't determine domain name");
62     }
63     
64     
65     protected ServerContext getServerContext() {
66         return ApplicationServer.getServerContext();
67     }
68     
69     protected void setExecutionContext() {
70         context = ExecutionContext.REMOTE_EC;
71     }
72     
73     protected void determineRepositoryDetails() {
74           File JavaDoc instanceRoot = new File JavaDoc(getServerContext().
75                     getInstanceEnvironment().getInstancesRoot());
76           repositoryDir = instanceRoot.getParentFile().getAbsolutePath();
77           repositoryName = instanceRoot.getName();
78
79           logger.log(Level.FINE, "diagnostic-service.resolver_repositoryDetails",
80                     new Object JavaDoc[] {repositoryDir, repositoryName});
81         /*try {
82             Class classObj = Class.forName(REPOSITORY_CONFIG_CLASS_NAME);
83             Constructor constructorObj =
84                     classObj.getDeclaredConstructor(new Class[]{});
85             Object obj = constructorObj.newInstance(new Object[]{});
86             Method method = classObj.getMethod(GET_REP_ROOT_METHOD, null);
87             repositoryDir = (String)method.invoke(obj, null);
88
89             method = classObj.getMethod(GET_REP_NAME, null);
90             repositoryName = (String)method.invoke(obj, null);
91             
92             logger.log(Level.FINEST,
93                 "diagnostic-service.target_dir", repositoryDir);
94                 if(type.equals(EETargetType.INSTANCE)) {
95                     targetDir = targetDir + File.separator + naName + File.separator + target;
96                 } else {
97                     targetDir = targetDir + File.separator + target;
98                 }
99         } catch(Exception e){
100             // WILL NEVER
101         }*/

102     }
103     
104     protected void determineTargetType() {
105         if(type == null)
106             setTargetType(TargetType.DAS);
107     }
108     
109     protected void determineInstances(){
110         addInstance(TargetType.DAS.getType());
111     }
112   
113   
114 }
115
Popular Tags