/** * Lookup the cache component with provided hint and create a new cache. * * @param <T> the class of the data stored in the cache. * @param config the cache configuration. * @param cacheHint the role hint to lookup. * @return a new {@link Cache}. * @throws CacheException error when creating the cache. */ public <T> Cache<T> createNewCache(CacheConfiguration config, String cacheHint) throws CacheException { CacheFactory cacheFactory; try { cacheFactory = this.componentManager.getInstance(CacheFactory.class, cacheHint); } catch (ComponentLookupException e) { throw new CacheException("Failed to get cache factory for role hint [" + cacheHint + "]", e); } return cacheFactory.newCache(config); } }
this.caches.put(coreIdentifier, cache); } catch (final CacheException ex) { throw new InitializationException("Cannot create cache: " + ex.getMessage(), ex); } catch (IOException ex) { throw new InitializationException("Invalid Solr resource: " + ex.getMessage(), ex);
@Override public void initialize() throws InitializationException { try { this.baseServiceURL = this.configuration.getProperty("phenotips.ontologies.hgnc.serviceURL", "http://rest.genenames.org/"); this.searchServiceURL = this.baseServiceURL + "search/"; this.infoServiceURL = this.baseServiceURL + "info"; this.fetchServiceURL = this.baseServiceURL + "fetch/"; this.cache = this.cacheFactory.createNewLocalCache(new CacheConfiguration()); EntryEvictionConfiguration infoConfig = new LRUEvictionConfiguration(1); infoConfig.setTimeToLive(300); this.infoCache = this.cacheFactory.createNewLocalCache(new CacheConfiguration(infoConfig)); } catch (final CacheException ex) { throw new InitializationException("Cannot create cache: " + ex.getMessage()); } QUERY_OPERATORS.put("OR", ""); QUERY_OPERATORS.put(DEFAULT_OPERATOR, DEFAULT_OPERATOR + ' '); QUERY_OPERATORS.put("NOT", "-"); }
@Override public void initialize(String serverName) throws InitializationException { try { this.server = new EmbeddedSolrServer(this.cores.getContainer(), serverName); this.cache = this.cacheFactory.createNewLocalCache(new CacheConfiguration()); } catch (RuntimeException ex) { throw new InitializationException("Invalid URL specified for the Solr server: {}"); } catch (final CacheException ex) { throw new InitializationException("Cannot create cache: " + ex.getMessage()); } }
/** * Lookup the cache component with provided hint and create a new cache. * * @param <T> the class of the data stored in the cache. * @param config the cache configuration. * @param cacheHint the role hint to lookup. * @return a new {@link Cache}. * @throws CacheException error when creating the cache. */ public <T> Cache<T> createNewCache(CacheConfiguration config, String cacheHint) throws CacheException { CacheFactory cacheFactory; try { cacheFactory = this.componentManager.getInstance(CacheFactory.class, cacheHint); } catch (ComponentLookupException e) { throw new CacheException("Failed to get cache factory for role hint [" + cacheHint + "]", e); } return cacheFactory.newCache(config); } }
@Override public void initialize() throws InitializationException { try { this.server = new HttpSolrServer("http://localhost:8080/solr/" + this.getName() + "/"); this.cache = this.cacheFactory.createNewLocalCache(new CacheConfiguration()); } catch (RuntimeException ex) { throw new InitializationException("Invalid URL specified for the Solr server: {}"); } catch (final CacheException ex) { throw new InitializationException("Cannot create cache: " + ex.getMessage()); } }