List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:com.flexive.shared.exceptions.FxApplicationException.java
/** * Log a message at a given level (or error if no level given) * * @param log Log to use// www .ja va 2s . co m * @param message message to LOG * @param level log4j level to apply */ private void logMessage(Log log, String message, LogLevel level) { this.messageLogged = true; if (FxContext.get() != null && FxContext.get().isTestDivision()) return; //dont log exception traces during automated tests final Throwable cause = getCause() != null ? getCause() : this; if (level == null) log.error(message, cause); else { switch (level) { case DEBUG: if (log.isDebugEnabled()) log.debug(message); break; case ERROR: if (log.isErrorEnabled()) log.error(message, cause); break; case FATAL: if (log.isFatalEnabled()) log.fatal(message, cause); break; case INFO: if (log.isInfoEnabled()) log.info(message); break; // case Level.WARN_INT: default: if (log.isWarnEnabled()) log.warn(message); } } }
From source file:com.acciente.induction.dispatcher.HttpDispatcher.java
/** * This method is called by the webcontainer to initialize this servlet * * @param oServletConfig web container-provided access to this servlet's configuration * @throws javax.servlet.ServletException *//*from w ww . j a va2 s. c om*/ public void init(ServletConfig oServletConfig) throws ServletException { super.init(oServletConfig); // first setup a logger _oLog = LogFactory.getLog(HttpDispatcher.class); Config oConfig; // load the configuration for the dispatcher try { oConfig = ConfigLoaderInitializer.getConfigLoader(oServletConfig).getConfig(); //System.out.println( "config: \n" + oConfig ); } catch (ClassNotFoundException e) { throw new ServletException("init-error: config-loader-initializer", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: config-loader-initializer", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: config-loader-initializer", e); } catch (InstantiationException e) { throw new ServletException("init-error: config-loader-initializer", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: config-loader-initializer", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: config-loader-initializer", e); } catch (ConfigLoaderException e) { throw new ServletException("init-error: config-loader", e); } // setup up our classloader ClassLoader oClassLoader; try { oClassLoader = ClassLoaderInitializer.getClassLoader(oConfig.getJavaClassPath(), getClass().getClassLoader()); } catch (ClassNotFoundException e) { throw new ServletException("init-error: class-loader-initializer", e); } // we setup the model factory and pool managers early since we now support inject models // into the initializers for the templating engine, controller resolver, view resolver and // redirect resolver ModelFactory oModelFactory = new ModelFactory(oClassLoader, oServletConfig, oConfig.getFileUpload()); ModelPool oModelPool; try { oModelPool = new ModelPool(oConfig.getModelDefs(), oModelFactory, oServletConfig.getServletContext()); } catch (MethodNotFoundException e) { throw new ServletException("init-error: model-pool", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: model-pool", e); } catch (ClassNotFoundException e) { throw new ServletException("init-error: model-pool", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: model-pool", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: model-pool", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: model-pool", e); } catch (InstantiationException e) { throw new ServletException("init-error: model-pool", e); } // now set the pool for the model factory to use in model-to-model injection oModelFactory.setModelPool(oModelPool); // we instantiate the templating engine early since we now support injecting the // TemplatingEngine instance into models TemplatingEngine oTemplatingEngine; try { oTemplatingEngine = TemplatingEngineInitializer.getTemplatingEngine(oConfig.getTemplating(), oModelPool, oClassLoader, oServletConfig); } catch (IOException e) { throw new ServletException("init-error: templating-engine-initializer", e); } catch (ClassNotFoundException e) { throw new ServletException("init-error: templating-engine-initializer", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: templating-engine-initializer", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: templating-engine-initializer", e); } catch (InstantiationException e) { throw new ServletException("init-error: templating-engine-initializer", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: templating-engine-initializer", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: templating-engine-initializer", e); } // after the templating engine is setup is we set the templating engine in the model factory, // to make it available to models or any of the other classes that can request it oModelFactory.setTemplatingEngine(oTemplatingEngine); // pre-initialize any app scope models that requested it Log oLog = LogFactory.getLog(ModelPool.class); for (Iterator oIter = oConfig.getModelDefs().getModelDefList().iterator(); oIter.hasNext();) { Config.ModelDefs.ModelDef oModelDef = (Config.ModelDefs.ModelDef) oIter.next(); if (oModelDef.isApplicationScope() && oModelDef.isInitOnStartUp()) { oLog.info("model-pool: initializing model: " + oModelDef.getModelClassName()); try { oModelPool.initAppModel(oModelDef.getModelClassName()); } catch (MethodNotFoundException e) { throw new ServletException("init-error: model-init-on-startup", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: model-init-on-startup", e); } catch (ClassNotFoundException e) { throw new ServletException("init-error: model-init-on-startup", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: model-init-on-startup", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: model-init-on-startup", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: model-init-on-startup", e); } catch (InstantiationException e) { throw new ServletException("init-error: model-init-on-startup", e); } } } // setup the interceptor chain try { RequestInterceptor[] oRequestInterceptorArray; oRequestInterceptorArray = RequestInterceptorInitializer.getRequestInterceptor( oConfig.getRequestInterceptors(), oModelPool, oClassLoader, oServletConfig); _oRequestInterceptorExecutor = new RequestInterceptorExecutor(oRequestInterceptorArray, new RequestInterceptorParameterProviderFactory(oModelPool, oConfig.getFileUpload(), oTemplatingEngine, oClassLoader)); } catch (ClassNotFoundException e) { throw new ServletException("init-error: request-interceptor-initializer", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: request-interceptor-initializer", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: request-interceptor-initializer", e); } catch (InstantiationException e) { throw new ServletException("init-error: request-interceptor-initializer", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: request-interceptor-initializer", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: request-interceptor-initializer", e); } // setup a resolver that maps a request to a controller try { ControllerResolver oControllerResolver; oControllerResolver = ControllerResolverInitializer.getControllerResolver( oConfig.getControllerResolver(), oConfig.getControllerMapping(), oModelPool, oClassLoader, oServletConfig); _oControllerResolverExecutor = new ControllerResolverExecutor(oControllerResolver, new ControllerResolverParameterProviderFactory(oModelPool, oConfig.getFileUpload(), oClassLoader)); } catch (ClassNotFoundException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } catch (InstantiationException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } catch (IOException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } catch (MethodNotFoundException e) { throw new ServletException("init-error: controller-resolver-initializer", e); } // setup a resolver that maps a request to a view try { ViewResolver oViewResolver; oViewResolver = ViewResolverInitializer.getViewResolver(oConfig.getViewResolver(), oConfig.getViewMapping(), oModelPool, oClassLoader, oServletConfig); _oViewResolverExecutor = new ViewResolverExecutor(oViewResolver, new ViewResolverParameterProviderFactory(oModelPool, oConfig.getFileUpload(), oClassLoader)); } catch (ClassNotFoundException e) { throw new ServletException("init-error: view-resolver-initializer", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: view-resolver-initializer", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: view-resolver-initializer", e); } catch (InstantiationException e) { throw new ServletException("init-error: view-resolver-initializer", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: view-resolver-initializer", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: view-resolver-initializer", e); } catch (IOException e) { throw new ServletException("init-error: view-resolver-initializer", e); } catch (MethodNotFoundException e) { throw new ServletException("init-error: view-resolver-initializer", e); } // setup a resolver that maps a redirect to a URL try { RedirectResolver oRedirectResolver; oRedirectResolver = RedirectResolverInitializer.getRedirectResolver(oConfig.getRedirectResolver(), oConfig.getRedirectMapping(), oModelPool, oClassLoader, oServletConfig); _oRedirectResolverExecutor = new RedirectResolverExecutor(oRedirectResolver, new RedirectResolverParameterProviderFactory(oModelPool, oConfig.getFileUpload(), oClassLoader)); } catch (ClassNotFoundException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } catch (InvocationTargetException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } catch (IllegalAccessException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } catch (InstantiationException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } catch (ConstructorNotFoundException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } catch (ParameterProviderException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } catch (IOException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } catch (MethodNotFoundException e) { throw new ServletException("init-error: redirect-resolver-initializer", e); } // tell the model pool of the redirect resolver, so that models can now request it oModelFactory.setRedirectResolver(_oRedirectResolverExecutor); // the ControllerPool manages a pool of controllers, reloading if the underlying controller def changes ControllerPool oControllerPool = new ControllerPool(oClassLoader, oServletConfig); // the ControllerExecutor manages the execution of controllers _oControllerExecutor = new ControllerExecutor(oControllerPool, new ControllerParameterProviderFactory( oModelPool, oConfig.getFileUpload(), oTemplatingEngine, _oRedirectResolverExecutor, oClassLoader)); // the ViewExecutor manages the loading (when needed) and processing of views ViewParameterProviderFactory oViewParameterProviderFactory = new ViewParameterProviderFactory(oModelPool, oConfig.getFileUpload(), oTemplatingEngine, _oRedirectResolverExecutor, oClassLoader); ViewFactory oViewFactory = new ViewFactory(oClassLoader, oViewParameterProviderFactory); // we have to delay setting this until here, since ViewParameterProviderFactory and // ViewFactory have a cyclical relationship oViewParameterProviderFactory.setViewFactory(oViewFactory); // finally create the view executor _oViewExecutor = new ViewExecutor(oViewFactory, oTemplatingEngine); }
From source file:com.flexive.tests.browser.AbstractBackendBrowserTest.java
/** * write the given String to a file/* w w w.ja v a 2 s. c o m*/ * @param prefix the prefix of the file * @param LOG the Log to log errors * @param html the String to write * @return the name of the file created */ protected String writeHTMLtoHD(String prefix, Log LOG, String html) { // http://localhost:8080/flexive/adm/structure/propertyEditor.jsf?action=createProperty&id=10&nodeType=Type File f = new File(prefix + "@" + System.currentTimeMillis() + ".html"); try { FileOutputStream fos = new FileOutputStream(f); fos.write(html.getBytes()); fos.flush(); fos.close(); LOG.info(f.getAbsolutePath() + "\t" + new Throwable().getStackTrace()[2].toString().replaceAll("com.flexive.tests.browser.", "")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return f.getAbsolutePath(); }
From source file:de.tudarmstadt.ukp.clarin.webanno.crowdflower.CrowdClient.java
/** * Upload the data vector as JSON to the specified Crowdflower job * @param job//from w w w .j a va 2 s. co m * @param data - Generic vector of data, containing ordinary java classes. * They should be annotated so that Jackson understands how to map them to JSON. * */ void uploadData(CrowdJob job, List<?> data) { Log LOG = LogFactory.getLog(getClass()); //Crowdflower wants a Multi-line JSON, with each line having a new JSON object //Thus we have to map each (raw) object in data individually to a JSON string ObjectMapper mapper = new ObjectMapper(); String jsonObjectCollection = ""; StringBuilder jsonStringBuilder = new StringBuilder(); int count = 0; for (Object obj : data) { count++; JsonNode jsonData = mapper.convertValue(obj, JsonNode.class); jsonStringBuilder.append(jsonData.toString()); jsonStringBuilder.append("\n"); } jsonObjectCollection = jsonStringBuilder.toString(); RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<String> request = new HttpEntity<String>(jsonObjectCollection, headers); String result = ""; if (job == null) { LOG.info("Upload new data and create new job: " + String.valueOf(count) + " data items"); result = restTemplate.postForObject(uploadDataURL, request, String.class, apiKey); } else { LOG.info("Uploading new data to job: " + job.getId() + ": " + String.valueOf(count) + " data items"); result = restTemplate.postForObject(uploadDataWithJobURL, request, String.class, job.getId(), apiKey); } LOG.info("Upload response:" + result); //set gold? this is what i would like to do... //updateVariable(job, "https://api.crowdflower.com/v1/jobs/{jobid}/gold?key={apiKey}", "set_standard_gold", "TRUE"); }
From source file:de.tudarmstadt.ukp.clarin.webanno.crowdflower.NamedEntityTaskManager.java
/** * Generate data for NER task1. This is a quite specific function exclusively for German NER, * but a more general version could one day replace this. * * You usually call this function twice, one time to generate gold data (generateGold=true) and one time to generate normal data * * @param documentsJCas/* w w w .ja v a 2 s. c o m*/ * List of Cas containing either the documents to be annotated or gold documents * @param goldOffset * This is an offset to the token number that is send to Crowdflower, so that (i - * goldOffset) = real token offset in webanno. This is needed so that continuous * token numbers can be send to Crowdflower * @param generateGold - whether gold data should be produced or normal data * @param limit - limit number of data items to this number * @return {@code List<NamedEntityTask1Data>}, representing a crowdflower task1 data upload. It can be directly mapped to JSON. * @throws CrowdException hum? */ public List<NamedEntityTask1Data> generateTask1Data(List<JCas> documentsJCas, int goldOffset, boolean generateGold, int limit) throws CrowdException { Log LOG = LogFactory.getLog(getClass()); List<NamedEntityTask1Data> data = new ArrayList<NamedEntityTask1Data>(); int i = goldOffset; StringBuilder textBuilder = new StringBuilder(); int docNo = 0; jcasloop: for (JCas documentJCas : documentsJCas) { int offset = i; int sentenceNo = 0; LOG.info("Generating data for document: " + docNo + "/" + documentsJCas.size()); for (Sentence sentence : select(documentJCas, Sentence.class)) { // if global limit of sentences reached, abort whole iteration if (limit != -1 && sentenceNo >= limit) { break jcasloop; } textBuilder.setLength(0); // Maps our own token offsets (needed by JS in the crowdflower task) to Jcas offsets Map<Integer, Integer> charOffsetStartMapping = new HashMap<Integer, Integer>(); Map<Integer, Integer> charOffsetEndMapping = new HashMap<Integer, Integer>(); for (Token token : selectCovered(Token.class, sentence)) { // check that token offsets match to (i - goldOffset) //String tokenString = ; textBuilder.append(HTML_SPAN_TOKEN_START); textBuilder.append(String.valueOf(i)); textBuilder.append(HTML_SPAN_TOKEN_CLOSE); textBuilder.append(escapeHtml(token.getCoveredText())); textBuilder.append(" "); textBuilder.append(HTML_SPAN_CLOSE); charOffsetStartMapping.put(token.getBegin(), i); charOffsetEndMapping.put(token.getEnd(), i); i++; } String text = textBuilder.toString(); // clear string builder textBuilder.setLength(0); NamedEntityTask1Data task1Data = new NamedEntityTask1Data(text); task1Data.setOffset(offset); task1Data.setDocument(JSON_SOURCEDOC_SHORTFORM + String.valueOf(docNo)); if (generateGold) { List<String> goldElems = new ArrayList<String>(); List<String> goldTokens = new ArrayList<String>(); List<String> goldTypes = new ArrayList<String>(); int lastNeBegin = -1; int lastNeEnd = -1; for (NamedEntity namedEntity : selectCovered(NamedEntity.class, sentence)) { List<Token> tokens = selectCovered(documentJCas, Token.class, namedEntity.getBegin(), namedEntity.getEnd()); List<String> strTokens = new ArrayList<String>(); // transform List<Tokens> to List<Strings> for (Token t : tokens) { strTokens.add(new String(t.getCoveredText())); } String strToken = concatWithSeparator(strTokens, " "); String type = namedEntity.getValue(); int neBegin = namedEntity.getBegin(); int neEnd = namedEntity.getEnd(); String strElem = buildTask1TokenJSON(textBuilder, namedEntity, charOffsetStartMapping, charOffsetEndMapping); // handling of nested NEs if (lastNeEnd != -1 && neBegin <= lastNeEnd) { // this NE is bigger = better if ((neEnd - neBegin) > (lastNeEnd - lastNeBegin)) { // remove last NE goldElems.remove(goldElems.size() - 1); goldTokens.remove(goldElems.size() - 1); goldTypes.remove(goldElems.size() - 1); // add new NE goldElems.add(strElem); goldTokens.add(strToken); goldTypes.add(type); lastNeBegin = neBegin; lastNeEnd = neEnd; } // else ignore this NE, keep last one } else { // standard case, no nested NE, or first NE of nested NEs goldElems.add(strElem); goldTokens.add(strToken); goldTypes.add(type); lastNeBegin = neBegin; lastNeEnd = neEnd; } } String strTypes = JSON_VALUE_EMPTY_ARRAY; String strGold = JSON_VALUE_NONE_MARKER; String strGoldReason = noGoldNER1Reason; int difficulty = 1; // Case where we have gold elements and want to give feedback to the crowd user if (goldElems.size() > 0) { strGold = buildTask1GoldElem(textBuilder, goldElems); // Difficulty is used to hint Crowdflower that more difficult sentences (the // ones // where users must mark many NEs) are displayed with less probability. difficulty = goldElems.size(); strTypes = buildTask1GoldElem(textBuilder, goldTypes); strGoldReason = buildTask1GoldElemReason(textBuilder, goldTokens); } task1Data.set_difficulty(difficulty); task1Data.setMarkertext_gold(strGold); task1Data.setMarkertext_gold_reason(strGoldReason); task1Data.setTypes(strTypes); task1Data.setDocument(JSON_GOLDDOC_SHORTFORM + String.valueOf(docNo)); // Marker flag for crowdflower that this data is gold data. // Note: Users still need to click on "convert uploaded gold" manually in the // interface. task1Data.set_golden(JSON_TRUE); } data.add(task1Data); sentenceNo++; } docNo++; } if (generateGold) { lastGoldOffset = i; } return data; }
From source file:com.amazon.carbonado.repo.replicated.ReplicationTrigger.java
/** * Re-sync the replica to the master. The primary keys of both entries are * assumed to match./*from www . ja v a2s .com*/ * * @param listener optional * @param replicaEntry current replica entry, or null if none * @param masterEntry current master entry, or null if none * @param reload true to reload master entry */ void resyncEntries(ResyncCapability.Listener<? super S> listener, S replicaEntry, S masterEntry, boolean reload) throws FetchException, PersistException { if (replicaEntry == null && masterEntry == null) { return; } Log log = LogFactory.getLog(ReplicatedRepository.class); setReplicationDisabled(); try { Transaction masterTxn = mRepository.getMasterRepository().enterTransaction(); Transaction replicaTxn = mRepository.getReplicaRepository().enterTransaction(); try { replicaTxn.setForUpdate(true); if (reload) { if (masterEntry == null) { masterEntry = mMasterStorage.prepare(); replicaEntry.copyAllProperties(masterEntry); } if (!masterEntry.tryLoad()) { masterEntry = null; } } final S newReplicaEntry; if (replicaEntry == null) { newReplicaEntry = mReplicaStorage.prepare(); masterEntry.copyAllProperties(newReplicaEntry); log.info("Inserting missing replica entry: " + newReplicaEntry); } else if (masterEntry != null) { if (replicaEntry.equalProperties(masterEntry)) { return; } newReplicaEntry = mReplicaStorage.prepare(); transferToReplicaEntry(replicaEntry, masterEntry, newReplicaEntry); log.info("Updating stale replica entry with: " + newReplicaEntry); } else { newReplicaEntry = null; log.info("Deleting bogus replica entry: " + replicaEntry); } final Object state; if (listener == null) { state = null; } else { if (replicaEntry == null) { state = listener.beforeInsert(newReplicaEntry); } else if (masterEntry != null) { state = listener.beforeUpdate(replicaEntry, newReplicaEntry); } else { state = listener.beforeDelete(replicaEntry); } } try { // Delete old entry. if (replicaEntry != null) { try { replicaEntry.tryDelete(); } catch (PersistException e) { log.error("Unable to delete replica entry: " + replicaEntry, e); if (masterEntry != null) { // Try to update instead. log.info("Updating corrupt replica entry with: " + newReplicaEntry); try { newReplicaEntry.update(); // This disables the insert step, which is not needed now. masterEntry = null; } catch (PersistException e2) { log.error("Unable to update replica entry: " + replicaEntry, e2); resyncFailed(listener, replicaEntry, masterEntry, newReplicaEntry, state); return; } } } } // Insert new entry. if (masterEntry != null && newReplicaEntry != null) { if (!newReplicaEntry.tryInsert()) { // Try to correct bizarre corruption. newReplicaEntry.tryDelete(); newReplicaEntry.tryInsert(); } } if (listener != null) { if (replicaEntry == null) { listener.afterInsert(newReplicaEntry, state); } else if (masterEntry != null) { listener.afterUpdate(newReplicaEntry, state); } else { listener.afterDelete(replicaEntry, state); } } replicaTxn.commit(); } catch (Throwable e) { resyncFailed(listener, replicaEntry, masterEntry, newReplicaEntry, state); ThrowUnchecked.fire(e); } } finally { try { masterTxn.exit(); } finally { // Do second, favoring any exception thrown from it. replicaTxn.exit(); } } } finally { setReplicationEnabled(); } }
From source file:io.smartspaces.system.bootstrap.osgi.GeneralSmartSpacesSupportActivator.java
/** * Set up the system configuration./* www .ja va2 s .c o m*/ * * @param containerProperties * properties for the container * @param log * the logger to use */ private void setupSystemConfiguration(Map<String, String> containerProperties, Log log) { expressionEvaluatorFactory = new SselExpressionEvaluatorFactory(); FileSystemConfigurationStorageManager fileSystemConfigurationStorageManager = new FileSystemConfigurationStorageManager(); fileSystemConfigurationStorageManager.setLog(spaceEnvironment.getLog()); fileSystemConfigurationStorageManager.setExpressionEvaluatorFactory(expressionEvaluatorFactory); fileSystemConfigurationStorageManager.setSmartspacesFilesystem(filesystem); fileSystemConfigurationStorageManager.setConfigFolder(configurationProvider.getConfigFolder()); systemConfigurationStorageManager = fileSystemConfigurationStorageManager; systemConfigurationStorageManager.startup(); containerManagedScope.addResource(systemConfigurationStorageManager); Configuration systemConfiguration = systemConfigurationStorageManager.getSystemConfiguration(); systemConfiguration.setProperties(containerProperties); systemConfiguration.setProperty(SmartSpacesEnvironment.CONFIGURATION_NAME_SMARTSPACES_VERSION, bundleContext.getProperty(CoreConfiguration.CONFIGURATION_NAME_SMARTSPACES_VERSION)); String hostAddress = getHostAddress(systemConfiguration); if (hostAddress != null) { log.info(String.format("Using container host address %s", hostAddress)); systemConfiguration.setProperty(SmartSpacesEnvironment.CONFIGURATION_NAME_HOST_ADDRESS, hostAddress); } else { log.warn("Could not determine container host address."); } systemConfiguration.setProperty(SmartSpacesEnvironment.CONFIGURATION_NAME_SYSTEM_FILESYSTEM_DIR_INSTALL, filesystem.getInstallDirectory().getAbsolutePath()); systemConfiguration.setProperty(SmartSpacesEnvironment.CONFIGURATION_NAME_SYSTEM_FILESYSTEM_DIR_DATA, filesystem.getDataDirectory().getAbsolutePath()); systemConfiguration.setProperty(SmartSpacesEnvironment.CONFIGURATION_NAME_SYSTEM_FILESYSTEM_DIR_TMP, filesystem.getTempDirectory().getAbsolutePath()); spaceEnvironment.setSystemConfiguration(systemConfiguration); }
From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfig.java
public void afterPropertiesSet() { final Log log; final ListableBeanFactory beanFactory; final String[] beanNames; final List<RemoteServiceConfig> serviceConfigs; log = LogFactory.getLog(AutowiredRemoteServiceGroupConfig.class); log.debug("Searching for remote services"); beanFactory = getApplicationContext(); beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, RemoteService.class, true, false);//from ww w .j a v a 2s.c om if (beanNames.length == 0) { return; } serviceConfigs = new ArrayList<RemoteServiceConfig>(); for (String beanName : beanNames) { final Class<?> beanType; final Class<?> serviceInterface; beanType = beanFactory.getType(beanName); serviceInterface = getRemoteServiceInterface(beanType); if (serviceInterface != null) { if (serviceInterface.getAnnotation(RemoteServiceRelativePath.class) != null) { if (isAcceptedServiceInterface(serviceInterface)) { if (log.isDebugEnabled()) { log.debug("Adding service '" + beanName + "'"); } serviceConfigs.add(new RemoteServiceConfig(beanName)); } } else { if (log.isDebugEnabled()) { log.debug("Ignoring service '" + beanName + "' since service does not specify " + "remote service relative path"); } } } else { if (log.isInfoEnabled()) { log.info("Ignoring service '" + beanName + "' since it implements multiple " + "remote service interfaces"); } } } setServiceConfigs(serviceConfigs); }
From source file:de.tudarmstadt.ukp.clarin.webanno.crowdflower.NamedEntityTaskManager.java
/** * Get status string for just one job id * @param jobId - Crowdflower job ID//from w w w .j av a 2 s . c om * @return status string describing the current status on crowdflower */ private String getStatusString(String jobId) { Log LOG = LogFactory.getLog(getClass()); JsonNode uploadStatus; try { uploadStatus = crowdclient.getUploadStatus(jobId); } catch (Exception e) { return "Error while trying to connect to Crowdflower: " + e.getMessage(); } String line; int uploadedUnits = -1; boolean finsishedUpload = false; int judgments = 0; int neededJudgments = 0; //Crowdflower reported an error in its JSON output if (uploadStatus != null && uploadStatus.has(JSON_FIELD_ERROR)) { return "error retrieving status: " + uploadStatus.path(JSON_FIELD_ERROR).getTextValue(); } //No error and JSON has required fields if (uploadStatus != null && uploadStatus.has(JSON_FIELD_COUNT) && uploadStatus.has(JSON_FIELD_DONE)) { uploadedUnits = uploadStatus.path(JSON_FIELD_COUNT).getIntValue(); LOG.info("status job1:" + uploadStatus.toString()); finsishedUpload = uploadStatus.path(JSON_FIELD_DONE).getBooleanValue(); if (finsishedUpload) { JsonNode status; //retrieve judgment stats try { status = crowdclient.getStatus(jobId); } catch (Exception e) { return "Error while trying to connect to Crowdflower: " + e.getMessage(); } if (status != null && status.has(JSON_FIELD_STATUS_ALL_JUDGMENTS) && status.has(JSON_FIELD_STATUS_NEEDED_JUDGMENTS)) { judgments = status.path(JSON_FIELD_STATUS_ALL_JUDGMENTS).getIntValue(); neededJudgments = status.path(JSON_FIELD_STATUS_NEEDED_JUDGMENTS).getIntValue(); } else { return malformedStatusErrorMsg; } } } else { return malformedStatusErrorMsg; } line = "is uploaded and has " + uploadedUnits + " uploaded units. " + (finsishedUpload ? "There are " + judgments + " judgments. Needed to complete job: " + neededJudgments + ")" : "Crowdflower is still processing the upload."); return line; }
From source file:interactivespaces.system.bootstrap.osgi.GeneralInteractiveSpacesSupportActivator.java
/** * Set up the full ROS environment./*from w w w. java 2 s. c o m*/ * * @param containerProperties * properties for configuration * @param log * logger to use */ private void setupRosEnvironment(Map<String, String> containerProperties, Log log) { RosLogFactory.setLog(log); rosEnvironment = new SimpleRosEnvironment(); rosEnvironment.setExecutorService(executorService); rosEnvironment.setLog(spaceEnvironment.getLog()); rosEnvironment.setMaster(InteractiveSpacesEnvironment.CONFIGURATION_CONTAINER_TYPE_MASTER .equals(containerProperties.get(InteractiveSpacesEnvironment.CONFIGURATION_CONTAINER_TYPE))); rosEnvironment .setNetworkType(containerProperties.get(InteractiveSpacesEnvironment.CONFIGURATION_NETWORK_TYPE)); for (Entry<String, String> entry : containerProperties.entrySet()) { rosEnvironment.setProperty(entry.getKey(), entry.getValue()); } configureRosFromInteractiveSpaces(containerProperties); // Want to start Interactive Spaces with no master URI unless there was // one in the config properties. rosEnvironment.setMasterUri(null); rosEnvironment.startup(); managedResources.addResource(new ManagedResource() { @Override public void startup() { // Won't be calling startup } @Override public void shutdown() { rosEnvironment.shutdown(); } }); MasterUriProvider baseProvider = null; URI masterUri = rosEnvironment.getMasterUri(); if (masterUri != null) { log.info(String.format("Have initial ROS master URI %s", masterUri)); baseProvider = new StaticMasterUriProvider(masterUri); } masterUriProvider = new SwitchableMasterUriProvider(baseProvider); rosEnvironment.setMasterUriProvider(masterUriProvider); }