### Eclipse Workspace Patch 1.0 #P org.eclipse.rap.rwt Index: src/org/eclipse/rwt/internal/lifecycle/EntryPointManager.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/lifecycle/EntryPointManager.java,v retrieving revision 1.9 diff -u -r1.9 EntryPointManager.java --- src/org/eclipse/rwt/internal/lifecycle/EntryPointManager.java 12 Jun 2008 13:12:18 -0000 1.9 +++ src/org/eclipse/rwt/internal/lifecycle/EntryPointManager.java 18 Mar 2009 09:25:45 -0000 @@ -44,16 +44,33 @@ Object[] args = new Object[] { IEntryPoint.class.getName() }; String mag = MessageFormat.format( text, args ); throw new IllegalArgumentException( mag ) ; - } + } + register( name, new IEntryPointFactory() { + public String getName() { return clazz.getName(); } + public IEntryPoint createEntryPoint() { + try { + return ( IEntryPoint ) clazz.newInstance(); + } catch( Exception e ) { + throw new RuntimeException(e); + } + } + }); + } + } + + public static void register( final String name, final IEntryPointFactory configElement ) { + synchronized( registry ) { + ParamCheck.notNull( name, "name" ); + ParamCheck.notNull( configElement, "configElement" ); if( registry.containsKey( name ) ) { String text = "An entry point named ''{0}'' already exists."; String msg = MessageFormat.format( text, new Object[] { name } ); throw new IllegalArgumentException( msg ); } - registry.put( name, clazz ); + registry.put( name, configElement ); } } - + public static void deregister( final String name ) { synchronized( registry ) { ParamCheck.notNull( name, "name" ); @@ -65,10 +82,10 @@ registry.remove( name ); } } - + public static int createUI( final String name ) { IEntryPoint entryPoint; - Class clazz; + Object registeredObject; ParamCheck.notNull( name, "name" ); synchronized( registry ) { if( !registry.containsKey( name ) ) { @@ -76,22 +93,25 @@ String msg = MessageFormat.format( text, new Object[] { name } ); throw new IllegalArgumentException( msg ); } - clazz = ( Class )registry.get( name ); + registeredObject = registry.get( name ); } // no synchronization during instance creation to avoid lock in case // of expensive constructor operations + IEntryPointFactory configElement = ( IEntryPointFactory )registeredObject; try { - entryPoint = ( IEntryPoint )clazz.newInstance(); + entryPoint = configElement.createEntryPoint(); } catch( Exception e ) { String text = "Failed to instantiate ''{0}''."; - Object[] args = new Object[] { clazz.getName() }; + Object[] args = new Object[] { configElement.getName() }; String msg = MessageFormat.format( text, args ); throw new EntryPointInstantiationException( msg, e ) ; } + ContextProvider.getSession().setAttribute( CURRENT_ENTRY_POINT, name ); return entryPoint.createUI(); } + public static String getCurrentEntryPoint() { ISessionStore session = ContextProvider.getSession(); return ( String )session.getAttribute( CURRENT_ENTRY_POINT ); Index: src/org/eclipse/rwt/internal/lifecycle/IEntryPointFactory.java =================================================================== RCS file: src/org/eclipse/rwt/internal/lifecycle/IEntryPointFactory.java diff -N src/org/eclipse/rwt/internal/lifecycle/IEntryPointFactory.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/rwt/internal/lifecycle/IEntryPointFactory.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Innoopract Informationssysteme GmbH - initial API and implementation + ******************************************************************************/ +package org.eclipse.rwt.internal.lifecycle; + +import org.eclipse.rwt.lifecycle.IEntryPoint; + + +/** + * Create an instance of an {@link IEntryPoint} implementation. + */ +public interface IEntryPointFactory { + + /** + * @return The Name of the EntryPoint Class. + */ + String getName(); + + /** + * This Method is called from the {@link EntryPointManager} to create an EntryPont. + * + * @return The created EntryPoint instance. + */ + IEntryPoint createEntryPoint(); + +} #P org.eclipse.rap.ui.workbench Index: Eclipse UI/org/eclipse/rap/ui/internal/servlet/EngineConfigWrapper.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/rap/ui/internal/servlet/EngineConfigWrapper.java,v retrieving revision 1.1 diff -u -r1.1 EngineConfigWrapper.java --- Eclipse UI/org/eclipse/rap/ui/internal/servlet/EngineConfigWrapper.java 12 Feb 2009 11:11:48 -0000 1.1 +++ Eclipse UI/org/eclipse/rap/ui/internal/servlet/EngineConfigWrapper.java 18 Mar 2009 09:25:47 -0000 @@ -24,6 +24,7 @@ import org.eclipse.rwt.internal.service.*; import org.eclipse.rwt.internal.theme.ResourceLoader; import org.eclipse.rwt.internal.theme.ThemeManager; +import org.eclipse.rwt.lifecycle.IEntryPoint; import org.eclipse.rwt.lifecycle.PhaseListener; import org.eclipse.rwt.resources.IResource; import org.eclipse.rwt.service.ISettingStoreFactory; @@ -205,6 +206,28 @@ } } + private static class EntryPointFactory implements IEntryPointFactory + { + private final IConfigurationElement entryPointConfig; + + EntryPointFactory(IConfigurationElement entryPointConfig) { + this.entryPointConfig = entryPointConfig; + + } + + public String getName() { + return entryPointConfig.getAttribute("class"); + } + + public IEntryPoint createEntryPoint() { + try { + return ( IEntryPoint )entryPointConfig.createExecutableExtension("class"); + } catch (CoreException e) { + throw new RuntimeException(e); + } + } + } + private static void registerWorkbenchEntryPoint() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint point = registry.getExtensionPoint( ID_ENTRY_POINT ); @@ -215,9 +238,7 @@ String parameter = elements[ i ].getAttribute( "parameter" ); String id = elements[ i ].getAttribute( "id" ); try { - Bundle bundle = Platform.getBundle( contributorName ); - Class clazz = bundle.loadClass( className ); - EntryPointManager.register( parameter, clazz ); + EntryPointManager.register( parameter, new EntryPointFactory(elements[ i ]) ); EntryPointExtension.bind( id, parameter ); } catch( final Throwable thr ) { String text = "Could not register entry point ''{0}'' "