You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
I have seen several postings asking about integration between Seam and JMX.
Here is a simple approach for registering a POJO as an MBean and a Component.
Here is the configuration:
<jmx:managed-bean name="echoService" objectName="net.taylor.jmx:service=EchoService" type="net.taylor.jmx.EchoServiceMBean" implementation="net.taylor.jmx.EchoService" />
Here is injections:
@In private EchoService echoService;
Here is the component code:
@Scope(ScopeType.APPLICATION)
@AutoCreate
@Startup
@BypassInterceptors
public class ManagedBean {
private String objectName;
private Class<?> type;
private Class<?> implementation;
private String agentId;
private ObjectName _objectName;
private MBeanServer server;
private Object mbean;
// setters/getters
@Create
public void create() throws Exception {
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(agentId);
server = servers.get(0);
_objectName = new ObjectName(objectName);
mbean = MBeanProxy.create(implementation, type, _objectName, server);
}
@Destroy
public void destroy() throws Exception {
server.unregisterMBean(_objectName);
}
@Unwrap
public Object getMBean() {
return mbean;
}
}
Here is the full code: ManagedBean.java
hi, - in what file does the goes in? (jmx:managed-bean...) - is there a special setup for JMX for Jboss 4 needed? I can do what i want i never get a MBeanServer. thanks joe
He's referring to components.xml descriptor file.
See this for more info on JMX/MBean example for Hibernate: https://www.hibernate.org/216.html
Well apparently it's not components.xml (unless there is some typo, etc.)
I tried this impelmentation and got the following on deployment:
I checked the 2.1.2 API doc and there is only one class in the org.jboss.seam.jmx package (JBossClusterMonitor).
So what is the deal here???
This component basically registers and unregisters a new instance of a class as an MBean. Which is not as good as registering and unregistering an existing Seam component.
I came up with this: JBSEAM-4329
There are lots of things lacking in Seam for complete JMX integration:
1. Simple ways to access JMX: Way to configure the MBeanServer used by Seam for registration, return the MBeanServer Seam uses, etc.
2. Converter for String to ObjectName.
3. Namespace for
<jmx:>, so you can do <jmx:mbean-server agent-id="platform" create="false"/> <jmx:mbean name=":type=MBean" component="#{component}" />4. Annotations for automatically creating MBeans from Seam components, something like support for JMX 2.0 annotations like @MBean etc.
5. Support for intercepting every MBean operation and attribute fetch and doing proper Seam injection.