GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Provide @Resource and/or @Inject injection of the currently used platform MBeanServer to any managed bean (EJB Component and/or CDI managed bean) · Issue #21 · javaee/javaee-spec

This repository was archived by the owner on Jan 30, 2019. It is now read-only.
This repository was archived by the owner on Jan 30, 2019. It is now read-only.

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

Copy link
Copy link
Open
Open
Provide @Resource and/or @Inject injection of the currently used platform MBeanServer to any managed bean (EJB Component and/or CDI managed bean)#21
Copy link
Assignees
ldemichiel
Labels
Priority: MinorType: New Featureinjectionmbeanresource-definition

Description

@glassfishrobot
glassfishrobot
opened on Mar 12, 2013
Issue body actions

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:

@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 {
// ... }

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.

Activity

  1. glassfishrobot commented on Mar 12, 2013

    @glassfishrobot
    glassfishrobot
    on Mar 12, 2013
    Author
    More actions

    Reported by rherschke

  2. glassfishrobot commented on Apr 4, 2013

    @glassfishrobot
    glassfishrobot
    on Apr 4, 2013
    Author
    More actions

    @bshannon said:
    For some time I've hoped that we would more fully define the use of JMX in Java EE
    applications. Sadly, it hasn't been a priority. Defining access to an MBeanServer
    is just a part of it.

    This is something we should consider to consider in future releases, but without
    significant customer feedback that this is important it's unlikely this will be
    addressed anytime soon.

  3. glassfishrobot commented on Apr 25, 2017

    @glassfishrobot
    glassfishrobot
    on Apr 25, 2017
    Author
    More actions

    This issue was imported from java.net JIRA JAVAEE_SPEC-21

  4. glassfishrobot
    added
    Type: New Feature
    Priority: Minor
    injection
    mbean
    resource-definition
    on Apr 25, 2017
  5. glassfishrobot
    assigned
    ldemichiel
    on Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @ldemichiel
    ldemichiel

Labels

Priority: MinorType: New Featureinjectionmbeanresource-definition

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.