directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r651583 - in /directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations: ./ model/
Date Fri, 25 Apr 2008 12:09:27 GMT
Author: pamarcelot
Date: Fri Apr 25 05:09:20 2008
New Revision: 651583

URL: http://svn.apache.org/viewvc?rev=651583&view=rev
Log:
Added a basic server handler and server instance model.

Added:
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandler.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerAdapter.java
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerListener.java
Modified:
    directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPlugin.java

Modified: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPlugin.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPlugin.java?rev=651583&r1=651582&r2=651583&view=diff
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPlugin.java
(original)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/ApacheDsPlugin.java
Fri Apr 25 05:09:20 2008
@@ -23,6 +23,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.studio.apacheds.experimentations.model.ServersHandler;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.eclipse.core.runtime.IPath;
@@ -49,13 +50,16 @@
  */
 public class ApacheDsPlugin extends AbstractUIPlugin
 {
-    // The plug-in ID
+    /** The plug-in ID */
     public static final String PLUGIN_ID = "org.apache.directory.studio.apacheds.experimentations";
-    private static Logger logger = Logger.getLogger( ApacheDsPlugin.class );
 
-    // The shared instance
+    /** The shared instance*/
     private static ApacheDsPlugin plugin;
 
+    /** The servers handler */
+    private ServersHandler serversHandler;
+
+    private static Logger logger = Logger.getLogger( ApacheDsPlugin.class );
     private ConsoleDisplayMgr consoleDisplayMgr;
     private MessageConsole logMessageConsole;
 
@@ -77,6 +81,13 @@
         super.start( context );
         plugin = this;
 
+        // Creating the servers handler
+        serversHandler = ServersHandler.getDefault();
+
+        // Initializing the server instances from the store
+        serversHandler.loadServerInstancesFromStore();
+
+        // Verifying the libraries in the plugin's folder
         ApacheDsPluginUtils.verifyLibrariesFolder();
 
         // Configuring Log4J

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java?rev=651583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServerInstance.java
Fri Apr 25 05:09:20 2008
@@ -0,0 +1,99 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.model;
+
+
+/**
+ * This class represents an Apache DS instance.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerInstance
+{
+    /** The name of the instance */
+    private String name;
+
+    /** The ID of the instance*/
+    private String id;
+
+
+    /**
+     * Creates a new instance of ApacheDsInstance.
+     *
+     * @param name
+     *      the name of the instance
+     * @param id
+     *      the id of the instance
+     */
+    public ServerInstance( String name, String id )
+    {
+        this.name = name;
+        this.id = id;
+    }
+
+
+    /**
+     * Gets the name of the instance
+     *
+     * @return
+     *      the name of the instance
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * Sets the name of the instance
+     *
+     * @param name
+     *      the name of the instance
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    /**
+     * Gets the ID of the instance.
+     *
+     * @return
+     *      the ID of the instance
+     */
+    public String getId()
+    {
+        return id;
+    }
+
+
+    /**
+     * Sets the ID of the instance.
+     *
+     * @param id
+     *      the ID of the instance
+     */
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+}

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandler.java?rev=651583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandler.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandler.java
Fri Apr 25 05:09:20 2008
@@ -0,0 +1,232 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.model;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * This class implements the servers handler.
+ * <p>
+ * It is used to store all the server instances used in the plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServersHandler
+{
+    /** The default instance */
+    private static ServersHandler instance;
+
+    /** The list of server instances */
+    private List<ServerInstance> serverInstancesList;
+
+    /** The map of server instances ordered by name */
+    private Map<String, ServerInstance> serverInstancesNameMap;
+
+    /** The map of server instances ordered by ID */
+    private Map<String, ServerInstance> serverInstancesIdMap;
+
+    /** The listeners */
+    private List<ServersHandlerListener> listeners;
+
+
+    /**
+     * Creates a new instance of ServersHandler.
+     */
+    private ServersHandler()
+    {
+        // Initializing list and maps
+        serverInstancesList = new ArrayList<ServerInstance>();
+        serverInstancesNameMap = new HashMap<String, ServerInstance>();
+        serverInstancesIdMap = new HashMap<String, ServerInstance>();
+    }
+
+
+    /**
+     * Gets the default servers handler (singleton pattern).
+     *
+     * @return
+     *      the default servers handler
+     */
+    public static ServersHandler getDefault()
+    {
+        synchronized ( instance )
+        {
+            if ( instance == null )
+            {
+                instance = new ServersHandler();
+            }
+        }
+
+        return instance;
+    }
+
+
+    /**
+     * Adds a server instance.
+     *
+     * @param serverInstance
+     *      the server instance to be added
+     */
+    public void addServerInstance( ServerInstance serverInstance )
+    {
+        addServerInstance( serverInstance, true );
+    }
+
+
+    /**
+     * Adds a server instance.
+     *
+     * @param serverInstance
+     *      the server instance to be added
+     * @param notifyListeners
+     *      <code>true</code> if the listeners need to be notified, 
+     *      <code>false</code> if not.
+     */
+    private void addServerInstance( ServerInstance serverInstance, boolean notifyListeners
)
+    {
+        if ( !serverInstancesList.contains( serverInstance ) )
+        {
+            serverInstancesList.add( serverInstance );
+            serverInstancesIdMap.put( serverInstance.getId(), serverInstance );
+            serverInstancesNameMap.put( serverInstance.getName(), serverInstance );
+
+            // Notifying listeners
+            if ( notifyListeners )
+            {
+                for ( ServersHandlerListener listener : listeners.toArray( new ServersHandlerListener[0]
) )
+                {
+                    listener.serverInstanceRemoved( serverInstance );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Removes a server instance
+     *
+     * @param serverInstance
+     *      the server instance to be removed
+     */
+    public void removeServerInstance( ServerInstance serverInstance )
+    {
+        removeServerInstance( serverInstance, true );
+    }
+
+
+    /**
+     * Removes a server instance
+     *
+     * @param serverInstance
+     *      the server instance to be removed
+     * @param notifyListeners
+     *      <code>true</code> if the listeners need to be notified, 
+     *      <code>false</code> if not.
+     */
+    private void removeServerInstance( ServerInstance serverInstance, boolean notifyListeners
)
+    {
+        if ( serverInstancesList.contains( serverInstance ) )
+        {
+            serverInstancesNameMap.remove( serverInstance.getName() );
+            serverInstancesIdMap.remove( serverInstance.getId() );
+            serverInstancesList.remove( serverInstance );
+
+            // Notifying listeners
+            if ( notifyListeners )
+            {
+                for ( ServersHandlerListener listener : listeners.toArray( new ServersHandlerListener[0]
) )
+                {
+                    listener.serverInstanceRemoved( serverInstance );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Indicates if the server handler contains the given server instance.
+     *
+     * @param serverInstance
+     *      the server instance
+     * @return
+     *      <code>true</code> if the server hander contains the given server
+     *      instance, <code>false</code> if not
+     */
+    public boolean containsServerInstance( ServerInstance serverInstance )
+    {
+        return serverInstancesList.contains( serverInstance );
+    }
+
+
+    /**
+     * Adds a listener to the servers handler.
+     *
+     * @param listener
+     *      the listener to add
+     */
+    public void addListener( ServersHandlerListener listener )
+    {
+        if ( !listeners.contains( listener ) )
+        {
+            listeners.add( listener );
+        }
+    }
+
+
+    /**
+     * Removes a listener to the servers handler.
+     *
+     * @param listener
+     *      the listener to remove
+     */
+    public void removeListener( ServersHandlerListener listener )
+    {
+        if ( listeners.contains( listener ) )
+        {
+            listeners.remove( listener );
+        }
+    }
+
+
+    /**
+     * Loads the server instances from the file store.
+     */
+    public void loadServerInstancesFromStore()
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    /**
+     * Saves the server instances to the file store.
+     */
+    public void saveServerInstancesToStore()
+    {
+        // TODO Auto-generated method stub
+
+    }
+}

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerAdapter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerAdapter.java?rev=651583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerAdapter.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerAdapter.java
Fri Apr 25 05:09:20 2008
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.model;
+
+
+/**
+ * This class implements a default servers handler listener.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServersHandlerAdapter implements ServersHandlerListener
+{
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.experimentations.model.ServersHandlerListener#serverInstanceAdded(org.apache.directory.studio.apacheds.experimentations.model.ServerInstance)
+     */
+    public void serverInstanceAdded( ServerInstance serverInstance )
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.experimentations.model.ServersHandlerListener#serverInstanceRemoved(org.apache.directory.studio.apacheds.experimentations.model.ServerInstance)
+     */
+    public void serverInstanceRemoved( ServerInstance serverInstance )
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.experimentations.model.ServersHandlerListener#serverInstanceUpdated(org.apache.directory.studio.apacheds.experimentations.model.ServerInstance)
+     */
+    public void serverInstanceUpdated( ServerInstance serverInstance )
+    {
+    }
+}

Added: directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerListener.java?rev=651583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerListener.java
(added)
+++ directory/sandbox/pamarcelot/studio-apacheds-plugin/studio-apacheds-experimentations/src/main/java/org/apache/directory/studio/apacheds/experimentations/model/ServersHandlerListener.java
Fri Apr 25 05:09:20 2008
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.experimentations.model;
+
+
+/**
+ * This interface represents a listener for the servers handler
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ServersHandlerListener
+{
+    /**
+     * This method is called when a server instance is added.
+     *
+     * @param serverInstance
+     *      the added server instance
+     */
+    void serverInstanceAdded( ServerInstance serverInstance );
+
+
+    /**
+     * This method is called when a server instance is removed.
+     *
+     * @param serverInstance
+     *      the removed server instance
+     */
+    void serverInstanceRemoved( ServerInstance serverInstance );
+
+
+    /**
+     * This method is called when a server instance is updated.
+     *
+     * @param serverInstance
+     *      the updated server instance
+     */
+    void serverInstanceUpdated( ServerInstance serverInstance );
+}



Mime
View raw message