Java 类javax.naming.event.NamingListener 实例源码

项目:cn1    文件:LdapContextImpl.java   
public void removeNamingListener(NamingListener namingListener)
        throws NamingException {
    if (listeners == null || !listeners.containsKey(namingListener)) {
        return;
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        unls.remove(namingListener);
    }

    List<Integer> idList = listeners.remove(namingListener);
    if (idList == null) {
        return;
    }

    try {
        for (Integer id : idList) {
            client.removePersistentSearch(id.intValue(), requestControls);
        }
    } catch (IOException e) {
        CommunicationException ex = new CommunicationException();
        ex.setRootCause(e);
    }
}
项目:cn1    文件:LdapContextImplTest.java   
public void test_removeNamingListener() throws Exception {
    MockLdapClient client = new MockLdapClient();
    Hashtable<Object, Object> env = new Hashtable<Object, Object>();

    context = new LdapContextImpl(client, env, "cn=test");
    // remove not registered listener, do nothing
    context.removeNamingListener(new TestNamingListener());

    NamingListener listener = new TestNamingListener();

    context.addNamingListener("test=listener", EventContext.OBJECT_SCOPE,
            listener);
    context.removeNamingListener(listener);

    listener = new TestNamingListener();
    context.addNamingListener("test=listener", EventContext.OBJECT_SCOPE,
            listener);
    context.addNamingListener("test=listener", EventContext.ONELEVEL_SCOPE,
            listener);
    context.removeNamingListener(listener);
}
项目:nextop-client    文件:LdapContextImpl.java   
public void removeNamingListener(NamingListener namingListener)
        throws NamingException {
    if (listeners == null || !listeners.containsKey(namingListener)) {
        return;
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        unls.remove(namingListener);
    }

    List<Integer> idList = listeners.remove(namingListener);
    if (idList == null) {
        return;
    }

    try {
        for (Integer id : idList) {
            client.removePersistentSearch(id.intValue(), requestControls);
        }
    } catch (IOException e) {
        CommunicationException ex = new CommunicationException();
        ex.setRootCause(e);
    }
}
项目:freeVM    文件:LdapContextImpl.java   
public void removeNamingListener(NamingListener namingListener)
        throws NamingException {
    if (listeners == null || !listeners.containsKey(namingListener)) {
        return;
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        unls.remove(namingListener);
    }

    List<Integer> idList = listeners.remove(namingListener);
    if (idList == null) {
        return;
    }

    try {
        for (Integer id : idList) {
            client.removePersistentSearch(id.intValue(), requestControls);
        }
    } catch (IOException e) {
        CommunicationException ex = new CommunicationException();
        ex.setRootCause(e);
    }
}
项目:freeVM    文件:LdapContextImplTest.java   
public void test_removeNamingListener() throws Exception {
    MockLdapClient client = new MockLdapClient();
    Hashtable<Object, Object> env = new Hashtable<Object, Object>();

    context = new LdapContextImpl(client, env, "cn=test");
    // remove not registered listener, do nothing
    context.removeNamingListener(new TestNamingListener());

    NamingListener listener = new TestNamingListener();

    context.addNamingListener("test=listener", EventContext.OBJECT_SCOPE,
            listener);
    context.removeNamingListener(listener);

    listener = new TestNamingListener();
    context.addNamingListener("test=listener", EventContext.OBJECT_SCOPE,
            listener);
    context.addNamingListener("test=listener", EventContext.ONELEVEL_SCOPE,
            listener);
    context.removeNamingListener(listener);
}
项目:freeVM    文件:EventDirCtx.java   
public void removeNamingListener(NamingListener l) throws NamingException {
    Iterator it = listeners.keySet().iterator();
    while (it.hasNext()) {
        String name = (String) it.next();
        getListeners(name).remove(l);
    }
}
项目:freeVM    文件:EventDirCtx.java   
/**
 * @param name
 * @param type
 * @param newBd
 * @param oldBd
 * @param changeInfo
 */
