use of javax.naming.Reference in project redisson by redisson.
the class JndiRedissonFactory method getObjectInstance.
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
Reference ref = (Reference) obj;
RefAddr addr = ref.get("configPath");
return buildClient(addr.getContent().toString());
}
use of javax.naming.Reference in project wildfly by wildfly.
the class ServiceReferenceObjectFactory method getObjectInstance.
@SuppressWarnings("unchecked")
@Override
public final Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
final Reference reference = (Reference) obj;
final ServiceNameRefAdr nameAdr = (ServiceNameRefAdr) reference.get("srof");
if (nameAdr == null) {
throw NamingLogger.ROOT_LOGGER.invalidContextReference("srof");
}
final ServiceName serviceName = (ServiceName) nameAdr.getContent();
try {
final ServiceController<?> controller = serviceRegistry.getRequiredService(serviceName);
return getObjectInstance(controller.awaitValue(), obj, name, nameCtx, environment);
} catch (ServiceNotFoundException e) {
throw NamingLogger.ROOT_LOGGER.cannotResolveService(serviceName);
} catch (InterruptedException e) {
throw NamingLogger.ROOT_LOGGER.threadInterrupt(serviceName);
} catch (Throwable t) {
throw NamingLogger.ROOT_LOGGER.cannotResolveService(serviceName, getClass().getName(), "START_FAILED");
}
}
use of javax.naming.Reference in project wildfly by wildfly.
the class ObjectFactoryTestCase method testBindAndRetrieveObjectFactoryFromInitialContext.
@Test
public void testBindAndRetrieveObjectFactoryFromInitialContext() throws Exception {
final Reference reference = new Reference("java.util.String", TestObjectFactory.class.getName(), null);
namingStore.bind(new CompositeName("test"), reference);
final InitialContext initialContext = new InitialContext();
final Object result = initialContext.lookup("test");
assertTrue(result instanceof String);
assertEquals("Test ParsedResult", result);
}
use of javax.naming.Reference in project wildfly by wildfly.
the class NamingContextTestCase method bindListWithContinuations.
private void bindListWithContinuations() throws NamingException {
final Name name = new CompositeName("test/test");
final Object object = new Object();
namingStore.bind(name, object);
final Name nameTwo = new CompositeName("test/testTwo");
final Object objectTwo = new Object();
namingStore.bind(nameTwo, objectTwo);
final Name nameThree = new CompositeName("test/testThree");
final Object objectThree = new Object();
namingStore.bind(nameThree, objectThree);
final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "test"), TestObjectFactoryWithNameResolution.class.getName(), null);
namingStore.bind(new CompositeName("comp"), reference);
}
use of javax.naming.Reference in project wildfly by wildfly.
the class NamingContextTestCase method testLookupWithContinuation.
@Test
public void testLookupWithContinuation() throws Exception {
namingStore.bind(new CompositeName("comp/nested"), "test");
final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "comp"), TestObjectFactoryWithNameResolution.class.getName(), null);
namingStore.bind(new CompositeName("test"), reference);
Object result = namingContext.lookup(new CompositeName("test/nested"));
assertEquals("test", result);
// the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("comp/nested", "lookup")), namingContext, "test/nested");
assertEquals("test", result);
}
Aggregations