Skip to main content

[javaee-spec issues] [JIRA] Created: (JAVAEE_SPEC-21) Provide @Resource and/or @Inject injection of the currently used platform MBeanServer to any managed bean (EJB Component and/or CDI managed bean)

  • From: "rherschke (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [javaee-spec issues] [JIRA] Created: (JAVAEE_SPEC-21) Provide @Resource and/or @Inject injection of the currently used platform MBeanServer to any managed bean (EJB Component and/or CDI managed bean)
  • Date: Tue, 12 Mar 2013 09:17:53 +0000 (GMT+00:00)
  • Auto-submitted: auto-generated

Provide @Resource and/or @Inject injection of the currently used platform 
MBeanServer to any managed bean (EJB Component and/or CDI managed bean)
-------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: JAVAEE_SPEC-21
                 URL: http://java.net/jira/browse/JAVAEE_SPEC-21
             Project: javaee-spec
          Issue Type: New Feature
            Reporter: rherschke
            Assignee: ldemichiel
            Priority: Minor


My proposal is to specify in EE 7 that MBeanServer injection should be able 
in a container environment.

The reason for this proposal is, that some AS provide it's own platform 
specific MBeanServer, so that ManagementFactory.getPlatformMBeanServer() will 
not provide the correct MBeanServer.

To build platform independent components, the container should provide the 
correct MBeanServer via @Resource or @Inject.

With this, one for example can implement an interceptor with @AroundConstruct 
to do the registration of a MXBean in a container environment.

This would pass the rule of separating concerns and will get a clear EJB Pojo 
as well.

Example:
{code}
@Inherited
@InterceptorBinding
@Target({TYPE}) @Retention(RUNTIME) public @interface MBean {
    @NotBinding String value() default "";
}

@Interceptor @MBean
public class MBeanInterceptor {

    @Resource
    MBeanServer server;

    @PostConstruct
    public void registerBean(InvocationContext ctx) {
        ctx.proceed();
        ObjectName on = ... // get objectname from annotation value
        server.register(on, ctx.getTarget());
        // or do the neccessary DynamicMBean work here...
    }

    @PreDestroy
    public void unregister(InvocationContext ctx) {
        ObjectName on = ... // get objectname from annotation
        server.unregister(on);
        ctx.proceed();
    }
}

@Singleton @Startup @MBean("com.example:type=MyMXBean")
public class MyMXBean {
// ...
}
{code}

So with @Resource injection, this will work even on appservers with its own 
MBeanServer, not only with JVM PlatformServer, but the developer do not care 
about this.

Next, @Resource injection could be used also in a normal EJB to do some 
client work (observe notifications, get attributes aso.) with a registered 
mbean without the need to distinguish about the right MBeanServer to be used.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[javaee-spec issues] [JIRA] Created: (JAVAEE_SPEC-21) Provide @Resource and/or @Inject injection of the currently used platform MBeanServer to any managed bean (EJB Component and/or CDI managed bean)

rherschke (JIRA) 03/12/2013
 
 
Close
loading
Please Confirm
Close