KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > internal > core > NullPackageSource


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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 package org.eclipse.osgi.framework.internal.core;
12
13 import java.net.URL JavaDoc;
14 import java.util.Enumeration JavaDoc;
15 import org.eclipse.osgi.framework.util.KeyedHashSet;
16
17 /**
18  * This class is used to optimize finding provided-packages for a bundle.
19  * If the package cannot be found in a list of required bundles then this class
20  * is used to cache a null package source so that the search does not need to
21  * be done again.
22  */

23 public class NullPackageSource extends PackageSource {
24     static KeyedHashSet sources;
25     private NullPackageSource(String JavaDoc name) {
26         super(name);
27     }
28
29     public SingleSourcePackage[] getSuppliers() {
30         return null;
31     }
32
33     public boolean isNullSource() {
34         return true;
35     }
36
37     public String JavaDoc toString() {
38         return id + " -> null"; //$NON-NLS-1$
39
}
40
41     public Class JavaDoc loadClass(String JavaDoc name) {
42         return null;
43     }
44
45     public URL JavaDoc getResource(String JavaDoc name) {
46         return null;
47     }
48
49     public Enumeration JavaDoc getResources(String JavaDoc name) {
50         return null;
51     }
52
53     public static synchronized NullPackageSource getNullPackageSource(String JavaDoc name) {
54         if (sources == null)
55             sources = new KeyedHashSet();
56         NullPackageSource result = (NullPackageSource) sources.getByKey(name);
57         if (result != null)
58             return result;
59         result = new NullPackageSource(name);
60         sources.add(result);
61         return result;
62     }
63 }
64
Popular Tags