Skip to content

Commit

Permalink
Management interface
Browse files Browse the repository at this point in the history
  • Loading branch information
okulikov committed May 22, 2012
1 parent 632a75d commit f156005
Show file tree
Hide file tree
Showing 14 changed files with 422 additions and 304 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
13 changes: 0 additions & 13 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/CommandLineInterface.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/AS7Instance.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/JBossProcess.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/LogViewer.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/nodes/Hk2InstanceNode.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/nodes/Hk2InstanceChildren.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/nodes/Hk2ItemNode.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/nodes/Hk2ApplicationChildren.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/Recognizer.java</file>
<file>file:/home/kulikov/work/jboss-as7/src/org/netbeans/modules/jbossas7/layout.xml</file>
<file>file:/home/kulikov/work/jboss-as7/manifest.mf</file>
</open-files>
</project-private>
110 changes: 41 additions & 69 deletions src/org/netbeans/modules/jbossas7/AS7Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
*/
package org.netbeans.modules.jbossas7;

import java.util.List;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Semaphore;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -46,14 +48,13 @@ public enum ServerState {
private ChangeSupport changeSupport = new ChangeSupport(this);


protected final CommandLineInterface cli = new CommandLineInterface();
protected final ManagementClient cli = new ManagementClient();
private static final RequestProcessor RP = new RequestProcessor("JBoss-AS7",5); // NOI18N

private StartServerTask startServer = new StartServerTask();
private StopServerTask stopServer = new StopServerTask();
private RestartTask restartServer = new RestartTask();

private List<String> applications;
private static final Logger logger = Logger.getLogger("AS7Instance");

public AS7Instance(String name, String path, boolean isDomain) {
Expand Down Expand Up @@ -105,8 +106,28 @@ public String getServerDisplayName() {
return name;
}

public List<String> getApplications() {
return this.applications;
public Collection<String> getApplications() {
try {
return cli.getApplications();
} catch (IOException e) {
return new ArrayList();
}
}

public Collection<String> getExtensions() {
try {
return cli.getExtensions();
} catch (IOException e) {
return new ArrayList();
}
}

public Collection<String> getDatasources() {
try {
return cli.getDataSources();
} catch (IOException e) {
return new ArrayList();
}
}

@Override
Expand Down Expand Up @@ -166,12 +187,11 @@ public void restartServer() {
RP.post(restartServer);
}

public void listApplications() {
cli.setListener(new ApplicationList());
cli.listApplications();
public Collection<String> listApplications() throws IOException {
return cli.getApplications();
}

private class StartServerTask implements Runnable, CommandLineListener {
private class StartServerTask implements Runnable {

private JBossProcess standalone = new JBossProcess("standalone");
private JBossProcess domain = new JBossProcess("domain");
Expand All @@ -192,89 +212,41 @@ public void run() {
LogViewer log = new LogViewer(process);
log.print();

cli.setJBossHome(getLocation());
cli.setListener(this);
cli.connect();
semaphore.acquire();
// semaphore.acquire();

if (success) {
// if (success) {
setState(ServerState.STARTED);
} else {
setState(ServerState.STOPPED);
}
// } else {
// setState(ServerState.STOPPED);
// }
} catch (Exception e) {
setState(ServerState.STOPPED);
}
}

@Override
public void onCommandCompleted(CommandLineInterface cli) {
success = true;
semaphore.release();

listApplications();
}

@Override
public void onCommandFail(CommandLineInterface cli, Exception e) {
success = false;
semaphore.release();
}

}

private class StopServerTask implements Runnable, CommandLineListener {
private class StopServerTask implements Runnable {

@Override
public void run() {
try {
cli.shutdown();
setState(ServerState.STOPPED);
} catch (IOException e) {
}
System.out.println("------------- STOP");
cli.setListener(this);
cli.shutdown();
}

@Override
public void onCommandCompleted(CommandLineInterface cli) {
setState(ServerState.STOPPED);
}

@Override
public void onCommandFail(CommandLineInterface cli, Exception e) {
}

}

private class RestartTask implements Runnable, CommandLineListener {
private class RestartTask implements Runnable {

@Override
public void run() {
System.out.println("------------- STOP");
cli.setListener(this);
cli.shutdown();
}

@Override
public void onCommandCompleted(CommandLineInterface cli) {
setState(ServerState.STOPPED);
startServer();
}

@Override
public void onCommandFail(CommandLineInterface cli, Exception e) {
}

}

private class ApplicationList implements CommandLineListener {

@Override
public void onCommandCompleted(CommandLineInterface cli) {
applications = cli.getApplications();
changeSupport.fireChange();
}

@Override
public void onCommandFail(CommandLineInterface cli, Exception e) {
}

}
}
Loading

0 comments on commit f156005

Please sign in to comment.