Package javax.naming.event

Examples of javax.naming.event.EventContext


      env.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");
      InitialContext ic = new InitialContext(env);
      log.info("Created InitialContext");
      Context ctx = (Context) ic.lookup("");
      assertTrue("Context is an EventContext", ctx instanceof EventContext);
      EventContext ectx = (EventContext) ctx;
      ectx.addNamingListener("", EventContext.ONELEVEL_SCOPE, listener);
      log.info("Added NamingListener");
      ctx.bind("testAddObject", "testAddObject.bind");
      assertTrue("Saw bind event", listener.waitOnEvent());
      NamingEvent event = listener.getEvent(0);
      assertEquals("OBJECT_ADDED", NamingEvent.OBJECT_ADDED, event.getType());
View Full Code Here


      env.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");
      InitialContext ic = new InitialContext(env);
      log.info("Created InitialContext");
      Context ctx = (Context) ic.lookup("");
      assertTrue("Context is an EventContext", ctx instanceof EventContext);
      EventContext ectx = (EventContext) ctx;
      ectx.addNamingListener("", EventContext.SUBTREE_SCOPE, listener);
      log.info("Added NamingListener");
      ctx.bind("testAddObject", "testAddObject.bind");
      assertTrue("Saw bind event", listener.waitOnEvent());
      NamingEvent event = listener.getEvent(0);
      assertEquals("OBJECT_ADDED", NamingEvent.OBJECT_ADDED, event.getType());
View Full Code Here

            assert configFile != null;

            initializeEngine(configFile.getContent().toString());

            if (nameCtx instanceof EventContext) {
                EventContext evtCtx = (EventContext)nameCtx;

                NamespaceChangeListener listener = new NamespaceChangeListener() {

                    public void namingExceptionThrown( NamingExceptionEvent evt ) {
                        evt.getException().printStackTrace();
                    }

                    public void objectAdded( NamingEvent evt ) {
                    }

                    public void objectRemoved( NamingEvent evt ) {
                        Object oldObject = evt.getOldBinding().getObject();
                        if (!(oldObject instanceof JcrEngine)) return;

                        JcrEngine engine = (JcrEngine)oldObject;

                        log.info(JcrI18n.engineStopping);
                        long start = System.currentTimeMillis();
                        engine.shutdown();
                        try {
                            engine.awaitTermination(30, TimeUnit.SECONDS);
                            log.info(JcrI18n.engineStopped, (System.currentTimeMillis() - start));
                        } catch (InterruptedException ie) {
                            // Thread.interrupted();
                        }
                    }

                    public void objectRenamed( NamingEvent evt ) {
                    }

                };

                evtCtx.addNamingListener(name, EventContext.OBJECT_SCOPE, listener);
            }
        }

        assert engine != null;
View Full Code Here

      env.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");
      InitialContext ic = new InitialContext(env);
      log.info("Created InitialContext");
      Context ctx = (Context) ic.lookup("");
      assertTrue("Context is an EventContext", ctx instanceof EventContext);
      EventContext ectx = (EventContext) ctx;
      ectx.addNamingListener("", EventContext.ONELEVEL_SCOPE, listener);
      log.info("Added NamingListener");
      ctx.bind("testAddObject", "testAddObject.bind");
      assertTrue("Saw bind event", listener.waitOnEvent());
      NamingEvent event = listener.getEvent(0);
      assertEquals("OBJECT_ADDED", NamingEvent.OBJECT_ADDED, event.getType());
View Full Code Here

      env.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");
      InitialContext ic = new InitialContext(env);
      log.info("Created InitialContext");
      Context ctx = (Context) ic.lookup("");
      assertTrue("Context is an EventContext", ctx instanceof EventContext);
      EventContext ectx = (EventContext) ctx;
      ectx.addNamingListener("", EventContext.SUBTREE_SCOPE, listener);
      log.info("Added NamingListener");
      ctx.bind("testAddObject", "testAddObject.bind");
      assertTrue("Saw bind event", listener.waitOnEvent());
      NamingEvent event = listener.getEvent(0);
      assertEquals("OBJECT_ADDED", NamingEvent.OBJECT_ADDED, event.getType());
View Full Code Here

TOP

Related Classes of javax.naming.event.EventContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.