KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > components > util > InstanceToComponentFactoryAdapter


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.util;
12
13 import org.eclipse.ui.internal.components.framework.ComponentException;
14 import org.eclipse.ui.internal.components.framework.ComponentFactory;
15 import org.eclipse.ui.internal.components.framework.ComponentHandle;
16 import org.eclipse.ui.internal.components.framework.IServiceProvider;
17 import org.eclipse.ui.internal.components.framework.NonDisposingHandle;
18
19 /**
20  * Factory that always returns the same instance
21  *
22  * <p>EXPERIMENTAL: The components framework is currently under active development. All
23  * aspects of this class including its existence, name, and public interface are likely
24  * to change during the development of Eclipse 3.1</p>
25  *
26  * @since 3.1
27  */

28 public class InstanceToComponentFactoryAdapter extends ComponentFactory {
29
30     private ComponentHandle handle;
31     
32     /**
33      * Creates a factory that always returns handles to the given object instance
34      *
35      * @param existingInstance instance to adapt
36      */

37     public InstanceToComponentFactoryAdapter(Object JavaDoc existingInstance) {
38         handle = new NonDisposingHandle(existingInstance);
39     }
40     
41     public ComponentHandle createHandle(IServiceProvider availableServices)
42             throws ComponentException {
43         return handle;
44     }
45 }
46
Popular Tags