1 Reply Latest reply on Feb 8, 2003 3:11 AM by nimrod

    How to instantiate an Object when Jboss3.04 start up?

    nimrod

      make a class implements org.jboss.system.ServiceMBean?

      could somebody give me an example?

      thank.

      I found a bit of code like this:

      public void startService() throws Exception{
      try{
      Class myClass = Class.forName(myclassName);
      Object myObj = myClass.newInstance();
      InitialContext ctx = new InitialContext(System.getProperties());
      NonSerializableFactory.rebind(ctx,"MyService",myObj );
      System.out.println("My Service Started...");

      }catch(Exception e){
      e.printStackTrace();
      }
      }

      I got something confused about this:
      org.jboss.naming.NonSerializableFactory.rebind(ctx,"MyService",myObj );
      I could find the class org.jboss.naming.NonSerializableFactory.

      and i was confused why not code like this:
      ctx.rebind("MyService",myObj );