KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.eclipse.osgi.framework.internal.core;
12
13 import java.net.URL JavaDoc;
14 import java.util.Enumeration JavaDoc;
15
16 public class MultiSourcePackage extends PackageSource {
17     SingleSourcePackage[] suppliers;
18
19     MultiSourcePackage(String JavaDoc id, SingleSourcePackage[] suppliers) {
20         super(id);
21         this.suppliers = suppliers;
22     }
23
24     public SingleSourcePackage[] getSuppliers() {
25         return suppliers;
26     }
27
28     public Class JavaDoc loadClass(String JavaDoc name) throws ClassNotFoundException JavaDoc {
29         Class JavaDoc result = null;
30         for (int i = 0; i < suppliers.length; i++) {
31             result = suppliers[i].loadClass(name);
32             if (result != null)
33                 return result;
34         }
35         return result;
36     }
37
38     public URL JavaDoc getResource(String JavaDoc name) {
39         URL JavaDoc result = null;
40         for (int i = 0; i < suppliers.length; i++) {
41             result = suppliers[i].getResource(name);
42             if (result != null)
43                 return result;
44         }
45         return result;
46     }
47
48     public Enumeration JavaDoc getResources(String JavaDoc name) {
49         Enumeration JavaDoc results = null;
50         for (int i = 0; i < suppliers.length; i++)
51             results = BundleLoader.compoundEnumerations(results, suppliers[i].getResources(name));
52         return results;
53     }
54 }
55
Popular Tags