Package javax.naming

Examples of javax.naming.Context


    * @param queueJNDI name of the queue destination to look up
    */
   public JmsReceiver() throws JMSException, NamingException {

      // Get the initial context
      Context jndicontext = getInitialContext();

      // Get the connection factory
      QueueConnectionFactory queueFactory =
   (QueueConnectionFactory)jndicontext.lookup("ConnectionFactory");

      // Create the connection
      queueConnection = queueFactory.createQueueConnection();

      // Create the session with: No transaction and Auto ack
      queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

      // Look up the destination
      queue = (Queue)jndicontext.lookup(queueJNDI);

      // Create a subsriber
      queueReceiver = queueSession.createReceiver(queue);

      // Set the message listener, which is this class since we implement
View Full Code Here


    * @param topicJNDI name of the topic destination to look up
    */
   public JmsSubscriber() throws JMSException, NamingException {

      // Get the initial context
      Context jndicontext = getInitialContext();

      // Get the connection factory
      TopicConnectionFactory topicFactory =
   (TopicConnectionFactory)jndicontext.lookup( "ConnectionFactory");

      // Create the connection
      topicConnection = topicFactory.createTopicConnection();

      // Create the session with: No transaction and auto ack
      topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

      // Look up the destination
      topic = (Topic)jndicontext.lookup(topicJNDI);

      // Create a subsriber
      topicSubscriber = topicSession.createSubscriber(topic);

      // Set the message listener, which is this class since we implement
View Full Code Here

    * @param queueJNDI name of the queue destination to look up
    */
   public JmsSender() throws JMSException, NamingException {

      // Get the initial context
      Context jndicontext = getInitialContext();

      // Get the connection factory
      QueueConnectionFactory queueFactory =
    (QueueConnectionFactory)jndicontext.lookup("ConnectionFactory");

      // Create the connection
      queueConnection = queueFactory.createQueueConnection();

      // Create the session with: No Transaction and Auto ack
      queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);

      // Look up the destination
      queue = (Queue)jndicontext.lookup(queueJNDI);

      // Create a sender
      queueSender = queueSession.createSender(queue);
   }
View Full Code Here

    * @param topicJNDI name of the topic destination to look up
    */
   public JmsPublisher() throws JMSException, NamingException {

      // Get the initial context
      Context jndicontext = getInitialContext();

      // Get the connection factory
      TopicConnectionFactory topicFactory =
    (TopicConnectionFactory)jndicontext.lookup("ConnectionFactory");

      // Create the connection
      topicConnection = topicFactory.createTopicConnection();

      // Create the session with: No Transaction  and Auto ack
      topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

      // Look up the destination
      topic = (Topic)jndicontext.lookup(topicJNDI);

      // Create a publisher
      topicPublisher = topicSession.createPublisher(topic);
   }
View Full Code Here

  private CacheManager cacheManager;
 
  private org.jboss.cache.Cache cache;
 
  public void start() throws Exception {
    Context ctx = new InitialContext();
    cacheManager = (CacheManager) ctx.lookup("java:CacheManager");
    cache = cacheManager.getCache("riftsaw-cache", true);
    cache.start();
  }
View Full Code Here

  }
 
  private Object getClusteredCache() {
    if (this.enabled && this.cacheManagerName != null) {
      try {
        Context ctx = new InitialContext();
        return ctx.lookup(this.cacheManagerName);
      } catch (NamingException e) {
        return null;
      }
    }
    return null;
View Full Code Here

    * @throws Exception
    */
   public void testDataSourceIntegration() throws Exception
   {
      props = null;
      Context context = new InitialContext();
      try
      {
         Object obj = context.lookup(JNDI_NAME);
         assertNull(JNDI_NAME + " not bound", obj);
      }
      catch (NameNotFoundException n)
      {
         // expected
      }
      props = UnitTestDatabaseManager.getTestDbProperties();
      cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false, getClass());
      cache.getConfiguration().setCacheMode("local");
      cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
      cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(props));
      cache.create();


      MockDataSource ds = new MockDataSource(props);
      context.bind(JNDI_NAME, ds);
      assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
      cache.start();

      assertNotNull("Cache has a cache loader", cache.getCacheLoaderManager().getCacheLoader());
   }
View Full Code Here

   }

   @AfterMethod(alwaysRun = true)
   public void tearDown() throws Exception
   {
      Context ctx = new InitialContext();
      ctx.unbind(JNDI_NAME);
      if (cache != null)
      {
         TestingUtil.killCaches(cache);
         UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
         cache = null;
View Full Code Here

      if (ds == null)
      {
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
         DummyTransactionManager.getInstance();

         Context context = new InitialContext();
         try
         {
            Object obj = context.lookup(JNDI_NAME);
            assertNull(JNDI_NAME + " not bound", obj);
         }
         catch (NameNotFoundException n)
         {
            // expected
         }

         prop = UnitTestDatabaseManager.getTestDbProperties();

         ds = new jdbcDataSource();
         ds.setDatabase(prop.getProperty("cache.jdbc.url"));
         ds.setUser("sa");

         context.bind(JNDI_NAME, ds);
         assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
      }
      Properties p = new Properties();
      p.setProperty("cache.jdbc.datasource", JNDI_NAME);
      p.setProperty("cache.jdbc.node.type", prop.getProperty("cache.jdbc.node.type"));
      p.setProperty("cache.jdbc.table.name", prop.getProperty("cache.jdbc.table.name"));
View Full Code Here

   @AfterTest
   protected void destroyDbAfterTest() throws Exception
   {
      Properties icProps = new Properties();
      icProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
      Context ctx = new InitialContext(icProps);
      ctx.unbind(JNDI_NAME);
      UnitTestDatabaseManager.shutdownInMemoryDatabase(prop);
   }
View Full Code Here

TOP

Related Classes of javax.naming.Context

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.