4 Replies Latest reply on Jan 18, 2012 9:59 AM by sodarfish

    how to initialize a stateless session bean in jboss 7?

    sodarfish

      hi guys,  I created a simple slsb , and do some initialization in the constructor ,  but when i deploy it, i found that it does not get initialized.

       

      I know @singleton and @startup of JavaEE 6 can do this, but i just want to know is there any other solution  ?   because my application uses Javaee 5 .

       

      I used websphere before, and there is a configation called  start-at-app-start  which allows an ejb get initialized when application start.  Is there something similar to that in

      Jboss ?

       

       

       

      @Stateless(name= "ApplicationController")
      
      public class ApplicationControllerBean implements ApplicationController {
      
        /**
         * 
         */
        protected Logger logger= Logger.getLogger( this.getClass());
        protected static ApplicationContext context;
      
        /**
         * 
         */
      
        public ApplicationControllerBean() {
          initApplicationContext();
        }
      
        /**
         * 
         */
        protected void initApplicationContext() {
            System.out.println("Initializing.....");
          }
        }
      
        public String status() {
          return String.valueOf( System.currentTimeMillis());
        }
      
      }
      

       

       

      Thanks !