public Object lookup(final Name name, boolean dereference) throws NamingException { check(name, JndiPermission.ACTION_LOOKUP); return new NamingContext(prefix, namingStore, environment); final Name absoluteName = getAbsoluteName(name); final Context continuationContext = NamingManager.getContinuationContext(cpe); if (continuationContext instanceof NamingContext) { result = ((NamingContext)continuationContext).lookup(cpe.getRemainingName(), dereference); } else { result = continuationContext.lookup(cpe.getRemainingName()); context = resolvedObject; } else if (resolvedObject instanceof LinkRef) { context = resolveLink(resolvedObject,dereference); } else { context = getObjectInstance(resolvedObject, absoluteName, environment); return ((NamingContext)namingContext).lookup(resolveResult.getRemainingName(), dereference); } else { return namingContext.lookup(resolveResult.getRemainingName()); result = resolveLink(result,dereference); } else if (result instanceof Reference) { result = getObjectInstance(result, absoluteName, environment); if (result instanceof LinkRef) { result = resolveLink(result,dereference);
/** * Removes the naming server from the naming context. * * @param context The stop context. */ public void stop(StopContext context) { NamingContext.setActiveNamingStore(null); }
/** {@inheritDoc} */ public void addNamingListener(final String target, final int scope, final NamingListener listener) throws NamingException { addNamingListener(parseName(target), scope, listener); }
/** {@inheritDoc} */ public void destroySubcontext(String name) throws NamingException { destroySubcontext(parseName(name)); }
/** {@inheritDoc} */ public Context createSubcontext(String name) throws NamingException { return createSubcontext(parseName(name)); }
/** {@inheritDoc} */ public Context createSubcontext(Name name) throws NamingException { check(name, JndiPermission.ACTION_CREATE_SUBCONTEXT); if(namingStore instanceof WritableNamingStore) { final Name absoluteName = getAbsoluteName(name); return getWritableNamingStore().createSubcontext(absoluteName); } else { throw NamingLogger.ROOT_LOGGER.readOnlyNamingContext(); } }
@Override public void inject(final NamingStore value) throws InjectionException { final NamingContext storeBaseContext = new NamingContext(value, null); final ManagedReferenceFactory factory = new ManagedReferenceFactory() { @Override public ManagedReference getReference() { try { return new ImmediateManagedReference(storeBaseContext.lookup(getBindName())); } catch (NamingException e) { if(!optional) { throw NamingLogger.ROOT_LOGGER.resourceLookupForInjectionFailed(getAbsoluteJndiName(), e); } else { NamingLogger.ROOT_LOGGER.tracef(e,"failed to lookup %s", getAbsoluteJndiName()); } } return null; } }; targetInjector.inject(factory); } };
/** {@inheritDoc} */ public void rename(final Name oldName, final Name newName) throws NamingException { //check for appropriate permissions first so that no other info leaks from this context //in case of insufficient perms (like the fact if it is readonly or not) check(oldName, JndiPermission.ACTION_LOOKUP | JndiPermission.ACTION_UNBIND); check(newName, JndiPermission.ACTION_BIND); if (namingStore instanceof WritableNamingStore) { bind(newName, lookup(oldName)); unbind(oldName); } else { throw NamingLogger.ROOT_LOGGER.readOnlyNamingContext(); } }
/** {@inheritDoc} */ public Object lookupLink(Name name) throws NamingException { check(name, JndiPermission.ACTION_LOOKUP); if (name.isEmpty()) { return lookup(name); } try { final Name absoluteName = getAbsoluteName(name); Object link = namingStore.lookup(absoluteName); if (!(link instanceof LinkRef) && link instanceof Reference) { link = getObjectInstance(link, name, null); } return link; } catch (Exception e) { throw namingException(NamingLogger.ROOT_LOGGER.cannotLookupLink(), e, name); } }
/** {@inheritDoc} */ public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST); try { return namingEnumeration(namingStore.list(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.list(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).list(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
/** {@inheritDoc} */ public String composeName(String name, String prefix) throws NamingException { return composeName(parseName(name), parseName(prefix)).toString(); }
NamingContext.initializeNamingManager(); final ServiceTarget target = context.getServiceTarget();
/** {@inheritDoc} */ public void destroySubcontext(final Name name) throws NamingException { check(name, JndiPermission.ACTION_DESTROY_SUBCONTEXT); if(!(namingStore instanceof WritableNamingStore)) { throw NamingLogger.ROOT_LOGGER.readOnlyNamingContext(); } }
public void bind(Name name, Object object) throws NamingException { final ParsedName parsedName = parse(name); final Context namespaceContext = findContext(name, parsedName); if (namespaceContext == null) super.bind(parsedName.remaining(), object); else namespaceContext.bind(parsedName.remaining(), object); }
public Context createSubcontext(Name name) throws NamingException { final ParsedName parsedName = parse(name); final Context namespaceContext = findContext(name, parsedName); if (namespaceContext == null) return super.createSubcontext(parsedName.remaining()); else return namespaceContext.createSubcontext(parsedName.remaining()); } }
public void destroySubcontext(Name name) throws NamingException { final ParsedName parsedName = parse(name); final Context namespaceContext = findContext(name, parsedName); if (namespaceContext == null) super.destroySubcontext(parsedName.remaining()); else namespaceContext.destroySubcontext(parsedName.remaining()); }
private Name getAbsoluteName(final Name name) throws NamingException { if(name.isEmpty()) { return composeName(name, prefix); } final String firstComponent = name.get(0); if(firstComponent.startsWith("java:")) { final String cleaned = firstComponent.substring(5); final Name suffix = name.getSuffix(1); if(cleaned.isEmpty()) { return suffix; } return suffix.add(0, cleaned); } else if(firstComponent.isEmpty()) { return name.getSuffix(1); } else { return composeName(name, prefix); } }
private void check(Name name, Action... actions) throws NamingException { Name absoluteName = getAbsoluteName(name); JndiPermission.check(absoluteName, actions); }
/** {@inheritDoc} */ public void unbind(final Name name) throws NamingException { check(name, JndiPermission.ACTION_UNBIND); if(namingStore instanceof WritableNamingStore) { final Name absoluteName = getAbsoluteName(name); getWritableNamingStore().unbind(absoluteName); } else { throw NamingLogger.ROOT_LOGGER.readOnlyNamingContext(); } }