Package org.jnp.server

Examples of org.jnp.server.Main


/* 426 */         this.port = PortUtil.findFreePort(this.host);
/*     */
/* 428 */         this.log.info("Remoting JNDI detector starting JNDI server instance since none where specified via configuration.");
/* 429 */         this.log.info("Remoting JNDI server started on host + " + this.host + " and port " + this.port);
/*     */
/* 432 */         Main server = new Main();
/* 433 */         server.setPort(this.port);
/* 434 */         server.setBindAddress(this.host);
/* 435 */         server.start();
/*     */
/* 437 */         this.contextFactory = NamingContextFactory.class.getName();
/* 438 */         this.urlPackage = "org.jboss.naming:org.jnp.interfaces";
/*     */       }
/*     */       catch (Exception e)
View Full Code Here


/*     */
/*     */   private void setupJNDIServer() throws Exception
/*     */   {
/*  90 */     String detectorHost = InetAddress.getLocalHost().getHostName();
/*     */
/*  92 */     Main JNDIServer = new Main();
/*  93 */     JNDIServer.setPort(this.detectorPort);
/*  94 */     JNDIServer.setBindAddress(detectorHost);
/*  95 */     JNDIServer.start();
/*  96 */     System.out.println("Started JNDI server on " + detectorHost + ":" + this.detectorPort);
/*     */   }
View Full Code Here

         // Step 3. Create and start the JNDI server
         System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
         NamingBeanImpl naming = new NamingBeanImpl();
         naming.start();
         Main jndiServer = new Main();
         jndiServer.setNamingInfo(naming);
         jndiServer.setPort(1099);
         jndiServer.setBindAddress("localhost");
         jndiServer.setRmiPort(1098);
         jndiServer.setRmiBindAddress("localhost");
         jndiServer.start();

         // Step 4. Create the JMS configuration
         JMSConfiguration jmsConfig = new JMSConfigurationImpl();

         // Step 5. Configure context used to bind the JMS resources to JNDI
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
         env.put("java.naming.provider.url", "jnp://localhost:1099");
         env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
         Context context = new InitialContext(env);
         jmsConfig.setContext(context);

         // Step 6. Configure the JMS ConnectionFactory
         TransportConfiguration connectorConfig = new TransportConfiguration(NettyConnectorFactory.class.getName());
         ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl("cf", connectorConfig, "/cf");
         jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);

         // Step 7. Configure the JMS Queue
         JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl("queue1", null, false, "/queue/queue1");
         jmsConfig.getQueueConfigurations().add(queueConfig);

         // Step 8. Start the JMS Server using the HornetQ core server and the JMS configuration
         JMSServerManager jmsServer = new JMSServerManagerImpl(hornetqServer, jmsConfig);
         jmsServer.start();
         System.out.println("Started Embedded JMS Server");

         // Step 9. Lookup JMS resources defined in the configuration
         ConnectionFactory cf = (ConnectionFactory)context.lookup("/cf");
         Queue queue = (Queue)context.lookup("/queue/queue1");

         // Step 10. Send and receive a message using JMS API
         Connection connection = null;
         try
         {
            connection = cf.createConnection();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);
            TextMessage message = session.createTextMessage("Hello sent at " + new Date());
            System.out.println("Sending message: " + message.getText());
            producer.send(message);
            MessageConsumer messageConsumer = session.createConsumer(queue);
            connection.start();
            TextMessage messageReceived = (TextMessage)messageConsumer.receive(1000);
            System.out.println("Received message:" + messageReceived.getText());
         }
         finally
         {
            if (connection != null)
            {
               connection.close();
            }

            // Step 11. Stop the JMS server
            jmsServer.stop();
            System.out.println("Stopped the JMS Server");

            // Step 12. Stop the JNDI server
            naming.stop();
            jndiServer.stop();
            System.exit(0);
         }
      }
      catch (Exception e)
      {
View Full Code Here

   protected void setUp() throws Exception
   {
      if (server != null)
         return;

      server = new Main();
      server.setPort(0);
      server.setBindAddress("localhost");
      server.setClientSocketFactory(ClientSocketFactory.class.getName());
      server.setServerSocketFactory(ServerSocketFactory.class.getName());
      server.start();
View Full Code Here

   @BeforeClass
   public void startJndiServer() throws Exception {
      // Create an in-memory jndi
      namingServer = new SingletonNamingServer();
      namingMain = new Main();
      namingMain.setInstallGlobalService(true);
      namingMain.setPort(-1);
      namingMain.start();
      props = new Properties();
      props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
View Full Code Here

         SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4");
      }
     
      int port = 1099;
      String host = InetAddress.getLocalHost().getHostName();
      Main JNDIServer = new Main();
      if (namingBean != null)
      {
         Class namingBeanClass = Class.forName("org.jnp.server.NamingBean");
         Method setNamingInfoMethod = JNDIServer.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
         setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean});
      }
      JNDIServer.setPort(port);
      JNDIServer.setBindAddress(host);
      JNDIServer.start();
      System.out.println("Started JNDI server on " + host + ":" + port);

      String detectorHost = InetAddress.getLocalHost().getHostName();

      detector = new JNDIDetector();
View Full Code Here

         }
        
         int port = 1099;
         //String host = "localhost";
         String host = InetAddress.getLocalHost().getHostName();
         Main JNDIServer = new Main();
         if (namingBean != null)
         {
            Class namingBeanClass = Class.forName("org.jnp.server.NamingBean");
            Method setNamingInfoMethod = JNDIServer.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
            setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean});
         }
         JNDIServer.setPort(port);
         JNDIServer.setBindAddress(host);
         JNDIServer.start();
         System.out.println("Started JNDI server on " + host + ":" + port);

         addTestClasses(JNDIDetectorTest1.class.getName(),
                        1,
                        JNDIDetectorTest2.class.getName());
View Full Code Here

         SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4");
      }

      String host = InetAddress.getLocalHost().getHostAddress();
     
      jserver = new Main();
      jserver.setPort(detectorPort);
      jserver.setBindAddress(host);
      jserver.setRmiPort(31000);
      if (namingBean != null)
      {
View Full Code Here

         SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4");
      }
     
      String host = InetAddress.getLocalHost().getHostAddress();

      Main jserver = new Main();
      if (namingBean != null)
      {
         Class namingBeanClass = Class.forName("org.jnp.server.NamingBean");
         Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
         setNamingInfoMethod.invoke(jserver, new Object[] {namingBean});
      }
      jserver.setPort(2410);
      jserver.setBindAddress(host);
      jserver.setRmiPort(31000);
      jserver.start();

   }
View Full Code Here

            SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4");
         }
        
         String host = InetAddress.getLocalHost().getHostAddress();

         Main jserver = new Main();
         if (namingBean != null)
         {
            Class namingBeanClass = Class.forName("org.jnp.server.NamingBean");
            Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
            setNamingInfoMethod.invoke(jserver, new Object[] {namingBean});
         }
         int port = 2410;
         jserver.setPort(port);
         jserver.setBindAddress(host);
         jserver.setRmiPort(31000);
         jserver.start();
         System.out.println("Started JNDI server on " + host + ":" + port);

         addTestClasses(Client.class.getName(),
                        1,
                        Server.class.getName());
View Full Code Here

TOP

Related Classes of org.jnp.server.Main

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.