KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > internal > protocol > reference > Handler


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.osgi.framework.internal.protocol.reference;
13
14 import java.io.IOException JavaDoc;
15 import java.net.*;
16
17 /**
18  * URLStreamHandler for reference protocol. A reference URL is used to hold a
19  * reference to a local file URL. A reference URL allows bundles to be installed
20  * by reference. This means the content of the bundle will not be copied. Instead
21  * the content of the bundle will be loaded from the reference location specified
22  * by the reference URL. The Framework only supports reference URLs that refer
23  * to a local file URL. For example: <p>
24  * <pre>
25  * reference:file:/eclipse/plugins/org.eclipse.myplugin_1.0.0/
26  * reference:file:/eclispe/plugins/org.eclipse.mybundle_1.0.0.jar
27  * </pre>
28  */

29 public class Handler extends URLStreamHandler {
30     public Handler() {
31     }
32
33     protected URLConnection openConnection(URL url) throws IOException JavaDoc {
34         return new ReferenceURLConnection(url);
35     }
36
37     protected void parseURL(URL url, String JavaDoc str, int start, int end) {
38         if (end < start) {
39             return;
40         }
41         String JavaDoc reference = (start < end) ? str.substring(start, end) : url.getPath();
42
43         setURL(url, url.getProtocol(), null, -1, null, null, reference, null, null);
44     }
45
46 }
47
Popular Tags