类javax.naming.event.EventContext源码实例Demo

下面列出了怎么用javax.naming.event.EventContext的API类实例代码及写法,或者点击链接到github查看源代码。

private LdapContext getLdapContext() throws NamingException {
    DirContext dirContext = getDirectoryContext();
    if (dirContext instanceof EventContext) {
        return (LdapContext) dirContext;
    }
    throw new NamingException("The given Context is not an instance of "
                              + LdapContext.class.getName());
}
 
private EventContext getEventContext(String name) throws NamingException {
    Context initialContext = getInitialContext(name);
    if (initialContext instanceof EventContext) {
        return (EventContext) initialContext;
    }
    throw new NamingException("The given Context is not an instance of "
                              + EventContext.class.getName());
}
 
private EventDirContext getEventDirContext(String name) throws NamingException {
    EventContext eventContext = getEventContext(name);
    if (eventContext instanceof EventDirContext) {
        return (EventDirContext) eventContext;
    }
    throw new NamingException("The given Context is not an instance of "
                              + EventDirContext.class.getName());
}
 
源代码4 项目: lams   文件: JndiServiceImpl.java
@Override
public void addListener(String jndiName, NamespaceChangeListener listener) {
	final InitialContext initialContext = buildInitialContext();
	final Name name = parseName( jndiName, initialContext );
	try {
		( (EventContext) initialContext ).addNamingListener( name, EventContext.OBJECT_SCOPE, listener );
	}
	catch (Exception e) {
		throw new JndiException( "Unable to bind listener to namespace [" + name + "]", e );
	}
	finally {
		cleanUp( initialContext );
	}
}
 
public static void addInstance(String uid, String name, SessionFactory instance, Properties properties) {

		log.debug("registered: " + uid + " (" + ( (name==null) ? "unnamed" : name ) + ')');
		INSTANCES.put(uid, instance);
		if (name!=null) NAMED_INSTANCES.put(name, instance);

		//must add to JNDI _after_ adding to HashMaps, because some JNDI servers use serialization
		if (name==null) {
			log.info("Not binding factory to JNDI, no JNDI name configured");
		}
		else {

			log.info("Factory name: " + name);

			try {
				Context ctx = NamingHelper.getInitialContext(properties);
				NamingHelper.bind(ctx, name, instance);
				log.info("Bound factory to JNDI name: " + name);
				( (EventContext) ctx ).addNamingListener(name, EventContext.OBJECT_SCOPE, LISTENER);
			}
			catch (InvalidNameException ine) {
				log.error("Invalid JNDI name: " + name, ine);
			}
			catch (NamingException ne) {
				log.warn("Could not bind factory to JNDI", ne);
			}
			catch(ClassCastException cce) {
				log.warn("InitialContext did not implement EventContext");
			}

		}

	}
 
private EventContext getEventContext(Name name) throws NamingException {
    return getEventContext(name.get(0));
}
 
private EventContext getEventContext() throws NamingException {
    return getEventContext((String) null);
}
 
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
源代码9 项目: TencentKona-8   文件: RemoveNamingListenerTest.java
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
源代码10 项目: openjdk-jdk8u   文件: RemoveNamingListenerTest.java
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
源代码11 项目: jdk8u_jdk   文件: RemoveNamingListenerTest.java
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
源代码12 项目: sis   文件: Initializer.java
/**
 * Creates a new listener for the given JNDI context.
 */
private Listener(final EventContext context) {
    this.context = context;
}
 
源代码13 项目: sis   文件: Initializer.java
/**
 * Registers a new listener for the given JNDI context.
 */
static void register(final EventContext context) throws NamingException {
    final Listener listener = new Listener(context);
    context.addNamingListener(JNDI, EventContext.OBJECT_SCOPE, listener);
    Shutdown.register(listener);
}
 
 类所在包
 类方法
 同包方法