0 Replies Latest reply on Jan 28, 2007 6:44 PM by Brad Douglas

    Preregister() not being called  on MBean before attribute se

    Brad Douglas Newbie

      Hi,

      I'm trying to get JPoller (http://sourceforge.net/projects/jpoller) working with JBoss 4.0.5 and have run into a problem. It appears that the preRegister() is not being called when I set the poller up to run as a MBean.

      We have configured it to use a factory to generate the PollManagers:

      <mbean code="org.sadun.util.polling.ManagedDirectoryPoller" name="user:service=DirectoryPoller">
       <attribute name="Verbose">true</attribute>
       <attribute name="PollInterval">1000</attribute>
       <attribute name="StartBySleeping">true</attribute>
       <attribute name="ControlledDirectories">c:\download\spurwing</attribute>
       <attribute name="PollManagerFactoryClass">com.synyati.spurwing.download.SpurwingPollManagerFactory</attribute>
      </mbean>
      


      The ManagedDirectoryPoller class implments MBeanRegistration:
      public class ManagedDirectoryPoller
       extends DirectoryPoller
       implements ManagedDirectoryPollerMBean, MBeanRegistration, NotificationListener, NotificationBroadcaster {
      ...
      


      and the preRegister() method stores the MBean name:
       public ObjectName preRegister(MBeanServer server, ObjectName name)
       throws Exception {
       pollerMBeanName=name;
       return name;
       }
      


      The setter for the PollFactoryClass attribute does a check to see if the MBean name is set:
      public void setPollManagerFactoryClass(String newFactoryClsName) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
      ...
      if (pollerMBeanName==null) throw new RuntimeException("PreRegister hasn't been called on this bean - poller bean name is null");
      ...
      


      When we start our application the server, that exception in setPollManagerFactoryClass() is being thrown. Can anyone give any insight into what's gone awry here, or point me to any doco on the lifecycle of MBeans (particularly with reference to the MBeanRegistration interface) within JBoss?

      Sorry is this is already covered somewhere I should have been able to find, but I did dig around for answers before posting here and came up blank.

      Thanks,
      Brad