[jboss-dev-forums] [Design of EJB 3.0] - Re: Cleanup problem with Ejb3Registrar and proxy factories

ALRubinger do-not-reply at jboss.com
Thu Aug 28 09:43:36 EDT 2008


I've fixed the problem with the Ejb3Registrar, as verified by the following test:

/**
  |     * Tests that an object bound with state other than "INSTALLED" may still be
  |     * unbound from MC via the Ejb3Registrar
  |     * 
  |     * EJBTHREE-1472
  |     */
  |    @Test
  |    public void testUnbindFromControllerStateOtherThanInstalled() throws Throwable
  |    {
  |       // Create a new key/value pair for binding into MC
  |       String name = "MyObject";
  |       Object value = new Object();
  | 
  |       // Construct BMDB, adding an unmet dependency
  |       BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(name, value.getClass().getName());
  |       bmdb.addDependency("SomeDependencyThatDoesn'tExist");
  | 
  |       // Install into MC, though because of the unmet dependency will not reach "INSTALLED" state
  |       try
  |       {
  |          getBootstrap().getKernel().getController().install(bmdb.getBeanMetaData(), value);
  |       }
  |       catch (Throwable e)
  |       {
  |          throw new RuntimeException("Could not install at name \"" + name + "\" value " + value, e);
  |       }
  | 
  |       // Ensure that the install didn't completely succeed
  |       ControllerContext context = getBootstrap().getKernel().getController().getContext(name, null);
  |       TestCase.assertTrue("The test object should not be fully installed for this test", !context.getState().equals(
  |             ControllerState.INSTALLED));
  | 
  |       // Unbind
  |       Ejb3RegistrarLocator.locateRegistrar().unbind(name);
  | 
  |       // Check that we've unbound
  |       boolean isUnbound = false;
  |       try
  |       {
  |          Ejb3RegistrarLocator.locateRegistrar().lookup(name);
  |       }
  |       catch (NotBoundException nbe)
  |       {
  |          isUnbound = true;
  |       }
  |       TestCase.assertTrue("The test object should be unbound", isUnbound);
  | 
  |    }

I guess I'll leave the checks that discovered this error in place in EJB3 Proxy JndiSessionRegistrarBase.deregisterProxyFactory(); after all, they gave us a nice fail-fast, right? ;)

S,
ALR

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

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



More information about the jboss-dev-forums mailing list