Author: adietish
Date: 2011-07-06 10:41:51 -0400 (Wed, 06 Jul 2011)
New Revision: 32656
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PollThreadUtils.java
Log:
[JBIDE-9215] deprecated #getPoller(String pollerId, boolean expectedState, IServer server)
since expected state and server is not used (!)
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java 2011-07-06
14:37:55 UTC (rev 32655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java 2011-07-06
14:41:51 UTC (rev 32656)
@@ -30,7 +30,7 @@
// IF shutting down a process started OUTSIDE of eclipse, force use the web poller,
// since there's no process watch for shutdowns
if( !expectedState && process == null )
- poller = PollThreadUtils.getPoller(WebPortPoller.WEB_POLLER_ID, false, getServer());
+ poller = PollThreadUtils.getPoller(WebPortPoller.WEB_POLLER_ID);
this.pollThread = new PollThread(expectedState, poller, getActualBehavior());
pollThread.start();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PollThreadUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PollThreadUtils.java 2011-07-06
14:37:55 UTC (rev 32655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/PollThreadUtils.java 2011-07-06
14:41:51 UTC (rev 32656)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.core.util;
import org.eclipse.wst.server.core.IServer;
@@ -25,24 +25,58 @@
*/
public class PollThreadUtils {
+ /**
+ * Returns the poller id of the poller that is currently used in the given server and
+ * that is waiting for the given state.
+ *
+ * @param expectedState
+ * @param server
+ * @return
+ */
public static String getPollerId(boolean expectedState, IServer server) {
JBossServer s = ServerConverter.getJBossServer(server);
ServerAttributeHelper helper = s.getAttributeHelper();
String key = expectedState == IServerStatePoller.SERVER_UP ?
- IJBossToolingConstants.STARTUP_POLLER_KEY
+ IJBossToolingConstants.STARTUP_POLLER_KEY
: IJBossToolingConstants.SHUTDOWN_POLLER_KEY;
String defaultPoller = expectedState == IServerStatePoller.SERVER_UP ?
- IJBossToolingConstants.DEFAULT_STARTUP_POLLER
+ IJBossToolingConstants.DEFAULT_STARTUP_POLLER
: IJBossToolingConstants.DEFAULT_SHUTDOWN_POLLER;
String pollerId = helper.getAttribute(key, defaultPoller);
return pollerId;
}
+ /**
+ * Returns the poller that is current used in the given server for the expected state.
+ *
+ * @param expectedState the state that the poller waits for
+ * @param server the server that is using the poller
+ * @return
+ */
public static IServerStatePoller getPoller(boolean expectedState, IServer server) {
- return getPoller(getPollerId(expectedState, server), expectedState, server);
+ return getPoller(getPollerId(expectedState, server));
}
+ /**
+ * Returns the poller for the given poller id.
+ *
+ * @param pollerId the id of the poller to use
+ * @param expectedState
+ * @param server
+ * @return
+ */
+ @Deprecated
public static IServerStatePoller getPoller(String pollerId, boolean expectedState,
IServer server) {
+ return getPoller(pollerId);
+ }
+
+ /**
+ * Returns the poller for the given poller id.
+ *
+ * @param pollerId the id of the poller to use
+ * @return the poller for the given id
+ */
+ public static IServerStatePoller getPoller(String pollerId) {
ServerStatePollerType type = ExtensionManager.getDefault().getPollerType(pollerId);
if (type != null) {
IServerStatePoller tempPoller = type.createPoller();
@@ -52,10 +86,21 @@
return null;
}
+ /**
+ * Stops the given poll thread.
+ *
+ * @param pollThread the poll thread to stop
+ */
public static void stopPolling(PollThread pollThread) {
cancelPolling(null, pollThread);
}
+ /**
+ * Cancels the given poll thread with the given message (that tells about the reason to
cancel polling).
+ *
+ * @param message the reason to cancel the poll thread
+ * @param pollThread the poll thread to cancel
+ */
public static void cancelPolling(String message, PollThread pollThread) {
if (pollThread != null) {
if (message != null) {
@@ -66,13 +111,34 @@
}
}
- protected void pollServer(final boolean expectedState, PollThread pollThread,
DelegatingServerBehavior behaviour, IServer server) {
+ /**
+ * Stops the given poll thread and creates a new poll thread for the given
+ * expected state and server behavior.
+ *
+ * @param expectedState the state to wait for
+ * @param poller the poller to use to wait for the expected state
+ * @param pollThread the poll thread to stop
+ * @param behaviour the server behavior to use.
+ * @return the new poll thread
+ */
+ public static void pollServer(final boolean expectedState, PollThread pollThread,
DelegatingServerBehavior behaviour,
+ IServer server) {
IServerStatePoller poller = PollThreadUtils.getPoller(expectedState, server);
pollServer(expectedState, poller, pollThread, behaviour);
}
-
- public static PollThread pollServer(boolean expectedState, IServerStatePoller poller,
PollThread pollThread, DelegatingServerBehavior behaviour) {
+ /**
+ * Stops the given poll thread and creates a new poll thread for the given
+ * expected state, poller and server behavior.
+ *
+ * @param expectedState the state to wait for
+ * @param poller the poller to use to wait for the expected state
+ * @param pollThread the poll thread to stop
+ * @param behaviour the server behavior to use.
+ * @return the new poll thread
+ */
+ public static PollThread pollServer(boolean expectedState, IServerStatePoller poller,
PollThread pollThread,
+ DelegatingServerBehavior behaviour) {
stopPolling(pollThread);
PollThread newPollThread = new PollThread(expectedState, poller, behaviour);
newPollThread.start();