directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r966154 - in /directory/studio/trunk: ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/
Date Wed, 21 Jul 2010 09:26:55 GMT
Author: pamarcelot
Date: Wed Jul 21 09:26:55 2010
New Revision: 966154

URL: http://svn.apache.org/viewvc?rev=966154&view=rev
Log:
Implemented a somehow simple and dirty stop method (will need to be cleaned afterwards).

Modified:
    directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java

Modified: directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java?rev=966154&r1=966153&r2=966154&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java
(original)
+++ directory/studio/trunk/ldapservers.apacheds.v156/src/main/java/org/apache/directory/studio/ldapserver/apacheds/v156/ApacheDS156LdapServerAdapter.java
Wed Jul 21 09:26:55 2010
@@ -41,6 +41,7 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
@@ -122,6 +123,7 @@ public class ApacheDS156LdapServerAdapte
         IPath resourceConfFolderPath = new Path( RESOURCES ).append( CONF );
         copyResource( resourceConfFolderPath.append( SERVER_XML ), new File( confFolder,
SERVER_XML ) );
         copyResource( resourceConfFolderPath.append( LOG4J_PROPERTIES ), new File( confFolder,
LOG4J_PROPERTIES ) );
+        
     }
 
 
@@ -222,6 +224,9 @@ public class ApacheDS156LdapServerAdapte
 
             // 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
+            server.putCustomObject( "launchConfiguration", launch );
         }
         catch ( CoreException e )
         {
@@ -236,9 +241,25 @@ public class ApacheDS156LdapServerAdapte
      */
     public void stop( LdapServer server, IProgressMonitor monitor ) throws Exception
     {
-        System.out.println( "stop " + server.getName() );
-
-        Thread.sleep( 3000 );
+        // Getting the launch
+        ILaunch launch = ( ILaunch ) server.getCustomObject( "launchConfiguration" );
+        if ( ( launch != null ) && ( !launch.isTerminated() ) )
+        {
+            // Terminating the launch
+            try
+            {
+                launch.terminate();
+            }
+            catch ( DebugException e )
+            {
+                CommonUiUtils.reportError( NLS.bind( "An error occurred when stopping the
server.\n\n{0}", new String[]
+                    { e.getMessage() } ) );
+            }
+        }
+        else
+        {
+            // TODO throw an error
+        }
 
         server.setStatus( LdapServerStatus.STOPPED );
     }

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java?rev=966154&r1=966153&r2=966154&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
Wed Jul 21 09:26:55 2010
@@ -22,7 +22,9 @@ package org.apache.directory.studio.ldap
 
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import org.eclipse.core.runtime.IAdaptable;
@@ -51,6 +53,9 @@ public class LdapServer implements IAdap
     /** The list of listeners */
     private List<LdapServerListener> listeners = new ArrayList<LdapServerListener>();
 
+    /** The Map for custom objects */
+    private Map<String, Object> customObjectsMap = new HashMap<String, Object>();
+
 
     /**
      * Creates a new instance of LDAP Server.
@@ -106,6 +111,22 @@ public class LdapServer implements IAdap
 
 
     /**
+     * Returns the value to which the specified key is mapped, 
+     * or null if no mapping for the key is found.
+     *
+     * @param key
+     *      the key
+     * @return
+     *      the value to which the specified key is mapped, 
+     *      or null if no mapping for the key is found.
+     */
+    public Object getCustomObject( String key )
+    {
+        return customObjectsMap.get( key );
+    }
+
+
+    /**
      * Gets the id of the server.
      *
      * @return
@@ -154,29 +175,46 @@ public class LdapServer implements IAdap
 
 
     /**
-     * Removes the {@link LdapServerListener} from the server.
+     * Associates the specified value with the specified key.
      *
-     * @param listener
-     *      the listener to be removed
+     * @param key
+     *      the key
+     * @param value
+     *      the value
      */
-    public void removeListener( LdapServerListener listener )
+    public void putCustomObject( String key, Object value )
     {
-        if ( !listeners.contains( listener ) )
-        {
-            listeners.remove( listener );
-        }
+        customObjectsMap.put( key, value );
     }
 
 
     /**
-     * Restarts the server.
+     * Removes the value to which the specified key is mapped.
+     * <p>
+     * Returns the value previously associated the key,
+     * or null if there was no mapping for the key.
      *
-     * @throws Exception
-     *      if an error occurs when restarting the server
+     * @param key
+     * @return
      */
-    public void restart() throws Exception
+    public Object removeCustomObject( String key )
     {
+        return customObjectsMap.remove( key );
+    }
+
 
+    /**
+     * Removes the {@link LdapServerListener} from the server.
+     *
+     * @param listener
+     *      the listener to be removed
+     */
+    public void removeListener( LdapServerListener listener )
+    {
+        if ( !listeners.contains( listener ) )
+        {
+            listeners.remove( listener );
+        }
     }
 
 
@@ -261,30 +299,6 @@ public class LdapServer implements IAdap
 
 
     /**
-     * Starts the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void start() throws Exception
-    {
-
-    }
-
-
-    /**
-     * Stops the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void stop() throws Exception
-    {
-
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public Object getAdapter( Class adapter )



Mime
View raw message