Search in sources :

Example 1 with BindingEnumeration

use of org.eclipse.jetty.jndi.BindingEnumeration in project jetty.project by eclipse.

the class localContextRoot method listBindings.

/**
     *
     *
     * @see javax.naming.Context#listBindings(javax.naming.Name)
     */
public NamingEnumeration listBindings(Name name) throws NamingException {
    synchronized (__root) {
        //return __root.listBindings(getSuffix(name));
        Name cname = __root.toCanonicalName(name);
        if (cname == null) {
            List<Binding> empty = Collections.emptyList();
            return new BindingEnumeration(empty.iterator());
        }
        if (cname.size() == 0) {
            return new BindingEnumeration(__root.getBindings().values().iterator());
        }
        //multipart name
        String firstComponent = cname.get(0);
        Object ctx = null;
        //at this level in the tree
        if (firstComponent.equals(""))
            ctx = this;
        else {
            //it is a non-empty name component
            Binding binding = __root.getBinding(firstComponent);
            if (binding == null)
                throw new NameNotFoundException();
            ctx = binding.getObject();
            if (ctx instanceof Reference) {
                //deference the object
                try {
                    ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env);
                } catch (NamingException e) {
                    throw e;
                } catch (Exception e) {
                    __log.warn("", e);
                    throw new NamingException(e.getMessage());
                }
            }
        }
        if (!(ctx instanceof Context))
            throw new NotContextException();
        return ((Context) ctx).listBindings(cname.getSuffix(1));
    }
}
Also used : Binding(javax.naming.Binding) Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) NamingContext(org.eclipse.jetty.jndi.NamingContext) NotContextException(javax.naming.NotContextException) NameNotFoundException(javax.naming.NameNotFoundException) Reference(javax.naming.Reference) NamingException(javax.naming.NamingException) NamingException(javax.naming.NamingException) NameNotFoundException(javax.naming.NameNotFoundException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) NotContextException(javax.naming.NotContextException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) CompoundName(javax.naming.CompoundName) Name(javax.naming.Name) BindingEnumeration(org.eclipse.jetty.jndi.BindingEnumeration)

Aggregations

Binding (javax.naming.Binding)1 CompoundName (javax.naming.CompoundName)1 Context (javax.naming.Context)1 InitialContext (javax.naming.InitialContext)1 Name (javax.naming.Name)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1 NameNotFoundException (javax.naming.NameNotFoundException)1 NamingException (javax.naming.NamingException)1 NotContextException (javax.naming.NotContextException)1 OperationNotSupportedException (javax.naming.OperationNotSupportedException)1 Reference (javax.naming.Reference)1 BindingEnumeration (org.eclipse.jetty.jndi.BindingEnumeration)1 NamingContext (org.eclipse.jetty.jndi.NamingContext)1