Author: rob.stryker(a)jboss.com
Date: 2012-04-05 02:18:15 -0400 (Thu, 05 Apr 2012)
New Revision: 40049
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IManagementPortProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerModuleStateVerifier.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLT6ModuleStateVerifier.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossEAP60ExtendedProperties.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS710ExtendedProperties.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS7ExtendedProperties.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss3To6ConnectionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ConnectionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/JBTWebLaunchableClient.java
Log:
JBIDE-11483, JBIDE-11479, JBIDE-11482, jmx related stuff with addition of verifier for
segregating module state verification
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IManagementPortProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IManagementPortProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IManagementPortProvider.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server;
+
+/**
+ * An object that can provide an as7-style management port
+ */
+public interface IManagementPortProvider {
+ public int getManagementPort();
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerModuleStateVerifier.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerModuleStateVerifier.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerModuleStateVerifier.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * An interface for checking the state of remote modules by
+ * actually communicating with the server to check it.
+ *
+ */
+public interface IServerModuleStateVerifier {
+ /**
+ * Check to see if the module is started on the server
+ */
+ public boolean isModuleStarted(IServer server, IModule module, IProgressMonitor
monitor);
+
+ /**
+ * Wait until the module is started on the server
+ */
+ public void waitModuleStarted(IServer server, IModule module, IProgressMonitor
monitor);
+
+ /**
+ * Wait until the module is started on the server with a max delay as provided
+ */
+ public void waitModuleStarted(IServer server, IModule module, int maxDelay);
+
+
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLT6ModuleStateVerifier.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLT6ModuleStateVerifier.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossLT6ModuleStateVerifier.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.ExtensionManager.IServerJMXRunnable;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
+import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
+
+public class JBossLT6ModuleStateVerifier implements IServerModuleStateVerifier {
+ public boolean isModuleStarted(final IServer server, final IModule module,
+ final IProgressMonitor monitor) {
+ final boolean[] result = new boolean[1];
+ result[0] = false;
+ IServerJMXRunnable r = new IServerJMXRunnable() {
+ public void run(MBeanServerConnection connection) throws Exception {
+ result[0] = checkDeploymentStarted(server, module, connection, monitor);
+ }
+ };
+ try {
+ ExtensionManager.getDefault().getJMXRunner().run(server, r);
+ } catch( CoreException jmxe ) {
+ IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.RESUME_DEPLOYMENT_SCANNER, Messages.JMXResumeScannerError, jmxe);
+ ServerLogger.getDefault().log(server, status);
+ } finally {
+ ExtensionManager.getDefault().getJMXRunner().endTransaction(server, this);
+ }
+ return result[0];
+ }
+
+ public void waitModuleStarted(IServer server, IModule module, int maxDelay) {
+ final NullProgressMonitor monitor = new NullProgressMonitor();
+ Thread t = new Thread(){
+ public void run() {
+ try {
+ Thread.sleep(20000);
+ } catch(InterruptedException ie) {
+ return;
+ }
+ synchronized(monitor) {
+ monitor.setCanceled(false);
+ }
+ }
+ };
+ t.start();
+
+ // synchronous call to wait
+ waitModuleStarted(server, module, monitor);
+
+ // call is over, can notify the thread to go finish itself
+ synchronized(monitor) {
+ if( !monitor.isCanceled() )
+ t.notify();
+ }
+ }
+ public void waitModuleStarted(IServer server, IModule module,
+ IProgressMonitor monitor) {
+ waitJMX(server, module);
+ }
+
+ protected void waitJMX(final IServer server, final IModule module) {
+ IServerJMXRunnable r = new IServerJMXRunnable() {
+ public void run(MBeanServerConnection connection) throws Exception {
+ jmxWaitForDeploymentStarted(server, module, connection, null);
+ }
+ };
+ try {
+ ExtensionManager.getDefault().getJMXRunner().run(server, r);
+ } catch( CoreException jmxe ) {
+ IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.RESUME_DEPLOYMENT_SCANNER, Messages.JMXResumeScannerError, jmxe);
+ ServerLogger.getDefault().log(server, status);
+ } finally {
+ ExtensionManager.getDefault().getJMXRunner().endTransaction(server, this);
+ }
+ }
+
+ protected void jmxWaitForDeploymentStarted(final IServer server, final IModule module,
+ final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
+ monitor = monitor == null ? new NullProgressMonitor() : monitor;
+ monitor.beginTask("Ensuring Deployments are Loaded", 10000); //$NON-NLS-1$
+ while( !monitor.isCanceled()) {
+ boolean done = checkDeploymentStarted(server, module, connection, monitor);
+ if( done ) {
+ monitor.done();
+ return;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch(InterruptedException ie) {
+ // Intentional ignore
+ }
+ }
+ }
+
+ protected boolean checkDeploymentStarted(final IServer server, final IModule module,
+ final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
+ String typeId;
+ typeId = module.getModuleType().getId();
+
+ if( typeId.equals("wst.web") || typeId.equals("jst.web")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ String mbeanName = null;
+ IModule earParent = findEarParent(server, module);
+ String stateAttribute;
+ Object result;
+ if( earParent == null ) {
+ mbeanName =
"jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,name=//localhost/"
+ module.getName(); //$NON-NLS-1$
+ stateAttribute = "state"; //$NON-NLS-1$
+ result = getAttributeResult(connection, mbeanName, stateAttribute);
+ if(result == null || !(result instanceof Integer) || ((Integer)result).intValue() !=
1 ) {
+ return false;
+ }
+ } else {
+ mbeanName = "jboss.deployment:id=\"jboss.web.deployment:war=/" +
module.getName() + "\",type=Component"; //$NON-NLS-1$//$NON-NLS-2$
+ stateAttribute = "State"; //$NON-NLS-1$
+ result = getAttributeResult(connection, mbeanName, stateAttribute);
+ if( result == null || !result.toString().equals("DEPLOYED"))
//$NON-NLS-1$
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private Object getAttributeResult(final MBeanServerConnection connection, String
mbeanName, String stateAttribute) throws Exception {
+ ObjectName on = new ObjectName(mbeanName);
+ try {
+ return connection.getAttribute(on, stateAttribute);
+ } catch(InstanceNotFoundException infe) {
+ return false;
+ }
+ }
+
+ /* TODO Unify findEarParent with findRootModule */
+ private IModule findEarParent(IServer server, IModule module) {
+ try {
+ IModule[] deployed = server.getModules();
+ ArrayList<IModule> deployedAsList = new ArrayList<IModule>();
+ deployedAsList.addAll(Arrays.asList(deployed));
+ IModule[] possibleParents = server.getRootModules(module, new NullProgressMonitor());
+ for( int i = 0; i < possibleParents.length; i++ ) {
+ if( possibleParents[i].getModuleType().getId().equals("jst.ear") &&
deployedAsList.contains(possibleParents[i])) //$NON-NLS-1$
+ return possibleParents[i];
+ }
+ } catch(CoreException ce) {
+ // Should never be reached
+ }
+ return null;
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS710ExtendedProperties.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS710ExtendedProperties.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS710ExtendedProperties.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -22,6 +22,9 @@
}
public int getJMXProviderType() {
- return JMX_AS_710_PROVIDER;
+ return JMX_OVER_AS_MANAGEMENT_PORT_PROVIDER;
}
+ public boolean runtimeSupportsBindingToAllInterfaces() {
+ return true;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS7ExtendedProperties.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS7ExtendedProperties.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossAS7ExtendedProperties.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -16,6 +16,8 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IRuntime;
import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ModuleStateVerifier;
import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
@@ -37,6 +39,8 @@
public boolean runtimeSupportsBindingToAllInterfaces() {
String version = getServerBeanLoader().getFullServerVersion();
+ if( version == null )
+ return true;
if( version.startsWith("7.0.1") || version.startsWith("7.0.0"))
//$NON-NLS-1$//$NON-NLS-2$
return false;
return true;
@@ -60,4 +64,12 @@
return null;
}
+ public boolean canVerifyRemoteModuleState() {
+ return true;
+ }
+
+ public IServerModuleStateVerifier getModuleStateVerifier() {
+ return new JBoss7ModuleStateVerifier();
+ }
+
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossEAP60ExtendedProperties.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossEAP60ExtendedProperties.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossEAP60ExtendedProperties.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.extendedproperties;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ *
+ */
+public class JBossEAP60ExtendedProperties extends JBossAS710ExtendedProperties {
+
+ public JBossEAP60ExtendedProperties(IAdaptable obj) {
+ super(obj);
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -12,16 +12,33 @@
import java.io.File;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.ExtensionManager.IServerJMXRunnable;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
+import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossLT6ModuleStateVerifier;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;
@@ -56,7 +73,7 @@
}
public int getJMXProviderType() {
- return JMX_AS_3_TO_6_PROVIDER;
+ return JMX_OVER_JNDI_PROVIDER;
}
public boolean hasWelcomePage() {
@@ -102,4 +119,12 @@
return null;
}
+ public boolean canVerifyRemoteModuleState() {
+ return true;
+ }
+
+ public IServerModuleStateVerifier getModuleStateVerifier() {
+ return new JBossLT6ModuleStateVerifier();
+ }
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -16,6 +16,7 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerAttributes;
+import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
public class ServerExtendedProperties {
protected IServerAttributes server;
@@ -35,8 +36,15 @@
public static final int JMX_NULL_PROVIDER = -1;
public static final int JMX_DEFAULT_PROVIDER = 0;
- public static final int JMX_AS_3_TO_6_PROVIDER = 1;
- public static final int JMX_AS_710_PROVIDER = 2;
+ public static final int JMX_OVER_JNDI_PROVIDER = 1;
+
+ /**
+ * Server types that have JMX_OVER_AS_MANAGEMENT_PORT as their jmx type
+ * are expected to implement IManagementPortProvider, so the jmx
+ * knows what port to check. Any servers that use JMX_OVER_AS_MANAGEMENT_PORT
+ * but do not implement the interface will have a default port of 9999 used.
+ */
+ public static final int JMX_OVER_AS_MANAGEMENT_PORT_PROVIDER = 2;
public int getJMXProviderType() {
return JMX_NULL_PROVIDER;
}
@@ -60,4 +68,12 @@
public IStatus verifyServerStructure() {
return Status.OK_STATUS;
}
+
+ public boolean canVerifyRemoteModuleState() {
+ return false;
+ }
+
+ public IServerModuleStateVerifier getModuleStateVerifier() {
+ return null;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/DelegatingJBoss7ServerBehavior.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugEvent;
@@ -27,6 +28,7 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.Trace;
@@ -35,8 +37,10 @@
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
+import
org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -102,6 +106,22 @@
}
@Override
+ public void stopModule(IModule[] module, IProgressMonitor monitor) throws CoreException
{
+ IDeployableServer ds = ServerConverter.getDeployableServer(getServer());
+ if( ds == null )
+ return;
+
+ IJBossServerPublishMethod method = createPublishMethod();
+ DeploymentMarkerUtils.removeDeployedMarkerIfExists(method, ds, module, monitor);
+ setModuleState(module, IServer.STATE_STOPPED );
+ }
+
+ @Override
+ public void startModule(IModule[] module, IProgressMonitor monitor) throws CoreException
{
+ restartModule(module, monitor);
+ }
+
+ @Override
public void restartModule(IModule[] module, IProgressMonitor monitor) throws
CoreException {
IDeployableServer ds = ServerConverter.getDeployableServer(getServer());
if( ds == null )
@@ -109,7 +129,16 @@
IJBossServerPublishMethod method = createPublishMethod();
IPath depPath = PublishUtil.getDeployPath(method, module, ds);
- createDoDeployMarker(method, new IPath[]{depPath}, monitor);
+ createDoDeployMarker(method, Arrays.asList(new IPath[]{depPath}), monitor);
+ setModuleState(module, IServer.STATE_STARTING);
+ ServerExtendedProperties props = (ServerExtendedProperties)getServer()
+ .loadAdapter(ServerExtendedProperties.class, new NullProgressMonitor());
+ if( props != null && props.canVerifyRemoteModuleState()) {
+ IServerModuleStateVerifier verifier = props.getModuleStateVerifier();
+ if( verifier != null ) {
+ verifier.waitModuleStarted(getServer(), module[module.length-1], 20000);
+ }
+ }
}
@Override
@@ -177,10 +206,7 @@
}
return (List<IPath>) o;
}
- private void createDoDeployMarker(IJBossServerPublishMethod method, IPath[] paths,
IProgressMonitor monitor) throws CoreException {
- List<IPath> allPaths = Arrays.asList(paths);
- createDoDeployMarker(method, allPaths, monitor);
- }
+
private void createDoDeployMarker(IJBossServerPublishMethod method, List<IPath>
paths, IProgressMonitor monitor) throws CoreException {
if( method == null )
method = createPublishMethod();
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ *
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.v7;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
+import org.jboss.ide.eclipse.as.core.server.v7.management.AS7ManagementDetails;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.management.core.IJBoss7ManagerService;
+import org.jboss.ide.eclipse.as.management.core.JBoss7DeploymentState;
+import org.jboss.ide.eclipse.as.management.core.JBoss7ManagerUtil;
+
+public class JBoss7ModuleStateVerifier implements IServerModuleStateVerifier {
+ public void waitModuleStarted(IServer server, IModule module, int maxDelay) {
+ final NullProgressMonitor monitor = new NullProgressMonitor();
+ Thread t = new Thread(){
+ public void run() {
+ try {
+ Thread.sleep(20000);
+ } catch(InterruptedException ie) {
+ return;
+ }
+ synchronized(monitor) {
+ monitor.setCanceled(true);
+ }
+ }
+ };
+ t.start();
+
+ // synchronous call to wait
+ waitModuleStarted(server, module, monitor);
+
+ // call is over, can notify the thread to go finish itself
+ synchronized(monitor) {
+ if( !monitor.isCanceled() )
+ t.notify();
+ }
+ }
+
+ public boolean isModuleStarted(IServer server, IModule module,
+ IProgressMonitor monitor) {
+ IModule rootModule = findRootModule(server, module);
+ try {
+ return isRootModuleStarted(server, rootModule, monitor);
+ } catch(Exception e ) {
+ String er = "Error occurred while checking module state for {0} on server
{1}"; //$NON-NLS-1$
+ IStatus s = new Status(
+ IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(er, rootModule.getName(), server.getName()), e);
+ ServerLogger.getDefault().log(server, s);
+ return false;
+ }
+ }
+
+ private boolean isRootModuleStarted(IServer server, IModule root, IProgressMonitor
monitor) throws Exception {
+ JBoss7Server jbossServer = ServerConverter.checkedGetJBossServer(server,
JBoss7Server.class);
+ IJBoss7ManagerService service = JBoss7ManagerUtil.getService(server);
+ IPath deployPath = PublishUtil.getDeployPath(new IModule[]{root}, jbossServer);
+ return isRootModuleStarted(server, root, service, deployPath, monitor);
+ }
+
+ private boolean isRootModuleStarted(IServer server, IModule root,
+ IJBoss7ManagerService service, IPath deployPath, IProgressMonitor monitor) throws
Exception {
+ AS7ManagementDetails details = new AS7ManagementDetails(server);
+ boolean done = false;
+ if (service.isRunning(details)) { // to avoid asking while server is starting up.
+ JBoss7DeploymentState state = service.getDeploymentState(
+ details, deployPath.lastSegment());
+ done = (state == JBoss7DeploymentState.STARTED);
+ }
+ return done;
+ }
+
+
+ public void waitModuleStarted(IServer server, IModule module, IProgressMonitor monitor)
{
+ IModule rootModule = findRootModule(server, module);
+ try {
+ JBoss7Server jbossServer = ServerConverter.checkedGetJBossServer(server,
JBoss7Server.class);
+ IJBoss7ManagerService service = JBoss7ManagerUtil.getService(server);
+ IPath deployPath = PublishUtil.getDeployPath(new IModule[]{rootModule}, jbossServer);
+ boolean waitedOnce = false;
+
+ while (!monitor.isCanceled()) {
+ boolean done = isRootModuleStarted(server, rootModule, service, deployPath,
monitor);
+ if (done) {
+ return;
+ }
+ if(!waitedOnce) {
+ String info = "Module {0} on {1} not yet fully deployed. Waiting...";
//$NON-NLS-1$
+ IStatus s = new Status( IStatus.INFO, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(info, rootModule.getName(), server.getName()),null);
+ ServerLogger.getDefault().log(server, s);
+ }
+ waitedOnce = true;
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ie) {
+ // Ignore, intentional
+ }
+ }
+
+ String warning = "Module {0} on {1} still not ready to be shown in browser.
Aborting delay."; //$NON-NLS-1$
+ IStatus s = new Status(
+ IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(warning, rootModule.getName(), server.getName()), null);
+ ServerLogger.getDefault().log(server, s);
+ } catch (Exception e) {
+ String er = "Error occurred while waiting for {0} to start on server {1}";
//$NON-NLS-1$
+ IStatus s = new Status(
+ IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(er, rootModule.getName(), server.getName()), e);
+ ServerLogger.getDefault().log(server, s);
+ }
+ }
+
+ private IModule findRootModule(IServer server, IModule module) {
+ IModule[] rootMods = null;
+ try {
+ rootMods = server.getRootModules(module, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ return module; // No need to log this
+ }
+ if( rootMods == null || rootMods.length == 0 )
+ return module;
+ List<IModule> serverHas = Arrays.asList(server.getModules());
+ for( int i = 0; i < rootMods.length; i++ ) {
+ if( serverHas.contains(rootMods[i]))
+ // Grab the first parent module that's already on the server
+ return rootMods[i];
+ }
+ return module;
+ }
+
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -23,13 +23,14 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.server.core.IRuntime;
import org.jboss.ide.eclipse.as.core.extensions.polling.WebPortPoller;
+import org.jboss.ide.eclipse.as.core.server.IManagementPortProvider;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import
org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
import org.jboss.ide.eclipse.as.core.util.ExpressionResolverUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;
-public class JBoss7Server extends JBossServer implements IJBoss7Deployment {
+public class JBoss7Server extends JBossServer implements IJBoss7Deployment,
IManagementPortProvider {
public void setDefaults(IProgressMonitor monitor) {
super.setDefaults(monitor);
setAttribute(DEPLOY_DIRECTORY_TYPE, DEPLOY_SERVER);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-04-05 06:08:00 UTC (rev
40048)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-04-05 06:18:15 UTC (rev
40049)
@@ -1202,6 +1202,16 @@
type="org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.JBossExtendedProperties">
</adapter>
</factory>
+ <factory
+ adaptableType="org.eclipse.wst.server.core.IRuntime"
+
class="org.jboss.ide.eclipse.as.core.server.internal.ExtendedServerPropertiesAdapterFactory">
+ <adapter
+
type="org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties">
+ </adapter>
+ <adapter
+
type="org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.JBossExtendedProperties">
+ </adapter>
+ </factory>
</extension>
</plugin>
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss3To6ConnectionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss3To6ConnectionProvider.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss3To6ConnectionProvider.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -23,7 +23,7 @@
public JBoss3To6ConnectionProvider() {
super();
repository = new JMXClassLoaderRepository();
- JBossJMXConnectionProviderModel.getDefault().registerProvider(ServerExtendedProperties.JMX_AS_3_TO_6_PROVIDER,
this);
+ JBossJMXConnectionProviderModel.getDefault().registerProvider(ServerExtendedProperties.JMX_OVER_JNDI_PROVIDER,
this);
}
public String getName(IConnectionWrapper wrapper) {
@@ -36,7 +36,7 @@
protected boolean belongsHere(IServer server) {
JBossExtendedProperties props =
ExtendedServerPropertiesAdapterFactory.getJBossExtendedProperties(server);
int type = props == null ? -1 : props.getJMXProviderType();
- return type == JBossExtendedProperties.JMX_AS_3_TO_6_PROVIDER;
+ return type == JBossExtendedProperties.JMX_OVER_JNDI_PROVIDER;
}
protected IConnectionWrapper createConnection(IServer server) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ConnectionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ConnectionProvider.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ConnectionProvider.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -23,7 +23,7 @@
public JBoss71ConnectionProvider() {
super();
repository = new AS71JMXClassLoaderRepository();
- JBossJMXConnectionProviderModel.getDefault().registerProvider(ServerExtendedProperties.JMX_AS_710_PROVIDER,
this);
+ JBossJMXConnectionProviderModel.getDefault().registerProvider(ServerExtendedProperties.JMX_OVER_AS_MANAGEMENT_PORT_PROVIDER,
this);
}
@@ -37,7 +37,7 @@
protected boolean belongsHere(IServer server) {
JBossExtendedProperties props =
ExtendedServerPropertiesAdapterFactory.getJBossExtendedProperties(server);
int type = props == null ? -1 : props.getJMXProviderType();
- return type == JBossExtendedProperties.JMX_AS_710_PROVIDER;
+ return type == JBossExtendedProperties.JMX_OVER_AS_MANAGEMENT_PORT_PROVIDER;
}
protected IConnectionWrapper createConnection(IServer server) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -19,6 +19,9 @@
import javax.management.remote.JMXServiceURL;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+import org.jboss.ide.eclipse.as.core.server.IManagementPortProvider;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.jmx.integration.JMXUtil.CredentialException;
import org.jboss.tools.jmx.core.ExtensionManager;
import org.jboss.tools.jmx.core.IConnectionProvider;
@@ -37,8 +40,15 @@
}
protected MBeanServerConnection createConnection(IServer s) throws Exception {
+ ServerDelegate sd = (ServerDelegate)s.loadAdapter(ServerDelegate.class, null);
+ int port = -1;
+ if( !(sd instanceof IManagementPortProvider))
+ port = IJBossToolingConstants.AS7_MANAGEMENT_PORT_DEFAULT_PORT;
+ else {
+ port = ((IManagementPortProvider)sd).getManagementPort();
+ }
try {
- String url = "service:jmx:remoting-jmx://" + s.getHost() +
":9999"; // TODO externalize this?
+ String url = "service:jmx:remoting-jmx://" + s.getHost() + ":" +
port;
Map<String, String[]> environment = new HashMap<String, String[]>();
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(url),
environment);
MBeanServerConnection connection = connector.getMBeanServerConnection();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/JBTWebLaunchableClient.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/JBTWebLaunchableClient.java 2012-04-05
06:08:00 UTC (rev 40048)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/JBTWebLaunchableClient.java 2012-04-05
06:18:15 UTC (rev 40049)
@@ -13,24 +13,12 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
@@ -41,22 +29,9 @@
import org.eclipse.wst.server.core.IServerListener;
import org.eclipse.wst.server.core.ServerEvent;
import org.eclipse.wst.server.core.model.ClientDelegate;
-import org.jboss.ide.eclipse.as.core.ExtensionManager;
-import org.jboss.ide.eclipse.as.core.ExtensionManager.IServerJMXRunnable;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.Messages;
-import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
-import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
-import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
import
org.jboss.ide.eclipse.as.core.server.internal.JBossLaunchAdapter.JBTCustomHttpLaunchable;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
-import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7Server;
-import org.jboss.ide.eclipse.as.core.server.v7.management.AS7ManagementDetails;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.core.util.ServerUtil;
-import org.jboss.ide.eclipse.as.management.core.IJBoss7ManagerService;
-import org.jboss.ide.eclipse.as.management.core.JBoss7DeploymentState;
-import org.jboss.ide.eclipse.as.management.core.JBoss7ManagerUtil;
+import
org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
public class JBTWebLaunchableClient extends ClientDelegate {
@@ -68,11 +43,6 @@
return (launchable instanceof JBTCustomHttpLaunchable);
}
- protected boolean isJMXServer(IServer server) {
- JBossServer jbs = ServerConverter.getJBossServer(server);
- return jbs != null && jbs.hasJMXProvider() &&
ExtensionManager.getDefault().getJMXRunner() != null;
- }
-
public IStatus launch(final IServer server, final Object launchable, final String
launchMode, final ILaunch launch) {
if( server.getServerState() == IServer.STATE_STOPPED || server.getServerState() ==
IServer.STATE_STOPPING)
return Status.CANCEL_STATUS;
@@ -97,17 +67,26 @@
});
} else {
JBossServerUIPlugin.getDefault().getLog().log(
- new Status(IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID, "Server stopped
before before browser could be opened.", null));
+ new Status(IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID,
+ "Server stopped before before browser could be opened.", null));
}
return null;
}
protected void wait(final IServer server, final IModule module) {
+ // Wait for the server to be started. No remote polling necessary.
+ // Framework poller is handling that. Here just wait in the state event framework
waitServerStarted(server);
- if( isJMXServer(server)) {
- waitJMX(server, module);
- } else if( ServerUtil.isJBoss7(server)) {
- waitJBoss7(server, module);
+
+ // Now check if we are able to poll the server on module state or not
+ ServerExtendedProperties props = (ServerExtendedProperties)server
+ .loadAdapter(ServerExtendedProperties.class, new NullProgressMonitor());
+ if( props != null && props.canVerifyRemoteModuleState()) {
+ IServerModuleStateVerifier verifier = props.getModuleStateVerifier();
+ if( verifier != null ) {
+ // we can verify the remote state, so go do it, so go wait for the module to be
deployed
+ verifier.waitModuleStarted(server, module, 20000);
+ }
}
}
@@ -135,168 +114,6 @@
server.removeServerListener(listener);
}
- private IModule findRootModule(IServer server, IModule module) {
- IModule[] rootMods = null;
- try {
- rootMods = server.getRootModules(module, new NullProgressMonitor());
- } catch( CoreException ce ) {
- return module; // No need to log this
- }
- if( rootMods == null || rootMods.length == 0 )
- return module;
- List<IModule> serverHas = Arrays.asList(server.getModules());
- for( int i = 0; i < rootMods.length; i++ ) {
- if( serverHas.contains(rootMods[i]))
- // Grab the first parent module that's already on the server
- return rootMods[i];
- }
- return module;
- }
-
- //TODO: the waiting/timeout logic in here should be done for waitJMX too.
- //TODO: should return true for succss or false if timeout so upper layer can report it.
- protected void waitJBoss7(final IServer server, final IModule module2) {
- IModule rootModule = findRootModule(server, module2);
- try {
- JBoss7Server jbossServer = ServerConverter.checkedGetJBossServer(server,
JBoss7Server.class);
- IJBoss7ManagerService service = JBoss7ManagerUtil.getService(server);
- IPath deployPath = PublishUtil.getDeployPath(new IModule[]{rootModule}, jbossServer);
- long time = new Date().getTime();
- long endTime = time + getMaxDelay();
- boolean waitedOnce = false;
-
- while (new Date().getTime() < endTime) { // no need to keep doing this if timed out
or server stopping/stopped but not sure how to avoid race condition.
- AS7ManagementDetails details = new AS7ManagementDetails(server);
- boolean done = false;
- if (service.isRunning(details)) { // to avoid asking while server is starting up.
- JBoss7DeploymentState state = service.getDeploymentState(
- details, deployPath.lastSegment());
- done = (state == JBoss7DeploymentState.STARTED);
- }
- if (done) {
- return;
- }
- if(!waitedOnce) {
- JBossServerUIPlugin.log(new Status(
- IStatus.INFO, JBossServerUIPlugin.PLUGIN_ID,
- "Module " + rootModule.getName() + " on " + server.getName() +
" not ready to be shown in web browser. Waiting...", null));
- }
- waitedOnce = true;
- try {
- Thread.sleep(2000);
- } catch (InterruptedException ie) {
- // Ignore, intentional
- }
- }
- } catch (Exception e) {
- IStatus s = new Status(
- IStatus.WARNING,
- JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(
- "Error occurred while waiting for " + rootModule.getName() + " to
start on " + server.getName(),
- server.getName()), e);
- JBossServerUIPlugin.log(s.getMessage(), e);
- }
-
- }
-
- protected void waitJMX(final IServer server, final IModule module) {
- IServerJMXRunnable r = new IServerJMXRunnable() {
- public void run(MBeanServerConnection connection) throws Exception {
- jmxWaitForDeploymentStarted(server, module, connection, null);
- }
- };
- try {
- ExtensionManager.getDefault().getJMXRunner().run(server, r);
- } catch( CoreException jmxe ) {
- IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.RESUME_DEPLOYMENT_SCANNER, Messages.JMXResumeScannerError, jmxe);
- ServerLogger.getDefault().log(server, status);
- } finally {
- ExtensionManager.getDefault().getJMXRunner().endTransaction(server, this);
- }
- }
-
- protected void jmxWaitForDeploymentStarted(final IServer server, final IModule module,
- final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
- monitor = monitor == null ? new NullProgressMonitor() : monitor;
- monitor.beginTask("Ensuring Deployments are Loaded", 10000); //$NON-NLS-1$
- long time = new Date().getTime();
- long endTime = time + getMaxDelay();
- while( new Date().getTime() < endTime ) {
- boolean done = checkDeploymentStarted(server, module, connection, monitor);
- if( done ) {
- monitor.done();
- return;
- }
- try {
- Thread.sleep(1000);
- } catch(InterruptedException ie) {
- // Intentional ignore
- }
- }
- }
-
- protected long getMaxDelay() {
- return 20000;
- }
-
- protected boolean checkDeploymentStarted(final IServer server, final IModule module,
- final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
- String typeId;
- typeId = module.getModuleType().getId();
-
- if( typeId.equals("wst.web") || typeId.equals("jst.web")) {
//$NON-NLS-1$ //$NON-NLS-2$
- String mbeanName = null;
- IModule earParent = findEarParent(server, module);
- String stateAttribute;
- Object result;
- if( earParent == null ) {
- mbeanName =
"jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,name=//localhost/"
+ module.getName(); //$NON-NLS-1$
- stateAttribute = "state"; //$NON-NLS-1$
- result = getAttributeResult(connection, mbeanName, stateAttribute);
- if(result == null || !(result instanceof Integer) || ((Integer)result).intValue() !=
1 ) {
- return false;
- }
- } else {
- mbeanName = "jboss.deployment:id=\"jboss.web.deployment:war=/" +
module.getName() + "\",type=Component"; //$NON-NLS-1$//$NON-NLS-2$
- stateAttribute = "State"; //$NON-NLS-1$
- result = getAttributeResult(connection, mbeanName, stateAttribute);
- if( result == null || !result.toString().equals("DEPLOYED"))
//$NON-NLS-1$
- return false;
- }
- }
- return true;
- }
-
- private Object getAttributeResult(final MBeanServerConnection connection, String
mbeanName, String stateAttribute) throws Exception {
- ObjectName on = new ObjectName(mbeanName);
- try {
- return connection.getAttribute(on, stateAttribute);
- } catch(InstanceNotFoundException infe) {
- return false;
- }
- }
-
- /* TODO Unify findEarParent with findRootModule */
- private IModule findEarParent(IServer server, IModule module) {
- try {
- IModule[] deployed = server.getModules();
- ArrayList<IModule> deployedAsList = new ArrayList<IModule>();
- deployedAsList.addAll(Arrays.asList(deployed));
- IModule[] possibleParents = server.getRootModules(module, new NullProgressMonitor());
- for( int i = 0; i < possibleParents.length; i++ ) {
- if( possibleParents[i].getModuleType().getId().equals("jst.ear") &&
deployedAsList.contains(possibleParents[i]))
- return possibleParents[i];
- }
- } catch(CoreException ce) {
- // Should never be reached
- }
- return null;
- }
-
-
-
-
/*
* Stolen from BrowserUtil
*/