KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > components > framework > ClassIdentifier


1 /*******************************************************************************
2  * Copyright (c) 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.ui.internal.components.framework;
12
13 import org.eclipse.core.runtime.Platform;
14 import org.osgi.framework.Bundle;
15
16
17 /**
18  * Identifies a class, given a namespace and a fully-qualified class name.
19  * This can be used to refer to a class without actually loading its plugin.
20  * Note that it is possible to have two different ClassIdentifiers that point
21  * to the same Class since the same class can exist in multiple namespaces.
22  *
23  * <p>EXPERIMENTAL: The components framework is currently under active development. All
24  * aspects of this class including its existence, name, and public interface are likely
25  * to change during the development of Eclipse 3.1</p>
26  *
27  * @since 3.1
28  */

29 public final class ClassIdentifier {
30
31     private String JavaDoc namespace;
32     private String JavaDoc className;
33     
34     /**
35      * Creates an identifier for the given class in the given namespace.
36      *
37      * @param namespace namespace in which to resolve the class
38      * @param className fully-qualified class name
39      */

40     public ClassIdentifier(String JavaDoc namespace, String JavaDoc className) {
41         this.namespace = namespace;
42         this.className = className;
43     }
44     
45     /* (non-Javadoc)
46      * @see org.eclipse.core.component.registry.IComponentType#getInterfaceId()
47      */

48     public String JavaDoc getTypeName() {
49         return className;
50     }
51
52     /* (non-Javadoc)
53      * @see org.eclipse.core.component.registry.IComponentType#getNamespace()
54      */

55     public String JavaDoc getNamespace() {
56         return namespace;
57     }
58
59     /**
60      * Loads and returns the class. Use with caution: may cause plugin activation.
61      *
62      * @return the Class being referred to
63      * @throws ClassNotFoundException if the given class cannot be found in the
64      * given bundle
65      */

66     public Class JavaDoc loadClass() throws ClassNotFoundException JavaDoc {
67         Bundle pluginBundle = Platform.getBundle(namespace);
68         Class JavaDoc result = pluginBundle.loadClass(className);
69         return result;
70     }
71     
72 }
73
Popular Tags