@Override
    public boolean hasObjectWithPrefix(JavaColonNamespace namespace, String name) throws NamingException {

        JavaColonNamespaceBindings<EJBBinding> bindings;
        boolean result = false;

        Lock readLock = null;
        ComponentMetaData cmd = null;

        try {
            // This helper only provides support for java:global, java:app, and java:module
            if (namespace == JavaColonNamespace.GLOBAL) {
                // Called to ensure that the java:global code path
                // is coming from a Java EE thread. If not this will reject this
                // method call with the correct Java EE error message.
                cmd = getComponentMetaData(namespace, name);
                bindings = javaColonGlobalBindings;
                readLock = javaColonLock.readLock();
                readLock.lock();

            } else if (namespace == JavaColonNamespace.APP) {
                // Get the ComponentMetaData for the currently active component.
                // There is no component name space if there is no active component.
                cmd = getComponentMetaData(namespace, name);
                bindings = getAppBindingMap(cmd.getModuleMetaData().getApplicationMetaData());

                readLock = javaColonLock.readLock();
                readLock.lock();

            } else if (namespace == JavaColonNamespace.MODULE) {
                cmd = getComponentMetaData(namespace, name);
                bindings = getModuleBindingMap(cmd.getModuleMetaData());
            } else {
                bindings = null;
            }

            result = bindings != null && bindings.hasObjectWithPrefix(name);
        } finally {
            if (readLock != null) {
                readLock.unlock();
            }
        }
        return result;
    }
@ Override public boolean hasObjectWithPrefix ( JavaColonNamespace namespace , String name ) throws NamingException { JavaColonNamespaceBindings < EJBBinding > bindings ; boolean result = false ; Lock readLock = null ; ComponentMetaData cmd = null ; try { if ( namespace == JavaColonNamespace . GLOBAL ) { cmd = getComponentMetaData ( namespace , name ) ; bindings = javaColonGlobalBindings ; readLock = javaColonLock . readLock ( ) ; readLock . lock ( ) ; } else if ( namespace == JavaColonNamespace . APP ) { cmd = getComponentMetaData ( namespace , name ) ; bindings = getAppBindingMap ( cmd . getModuleMetaData ( ) . getApplicationMetaData ( ) ) ; readLock = javaColonLock . readLock ( ) ; readLock . lock ( ) ; } else if ( namespace == JavaColonNamespace . MODULE ) { cmd = getComponentMetaData ( namespace , name ) ; bindings = getModuleBindingMap ( cmd . getModuleMetaData ( ) ) ; } else { bindings = null ; } result = bindings != null && bindings . hasObjectWithPrefix ( name ) ; } finally { if ( readLock != null ) { readLock . unlock ( ) ; } } return result ; }
can suppress warning - if cmd is null NamingException will be thrown by getComponentMetaData