javax.naming.event.EventContext Java Examples

The following examples show how to use javax.naming.event.EventContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #2
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #3
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #4
Source File: JndiServiceImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 );
	}
}
 
Example #5
Source File: SessionFactoryObjectFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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");
			}

		}

	}
 
Example #6
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private EventContext getEventContext(Name name) throws NamingException {
    return getEventContext(name.get(0));
}
 
Example #7
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private EventContext getEventContext() throws NamingException {
    return getEventContext((String) null);
}
 
Example #8
Source File: RemoveNamingListenerTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
Example #9
Source File: RemoveNamingListenerTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
Example #10
Source File: RemoveNamingListenerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
Example #11
Source File: RemoveNamingListenerTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
RemoveNamingListener(EventContext ctx, NamingListener listener) {
    this.ctx = ctx;
    this.listener = listener;
}
 
Example #12
Source File: Initializer.java    From sis with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new listener for the given JNDI context.
 */
private Listener(final EventContext context) {
    this.context = context;
}
 
Example #13
Source File: Initializer.java    From sis with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}