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,
NLS.bind( Messages.getString( "ApacheDS200LdapServerAdapter.Starting" ), new String[] //$NON-NLS-1$
{ 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.server.UberjarMain" ); //$NON-NLS-1$
// Creating the classpath list
List<String> classpath = new ArrayList<String>();
for ( String library : libraries )
{
IRuntimeClasspathEntry libraryClasspathEntry = JavaRuntime
.newArchiveRuntimeClasspathEntry( getServerLibrariesFolder().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 = LdapServersManager.getServerFolder( server );
// Setting the program arguments attribute
workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "\"" //$NON-NLS-1$
+ serverFolderPath.toOSString() + "\"" ); //$NON-NLS-1$
// Creating the VM arguments string
StringBuffer vmArguments = new StringBuffer();
vmArguments.append( "-Dlog4j.configuration=file:\"" //$NON-NLS-1$
+ serverFolderPath.append( CONF ).append( LOG4J_PROPERTIES ).toOSString() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vmArguments.append( " " ); //$NON-NLS-1$
vmArguments.append( "-Dapacheds.var.dir=\"" + serverFolderPath.toOSString() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$
vmArguments.append( " " ); //$NON-NLS-1$
vmArguments.append( "-Dapacheds.log.dir=\"" + serverFolderPath.append( "log" ).toOSString() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vmArguments.append( " " ); //$NON-NLS-1$
vmArguments.append( "-Dapacheds.instance=\"" + server.getName() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$
vmArguments.append( " " ); //$NON-NLS-1$
vmArguments
.append( "-Ddefault.controls=org.apache.directory.api.ldap.codec.controls.cascade.CascadeFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.codec.controls.manageDsaIT.ManageDsaITFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.codec.controls.search.persistentSearch.PersistentSearchFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory" ); //$NON-NLS-1$
vmArguments.append( " " ); //$NON-NLS-1$
vmArguments
.append( "-Dextra.controls=org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory" ); //$NON-NLS-1$
vmArguments.append( " " ); //$NON-NLS-1$
vmArguments
.append( "-Ddefault.extendedOperation.requests=org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownFactory," + //$NON-NLS-1$
"org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure.StoredProcedureFactory" ); //$NON-NLS-1$
vmArguments.append( " " ); //$NON-NLS-1$
vmArguments
.append( "-Ddefault.extendedOperation.responses=org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory" ); //$NON-NLS-1$
// 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
ILaunch launch = configuration.launch( ILaunchManager.RUN_MODE, new NullProgressMonitor() );
// Storing the launch configuration as a custom object in the LDAP Server for later use