Author: rob.stryker(a)jboss.com
Date: 2007-09-26 23:03:19 -0400 (Wed, 26 Sep 2007)
New Revision: 3840
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
Log:
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2007-09-27
01:58:32 UTC (rev 3839)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2007-09-27
03:03:19 UTC (rev 3840)
@@ -42,9 +42,9 @@
return instance;
}
- private HashMap pollers;
+ private HashMap<String, ServerStatePollerType> pollers;
public void loadPollers() {
- pollers = new HashMap();
+ pollers = new HashMap<String, ServerStatePollerType>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID,
"pollers");
for( int i = 0; i < cf.length; i++ ) {
@@ -54,33 +54,33 @@
public ServerStatePollerType getPollerType(String id) {
if( pollers == null )
loadPollers();
- return (ServerStatePollerType)pollers.get(id);
+ return pollers.get(id);
}
public ServerStatePollerType[] getStartupPollers() {
if( pollers == null )
loadPollers();
- ArrayList list = new ArrayList();
- Iterator i = pollers.values().iterator();
+ ArrayList<ServerStatePollerType> list = new
ArrayList<ServerStatePollerType>();
+ Iterator<ServerStatePollerType> i = pollers.values().iterator();
ServerStatePollerType type;
while(i.hasNext()) {
- type = (ServerStatePollerType)i.next();
+ type = i.next();
if( type.supportsStartup())
list.add(type);
}
- return (ServerStatePollerType[]) list.toArray(new ServerStatePollerType[list.size()]);
+ return list.toArray(new ServerStatePollerType[list.size()]);
}
public ServerStatePollerType[] getShutdownPollers() {
if( pollers == null )
loadPollers();
- ArrayList list = new ArrayList();
- Iterator i = pollers.values().iterator();
+ ArrayList<ServerStatePollerType> list = new
ArrayList<ServerStatePollerType>();
+ Iterator<ServerStatePollerType> i = pollers.values().iterator();
ServerStatePollerType type;
while(i.hasNext()) {
- type = (ServerStatePollerType)i.next();
+ type = i.next();
if( type.supportsShutdown() )
list.add(type);
}
- return (ServerStatePollerType[]) list.toArray(new ServerStatePollerType[list.size()]);
+ return list.toArray(new ServerStatePollerType[list.size()]);
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2007-09-27
01:58:32 UTC (rev 3839)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2007-09-27
03:03:19 UTC (rev 3840)
@@ -31,6 +31,7 @@
import org.eclipse.core.runtime.Plugin;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.modules.ArchivesBuildListener;
+import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.osgi.framework.BundleContext;
/**
@@ -72,6 +73,7 @@
super.start(context);
ArchivesBuildListener.getInstance();
XPathModel.getDefault();
+ UnitedServerListenerManager.getDefault();
}
/**
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListener.java 2007-09-27
03:03:19 UTC (rev 3840)
@@ -0,0 +1,17 @@
+package org.jboss.ide.eclipse.as.core.server;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerEvent;
+
+public class UnitedServerListener {
+
+ public void init(IServer server) {}
+ public void serverAdded(IServer server) {}
+ public void serverChanged(IServer server) {}
+ public void serverRemoved(IServer server) {}
+ public void serverChanged(ServerEvent event) {}
+ public void publishStarted(IServer server){}
+ public void publishFinished(IServer server, IStatus status){}
+ public void cleanUp(IServer server) {}
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java 2007-09-27
03:03:19 UTC (rev 3840)
@@ -0,0 +1,86 @@
+package org.jboss.ide.eclipse.as.core.server;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IPublishListener;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerEvent;
+
+public class UnitedServerListenerManager implements
+ IServerLifecycleListener, IServerListener, IPublishListener {
+ protected static UnitedServerListenerManager instance;
+ public static UnitedServerListenerManager getDefault() {
+ if( instance == null )
+ instance = new UnitedServerListenerManager();
+ return instance;
+ }
+
+ protected ArrayList<UnitedServerListener> list;
+ protected UnitedServerListenerManager() {
+ list = new ArrayList<UnitedServerListener>();
+ ServerCore.addServerLifecycleListener(this);
+ IServer[] allServers = ServerCore.getServers();
+ for( int i = 0; i < allServers.length; i++ ) {
+ allServers[i].addServerListener(this);
+ allServers[i].addPublishListener(this);
+ }
+ }
+
+
+ public void addListener(UnitedServerListener listener) {
+ if( !list.contains(listener)) {
+ list.add(listener);
+ IServer[] allServers = ServerCore.getServers();
+ for( int i = 0; i < allServers.length; i++ )
+ listener.init(allServers[i]);
+ }
+ }
+ public void removeListener(UnitedServerListener listener) {
+ list.remove(listener);
+ IServer[] allServers = ServerCore.getServers();
+ for( int i = 0; i < allServers.length; i++ )
+ listener.cleanUp(allServers[i]);
+ }
+
+ public void serverAdded(IServer server) {
+ server.addServerListener(this);
+ server.addPublishListener(this);
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverAdded(server);
+ }
+ }
+ public void serverChanged(IServer server) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverChanged(server);
+ }
+ }
+ public void serverRemoved(IServer server) {
+ server.removeServerListener(this);
+ server.removePublishListener(this);
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverRemoved(server);
+ }
+ }
+
+ public void serverChanged(ServerEvent event) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); ) {
+ i.next().serverChanged(event);
+ }
+ }
+
+ public void publishStarted(IServer server) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); )
+ i.next().publishStarted(server);
+ }
+
+ public void publishFinished(IServer server, IStatus status) {
+ for( Iterator<UnitedServerListener> i = list.iterator(); i.hasNext(); )
+ i.next().publishFinished(server, status);
+ }
+
+}
Show replies by date