Author: adietish
Date: 2011-05-03 08:10:45 -0400 (Tue, 03 May 2011)
New Revision: 31031
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerState.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/ModelDescriptionConstants.java
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java
Log:
[JBIDE-8836] added capability to query the as7 for its state
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerState.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerState.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerState.java 2011-05-03
12:10:45 UTC (rev 31031)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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;
+
+/**
+ * @author André Dietisheim
+ */
+public enum JBoss7ServerState {
+ STARTING, RUNNING, RESTART_REQUIRED;
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerState.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java 2011-05-03
11:19:31 UTC (rev 31030)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java 2011-05-03
12:10:45 UTC (rev 31031)
@@ -14,9 +14,12 @@
import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.DEPLOYMENT;
import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.ENABLED;
import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.FAILURE_DESCRIPTION;
+import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.NAME;
import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.OP;
+import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.RESULT;
+import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.SERVER_STATE;
import static
org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.SHUTDOWN;
import java.io.EOFException;
@@ -38,6 +41,7 @@
import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7DeploymentResult;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7DeploymentState;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ManangerException;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ServerState;
import org.jboss.ide.eclipse.as.management.as7.AS7Messages;
/**
@@ -153,6 +157,22 @@
quietlyExecute(request);
}
+ public JBoss7ServerState getServerState() throws JBoss7ManangerException {
+ ModelNode request = new ModelNode();
+ request.get(OP).set(READ_ATTRIBUTE_OPERATION);
+ request.get(NAME).set(SERVER_STATE);
+ ModelNode response = execute(request);
+ return toJBoss7ServerState(response);
+ }
+
+ private JBoss7ServerState toJBoss7ServerState(ModelNode response) throws
JBoss7ManangerException {
+ try {
+ return JBoss7ServerState.valueOf(response.asString());
+ } catch (IllegalArgumentException e) {
+ throw new JBoss7ManangerException(e);
+ }
+ }
+
public void dispose() {
StreamUtils.safeClose(client);
}
@@ -185,7 +205,7 @@
}
private boolean isConnectionCloseException(Exception e) {
- return e instanceof IOException
+ return e instanceof IOException
&& e.getCause() instanceof ExecutionException
&& e.getCause().getCause() instanceof EOFException
&& e.getCause().getCause().getMessage().indexOf("Connection
closed") > -1;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/ModelDescriptionConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/ModelDescriptionConstants.java 2011-05-03
11:19:31 UTC (rev 31030)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/ModelDescriptionConstants.java 2011-05-03
12:10:45 UTC (rev 31031)
@@ -151,6 +151,7 @@
public static final String SERVER_GROUP = "server-group";
public static final String SERVER_GROUPS = "server-groups";
public static final String SERVER_OPERATIONS = "server-operations";
+ public static final String SERVER_STATE = "server-state";
public static final String SHUTDOWN = "shutdown";
public static final String SOCKET_BINDING = "socket-binding";
public static final String SOCKET_BINDING_GROUP = "socket-binding-group";
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java 2011-05-03
11:19:31 UTC (rev 31030)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java 2011-05-03
12:10:45 UTC (rev 31031)
@@ -12,6 +12,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -24,6 +25,7 @@
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7DeploymentState;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ManangerException;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ServerState;
import org.jboss.ide.eclipse.as.management.as7.deployment.AS7Manager;
import org.junit.After;
import org.junit.Before;
@@ -160,11 +162,16 @@
}
@Test
+ public void canGetServerState() throws JBoss7ManangerException {
+ assertEquals(JBoss7ServerState.RUNNING, manager.getServerState());
+ }
+
+ @Test
public void canStopServer() throws JBoss7ManangerException, UnknownHostException,
IOException {
- assertTrue(
- AS7ManagerTestUtils.isListening(AS7ManagerTestUtils.HOST, AS7Manager.MGMT_PORT));
manager.stopServer();
assertFalse(
AS7ManagerTestUtils.isListening(AS7ManagerTestUtils.HOST, AS7Manager.MGMT_PORT));
}
+
+
}
\ No newline at end of file