示例#1
0
  /** Binds mockup <code>IDGeneratorHome</code>'s home. */
  public static void bindIdGenerator() {

    try {
      MockContextFactory.setAsInitial();
      Context context = new InitialContext();

      MockContainer container = new MockContainer(context);

      SessionBeanDescriptor descriptor =
          new SessionBeanDescriptor(
              "IDGeneratorBean/home",
              IDGeneratorHome.class,
              IDGenerator.class,
              new IDGeneratorBean());
      container.deploy(descriptor);
      //            // put object to JNDI
      //            Context ctx = new InitialContext();
      //            unbindIdGenerator();
      //            String path1 = "java:comp";
      //            String path2 = "ejb";
      //            String path3 = "IDGeneratorHome";
      //            ctx = ctx.createSubcontext(path1);
      //            ctx = ctx.createSubcontext(path2);
      //            ctx.bind(path3, new MockRemoteHome());
    } catch (NamingException e) {
      throw new IllegalStateException(
          "Cannot bind 'IDGeneratorHome'. Check the configuration. "
              + "The nested exception is: "
              + e.getMessage(),
          e);
    }
  }