List of usage examples for javax.naming InitialContext InitialContext
public InitialContext() throws NamingException
From source file:com.heliumv.api.cc.ClevercureApi.java
private void receiveCCDataOsd(String companyCode, String token, String ccdata) throws NamingException, RemoteException { Context env = (Context) new InitialContext().lookup("java:comp/env"); String hvUser = (String) env.lookup("heliumv.credentials.user"); String hvPassword = (String) env.lookup("heliumv.credentials.password"); String hvWebshop = (String) env.lookup("heliumv.credentials.webshop"); Boolean hvStoreReceivedData = (Boolean) env.lookup("heliumv.cc.data.storebefore"); System.out.println("Received osd data"); if (hvStoreReceivedData) { persistOsdData(ccdata);/*from w ww . j a va 2 s. com*/ } WebshopAuthHeader authHeader = new WebshopAuthHeader(); authHeader.setUser(hvUser); authHeader.setPassword(hvPassword); // authHeader.setIsoCountry("AT") ; // authHeader.setIsoLanguage("de") ; authHeader.setShopName(hvWebshop); authHeader.setToken(token); try { CreateOrderResult result = auftragRestCall.createOrder(authHeader, ccdata); if (Helper.isOneOf(result.getRc(), new int[] { CreateOrderResult.ERROR_EMPTY_ORDER, CreateOrderResult.ERROR_JAXB_EXCEPTION, CreateOrderResult.ERROR_SAX_EXCEPTION, CreateOrderResult.ERROR_UNMARSHALLING })) { persistOsdData(ccdata, "error"); respondBadRequest(result.getRc()); return; } if (result.getRc() == CreateOrderResult.ERROR_AUTHENTIFICATION) { respondForbidden(); persistOsdData(ccdata, "error_auth_.xml"); return; } if (result.getRc() == CreateOrderResult.ERROR_CUSTOMER_NOT_FOUND) { respondNotFound(); persistOsdData(ccdata, "error_customer_.xml"); return; } if (result.getRc() >= CreateOrderResult.ERROR_EJB_EXCEPTION) { respondBadRequest(result.getRc()); persistOsdData(ccdata, "error_ejb_.xml"); return; } if (result.getRc() == BaseRequestResult.OKAY) { respondOkay(); persistOsdData(ccdata, "200_.xml"); } else { respondExpectationFailed(result.getRc()); } } catch (EJBExceptionLP e) { respondBadRequest(e); persistOsdData(ccdata, "error_.xml"); } }
From source file:de.zib.gndms.dspace.subspace.service.globus.resource.SubspaceResourceBase.java
public SubspaceResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/* w ww . j a v a 2s . com*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/Subspace"; 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 = (SubspaceResourceConfiguration) 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.cagrid.cananolab.service.globus.resource.CaNanoLabServiceResourceBase.java
public CaNanoLabServiceResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }//from www .jav a 2s. c o m MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/CaNanoLabService"; 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 = (CaNanoLabServiceResourceConfiguration) initialContext.lookup(jndiName); } catch (Exception e) { logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e); } return this.configuration; }
From source file:com.krminc.phr.security.PHRRealm.java
private boolean createDS() { if (ds != null) return true; try {//from w w w . j av a 2s. c om InitialContext ctx = new InitialContext(); if (ctx == null) { log("JNDI problem, Cannot get Initial Context."); return false; } ds = (com.sun.appserv.jdbc.DataSource) ctx.lookup(jdbcResource); if (ds == null) { log("Unable to lookup datasource."); return false; } } catch (Exception e) { log("Exception encountered in database connection initialization."); log(e.getMessage()); return false; } return true; }
From source file:com.duroty.application.files.manager.SearchManager.java
/** * @throws NamingException //www . j av a 2s . co m * */ public SearchManager(HashMap mail) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NamingException { super(); String luceneAnalyzer = (String) mail.get(Constants.MAIL_LUCENE_ANALYZER); if ((luceneAnalyzer != null) && !luceneAnalyzer.trim().equals("")) { Class clazz = null; clazz = Class.forName(luceneAnalyzer.trim()); this.analyzer = (Analyzer) clazz.newInstance(); } this.defaultLucenePath = (String) mail.get(Constants.MAIL_LUCENE_PATH); this.folderAll = (String) mail.get(Constants.MAIL_FOLDER_ALL); this.folderInbox = (String) mail.get(Constants.MAIL_FOLDER_INBOX); this.folderSent = (String) mail.get(Constants.MAIL_FOLDER_SENT); this.folderTrash = (String) mail.get(Constants.MAIL_FOLDER_TRASH); this.folderBlog = (String) mail.get(Constants.MAIL_FOLDER_BLOG); this.folderDraft = (String) mail.get(Constants.MAIL_FOLDER_DRAFT); this.folderSpam = (String) mail.get(Constants.MAIL_FOLDER_SPAM); //this.folderImportant = (String) mail.get(Constants.MAIL_FOLDER_IMPORTANT); this.folderHidden = (String) mail.get(Constants.MAIL_FOLDER_HIDDEN); this.folderFiles = (String) mail.get(Constants.MAIL_FOLDER_FILES); //this.folderChat = (String) mail.get(Constants.MAIL_FOLDER_CHAT); Map options = ApplicationConstants.options; Context ctx = new InitialContext(); this.extensions = (HashMap) ctx.lookup((String) options.get(Constants.EXTENSION_CONFIG)); }
From source file:gov.nih.nci.ess.safetyreporting.qry.service.globus.resource.SafetyReportQueryResourceBase.java
public SafetyReportQueryResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/*from w w w . j ava2 s . c o m*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/SafetyReportQuery"; 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 = (SafetyReportQueryResourceConfiguration) 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.cagrid.protexpress.service.globus.resource.ProtExpressGridServiceResourceBase.java
public ProtExpressGridServiceResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/* www.j a v a2 s .c o m*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/ProtExpressGridService"; 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 = (ProtExpressGridServiceResourceConfiguration) 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.safetyreporting.review.service.globus.resource.SafetyReportReviewResourceBase.java
public SafetyReportReviewResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/*from ww w .j ava2s . c o m*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/SafetyReportReview"; 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 = (SafetyReportReviewResourceConfiguration) 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.cagrid.labviewer.service.globus.resource.LabLoaderResourceBase.java
public LabLoaderResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/*from w ww . j a v a 2 s . c o m*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/LabLoader"; 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 = (LabLoaderResourceConfiguration) 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.safetyreporting.tx.service.globus.resource.SafetyReportTransactionResourceBase.java
public SafetyReportTransactionResourceConfiguration getConfiguration() { if (this.configuration != null) { return this.configuration; }/* w w w. ja va 2 s . co m*/ MessageContext ctx = MessageContext.getCurrentContext(); String servicePath = ctx.getTargetService(); servicePath = servicePath.substring(0, servicePath.lastIndexOf("/")); servicePath += "/SafetyReportTransaction"; 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 = (SafetyReportTransactionResourceConfiguration) initialContext.lookup(jndiName); } catch (Exception e) { logger.error("when performing JNDI lookup for " + jndiName + ": " + e, e); } return this.configuration; }