OK ignore my previous post as I obviously didn't understand how mbeans work.  

This is the code that I believe takes the approach Adrian suggested. I have 
made it detailed for Adrian to check the approach is valid and so anyone else 
following in my footsteps doesn't have to trawl through the doco like I did.

JmsClassPreloader.java

  | package com.acme.server.plugin.mbean;
  | 
  | import org.apache.log4j.Logger;
  | import org.jboss.system.ServiceMBeanSupport;
  | 
  | public class JmsClassPreloader extends ServiceMBeanSupport implements 
JmsClassPreloaderMBean {
  |     private static final Logger logger = 
Logger.getLogger(JmsClassPreloader.class);
  | 
  |     public void start() throws Exception {
  |             try {
  |                     if (logger.isDebugEnabled()) {
  |                             logger.debug("starting JmsClassPreloader mbean 
service");
  |                     }
  |                     // get the classloader associated with the thread
  |                     ClassLoader cl = 
Thread.currentThread().getContextClassLoader();            
  |                     // load the class           
  |                     cl.loadClass("org.jboss.mq.selectors.Operator");
  |                     cl.loadClass("org.jboss.mq.selectors.Token");
  |                     //etc for every possible class that jboss mq uses!
  |             } catch (Exception ex) {
  |                     logger.warn("Exception in class preloader", ex);
  |             }               
  |     }
  | }
  | 

JmsClassPreloaderMBean.java

  | package com.acme.server.plugin.mbean;
  | 
  | import org.jboss.system.ServiceMBean;
  | 
  | public interface JmsClassPreloaderMBean extends ServiceMBean {
  | 
  | }
  | 

Then I create the following directory structure in my jboss server/deploy 
directory

[acme-com-mbeans.sar]
----acme-mbeans.jar
----[META-INF]
--------jboss-service.xml

Where acme-mbeans.jar file is a jar containing the above two java class files 
and jboss-service.xml contains the following


  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE server>
  | <!-- $Id$ -->
  | 
  | <server>
  | 
  |    <mbean code="com.acme.server.plugin.mbean.JmsClassPreloader" 
  |           name="acme.com:service=JmsClassPreloader">
  |    </mbean>
  |    
  | </server>
  | 

Questions

Is this what you had in mind Adrian? Considering how many classes are in the 
jboss mq jar file I dont think this is going to be practical since I have to 
list every single class in the jar in the mbean start method for it to be 
loaded (probably 50 or more).  Is there a way of just loading a whole jar?

If not maybe I should instead create an MBean that presubscribes to one of the 
topics instead to achieve the same classloading effect. But then am i 
guaranteed my MBean will execute after the mbeans in the deploy/jms directory 
that initialise the topics? 

I await your response in hope,

Gray.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3886519#3886519

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3886519


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to