Thanks. I ended up doing something like:
final Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages", resources);
GrizzlyWebServer webServer = new GrizzlyWebServer(9090);
ServletAdapter adapter = new ServletAdapter();
CacheManager manager = new CacheManager();
MBeanServer mBeanServer =
ManagementFactory.getPlatformMBeanServer();
ManagementService.registerMBeans(manager, mBeanServer, false, false,
false, true);
adapter.addInitParameter("com.sun.jersey.config.property.packages",
resources);
adapter.setServletInstance(new SpringServletContainer());
adapter.setContextPath("/abc");
adapter.setServletPath("");
webServer.enableJMX(new Management() {
public void registerComponent(Object bean, ObjectName oname,
String type) throws Exception {
Registry.getRegistry("jmx", "jmx").registerComponent(bean,
oname, type);
}
public void unregisterComponent(ObjectName oname) throws Exception {
Registry.getRegistry("jmx", "jmx").unregisterComponent(oname);
}
});
Paul Sandoz wrote:
>
>
> On Jun 26, 2009, at 3:59 AM, testn wrote:
>
>>
>> Hmm... sounds like using GrizzlyWebContainerFactory causing too much
>> trouble.
>
> Yes, this is a helper class, recommend for your case you do not use it.
>
> You can use the Grizzly Web support + ServletAdapter, i cannot recall
> off the top of my head, which provides similar high-level
> functionality that one can use with Jersey.
>
> Or copy the code from GrizzlyWebContainerFactory:
>
> http://fisheye4.atlassian.com/browse/jersey/trunk/jersey/jersey-server/src/main/java/com/sun/jersey/api/container/grizzly/GrizzlyWebContainerFactory.java?r=1471
>
> Paul.
>
>>
>> It turns out that it calls .listen() immediately therefore, I don't
>> have a
>> chance to set jmxManagement.
>>
>>
>>
>> testn wrote:
>>>
>>> Hi,
>>>
>>> I tried to enable JMX when running Jersey under Grizzly but it
>>> doesn't
>>> quite work. It seems that Management anonymous class is not getting
>>> any
>>> callback. Any idea?
>>>
>>> thread =
>>> com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory
>>> .create(uri, SpringServletContainer.class, initParams);
>>> thread.setManagement(new Management() {
>>>
>>> public void registerComponent(Object bean, ObjectName oname,
>>> String type) throws Exception {
>>> Registry.getRegistry("jmx", "jmx").registerComponent(bean,
>>> oname, type);
>>> }
>>>
>>> public void unregisterComponent(ObjectName oname) throws
>>> Exception {
>>> Registry.getRegistry("jmx", "jmx").unregisterComponent(oname);
>>> }
>>> });
>>> thread.setCompression("deflate");
>>> thread.start();
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-enable-JMX-with-Jersey-Grizzly-tp24213708p24213815.html
>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>
>
--
View this message in context: http://www.nabble.com/How-to-enable-JMX-with-Jersey-Grizzly-tp24213708p24215969.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.