use of javax.naming.Binding in project activemq-artemis by apache.
the class JNDITestSupport method tearDown.
/**
* Stops all existing ActiveMQConnectionFactory in Context.
*
* @throws javax.naming.NamingException
*/
@Override
protected void tearDown() throws NamingException, JMSException {
NamingEnumeration<Binding> iter = context.listBindings("");
while (iter.hasMore()) {
Binding binding = iter.next();
Object connFactory = binding.getObject();
if (connFactory instanceof ActiveMQConnectionFactory) {
// ((ActiveMQConnectionFactory) connFactory).stop();
}
}
}
use of javax.naming.Binding in project activemq-artemis by apache.
the class InVMContext method listBindings.
@Override
public NamingEnumeration<Binding> listBindings(String contextName) throws NamingException {
contextName = trimSlashes(contextName);
if (!"".equals(contextName) && !".".equals(contextName)) {
try {
return ((InVMContext) lookup(contextName)).listBindings("");
} catch (Throwable t) {
throw new NamingException(t.getMessage());
}
}
List<Binding> l = new ArrayList<>();
for (Object element : map.keySet()) {
String name = (String) element;
Object object = map.get(name);
l.add(new Binding(name, object));
}
return new NamingEnumerationImpl<>(l.iterator());
}
use of javax.naming.Binding in project activemq-artemis by apache.
the class InVMNamingContext method listBindings.
@Override
public NamingEnumeration<Binding> listBindings(String contextName) throws NamingException {
contextName = trimSlashes(contextName);
if (!"".equals(contextName) && !".".equals(contextName)) {
try {
return ((InVMNamingContext) lookup(contextName)).listBindings("");
} catch (Throwable t) {
throw new NamingException(t.getMessage());
}
}
List<Binding> l = new ArrayList<>();
for (Object element : map.keySet()) {
String name = (String) element;
Object object = map.get(name);
l.add(new Binding(name, object));
}
return new NamingEnumerationImpl<>(l.iterator());
}
use of javax.naming.Binding in project activemq-artemis by apache.
the class InVMContext method listBindings.
@Override
public NamingEnumeration<Binding> listBindings(String contextName) throws NamingException {
contextName = trimSlashes(contextName);
if (!"".equals(contextName) && !".".equals(contextName)) {
try {
return ((InVMContext) lookup(contextName)).listBindings("");
} catch (Throwable t) {
throw new NamingException(t.getMessage());
}
}
List<Binding> l = new ArrayList<>();
for (String name : map.keySet()) {
Object object = map.get(name);
l.add(new Binding(name, object));
}
return new NamingEnumerationImpl(l.iterator());
}
use of javax.naming.Binding in project wildfly by wildfly.
the class RemoteNamingEjbTestCase method testDeploymentBinding.
@Test
public void testDeploymentBinding() throws Exception {
final InitialContext ctx = getRemoteContext();
BinderRemote binder = null;
try {
try {
ctx.lookup("some/entry");
fail("expected exception");
} catch (NameNotFoundException e) {
// expected
}
// test binding
binder = (BinderRemote) ctx.lookup(ARCHIVE_NAME + "/" + Singleton.class.getSimpleName() + "!" + BinderRemote.class.getName());
assertNotNull(binder);
binder.bind();
assertEquals("Test", ctx.lookup("some/entry"));
NamingEnumeration<Binding> bindings = ctx.listBindings("some");
assertTrue(bindings.hasMore());
assertEquals("Test", bindings.next().getObject());
assertFalse(bindings.hasMore());
// test rebinding
binder.rebind();
assertEquals("Test2", ctx.lookup("some/entry"));
bindings = ctx.listBindings("some");
assertTrue(bindings.hasMore());
assertEquals("Test2", bindings.next().getObject());
assertFalse(bindings.hasMore());
// test unbinding
binder.unbind();
try {
ctx.lookup("some/entry");
fail("expected exception");
} catch (NameNotFoundException e) {
// expected
}
// test rebinding when it doesn't already exist
binder.rebind();
assertEquals("Test2", ctx.lookup("some/entry"));
bindings = ctx.listBindings("some");
assertTrue(bindings.hasMore());
assertEquals("Test2", bindings.next().getObject());
assertFalse(bindings.hasMore());
} finally {
// clean up in case any JNDI bindings were left around
try {
if (binder != null)
binder.unbind();
} catch (Exception e) {
// expected
}
ctx.close();
}
}
Aggregations