Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
[WFLY-1197] Port of legacy JMX Console
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Laskawiec authored and Sebastian Laskawiec committed Jun 8, 2014
0 parents commit 8bcd82d
Show file tree
Hide file tree
Showing 20 changed files with 2,171 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.class
target/
*.iml
88 changes: 88 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.wildfly.jmx-console</groupId>
<artifactId>jmx-console</artifactId>
<version>1.0.0-SNAPSHOT</version>

<name>WildFly: Legacy jmx-console</name>

<packaging>war</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-parent</artifactId>
<version>8.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>org.dom4j, org.jboss.common-core</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
96 changes: 96 additions & 0 deletions src/main/java/org/wildfly/jmx/adaptor/control/AddressPort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file 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.wildfly.jmx.adaptor.control;

import java.io.IOException;
import java.lang.reflect.Method;
import java.net.InetAddress;

/**
* A utility class for parsing cluster member addresses
*
* @author [email protected]
* @author [email protected]
*/
public class AddressPort {

InetAddress addr;

Integer port;

/**
* Use reflection to access the address InetAddress and port if they exist in the Address implementation
*/
public static AddressPort getMemberAddress(Object addr) throws IOException {
AddressPort info = null;
try {
Class[] parameterTypes = { };
Object[] args = { };
Method getIpAddress = addr.getClass().getMethod("getIpAddress", parameterTypes);
InetAddress inetAddr = (InetAddress) getIpAddress.invoke(addr, args);
Method getPort = addr.getClass().getMethod("getPort", parameterTypes);
Integer port = (Integer) getPort.invoke(addr, args);
info = new AddressPort(inetAddr, port);
} catch (Exception e) {
if (addr instanceof String) {
// Parse as a host:port string
String hostAddr = (String) addr;
int colon = hostAddr.indexOf(':');
String host = hostAddr;
Integer port = new Integer(0);
if (colon > 0) {
host = hostAddr.substring(0, colon);
port = Integer.valueOf(hostAddr.substring(colon + 1));
}
info = new AddressPort(InetAddress.getByName(host), port);
} else {
throw new IOException("Failed to parse addrType=" + addr.getClass() + ", msg=" + e.getMessage());
}
}
return info;
}

AddressPort(InetAddress addr, Integer port) {
this.addr = addr;
this.port = port;
}

public Integer getPort() {
return port;
}

public InetAddress getInetAddress() {
return addr;
}

public String getHostAddress() {
return addr.getHostAddress();
}

public String getHostName() {
return addr.getHostName();
}

public String toString() {
return "{host(" + addr + "), port(" + port + ")}";
}
}
67 changes: 67 additions & 0 deletions src/main/java/org/wildfly/jmx/adaptor/control/AttrResultInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file 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.wildfly.jmx.adaptor.control;

import java.beans.PropertyEditor;

/**
* A simple tuple of an mbean operation name, signature and result.
*
* @author [email protected]
* @author [email protected]
*/
public class AttrResultInfo {

public String name;

public PropertyEditor editor;

public Object result;

public Throwable throwable;

public AttrResultInfo(String name, PropertyEditor editor, Object result, Throwable throwable) {
this.name = name;
this.editor = editor;
this.result = result;
this.throwable = throwable;
}

public String getAsText() {
if (throwable != null) {
return throwable.toString();
}
if (result != null) {
try {
if (editor != null) {
editor.setValue(result);
return editor.getAsText();
} else {
return result.toString();
}
} catch (Exception e) {
return "String representation of " + name + "unavailable";
} // end of try-catch
}
return null;
}
}
49 changes: 49 additions & 0 deletions src/main/java/org/wildfly/jmx/adaptor/control/OpResultInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file 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.wildfly.jmx.adaptor.control;

/**
* A simple tuple of an mbean operation name, index, signature, args and operation result.
*
* @author [email protected]
* @author [email protected]
*/
public class OpResultInfo {

public String name;

public String[] signature;

public String[] args;

public Object result;

public OpResultInfo() {
}

public OpResultInfo(String name, String[] signature, String[] args, Object result) {
this.name = name;
this.signature = signature;
this.args = args;
this.result = result;
}
}
Loading

0 comments on commit 8bcd82d

Please sign in to comment.