IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
// Creating a new editable launch configuration
ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(
IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION );
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance( null, "Starting " + server.getName() );
// Setting the JRE container path attribute
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmInstall
.getInstallLocation().toString() );
// Setting the main type attribute
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
"org.apache.directory.studio.apacheds.Launcher" );
// Creating the classpath list
List<String> classpath = new ArrayList<String>();
IPath apacheDsLibrariesFolder = ApacheDsPluginUtils.getApacheDsLibrariesFolder();
for ( String library : ApacheDsPluginUtils.apachedsLibraries )
{
IRuntimeClasspathEntry libraryClasspathEntry = JavaRuntime
.newArchiveRuntimeClasspathEntry( apacheDsLibrariesFolder.append( library ) );
libraryClasspathEntry.setClasspathProperty( IRuntimeClasspathEntry.USER_CLASSES );
classpath.add( libraryClasspathEntry.getMemento() );
}
// Setting the classpath type attribute
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath );
// Setting the default classpath type attribute to false
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false );
// The server folder path
IPath serverFolderPath = ApacheDsPluginUtils.getApacheDsServersFolder().append( server.getId() );
// Setting the program arguments attribute
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "\""
+ serverFolderPath.toOSString() + "\"" );
// Creating the VM arguments string
StringBuffer vmArguments = new StringBuffer();
vmArguments.append( "-Dlog4j.configuration=file:\""
+ serverFolderPath.append( "conf" ).append( "log4j.properties" ).toOSString() + "\"" );
vmArguments.append( " " );
vmArguments.append( "-Dapacheds.var.dir=\"" + serverFolderPath.toOSString() + "\"" );
vmArguments.append( " " );
vmArguments.append( "-Dapacheds.log.dir=\"" + serverFolderPath.append( "log" ).toOSString() + "\"" );
vmArguments.append( " " );
vmArguments.append( "-Dapacheds.run.dir=\"" + serverFolderPath.append( "run" ).toOSString() + "\"" );
vmArguments.append( " " );
vmArguments.append( "-Dapacheds.instance=\"" + server.getName() + "\"" );
// Setting the VM arguments attribute
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArguments.toString() );
// Setting the launch configuration as private
workingCopy.setAttribute( IDebugUIConstants.ATTR_PRIVATE, true );
// Indicating that we don't want any console to show up
workingCopy.setAttribute( DebugPlugin.ATTR_CAPTURE_OUTPUT, false );
// Saving the launch configuration
ILaunchConfiguration configuration = workingCopy.doSave();
// Launching the launch configuration
launch = configuration.launch( ILaunchManager.RUN_MODE, new NullProgressMonitor() );
}
catch ( CoreException e )