Search in sources :

Example 1 with NameClassPairEnumeration

use of org.apache.openejb.client.NameClassPairEnumeration in project tomee by apache.

the class JndiRequestHandler method doList.

private void doList(final JNDIRequest req, final JNDIResponse res, final String prefix) {
    final String name = req.getRequestString();
    try {
        final NamingEnumeration<NameClassPair> namingEnumeration = rootContext.list(prefix + name);
        if (namingEnumeration == null) {
            res.setResponseCode(ResponseCodes.JNDI_OK);
            res.setResult(null);
        } else {
            res.setResponseCode(ResponseCodes.JNDI_ENUMERATION);
            final ArrayList<NameClassPair> list = Collections.list(namingEnumeration);
            for (final NameClassPair pair : list) {
                if (pair.getClassName().equals(IvmContext.class.getName())) {
                    pair.setClassName(javax.naming.Context.class.getName());
                }
            }
            res.setResult(new NameClassPairEnumeration(list));
        }
    } catch (NameNotFoundException e) {
        res.setResponseCode(ResponseCodes.JNDI_NOT_FOUND);
    } catch (NamingException e) {
        res.setResponseCode(ResponseCodes.JNDI_NAMING_EXCEPTION);
        res.setResult(new ThrowableArtifact(e));
    }
}
Also used : IvmContext(org.apache.openejb.core.ivm.naming.IvmContext) BeanContext(org.apache.openejb.BeanContext) Context(javax.naming.Context) IvmContext(org.apache.openejb.core.ivm.naming.IvmContext) NameNotFoundException(javax.naming.NameNotFoundException) NameClassPair(javax.naming.NameClassPair) ThrowableArtifact(org.apache.openejb.client.ThrowableArtifact) NamingException(javax.naming.NamingException) NameClassPairEnumeration(org.apache.openejb.client.NameClassPairEnumeration)

Aggregations

Context (javax.naming.Context)1 NameClassPair (javax.naming.NameClassPair)1 NameNotFoundException (javax.naming.NameNotFoundException)1 NamingException (javax.naming.NamingException)1 BeanContext (org.apache.openejb.BeanContext)1 NameClassPairEnumeration (org.apache.openejb.client.NameClassPairEnumeration)1 ThrowableArtifact (org.apache.openejb.client.ThrowableArtifact)1 IvmContext (org.apache.openejb.core.ivm.naming.IvmContext)1