use of org.jboss.as.naming.deployment.RuntimeBindReleaseService in project wildfly by wildfly.
the class WritableServiceBasedNamingStoreTestCase method testMultipleOwnersBindingReferences.
@Test
public void testMultipleOwnersBindingReferences() throws Exception {
final Name name = new CompositeName("test");
final ServiceName serviceName = store.buildServiceName(name);
final Object value = new Object();
// ensure bind does not exists
try {
store.lookup(name);
fail("Should have thrown name not found");
} catch (NameNotFoundException expect) {
}
// ensure the owners RuntimeBindReleaseService have no reference to the future bind
final RuntimeBindReleaseService.References fooDuBindingReferences = (RuntimeBindReleaseService.References) container.getService(JndiNamingDependencyProcessor.serviceName(OWNER_FOO)).getValue();
assertFalse(fooDuBindingReferences.contains(serviceName));
final RuntimeBindReleaseService.References barDuBindingReferences = (RuntimeBindReleaseService.References) container.getService(JndiNamingDependencyProcessor.serviceName(OWNER_BAR)).getValue();
assertFalse(barDuBindingReferences.contains(serviceName));
WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
try {
store.bind(name, value);
// Foo's RuntimeBindReleaseService should now have a reference to the new bind
assertTrue(fooDuBindingReferences.contains(serviceName));
// Bar's RuntimeBindReleaseService reference to the bind should not exist
assertFalse(barDuBindingReferences.contains(serviceName));
} finally {
WritableServiceBasedNamingStore.popOwner();
}
WritableServiceBasedNamingStore.pushOwner(OWNER_BAR);
try {
store.rebind(name, value);
// after rebind, Foo's RuntimeBindReleaseService reference to the bind should still exist
assertTrue(fooDuBindingReferences.contains(serviceName));
// after rebind, Bar's RuntimeBindReleaseService reference to the bind should now exist
assertTrue(barDuBindingReferences.contains(serviceName));
} finally {
WritableServiceBasedNamingStore.popOwner();
}
WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
try {
store.unbind(name);
} finally {
WritableServiceBasedNamingStore.popOwner();
}
}
use of org.jboss.as.naming.deployment.RuntimeBindReleaseService in project wildfly by wildfly.
the class WritableServiceBasedNamingStoreTestCase method installOwnerService.
private void installOwnerService(ServiceName owner) throws InterruptedException {
final CountDownLatch latch1 = new CountDownLatch(1);
container.addService(JndiNamingDependencyProcessor.serviceName(owner), new RuntimeBindReleaseService()).setInitialMode(ServiceController.Mode.ACTIVE).addListener(new AbstractServiceListener<Object>() {
public void transition(ServiceController<?> controller, ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
latch1.countDown();
break;
}
case STARTING_to_START_FAILED:
{
latch1.countDown();
fail("Did not install store service - " + controller.getStartException().getMessage());
break;
}
default:
break;
}
}
}).install();
latch1.await(10, TimeUnit.SECONDS);
}
use of org.jboss.as.naming.deployment.RuntimeBindReleaseService in project wildfly by wildfly.
the class WritableServiceBasedNamingStoreTestCase method testOwnerBindingReferences.
@Test
public void testOwnerBindingReferences() throws Exception {
final Name name = new CompositeName("test");
final ServiceName serviceName = store.buildServiceName(name);
final Object value = new Object();
// ensure bind does not exists
try {
store.lookup(name);
fail("Should have thrown name not found");
} catch (NameNotFoundException expect) {
}
final RuntimeBindReleaseService.References duBindingReferences = (RuntimeBindReleaseService.References) container.getService(JndiNamingDependencyProcessor.serviceName(OWNER_FOO)).getValue();
WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
try {
store.bind(name, value);
// Foo's RuntimeBindReleaseService should now have a reference to the new bind
assertTrue(duBindingReferences.contains(serviceName));
store.rebind(name, value);
// after rebind, Foo's RuntimeBindReleaseService should continue to have a reference to the bind
assertTrue(duBindingReferences.contains(serviceName));
store.unbind(name);
} finally {
WritableServiceBasedNamingStore.popOwner();
}
}
Aggregations