Author: rob.stryker(a)jboss.com
Date: 2008-03-06 18:14:53 -0500 (Thu, 06 Mar 2008)
New Revision: 6749
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/SecurityFailureHandler.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/extensions/jmx/JMXUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-1646 - trying to allow any type of poller the flexibility to request more info.
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 2008-03-06
22:25:41 UTC (rev 6748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -22,12 +22,17 @@
package org.jboss.ide.eclipse.as.core;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
/**
@@ -49,6 +54,9 @@
/** The map of pollerID -> PollerObject */
private HashMap<String, ServerStatePollerType> pollers;
+ /** The map of pollerID -> PollerObject */
+ private HashMap<String, IPollerFailureHandler> pollerFailureHandlers;
+
/** The method used to load / instantiate the pollers */
public void loadPollers() {
pollers = new HashMap<String, ServerStatePollerType>();
@@ -99,5 +107,39 @@
}
return list.toArray(new ServerStatePollerType[list.size()]);
}
+
+ /** The method used to load / instantiate the failure handlers */
+ public void loadFailureHandler() {
+ pollerFailureHandlers = new HashMap<String, IPollerFailureHandler>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID,
"pollerFailureHandler");
+ for( int i = 0; i < cf.length; i++ ) {
+ try {
+ pollerFailureHandlers.put(cf[i].getAttribute("id"),
+ (IPollerFailureHandler)cf[i].createExecutableExtension("class"));
+ } catch( CoreException e ) {
+ // TODO ERROR LOG
+ } catch( ClassCastException cce ) {
+ // TODO ERROR LOG
+ }
+ }
+ }
+
+ public IPollerFailureHandler[] getPollerFailureHandlers() {
+ if( pollerFailureHandlers == null )
+ loadFailureHandler();
+ Collection<IPollerFailureHandler> c = pollerFailureHandlers.values();
+ return c.toArray(new IPollerFailureHandler[c.size()]);
+ }
+
+ public IPollerFailureHandler getFirstPollFailureHandler(IServerStatePoller poller,
String action, List requiredProperties) {
+ IPollerFailureHandler[] handlers = getPollerFailureHandlers();
+ for( int i = 0; i < handlers.length; i++ ) {
+ if( handlers[i].accepts(poller, action, requiredProperties)) {
+ return handlers[i];
+ }
+ }
+ return null;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXUtil.java 2008-03-06
22:25:41 UTC (rev 6748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXUtil.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -4,7 +4,7 @@
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
-* This is free software; you can redistribute it and/or modify it
+ * This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
@@ -27,35 +27,33 @@
import java.security.Principal;
import java.util.Properties;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
/**
* Utility class
+ *
* @author Rob Stryker rob.stryker(a)redhat.com
- *
+ *
*/
public class JMXUtil {
-
/**
* In the current thread, set the credentials from some server
+ *
* @param server
*/
- public static void setCredentials(IServer server) throws CredentialException {
+ public static void setCredentials(IServer server)
+ throws CredentialException {
+ String user = ServerConverter.getJBossServer(server).getUsername();
+ String pass = ServerConverter.getJBossServer(server).getPassword();
+ setCredentials(server, user, pass);
+ }
+
+ public static void setCredentials(IServer server, Object principal,
+ Object credential) throws CredentialException {
Exception temp = null;
try {
- ILaunchConfiguration lc = server.getLaunchConfiguration(true,
- new NullProgressMonitor());
- // get user from the IServer, but override with launch configuration
- String user = ServerConverter.getJBossServer(server).getUsername();
-
- // get password from the IServer, but override with launch configuration
- String pass = ServerConverter.getJBossServer(server).getPassword();
-
// get our methods
Class simplePrincipal = Thread.currentThread()
.getContextClassLoader().loadClass(
@@ -69,20 +67,18 @@
Constructor newSimplePrincipal = simplePrincipal
.getConstructor(new Class[] { String.class });
Object newPrincipalInstance = newSimplePrincipal
- .newInstance(new Object[] { user });
+ .newInstance(new Object[] { principal });
// set the principal
- Method setPrincipalMethod = securityAssoc.getMethod(
- "setPrincipal", new Class[] { Principal.class });
+ Method setPrincipalMethod = securityAssoc.getMethod("setPrincipal",
+ new Class[] { Principal.class });
setPrincipalMethod.invoke(null,
new Object[] { newPrincipalInstance });
// set the credential
Method setCredentialMethod = securityAssoc.getMethod(
"setCredential", new Class[] { Object.class });
- setCredentialMethod.invoke(null, new Object[] { pass });
- } catch (CoreException e) {
- temp = e;
+ setCredentialMethod.invoke(null, new Object[] { credential });
} catch (ClassNotFoundException e) {
temp = e;
} catch (SecurityException e) {
@@ -101,16 +97,20 @@
if( temp != null )
throw new CredentialException(temp);
}
-
+
public static class CredentialException extends Exception {
private static final long serialVersionUID = 1L;
protected Exception wrapped;
+
public CredentialException(Exception wrapped) {
this.wrapped = wrapped;
}
- public Exception getWrapped() { return wrapped; }
+
+ public Exception getWrapped() {
+ return wrapped;
+ }
}
-
+
public static Properties getDefaultProperties(IServer server) {
int port = ServerConverter.getJBossServer(server).getJNDIPort();
Properties props = new Properties();
@@ -118,8 +118,8 @@
"org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
- props.put("java.naming.provider.url", "jnp://"
- + server.getHost() + ":" + port);
+ props.put("java.naming.provider.url", "jnp://" + server.getHost() +
":"
+ + port);
return props;
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-06
22:25:41 UTC (rev 6748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -22,6 +22,8 @@
package org.jboss.ide.eclipse.as.core.extensions.polling;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import javax.management.MBeanException;
@@ -41,6 +43,7 @@
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXUtil.CredentialException;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
/**
@@ -55,6 +58,8 @@
public static final String STARTED_PROPERTY =
"org.jboss.ide.eclipse.as.core.extensions.polling.jmx.STARTED_PROPERTY";
public static final String EVENT_TYPE_STARTING =
"org.jboss.ide.eclipse.as.core.extensions.polling.jmx.eventTypes.STARTING";
+ public static final String REQUIRED_USER =
"org.jboss.ide.eclipse.as.core.extensions.polling.jmx.REQUIRED_USER";
+ public static final String REQUIRED_PASS =
"org.jboss.ide.eclipse.as.core.extensions.polling.jmx.REQUIRED_PASS";
public static final int STATE_STARTED = 1;
public static final int STATE_STOPPED = 0;
@@ -63,8 +68,12 @@
private int started;
private boolean canceled;
private boolean done;
+ private boolean waitingForCredentials = false;
private IServer server;
+ private ServerStatePollerType type;
private PollingException pollingException = null;
+ private RequiresInfoException requiresInfoException = null;
+ private Properties requiredPropertiesReturned = null;
private EventLogTreeItem event;
@@ -108,9 +117,21 @@
new JMXEvent(event, b);
}
} catch (SecurityException se) {
- pollingException = new PollingSecurityException(
- "Security Exception: " + se.getMessage());
- done = true;
+ if( !waitingForCredentials ) {
+ waitingForCredentials = true;
+ requiresInfoException = new PollingSecurityException(
+ "Security Exception: " + se.getMessage());
+ } else {
+ // we're waiting. are they back yet?
+ if( requiredPropertiesReturned != null ) {
+ requiresInfoException = null;
+ String user, pass;
+ user = (String)requiredPropertiesReturned.get(REQUIRED_USER);
+ pass = (String)requiredPropertiesReturned.get(REQUIRED_PASS);
+ setCredentials(user, pass);
+ waitingForCredentials = false;
+ }
+ }
} catch (CommunicationException ce) {
started = STATE_STOPPED;
new JMXEvent(event, ce);
@@ -152,8 +173,18 @@
pollingException = new PollingException(ce.getWrapped().getMessage());
}
}
+
+ protected void setCredentials(String user, String pass) {
+ try {
+ JMXUtil.setCredentials(server, user, pass);
+ } catch( CredentialException ce ) {
+ pollingException = new PollingException(ce.getWrapped().getMessage());
+ }
+ }
}
+
+
private void launchJMXPoller() {
PollerRunnable run = new PollerRunnable();
Thread t = new Thread(run, "JMX Poller");
@@ -167,16 +198,19 @@
public void cleanup() {
}
- public class PollingSecurityException extends PollingException {
+ public class PollingSecurityException extends RequiresInfoException {
private static final long serialVersionUID = 1L;
public PollingSecurityException(String msg) {
super(msg);
}
}
- public boolean getState() throws PollingException {
+ public boolean getState() throws PollingException, RequiresInfoException {
if (pollingException != null)
throw pollingException;
+ if( requiresInfoException != null )
+ throw requiresInfoException;
+
if (started == 0)
return SERVER_DOWN;
if (started == 1)
@@ -188,9 +222,11 @@
return SERVER_UP; // done or canceled, doesnt matter
}
- public boolean isComplete() throws PollingException {
+ public boolean isComplete() throws PollingException, RequiresInfoException {
if (pollingException != null)
throw pollingException;
+ if( requiresInfoException != null )
+ throw requiresInfoException;
return done;
}
@@ -205,4 +241,24 @@
setProperty(EventLogModel.EXCEPTION_PROPERTY, e);
}
}
+
+
+ public void failureHandled(Properties properties) {
+ requiredPropertiesReturned = properties;
+ }
+
+ public List<String> getRequiredProperties() {
+ ArrayList<String> list = new ArrayList<String>();
+ list.add(REQUIRED_USER);
+ list.add(REQUIRED_PASS);
+ return list;
+ }
+
+ public ServerStatePollerType getPollerType() {
+ return type;
+ }
+
+ public void setPollerType(ServerStatePollerType type) {
+ this.type = type;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2008-03-06
22:25:41 UTC (rev 6748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -21,11 +21,15 @@
*/
package org.jboss.ide.eclipse.as.core.extensions.polling;
+import java.util.List;
+import java.util.Properties;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
/**
* Essentially does nothing because the process already has a listener
@@ -40,6 +44,7 @@
public static final String POLLER_ID =
"org.jboss.ide.eclipse.as.core.runtime.server.processTerminatedPoller";
+ private ServerStatePollerType type;
private JBossServerBehavior server;
public void beginPolling(IServer server, boolean expectedState,
PollThread pt) {
@@ -60,4 +65,20 @@
return server.getProcess() == null || server.getProcess().isTerminated();
}
+ public void failureHandled(Properties properties) {
+ }
+
+ public List getRequiredProperties() {
+ return null;
+ }
+
+ public ServerStatePollerType getPollerType() {
+ return type;
+ }
+
+ public void setPollerType(ServerStatePollerType type) {
+ this.type = type;
+ }
+
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2008-03-06
22:25:41 UTC (rev 6748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -22,6 +22,8 @@
package org.jboss.ide.eclipse.as.core.extensions.polling;
import java.util.Date;
+import java.util.List;
+import java.util.Properties;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.ServerType;
@@ -30,6 +32,7 @@
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
/**
* Wait 15 seconds, then say it's at it's expected state
@@ -42,9 +45,10 @@
private boolean expectedState;
private long endTime;
private IServer server;
- int timeout = -1;
+ private int timeout = -1;
+ private ServerStatePollerType type;
+
-
public void beginPolling(IServer server, boolean expectedState, PollThread pt) {
this.expectedState = expectedState;
this.server = server;
@@ -88,6 +92,21 @@
public boolean supportsStartup() {
return true;
}
+
+ public void failureHandled(Properties properties) {
+ }
+
+ public List getRequiredProperties() {
+ return null;
+ }
+ public ServerStatePollerType getPollerType() {
+ return type;
+ }
+ public void setPollerType(ServerStatePollerType type) {
+ this.type = type;
+ }
+
+
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -0,0 +1,33 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.core.server;
+
+import java.util.List;
+
+/**
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public interface IPollerFailureHandler {
+ public boolean accepts(IServerStatePoller poller, String action, List
requiredProperties);
+ public void handle(IServerStatePoller poller, String action, List requiredProperties);
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-06
22:25:41 UTC (rev 6748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -21,8 +21,12 @@
*/
package org.jboss.ide.eclipse.as.core.server;
+import java.util.List;
+import java.util.Properties;
+
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
/**
* A server state poller will
@@ -37,10 +41,16 @@
public static final int CANCEL = 0;
public static final int TIMEOUT_REACHED = 1;
+ public ServerStatePollerType getPollerType();
+ public void setPollerType(ServerStatePollerType type);
public void beginPolling(IServer server, boolean expectedState, PollThread pt); //
expected to launch own thread
- public boolean isComplete() throws PollingException;
- public boolean getState() throws PollingException;
+
+ public boolean isComplete() throws PollingException, RequiresInfoException;
+ public boolean getState() throws PollingException, RequiresInfoException;
+
public void cleanup(); // clean up any resources / processes. Will ALWAYS be called
+ public List getRequiredProperties();
+ public void failureHandled(Properties properties);
/**
* Cancel the polling.
@@ -51,4 +61,11 @@
public class PollingException extends Exception {
public PollingException(String message) {super(message);}
}
+
+ public class RequiresInfoException extends Exception {
+ private boolean checked = false;
+ public RequiresInfoException(String msg) {super(msg);}
+ public void setChecked() { this.checked = true; }
+ public boolean getChecked() { return this.checked; }
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-03-06
22:25:41 UTC (rev 6748)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -29,9 +29,11 @@
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogRoot;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
+import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
import org.jboss.ide.eclipse.as.core.server.IServerPollingAttributes;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.PollingException;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.RequiresInfoException;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
@@ -86,7 +88,12 @@
IServerPollingAttributes.DEFAULT_SHUTDOWN_POLLER;
String pollerId = helper.getAttribute(key, defaultPoller);
ServerStatePollerType type = ExtensionManager.getDefault().getPollerType(pollerId);
- return type == null ? null : type.createPoller();
+ if( type != null ) {
+ IServerStatePoller tempPoller = type.createPoller();
+ tempPoller.setPollerType(type);
+ return tempPoller;
+ }
+ return null;
}
public void cancel() {
@@ -145,6 +152,14 @@
alertEventLogPollerException(e);
alertBehavior(IServerStatePoller.SERVER_DOWN, false);
return;
+ } catch( RequiresInfoException rie ) {
+ // This way each request for new info is checked only once.
+ if( !rie.getChecked()) {
+ rie.setChecked();
+ String action = expectedState == IServerStatePoller.SERVER_UP ? SERVER_STARTING :
SERVER_STOPPING;
+ IPollerFailureHandler handler =
ExtensionManager.getDefault().getFirstPollFailureHandler(poller, action,
poller.getRequiredProperties());
+ handler.handle(poller, action, poller.getRequiredProperties());
+ }
}
}
@@ -168,6 +183,8 @@
alertEventLogPollerException(pe);
alertBehavior(IServerStatePoller.SERVER_DOWN, false);
return;
+ } catch( RequiresInfoException rie ) {
+ // You don't have an answer... liar!
}
} else {
// we timed out. get response from preferences
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-03-06 22:25:41 UTC (rev
6748)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-03-06 23:14:53 UTC (rev
6749)
@@ -3,6 +3,7 @@
<plugin>
<extension-point id="pollers"
name="org.jboss.ide.eclipse.as.core.runtime.server.pollers"
schema="schema/pollers.exsd"/>
+ <extension-point id="pollerFailureHandler"
name="org.jboss.ide.eclipse.as.core.runtime.server.pollerFailureHandler"
schema="schema/pollerFailureHandler.exsd"/>
<extension
point="org.eclipse.wst.server.core.serverTypes">
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd 2008-03-06
23:14:53 UTC (rev 6749)
@@ -0,0 +1,112 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.ide.eclipse.as.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.ide.eclipse.as.core"
id="pollerFailureHandler"
name="org.jboss.ide.eclipse.as.core.runtime.server."/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="pollerHandler" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="pollerHandler">
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/SecurityFailureHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/SecurityFailureHandler.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/SecurityFailureHandler.java 2008-03-06
23:14:53 UTC (rev 6749)
@@ -0,0 +1,31 @@
+package org.jboss.ide.eclipse.as.ui.launch;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.jboss.ide.eclipse.as.core.extensions.polling.JMXPoller;
+import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
+
+/**
+ *
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public class SecurityFailureHandler implements IPollerFailureHandler {
+
+ public boolean accepts(IServerStatePoller poller, String action,
+ List requiredProperties) {
+ if(
poller.getPollerType().getId().equals("org.jboss.ide.eclipse.as.core.runtime.server.JMXPoller"))
+ return true;
+ return false;
+ }
+
+ public void handle(IServerStatePoller poller, String action, List requiredProperties) {
+ Properties p = new Properties();
+ p.put(JMXPoller.REQUIRED_USER, "admin" );
+ p.put(JMXPoller.REQUIRED_PASS, "admin");
+ poller.failureHandled(p);
+ System.out.println("handled");
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-03-06 22:25:41 UTC (rev
6748)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-03-06 23:14:53 UTC (rev
6749)
@@ -340,5 +340,12 @@
</enablement>
</consolePatternMatchListener>
</extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.pollerFailureHandler">
+ <pollerHandler
+ class="org.jboss.ide.eclipse.as.ui.launch.SecurityFailureHandler"
+ id="org.jboss.ide.eclipse.as.ui.launch.securityPollerHandler">
+ </pollerHandler>
+ </extension>
</plugin>