Package javax.naming

Examples of javax.naming.Context


  }

  /** Binds an object to the JNDI context. */
  void bind(String name, Object obj) {
    try {
      Context ctx = new InitialContext();
      ctx.rebind(name, obj);
      if (! boundNames.contains(name))
        boundNames.add(name);
    } catch (Exception e) {
      if (logger.isLoggable(BasicLevel.WARN))
        logger.log(BasicLevel.WARN,
View Full Code Here


  }

  /** Unbinds an object from the JNDI context. */
  void unbind(String name) {
    try {
      Context ctx = new InitialContext();
      ctx.unbind(name);
      boundNames.remove(name);
    } catch (Exception exc) {}
  }
View Full Code Here

  public static void main(String[] args) throws Exception {
    System.out.println();
    System.out.println("Queries to the monitoring queue...");

    Context ictx = new InitialContext();
    Queue queue = (Queue) ictx.lookup("MonitoringQueue");
    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer prod = sess.createProducer(queue);
    MessageConsumer cons = sess.createConsumer(queue);
View Full Code Here

      if ("AUTO_ACKNOWLEDGE".equals(acknowledgeModeString)) {
        acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
      } else if ("CLIENT_ACKNOWLEDGE".equals(acknowledgeModeString)) {
        acknowledgeMode = Session.CLIENT_ACKNOWLEDGE;
      }
      Context ctx = this.context;
      if (ctx == null) {
        ctx = new InitialContext();
      }
      QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup(connFactoryName);
      this.connection = factory.createQueueConnection();
      this.session = this.connection.createQueueSession(transactedQueue, acknowledgeMode);
      this.queue = this.session.createQueue(queueName);
      this.responseQueue = this.session.createQueue(responseQueueName);
      this.producer = this.session.createProducer(this.queue);
View Full Code Here

  private String readSelector(Message msgReceived) throws JMSException {
    return msgReceived.getStringProperty(TaskServiceConstants.SELECTOR_NAME);
  }

  public void start() throws Exception {
    Context ctx = this.context;
    if (this.context == null) {
      ctx = new InitialContext();
    }
    String connFactoryName = this.connectionProperties.getProperty(TaskServiceConstants.TASK_SERVER_CONNECTION_FACTORY_NAME);
    boolean transacted = Boolean.valueOf(this.connectionProperties.getProperty(TaskServiceConstants.TASK_SERVER_TRANSACTED_NAME));
    String ackModeString = this.connectionProperties.getProperty(TaskServiceConstants.TASK_SERVER_ACKNOWLEDGE_MODE_NAME);
    String queueName = this.connectionProperties.getProperty(TaskServiceConstants.TASK_SERVER_QUEUE_NAME_NAME);
    String responseQueueName = this.connectionProperties.getProperty(TaskServiceConstants.TASK_SERVER_RESPONSE_QUEUE_NAME_NAME);
    int ackMode = Session.DUPS_OK_ACKNOWLEDGE; //default
    if ("AUTO_ACKNOWLEDGE".equals(ackModeString)) {
      ackMode = Session.AUTO_ACKNOWLEDGE;
    } else if ("CLIENT_ACKNOWLEDGE".equals(ackModeString)) {
      ackMode = Session.CLIENT_ACKNOWLEDGE;
    }
    QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup(connFactoryName);
    try {
      this.connection = factory.createQueueConnection();
      this.session = connection.createQueueSession(transacted, ackMode);
      this.queue = this.session.createQueue(queueName);
      this.responseQueue = this.session.createQueue(responseQueueName);
View Full Code Here

  }
 
  private EventDistributor getLocalEventDistributor() {
    if (localEventDistributor == null && this.localEventDistributorName != null) {
      try {
        Context ctx = new InitialContext();
        return (EventDistributor) ctx.lookup(this.localEventDistributorName);
      } catch (NamingException e) {
        return null;
      }
    }
    return localEventDistributor;
View Full Code Here

    /** Factory method - gets a reference to the Report home interface.
     */
    public static ReportLocalHome getReportLocalHome()
    throws NamingException {
        Context context = new InitialContext();
        ReportLocalHome home = (ReportLocalHome)context.lookup(JNDI_NAME_REPORT);
        return home;
    }
View Full Code Here

    /** Factory method - gets a reference to the ReportContent home interface.
     */
    public static ReportContentLocalHome getReportContentLocalHome()
    throws NamingException {
        Context context = new InitialContext();
        ReportContentLocalHome home = (ReportContentLocalHome)context.lookup(JNDI_NAME_REPORT_CONTENT);
        return home;
    }
View Full Code Here

    /** Factory method - gets a reference to the ReportType home interface.
     */
    public static ReportTypeLocalHome getReportTypeLocalHome()
    throws NamingException {
        Context context = new InitialContext();
        ReportTypeLocalHome home = (ReportTypeLocalHome)context.lookup(JNDI_NAME_REPORT_TYPE);
        return home;
    }
View Full Code Here

     *************************************************************************************/

    /** Helper method - gets the EJB home interface based on name. */
    public static Object getHomeInterface(String name, Class homeInterface)
            throws NamingException {
        Context context = new InitialContext();
        Object ref = context.lookup(name);

        if (null == ref)
            return null;

        return PortableRemoteObject.narrow(ref, homeInterface);
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.