private void fire(String name, int type, Binding newBd, Binding oldBd,
    Object changeInfo) {

    NamingEvent e = new NamingEvent(this, type, newBd, oldBd, changeInfo);
    List l = getListeners(name);
    for (int i = 0; i < l.size(); i++) {
        e.dispatch((NamingListener) l.get(i));
    }
}
项目:freeVM    文件:EventDirCtx.java   
public DirContext getSchema(String name) throws NamingException {
    List l = getListeners(name);
    NamingExceptionEvent e = new NamingExceptionEvent(this,
        new NamingException("Ok"));
    for (int i = 0; i < l.size(); i++) {
        e.dispatch((NamingListener) l.get(i));
    }
    return null;
}
项目:OpenJSharp    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:jdk8u-jdk    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:openjdk-jdk10    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:openjdk-jdk10    文件:RemoveNamingListenerTest.java   
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
项目:openjdk9    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:jdk8u_jdk    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:lookaside_java-1.8.0-openjdk    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:infobip-open-jdk-8    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:jdk8u-dev-jdk    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:OLD-OpenJDK8    文件:EventQueue.java   
QueueElement(EventObject event, Vector<NamingListener> vector) {
    this.event = event;
    this.vector = vector;
}
项目:cn1    文件:LdapContextImpl.java   
public void addNamingListener(Name name, String filter,
        Object[] filterArgs, SearchControls searchControls,
        NamingListener namingListener) throws NamingException {
    checkName(name);

    if (namingListener == null) {
        return;
    }

    if (!(name instanceof LdapName)) {
        if (name instanceof CompositeName && name.size() == 1) {
            name = name.getPrefix(1);
        } else {
            // FIXME: read message from file
            throw new InvalidNameException(
                    "Target cannot span multiple namespaces: "
                            + name.toString());
        }
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        if (unls == null) {
            unls = new ArrayList<UnsolicitedNotificationListener>();
            addUnsolicitedListener();
        }

        unls.add((UnsolicitedNotificationListener) namingListener);

        if (!(namingListener instanceof NamespaceChangeListener)
                && !(namingListener instanceof ObjectChangeListener)) {
            return;
        }
    }

    if (searchControls == null) {
        searchControls = new SearchControls();
    }

    Filter f = LdapUtils.parseFilter(filter, filterArgs);

    String targetDN = getTargetDN(name, contextDn);

    Name tempName = new LdapName(contextDn.toString());
    tempName.addAll(name);
    String baseDN = tempName.toString();

    int messageId = doPersistentSearch(targetDN, baseDN, f, searchControls,
            namingListener);

    if (listeners == null) {
        listeners = new HashMap<NamingListener, List<Integer>>();
    }

    List<Integer> idList = listeners.get(namingListener);
    if (idList == null) {
        idList = new ArrayList<Integer>();
    }

    idList.add(Integer.valueOf(messageId));
}
项目:cn1    文件:LdapContextImpl.java   
public void addNamingListener(Name name, String filter,
        SearchControls searchControls, NamingListener namingListener)
        throws NamingException {
    addNamingListener(name, filter, new Object[0], searchControls,
            namingListener);
}
项目:cn1    文件:LdapContextImpl.java   
public void addNamingListener(String name, String filter,
        Object[] filterArgs, SearchControls searchControls,
        NamingListener namingListener) throws NamingException {
    addNamingListener(convertFromStringToName(name), filter, filterArgs,
            searchControls, namingListener);
}
项目:cn1    文件:LdapContextImpl.java   
public void addNamingListener(String name, String filter,
        SearchControls searchControls, NamingListener namingListener)
        throws NamingException {
    addNamingListener(convertFromStringToName(name), filter,
            searchControls, namingListener);
}
项目:cn1    文件:LdapContextImpl.java   
public void addNamingListener(Name name, int scope,
        NamingListener namingListener) throws NamingException {
    checkName(name);

    if (namingListener == null) {
        return;
    }

    // only ldap name is supportted
    if (!(name instanceof LdapName)) {
        if (name instanceof CompositeName && name.size() == 1) {
            name = name.getPrefix(0);
        } else {
            // ldap.32=Target cannot span multiple namespaces: {0}
            throw new InvalidNameException(Messages.getString("ldap.32", //$NON-NLS-1$
                    new Object[] { name.toString() }));
        }
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        if (unls == null) {
            unls = new ArrayList<UnsolicitedNotificationListener>();
            addUnsolicitedListener();
        }

        unls.add((UnsolicitedNotificationListener) namingListener);

        if (!(namingListener instanceof NamespaceChangeListener)
                && !(namingListener instanceof ObjectChangeListener)) {
            return;
        }
    }

    // ri is silent in this case
    if (scope != EventContext.OBJECT_SCOPE
            && scope != EventContext.ONELEVEL_SCOPE
            && scope != EventContext.SUBTREE_SCOPE) {
        // ldap.33=Scope should be one of 'OBJECT_SCOPE', 'ONELEVEL_SCOPE'
        // or 'SUBTREE_SCOPE'
        throw new IllegalArgumentException(Messages.getString("ldap.33")); //$NON-NLS-1$
    }

    String targetDN = getTargetDN(name, contextDn);

    Filter filter = new Filter(Filter.PRESENT_FILTER);
    filter.setValue("objectClass");

    SearchControls controls = new SearchControls();
    controls.setSearchScope(scope);

    Name tempName = new LdapName(contextDn.toString());
    tempName.addAll(name);
    String baseDN = tempName.toString();

    int messageId = doPersistentSearch(targetDN, baseDN, filter, controls,
            namingListener);

    if (listeners == null) {
        listeners = new HashMap<NamingListener, List<Integer>>();
    }

    List<Integer> idList = listeners.get(namingListener);
    if (idList == null) {
        idList = new ArrayList<Integer>();
        listeners.put(namingListener, idList);
    }

    idList.add(Integer.valueOf(messageId));

}
项目:cn1    文件:LdapContextImpl.java   
public void addNamingListener(String s, int i, NamingListener namingListener)
        throws NamingException {
    addNamingListener(convertFromStringToName(s), i, namingListener);
}
项目:cn1    文件:MockEventDirContext.java   
public void addNamingListener(Name name, String s, Object[] aobj,
        SearchControls searchcontrols, NamingListener naminglistener)
        throws NamingException {

}
项目:cn1    文件:MockEventDirContext.java   
public void addNamingListener(String s, String s1, Object[] aobj,
        SearchControls searchcontrols, NamingListener naminglistener)
        throws NamingException {

}
项目:cn1    文件:NamingEventTest.java   
public void addNamingListener(Name name, int i, NamingListener naminglistener)
        throws NamingException {
    throw new UnsupportedOperationException("in EventContextMockUp");
}
项目:cn1    文件:NamingEventTest.java   
public void addNamingListener(String s, int i, NamingListener naminglistener)
        throws NamingException {
    throw new UnsupportedOperationException("in EventContextMockUp");
}
项目:cn1    文件:NamingEventTest.java   
public void removeNamingListener(NamingListener naminglistener) throws NamingException {
    throw new UnsupportedOperationException("in EventContextMockUp");
}
项目:cn1    文件:NamingExceptionEventTest.java   
public void addNamingListener(Name name, int i,
        NamingListener naminglistener) throws NamingException {
    throw new UnsupportedOperationException("in EventContextMockUp");
}
项目:cn1    文件:NamingExceptionEventTest.java   
public void addNamingListener(String s, int i,
        NamingListener naminglistener) throws NamingException {
    throw new UnsupportedOperationException("in EventContextMockUp");
}
项目:cn1    文件:NamingExceptionEventTest.java   
public void removeNamingListener(NamingListener naminglistener)
        throws NamingException {
    throw new UnsupportedOperationException("in EventContextMockUp");
}
项目:nextop-client    文件:LdapContextImpl.java   
public void addNamingListener(Name name, String filter,
        Object[] filterArgs, SearchControls searchControls,
        NamingListener namingListener) throws NamingException {
    checkName(name);

    if (namingListener == null) {
        return;
    }

    if (!(name instanceof LdapName)) {
        if (name instanceof CompositeName && name.size() == 1) {
            name = name.getPrefix(1);
        } else {
            // FIXME: read message from file
            throw new InvalidNameException(
                    "Target cannot span multiple namespaces: "
                            + name.toString());
        }
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        if (unls == null) {
            unls = new ArrayList<UnsolicitedNotificationListener>();
            addUnsolicitedListener();
        }

        unls.add((UnsolicitedNotificationListener) namingListener);

        if (!(namingListener instanceof NamespaceChangeListener)
                && !(namingListener instanceof ObjectChangeListener)) {
            return;
        }
    }

    if (searchControls == null) {
        searchControls = new SearchControls();
    }

    Filter f = LdapUtils.parseFilter(filter, filterArgs);

    String targetDN = getTargetDN(name, contextDn);

    Name tempName = new LdapName(contextDn.toString());
    tempName.addAll(name);
    String baseDN = tempName.toString();

    int messageId = doPersistentSearch(targetDN, baseDN, f, searchControls,
            namingListener);

    if (listeners == null) {
        listeners = new HashMap<NamingListener, List<Integer>>();
    }

    List<Integer> idList = listeners.get(namingListener);
    if (idList == null) {
        idList = new ArrayList<Integer>();
    }

    idList.add(Integer.valueOf(messageId));
}
项目:nextop-client    文件:LdapContextImpl.java   
public void addNamingListener(Name name, String filter,
        SearchControls searchControls, NamingListener namingListener)
        throws NamingException {
    addNamingListener(name, filter, new Object[0], searchControls,
            namingListener);
}
项目:nextop-client    文件:LdapContextImpl.java   
public void addNamingListener(String name, String filter,
        Object[] filterArgs, SearchControls searchControls,
        NamingListener namingListener) throws NamingException {
    addNamingListener(convertFromStringToName(name), filter, filterArgs,
            searchControls, namingListener);
}
项目:nextop-client    文件:LdapContextImpl.java   
public void addNamingListener(String name, String filter,
        SearchControls searchControls, NamingListener namingListener)
        throws NamingException {
    addNamingListener(convertFromStringToName(name), filter,
            searchControls, namingListener);
}
项目:nextop-client    文件:LdapContextImpl.java   
public void addNamingListener(Name name, int scope,
        NamingListener namingListener) throws NamingException {
    checkName(name);

    if (namingListener == null) {
        return;
    }

    // only ldap name is supportted
    if (!(name instanceof LdapName)) {
        if (name instanceof CompositeName && name.size() == 1) {
            name = name.getPrefix(0);
        } else {
            // ldap.32=Target cannot span multiple namespaces: {0}
            throw new InvalidNameException(Messages.getString("ldap.32", //$NON-NLS-1$
                    new Object[] { name.toString() }));
        }
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        if (unls == null) {
            unls = new ArrayList<UnsolicitedNotificationListener>();
            addUnsolicitedListener();
        }

        unls.add((UnsolicitedNotificationListener) namingListener);

        if (!(namingListener instanceof NamespaceChangeListener)
                && !(namingListener instanceof ObjectChangeListener)) {
            return;
        }
    }

    // ri is silent in this case
    if (scope != EventContext.OBJECT_SCOPE
            && scope != EventContext.ONELEVEL_SCOPE
            && scope != EventContext.SUBTREE_SCOPE) {
        // ldap.33=Scope should be one of 'OBJECT_SCOPE', 'ONELEVEL_SCOPE'
        // or 'SUBTREE_SCOPE'
        throw new IllegalArgumentException(Messages.getString("ldap.33")); //$NON-NLS-1$
    }

    String targetDN = getTargetDN(name, contextDn);

    Filter filter = new Filter(Filter.PRESENT_FILTER);
    filter.setValue("objectClass");

    SearchControls controls = new SearchControls();
    controls.setSearchScope(scope);

    Name tempName = new LdapName(contextDn.toString());
    tempName.addAll(name);
    String baseDN = tempName.toString();

    int messageId = doPersistentSearch(targetDN, baseDN, filter, controls,
            namingListener);

    if (listeners == null) {
        listeners = new HashMap<NamingListener, List<Integer>>();
    }

    List<Integer> idList = listeners.get(namingListener);
    if (idList == null) {
        idList = new ArrayList<Integer>();
        listeners.put(namingListener, idList);
    }

    idList.add(Integer.valueOf(messageId));

}
项目:nextop-client    文件:LdapContextImpl.java   
public void addNamingListener(String s, int i, NamingListener namingListener)
        throws NamingException {
    addNamingListener(convertFromStringToName(s), i, namingListener);
}
项目:edal-java    文件:JNDI.java   
@Override
public void addNamingListener(String target, int scope, NamingListener listener) {
}
项目:edal-java    文件:JNDI.java   
@Override
public void removeNamingListener(NamingListener listener) {
}