/** * Adds a permission to the JndiPermissions. The key for the hash is * permission.path. * * @param permission the Permission object to add. * @throws IllegalArgumentException - * if the permission is not a JndiPermission * @throws SecurityException - * if this JndiPermissionCollection object has been marked * readonly */ public void add(Permission permission) { if (!(permission instanceof JndiPermission)) throw MESSAGES.invalidPermission(permission); if (isReadOnly()) throw MESSAGES.cannotAddToReadOnlyPermissionCollection(); synchronized (this) { perms.add((JndiPermission) permission); } }
throw MESSAGES.invalidActionMask(); throw MESSAGES.invalidActionMask(); throw new NullPointerException(MESSAGES.cannotBeNull("name"));
private Object getObjectInstance(final Object object, final Name name, final Hashtable<?, ?> environment) throws NamingException { try { final ObjectFactoryBuilder factoryBuilder = ObjectFactoryBuilder.INSTANCE; final ObjectFactory objectFactory = factoryBuilder.createObjectFactory(object, environment); return objectFactory.getObjectInstance(object, name, this, environment); } catch(NamingException e) { throw e; } catch(Throwable t) { throw MESSAGES.cannotDeferenceObject(t); } }
final ServiceNameRefAdr nameAdr = (ServiceNameRefAdr) reference.get("srof"); if (nameAdr == null) { throw MESSAGES.invalidContextReference("srof"); controller = serviceRegistry.getRequiredService(serviceName); } catch (ServiceNotFoundException e) { throw MESSAGES.cannotResolveService(serviceName); listener.wait(); } catch (InterruptedException e) { throw MESSAGES.threadInterrupt(serviceName); return getObjectInstance(listener.getValue(), obj, name, nameCtx, environment); case START_FAILED: throw MESSAGES.cannotResolveService(serviceName, getClass().getName(), "START_FAILED"); case REMOVED: throw MESSAGES.cannotResolveService(serviceName, getClass().getName(), "START_FAILED"); throw MESSAGES.cannotResolveServiceBug(serviceName, getClass().getName(), listener.getState().toString());
module = Module.getBootModuleLoader().loadModule(moduleID); } catch (ModuleLoadException e) { throw NamingMessages.MESSAGES.couldNotLoadModule(moduleID); objectFactoryClassInstance = (ObjectFactory) clazz.newInstance(); } catch (ClassNotFoundException e) { throw NamingMessages.MESSAGES.couldNotLoadClassFromModule(className, moduleID); } catch (InstantiationException e) { throw NamingMessages.MESSAGES.couldNotInstantiateClassInstanceFromModule(className, moduleID); } catch (IllegalAccessException e) { throw NamingMessages.MESSAGES.couldNotInstantiateClassInstanceFromModule(className, moduleID); } catch (ClassCastException e) { throw NamingMessages.MESSAGES.notAnInstanceOfObjectFactory(className, moduleID); } finally { SecurityActions.setContextClassLoader(cl);
private List<ServiceName> listChildren(final ServiceName name, boolean isContextBinding) throws NamingException { final ConcurrentSkipListSet<ServiceName> boundServices = this.boundServices; if (!isContextBinding && boundServices.contains(name)) { throw MESSAGES.cannotListNonContextBinding(); } final NavigableSet<ServiceName> tail = boundServices.tailSet(name); final List<ServiceName> children = new ArrayList<ServiceName>(); for (ServiceName next : tail) { if (name.isParentOf(next)) { if (!name.equals(next)) { children.add(next); } } else { break; } } return children; }
private void unbind(final Name name, final ServiceName bindName) throws NamingException { final ServiceController<?> controller = getServiceRegistry().getService(bindName); if (controller == null) { throw MESSAGES.cannotResolveService(bindName); } final UnbindListener listener = new UnbindListener(); controller.addListener(listener); try { // when added, the listener stops the binding service listener.await(); } catch (Exception e) { throw namingException("Failed to unbind [" + bindName + "]", e); } }
/** {@inheritDoc} */ public Object lookupLink(Name name) throws NamingException { check(name, 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(MESSAGES.cannotLookupLink(), e, name); } }
private Object resolveLink(Object result, boolean dereference) throws NamingException { final Object linkResult; try { final LinkRef linkRef = (LinkRef) result; final String referenceName = linkRef.getLinkName(); if (referenceName.startsWith("./")) { linkResult = lookup(parseName(referenceName.substring(2)) ,dereference); } else { linkResult = new InitialContext().lookup(referenceName); } } catch (Throwable t) { throw MESSAGES.cannotDeferenceObject(t); } return linkResult; }