This repository has been archived by the owner on Feb 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switched to JMXConnector factory instead of MBeanServerConnectionFact…
…oryBean injection
- Loading branch information
Dominik Mengelt
committed
Oct 10, 2014
1 parent
77d44cd
commit 365636b
Showing
9 changed files
with
85 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/ch/filecloud/queuemonitor/client/JmxConnectionClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ch.filecloud.queuemonitor.client; | ||
|
||
import ch.filecloud.queuemonitor.common.QmonEnvironment; | ||
import ch.filecloud.queuemonitor.common.QmonEnvironmentConfiguration; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.inject.Inject; | ||
import javax.management.MBeanServerConnection; | ||
import javax.management.remote.JMXConnector; | ||
import javax.management.remote.JMXConnectorFactory; | ||
import javax.management.remote.JMXServiceURL; | ||
import java.util.HashMap; | ||
|
||
/** | ||
* Created by domi on 10/10/14. | ||
*/ | ||
@Component | ||
public class JmxConnectionClient { | ||
|
||
@Inject | ||
private QmonEnvironmentConfiguration qmonEnvironmentConfiguration; | ||
|
||
public MBeanServerConnection get() { | ||
|
||
try { | ||
QmonEnvironment qmonEnvironment = qmonEnvironmentConfiguration.getCurrent(); | ||
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(qmonEnvironment.getJmxRemoteUrl()), new HashMap<String, Object>()); | ||
|
||
return connector.getMBeanServerConnection(); | ||
} catch (Exception e) { | ||
// throw a nice custom exception here | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,35 +2,25 @@ | |
|
||
import ch.filecloud.queuemonitor.common.QmonEnvironment; | ||
import ch.filecloud.queuemonitor.common.QmonEnvironmentConfiguration; | ||
import org.springframework.jmx.support.MBeanServerConnectionFactoryBean; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.inject.Inject; | ||
import java.net.MalformedURLException; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by domi on 10/5/14. | ||
* @author [email protected] | ||
*/ | ||
@Component | ||
public class SystemInformationService { | ||
|
||
@Inject | ||
private QmonEnvironmentConfiguration qmonEnvironmentConfiguration; | ||
|
||
@Inject | ||
protected MBeanServerConnectionFactoryBean mBeanServerConnectionFactoryBean; | ||
|
||
public List<QmonEnvironment> getEnvironments() { | ||
return qmonEnvironmentConfiguration.getAll(); | ||
} | ||
|
||
public void setCurrentEnvironment(String environmentName) { | ||
QmonEnvironment qmonEnvironment = qmonEnvironmentConfiguration.get(environmentName); | ||
try { | ||
mBeanServerConnectionFactoryBean.setServiceUrl(qmonEnvironment.getJmxRemoteUrl()); | ||
} catch (MalformedURLException e) { | ||
e.printStackTrace(); | ||
} | ||
qmonEnvironmentConfiguration.setCurrent(environmentName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters