List of usage examples for javax.naming Context lookup
public Object lookup(String name) throws NamingException;
From source file:de.zib.gndms.GORFX.ORQ.service.globus.resource.ORQResourceBase.java
public ORQResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }//from w ww . j a v a 2 s. co m MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/ORQ"; String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration"; logger.debug("Will read configuration from jndi name: " + jndiName); try { Context initialContext = new InitialContext(); this.configuration = (ORQResourceConfiguration) initialContext.lookup(jndiName); } catch (Exception e) { logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e); } return this.configuration; }
From source file:gov.nih.nci.ccts.grid.service.globus.resource.RegistrationConsumerResourceBase.java
public RegistrationConsumerResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/*from w w w . ja v a 2 s . c o m*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/RegistrationConsumer"; String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration"; logger.debug("Will read configuration from jndi name: " + jndiName); try { Context initialContext = new InitialContext(); this.configuration = (RegistrationConsumerResourceConfiguration) initialContext.lookup(jndiName); } catch (Exception e) { logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e); } return this.configuration; }
From source file:gov.nih.nci.ess.ae.service.aeassociate.service.globus.resource.AEAssociateResourceBase.java
public AEAssociateResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }//w ww .j a va 2s . c om MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/AEAssociate"; String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration"; logger.debug("Will read configuration from jndi name: " + jndiName); try { Context initialContext = new InitialContext(); this.configuration = (AEAssociateResourceConfiguration) initialContext.lookup(jndiName); } catch (Exception e) { logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e); } return this.configuration; }
From source file:org.exist.messaging.JmsMessageSender.java
@Override public NodeImpl send(JmsMessagingConfiguration config, MessagingMetadata metadata, Item content) throws XPathException { // JMS specific checks config.validateContent();//from w ww . j a va2 s . c o m // Retrieve relevant values String initialContextFactory = config.getInitalContextProperty(Context.INITIAL_CONTEXT_FACTORY); String providerURL = config.getInitalContextProperty(Context.PROVIDER_URL); String connectionFactory = config.getConnectionFactory(); String destination = config.getDestination(); // TODO split up, use more exceptions, add better reporting try { Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory); props.setProperty(Context.PROVIDER_URL, providerURL); javax.naming.Context context = new InitialContext(props); // Setup connection ConnectionFactory cf = (ConnectionFactory) context.lookup(connectionFactory); Connection connection = cf.createConnection(); // Lookup queue Destination dest = (Destination) context.lookup(destination); // Create session Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Create message producer MessageProducer producer = session.createProducer(dest); // Create message Message message = createMessage(session, content, metadata, xqcontext); // Write properties Map<String, String> kvs = metadata.getValueMap(); for (String key : kvs.keySet()) { message.setStringProperty(key, kvs.get(key)); } // Send message producer.send(message); // Close connection // TODO keep connection open for re-use, efficiency connection.close(); return createReport(message, xqcontext); } catch (Throwable ex) { LOG.error(ex); throw new XPathException(ex); } }
From source file:com.netcracker.tss.web.servlet.customer.CustomerMMGServiceServlet.java
private MapBeanLocal getMapBean(HttpServletRequest req) { Context context; try {/* ww w. java2s . co m*/ context = new InitialContext(); MapBeanLocalHome mapBeanLocalHome = (MapBeanLocalHome) context .lookup("java:app/tss-ejb/MapBean!com.netcracker.ejb.MapBeanLocalHome"); return mapBeanLocalHome.create(); } catch (NamingException ex) { Logger.getLogger(AdminGroupServlet.class.getName()).log(Level.SEVERE, "Can't find taxiOrderBean with name java:app/tss-ejb/MapBean!com.netcracker.ejb.MapBeanLocalHome ", ex); throw new RuntimeException("Internal server error!");// maybe have // to create // custom // exception? } }
From source file:gov.nih.nci.ess.ae.service.aeadvancedquery.service.globus.resource.AEAdvancedQueryResourceBase.java
public AEAdvancedQueryResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/*from w w w.j a va 2 s. c o m*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/AEAdvancedQuery"; String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration"; logger.debug("Will read configuration from jndi name: " + jndiName); try { Context initialContext = new InitialContext(); this.configuration = (AEAdvancedQueryResourceConfiguration) initialContext.lookup(jndiName); } catch (Exception e) { logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e); } return this.configuration; }
From source file:com.netcracker.tss.web.servlet.customer.CustomerMMGServiceServlet.java
private PriceBeanLocal getPriceBean(HttpServletRequest req) { Context context; try {//from ww w.j a v a2s . co m context = new InitialContext(); PriceBeanLocalHome priceBeanLocalHome = (PriceBeanLocalHome) context .lookup("java:app/tss-ejb/PriceBean!com.netcracker.ejb.PriceBeanLocalHome"); return priceBeanLocalHome.create(); } catch (NamingException ex) { throw new RuntimeException("Internal server error!");// maybe have // to create // custom // exception? } }
From source file:com.netcracker.tss.web.servlet.customer.CustomerMMGServiceServlet.java
private UserBeanLocal getUserBean(HttpServletRequest req) { Context context; try {//from ww w . j a v a 2 s.co m context = new InitialContext(); UserBeanLocalHome userBeanLocalHome = (UserBeanLocalHome) context .lookup("java:app/tss-ejb/UserBean!com.netcracker.ejb.UserBeanLocalHome"); return userBeanLocalHome.create(); } catch (NamingException ex) { Logger.getLogger(AdminGroupServlet.class.getName()).log(Level.SEVERE, "Can't find userBean with name java:app/tss-ejb/UserBean!com.netcracker.ejb.UserBeanLocalHome ", ex); throw new RuntimeException("Internal server error!");// maybe have // to create // custom // exception? } }
From source file:de.zib.gndms.infra.system.GNDMSystem.java
/** * Retrieves a GNDMSSystem using context.lookup(name). * * A lightweight factory facade is either atomically retrieved from context or bound under name * if name is unbound in context. The factory acts as an intermediary and ensures that at most * one DbSetupFacade ever gets instantiated and initialized. * * This instance is returned by this call from the factory facade. * * @param sharedContext//from ww w .j a v a 2s . c o m * @param facadeName * @return GNDMSSystem singleton * @throws NamingException */ @NotNull public static GNDMSystem lookupSystem(@NotNull Context sharedContext, @NotNull Name facadeName, @NotNull GridConfig anySharedConfig, boolean debugModeParam) throws NamingException { try { final SysFactory theFactory = new SysFactory(createLogger(), anySharedConfig, debugModeParam); sharedContext.bind(facadeName, theFactory); return theFactory.getInstance(); } catch (NameAlreadyBoundException ne) { return ((SysFactory) sharedContext.lookup(facadeName)).getInstance(); } }
From source file:gov.nih.nci.cabig.ctms.grid.ae.service.globus.resource.AdverseEventConsumerResourceBase.java
public AdverseEventConsumerResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }//w w w .j a va 2s. c om MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/AdverseEventConsumer"; String jndiName = Constants.JNDI_SERVICES_BASE_NAME + servicePath + "/configuration"; logger.debug("Will read configuration from jndi name: " + jndiName); try { Context initialContext = new InitialContext(); this.configuration = (AdverseEventConsumerResourceConfiguration) initialContext.lookup(jndiName); } catch (Exception e) { logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e); } return this.configuration; }