KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > baseadaptor > loader > ClasspathEntry


1 /*******************************************************************************
2  * Copyright (c) 2005, 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
12 package org.eclipse.osgi.baseadaptor.loader;
13
14 import java.security.ProtectionDomain JavaDoc;
15 import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
16 import org.eclipse.osgi.framework.util.KeyedElement;
17 import org.eclipse.osgi.framework.util.KeyedHashSet;
18
19 /**
20  * A ClasspathEntry contains a single <code>BundleFile</code> which is used as
21  * a source to load classes and resources from, and a single
22  * <code>ProtectionDomain</code> which is used as the domain to define classes
23  * loaded from this ClasspathEntry.
24  * @since 3.2
25  */

26 public class ClasspathEntry {
27     private BundleFile bundlefile;
28     private ProtectionDomain JavaDoc domain;
29     private KeyedHashSet userObjects = null;
30
31     /**
32      * Constructs a ClasspathElement with the specified bundlefile and domain
33      * @param bundlefile A BundleFile object which acts as a source
34      * @param domain the ProtectDomain for all code loaded from this classpath element
35      */

36     public ClasspathEntry(BundleFile bundlefile, ProtectionDomain JavaDoc domain) {
37         this.bundlefile = bundlefile;
38         this.domain = domain;
39     }
40
41     /**
42      * Returns the source BundleFile for this classpath entry
43      * @return the source BundleFile for this classpath entry
44      */

45     public BundleFile getBundleFile() {
46         return bundlefile;
47     }
48
49     /**
50      * Returns the ProtectionDomain for this classpath entry
51      * @return the ProtectionDomain for this classpath entry
52      */

53     public ProtectionDomain JavaDoc getDomain() {
54         return domain;
55     }
56
57     /**
58      * Returns a user object which is keyed by the specified key
59      * @param key the key of the user object to get
60      * @return a user object which is keyed by the specified key
61      */

62     public Object JavaDoc getUserObject(Object JavaDoc key) {
63         if (userObjects == null)
64             return null;
65         synchronized (userObjects) {
66             return userObjects.getByKey(key);
67         }
68     }
69
70     /**
71      * Adds a user object
72      * @param userObject the user object to add
73      */

74     public synchronized void addUserObject(KeyedElement userObject) {
75         if (userObjects == null)
76             userObjects = new KeyedHashSet(5, false);
77         synchronized (userObjects) {
78             userObjects.add(userObject);
79         }
80     }
81 }
82
Popular Tags