KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > connectors > util > ConnectorClassLoaderUtils


1
2 /*
3  * The contents of this file are subject to the terms
4  * of the Common Development and Distribution License
5  * (the License). You may not use this file except in
6  * compliance with the License.
7  *
8  * You can obtain a copy of the license at
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
10  * glassfish/bootstrap/legal/CDDLv1.0.txt.
11  * See the License for the specific language governing
12  * permissions and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL
15  * Header Notice in each file and include the License file
16  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
17  * If applicable, add the following below the CDDL Header,
18  * with the fields enclosed by brackets [] replaced by
19  * you own identifying information:
20  * "Portions Copyrighted [year] [name of copyright owner]"
21  *
22  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23  */

24
25 package com.sun.enterprise.connectors.util;
26
27 import com.sun.enterprise.connectors.*;
28 import com.sun.enterprise.util.*;
29 import java.io.IOException JavaDoc;
30 import java.lang.ClassLoader JavaDoc;
31 import com.sun.logging.LogDomains;
32 import java.util.logging.*;
33 import java.io.File JavaDoc;
34 import java.net.*;
35
36
37 /**
38  * This is an util class to get the ClassLoader pertaining to the
39  * stand alone connector modules.
40  * @author Srikanth P
41  */

42
43 public class ConnectorClassLoaderUtils {
44
45     static Logger _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER);
46     
47     /**
48      * Obtains the class loader. The Connector class loader is a
49      * singleton instance. The directory where rar is exploded is
50      * added to the classloader path before returing the instance.
51      * @param moduleDir Directory where rar is exploded
52      * @return connector Classloader instance
53      */

54
55     public static ClassLoader JavaDoc getClassLoader(String JavaDoc moduleDir) {
56         try {
57             ClassLoader JavaDoc jcl = null;
58             jcl = ConnectorClassLoader.getInstance();
59             File JavaDoc f = new File JavaDoc(moduleDir);
60                        ((ConnectorClassLoader)jcl).appendURL(f);
61             return jcl;
62         } catch (IOException JavaDoc ex) {
63             _logger.log(Level.SEVERE,
64                      "rardeployment.malfarmed_url_for_classloader",moduleDir);
65         }
66         return null;
67     }
68 }
69
Popular Tags