List of usage examples for javax.naming.event EventContext OBJECT_SCOPE
int OBJECT_SCOPE
To view the source code for javax.naming.event EventContext OBJECT_SCOPE.
Click Source Link
From source file:org.compass.core.jndi.CompassObjectFactory.java
public static void addInstance(String uid, String name, Compass instance, CompassSettings settings) { if (log.isDebugEnabled()) { log.debug("Registering compass [" + uid + "] with [" + ((name == null) ? "unnamed" : name) + ']'); }//from w ww . ja va 2 s.c o m 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 compass to JNDI, no JNDI name configured"); } else { if (log.isInfoEnabled()) { log.info("Binding compass to JNDI under [" + name + "]"); } try { Context ctx = NamingHelper.getInitialContext(settings); NamingHelper.bind(ctx, name, instance); ((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 compass to JNDI", ne); } catch (ClassCastException cce) { log.warn("InitialContext did not implement EventContext"); } } }