Hi,
I launch new java process from my eclipse plugin:
<extension point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
name="%systemincloud.launch.type.name"
delegateDescription="%systemincloud.launch.type.description"
id="com.systemincloud.modeler.systemincloudLaunchConfigurationType"
delegate="com.systemincloud.modeler.launch.SystemInCloudLaunchDelegate"
sourceLocatorId="com.systemincloud.modeler.launch.SystemInCloudSourceLocator"
sourcePathComputerId="com.systemincloud.modeler.launch.SystemInCloudSourceComputer"
modes="run" public="true"/>
</extension>
My delegate extends JavaLaunchDelegate:
public class SystemInCloudLaunchDelegate extends JavaLaunchDelegate {
I added in Delegate my plugin API_PLUGIN_ID in classpath to be able to access their classes from new process.
@Override
public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
List<String> extendedClasspath = new ArrayList<String>();
Collections.addAll(extendedClasspath, super.getClasspath(configuration));
if (!Platform.inDevelopmentMode()) {
try {
extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.API_PLUGIN_ID));
} catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, SystemInCloudConstants.LAUNCHER_PLUGIN_ID, IStatus.OK, "Failed to compose classpath!", e)); }
} else {
try {
extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.API_PLUGIN_ID) + "target/classes");
} catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, SystemInCloudConstants.LAUNCHER_PLUGIN_ID, IStatus.OK, "Failed to compose classpath!", e)); }
}
try {
extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_ECORE_PLUGIN_ID));
extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_COMMON_PLUGIN_ID));
extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_TRANSACTION_PLUGIN_ID));
extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_XMI_PLUGIN_ID));
extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.GRAPHITI_MM_PLUGIN_ID));
} catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, SystemInCloudConstants.LAUNCHER_PLUGIN_ID, IStatus.OK, "Failed to compose classpath!", e)); }
return extendedClasspath.toArray(new String[extendedClasspath.size()]);
}
In one class of my plugin I read resource file:
protected InputStream getServiceConfig() {
InputStream is = null;
try {
URL url = new URL("platform:/plugin/" + SystemInCloudConstants.API_PLUGIN_ID + "/service.properties");
is = url.openConnection().getInputStream();
} catch (IOException e) { e.printStackTrace(); }
return is;
}
When I am using this method inside plugin there is no problem. When I use this class inside new process I get an exception:
java.net.MalformedURLException: unknown protocol: platform
at java.net.URL.<init>(URL.java:592)
at java.net.URL.<init>(URL.java:482)
at java.net.URL.<init>(URL.java:431)
at com.systemincloud.modeler.api.SicConnectionModeler.getServiceConfig(SicConnectionModeler.java:25)
at com.systemincloud.api.java.SicConnection.<init>(SicConnection.java:66)
Is there an eclipse plugin that I can add to classpath or I should translate this url to non-relative path before using it?
Thanks for any hint,
Marek