KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > appclient > jws > boot > ClassPathManager15


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.appclient.jws.boot;
24
25 import java.io.File JavaDoc;
26 import java.net.MalformedURLException JavaDoc;
27 import java.net.URI JavaDoc;
28 import java.net.URISyntaxException JavaDoc;
29 import java.net.URL JavaDoc;
30
31 /**
32  * Class Path manager for Java Web Start-aware ACC running under Java runtime 1.5.x.
33  *
34  * @author tjquinn
35  */

36 public class ClassPathManager15 extends ClassPathManager {
37     
38     /**
39      *Return a new instance of the manager
40      *@param loader the Java Web Start-provided class loader
41      */

42     protected ClassPathManager15(ClassLoader JavaDoc loader) {
43         super(loader);
44     }
45     
46     public ClassLoader JavaDoc getParentClassLoader() {
47         return null;
48     }
49
50     public File JavaDoc findContainingJar(URL JavaDoc resourceURL) throws IllegalArgumentException JavaDoc, URISyntaxException JavaDoc {
51         File JavaDoc result = null;
52         if (resourceURL != null) {
53             URI JavaDoc uri = resourceURL.toURI();
54             String JavaDoc scheme = uri.getScheme();
55             String JavaDoc ssp = uri.getSchemeSpecificPart();
56             if (scheme.equals("jar")) {
57                 /*
58                  *The scheme-specific part will look like "file:<file-spec>!/<path-to-class>.class"
59                  *so we need to isolate the scheme and the <file-spec> part.
60                  *The subscheme (the scheme within the jar) precedes the colon
61                  *and the file spec appears after it and before the exclamation point.
62                  */

63                 int colon = ssp.indexOf(':');
64                 String JavaDoc subscheme = ssp.substring(0, colon);
65                 int excl = ssp.indexOf('!');
66                 String JavaDoc containingJarPath = ssp.substring(colon + 1, excl);
67                 result = new File JavaDoc(containingJarPath);
68             } else {
69                 throw new IllegalArgumentException JavaDoc(resourceURL.toExternalForm());
70             }
71         }
72         return result;
73     }
74     
75
76 }
Popular Tags