diff options
| author | Raimar Buehmann | 2013-02-21 15:07:08 +0000 |
|---|---|---|
| committer | Raimar Buehmann | 2013-02-21 15:21:00 +0000 |
| commit | 59f58ced8a05bf1e9c67673e19e32062bd016ad3 (patch) | |
| tree | e99d9125af588da7653a175b109c46662b2d4ed5 | |
| parent | 292a6ff0bcdb19b3ecf29f084296eac45f062c89 (diff) | |
| download | org.eclipse.jubula.core-59f58ced8a05bf1e9c67673e19e32062bd016ad3.tar.gz org.eclipse.jubula.core-59f58ced8a05bf1e9c67673e19e32062bd016ad3.tar.xz org.eclipse.jubula.core-59f58ced8a05bf1e9c67673e19e32062bd016ad3.zip | |
Non-sprint-task - fix for P1 issue https://bxapps.bredex.de/bugzilla/show_bug.cgi?id=699
9 files changed, 133 insertions, 19 deletions
diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/AdapterFactoryRegistry.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/AdapterFactoryRegistry.java index 88cd0433d..6be9eee00 100644 --- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/AdapterFactoryRegistry.java +++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/AdapterFactoryRegistry.java @@ -144,13 +144,13 @@ public class AdapterFactoryRegistry { } /** - * Must be called to initialize the registration of adapters - * - * @throws InstantiationException - * @throws IllegalAccessException + * Use this method in eclipse environments. + * Must be called to initialize the registration of adapters. + * @param urlLocator The URL location converter needed in eclipse environments. */ - public static void initRegistration() { - Class[] adapterFactories = findClassesOfType(ADAPTER_PACKAGE_NAME, + public static void initRegistration(IUrlLocator urlLocator) { + Class[] adapterFactories = findClassesOfType(urlLocator, + ADAPTER_PACKAGE_NAME, IAdapterFactory.class); //Register all found factories @@ -167,20 +167,30 @@ public class AdapterFactoryRegistry { } } + /** + * Use this method outside of eclipse environments. Must be called to + * initialize the registration of adapters. This method directly + * calls {@link AdapterFactoryRegistry#initRegistration(IUrlLocator)} with + * the {@link DefaultUrlLocator}. + */ + public static void initRegistration() { + initRegistration(new DefaultUrlLocator()); + } /** * Investigate a package of subclasses of a specific superclass - * + * @param urlLocator + * The URL location converter needed in eclipse environments. * @param packageName * name of the package * @param superclass * parent class for found classes * @return found classes */ - private static Class[] findClassesOfType(String packageName, - Class superclass) { + private static Class[] findClassesOfType(IUrlLocator urlLocator, + String packageName, Class superclass) { try { - Class[] allClasses = getClasses(packageName); + Class[] allClasses = getClasses(urlLocator, packageName); List assignableClasses = new ArrayList(); for (int i = 0; i < allClasses.length; i++) { @@ -214,15 +224,17 @@ public class AdapterFactoryRegistry { /** * Scans all classes accessible from the context class loader which belong - * to the given package and subpackages. - * + * to the given package and sub packages. + * @param urlLocator + * The URL location converter needed in eclipse environments. * @param packageName * The base package * @return The classes * @throws ClassNotFoundException * @throws IOException */ - private static Class[] getClasses(String packageName) + private static Class[] getClasses(IUrlLocator urlLocator, + String packageName) throws ClassNotFoundException, IOException { ClassLoader classLoader = AdapterFactoryRegistry.class.getClassLoader(); String path = packageName.replace('.', '/'); @@ -231,7 +243,12 @@ public class AdapterFactoryRegistry { while (resources.hasMoreElements()) { URL resource = (URL) resources.nextElement(); - dirs.add(resource); + try { + resource = urlLocator.convertUrl(resource); + dirs.add(resource); + } catch (IOException e) { + log.error(e.getLocalizedMessage(), e); + } } List classes = new ArrayList(); for (int i = 0; i < dirs.size(); i++) { diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/DefaultUrlLocator.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/DefaultUrlLocator.java new file mode 100644 index 000000000..22096bfde --- /dev/null +++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/DefaultUrlLocator.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004, 2013 BREDEX 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: + * BREDEX GmbH - initial API and implementation and/or initial documentation + *******************************************************************************/ +package org.eclipse.jubula.rc.common.adaptable; + +import java.net.URL; + +/** + * The default default implementation for the URL locator, + * which do not change the given URL. + */ +public class DefaultUrlLocator implements IUrlLocator { + + /** + * @return The same as the given URL. + * {@inheritDoc} + */ + public URL convertUrl(URL url) { + return url; + } + +} diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/IUrlLocator.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/IUrlLocator.java new file mode 100644 index 000000000..fa79cbab7 --- /dev/null +++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/adaptable/IUrlLocator.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004, 2013 BREDEX 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: + * BREDEX GmbH - initial API and implementation and/or initial documentation + *******************************************************************************/ +package org.eclipse.jubula.rc.common.adaptable; + +import java.io.IOException; +import java.net.URL; + +/** + * This interface defines the method for resolving a URL, which depends on + * eclipse or not. + */ +public interface IUrlLocator { + + /** + * @param url The URL, which will be converted + * @return The converted URL, which can be used by {@link java.io.File}. + * @throws IOException + */ + public URL convertUrl(URL url) throws IOException; + +} diff --git a/org.eclipse.jubula.rc.rcp.common/.classpath b/org.eclipse.jubula.rc.rcp.common/.classpath index 5e80887d5..8e3e5aa54 100644 --- a/org.eclipse.jubula.rc.rcp.common/.classpath +++ b/org.eclipse.jubula.rc.rcp.common/.classpath @@ -15,7 +15,7 @@ <classpathentry exported="true" kind="lib" path="lib/org.apache.commons.beanutils.jar"/> <classpathentry exported="true" kind="lib" path="lib/org.eclipse.jubula.communication.jar" sourcepath="/org.eclipse.jubula.communication/src"/> <classpathentry exported="true" kind="lib" path="lib/org.eclipse.jubula.tools.jar" sourcepath="/org.eclipse.jubula.tools/src"/> - <classpathentry exported="true" kind="lib" path="lib/org.eclipse.jubula.rc.common.jar" sourcepath="/org.eclipse.jubula.rc.common"/> + <classpathentry exported="true" kind="lib" path="lib/org.eclipse.jubula.rc.common.jar" sourcepath="/org.eclipse.jubula.rc.common/src"/> <classpathentry exported="true" kind="lib" path="resources" sourcepath="resources"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/org.eclipse.jubula.rc.rcp.common/META-INF/MANIFEST.MF b/org.eclipse.jubula.rc.rcp.common/META-INF/MANIFEST.MF index 71555d38f..9ed36b09f 100644 --- a/org.eclipse.jubula.rc.rcp.common/META-INF/MANIFEST.MF +++ b/org.eclipse.jubula.rc.rcp.common/META-INF/MANIFEST.MF @@ -4,7 +4,8 @@ Bundle-ManifestVersion: 2 Bundle-Name: Jubula Remote Control - RCP Bundle-SymbolicName: org.eclipse.jubula.rc.rcp.common; singleton:=true Bundle-Version: 2.0.0.qualifier -Require-Bundle: org.eclipse.osgi;bundle-version="[3.3.0,5.0.0)" +Require-Bundle: org.eclipse.osgi;bundle-version="[3.3.0,5.0.0)", + org.eclipse.core.runtime;bundle-version="[3.3.0,5.0.0)" Bundle-ClassPath: ., lib/xpp3_min-1.1.3.4.O.jar, lib/xstream-1.3.1.jar, @@ -29,7 +30,6 @@ Export-Package: org.apache.commons.beanutils, org.eclipse.jubula.communication.message, org.eclipse.jubula.rc.common, org.eclipse.jubula.rc.common.adaptable, - org.eclipse.jubula.rc.common.tester, org.eclipse.jubula.rc.common.commands, org.eclipse.jubula.rc.common.components, org.eclipse.jubula.rc.common.driver, @@ -37,8 +37,10 @@ Export-Package: org.apache.commons.beanutils, org.eclipse.jubula.rc.common.implclasses, org.eclipse.jubula.rc.common.listener, org.eclipse.jubula.rc.common.logger, + org.eclipse.jubula.rc.common.tester, org.eclipse.jubula.rc.common.tester.adapter.interfaces, org.eclipse.jubula.rc.common.util, + org.eclipse.jubula.rc.rcp.common.utils, org.eclipse.jubula.tools.constants, org.eclipse.jubula.tools.exception, org.eclipse.jubula.tools.i18n, diff --git a/org.eclipse.jubula.rc.rcp.common/src/org/eclipse/jubula/rc/rcp/common/utils/EclipseUrlLocator.java b/org.eclipse.jubula.rc.rcp.common/src/org/eclipse/jubula/rc/rcp/common/utils/EclipseUrlLocator.java new file mode 100644 index 000000000..46142a987 --- /dev/null +++ b/org.eclipse.jubula.rc.rcp.common/src/org/eclipse/jubula/rc/rcp/common/utils/EclipseUrlLocator.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2004, 2013 BREDEX 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: + * BREDEX GmbH - initial API and implementation and/or initial documentation + *******************************************************************************/ +package org.eclipse.jubula.rc.rcp.common.utils; + +import java.io.IOException; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.jubula.rc.common.adaptable.IUrlLocator; + +/** + * This class implements the URL locator for Eclipse environments. + */ +public class EclipseUrlLocator implements IUrlLocator { + + /** + * @return The given URL converted by Eclipse runtime method {@link FileLocator#resolve(URL)}. + * {@inheritDoc} + * @throws IOException + */ + public URL convertUrl(URL url) throws IOException { + return FileLocator.resolve(url); + } + +} diff --git a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java b/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java index 2aecc0bce..b36b7eafc 100644 --- a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java +++ b/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java @@ -18,6 +18,7 @@ import java.util.Properties; import org.eclipse.core.runtime.Platform; import org.eclipse.jubula.rc.common.AUTServer; import org.eclipse.jubula.rc.common.adaptable.AdapterFactoryRegistry; +import org.eclipse.jubula.rc.rcp.common.utils.EclipseUrlLocator; import org.eclipse.jubula.rc.rcp.e3.gef.inspector.GefInspectorListenerAppender; import org.eclipse.jubula.rc.rcp.e3.gef.listener.GefPartListener; import org.eclipse.jubula.rc.rcp.swt.aut.RcpSwtComponentNamer; @@ -268,7 +269,7 @@ public abstract class E3Startup implements IStartup { }); // Registering the AdapterFactory for SWT at the registry - AdapterFactoryRegistry.initRegistration(); + AdapterFactoryRegistry.initRegistration(new EclipseUrlLocator()); // add listener to AUT AUTServer.getInstance().addToolKitEventListenerToAUT(); diff --git a/org.eclipse.jubula.rc.rcp.swt/.classpath b/org.eclipse.jubula.rc.rcp.swt/.classpath index c9abe4f82..797790cb5 100644 --- a/org.eclipse.jubula.rc.rcp.swt/.classpath +++ b/org.eclipse.jubula.rc.rcp.swt/.classpath @@ -3,6 +3,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> - <classpathentry exported="true" kind="lib" path="lib/org.eclipse.jubula.rc.swt.jar"/> + <classpathentry exported="true" kind="lib" path="lib/org.eclipse.jubula.rc.swt.jar" sourcepath="/org.eclipse.jubula.rc.swt/src"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java b/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java index 1c80cefed..cd2ce1d24 100644 --- a/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java +++ b/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java @@ -4,6 +4,7 @@ import java.util.Properties; import org.eclipse.jubula.rc.common.AUTServer; import org.eclipse.jubula.rc.common.adaptable.AdapterFactoryRegistry; +import org.eclipse.jubula.rc.rcp.common.utils.EclipseUrlLocator; import org.eclipse.jubula.rc.swt.SwtAUTServer; import org.eclipse.jubula.tools.constants.AutConfigConstants; import org.eclipse.jubula.tools.utils.EnvironmentUtils; @@ -86,6 +87,8 @@ public class SwtRemoteControlService extends SwtAUTServer { * Prepare the SwtAUTServer for SWT components. */ private static void prepareRemoteControlService() { + // Registering the AdapterFactory for SWT at the registry + AdapterFactoryRegistry.initRegistration(new EclipseUrlLocator()); // add listener to AUT AUTServer.getInstance().addToolKitEventListenerToAUT(); } |
