class JcrNamespaceRegistry implements org.modeshape.jcr.api.NamespaceRegistry {

    @Override
    public synchronized void unregisterNamespace( String prefix )
        throws NamespaceException, AccessDeniedException, RepositoryException {
        CheckArg.isNotNull(prefix, "prefix");
        checkSession();

        // Don't need to check permissions for transient registration/unregistration
        if (behavior.equals(Behavior.WORKSPACE)) {
            try {
                session.checkWorkspacePermission(session.workspaceName(), ModeShapePermissions.REGISTER_NAMESPACE);
            } catch (AccessControlException ace) {
                throw new AccessDeniedException(ace);
            }
        }

        // Look to see whether the prefix is registered ...
        String uri = registry.getNamespaceForPrefix(prefix);
        // It is an error to unregister a namespace that is not registered ...
        if (uri == null) {
            throw new NamespaceException(JcrI18n.unableToUnregisterPrefixForNamespaceThatIsNotRegistered.text(prefix));
        }
        // Unregistering a built-in prefix or URI is invalid ...
        if (STANDARD_BUILT_IN_PREFIXES.contains(prefix)) {
            throw new NamespaceException(JcrI18n.unableToUnregisterReservedNamespacePrefix.text(prefix, uri));
        }
        if (STANDARD_BUILT_IN_URIS.contains(uri)) {
            throw new NamespaceException(JcrI18n.unableToUnregisterReservedNamespaceUri.text(prefix, uri));
        }

        // Do not allow to unregister a namespace which is used by a node type
        checkURINotInUse(uri);

        boolean global = false;
        switch (behavior) {
            case WORKSPACE: {
                global = true;
                break;
            }
            case SESSION: {
                break;
            }
            default: {
                //should never happen
                assert false;
            }
        }

        // Now we're sure the prefix is valid and is actually used in a mapping ...
        try {
            registry.unregister(uri);
            session.signalNamespaceChanges(global);
        } catch (RuntimeException e) {
            throw new RepositoryException(e.getMessage(), e.getCause());
        }
    }

    protected  JcrNamespaceRegistry( NamespaceRegistry workspaceRegistry,
                                    JcrSession session );
      JcrNamespaceRegistry( Behavior behavior,
                          NamespaceRegistry localRegistry,
                          NamespaceRegistry workspaceRegistry,
                          JcrSession session );

}