Tabnine Logo
ClassLoading.servicesOfType
Code IndexAdd Tabnine to your IDE (free)

How to use
servicesOfType
method
in
org.ehcache.core.util.ClassLoading

Best Java code snippets using org.ehcache.core.util.ClassLoading.servicesOfType (Showing top 7 results out of 315)

origin: ehcache/ehcache3

 public static Schema discoverSchema(Source ... fixedSources) throws SAXException, IOException {
  ArrayList<Source> schemaSources = new ArrayList<>(asList(fixedSources));
  for (CacheManagerServiceConfigurationParser<?> p : servicesOfType(CacheManagerServiceConfigurationParser.class)) {
   schemaSources.add(p.getXmlSchema());
  }
  for (CacheServiceConfigurationParser<?> p : servicesOfType(CacheServiceConfigurationParser.class)) {
   schemaSources.add(p.getXmlSchema());
  }
  for (CacheResourceConfigurationParser p : servicesOfType(CacheResourceConfigurationParser.class)) {
   schemaSources.add(p.getXmlSchema());
  }
  return newSchema(schemaSources.toArray(new Source[0]));
 }
}
origin: ehcache/ehcache3

ConfigurationParser() throws IOException, SAXException, JAXBException, ParserConfigurationException {
 serviceCreationConfigurationParser = ConfigurationParser.<CacheManagerServiceConfigurationParser<?>>stream(
  servicesOfType(CacheManagerServiceConfigurationParser.class))
  .collect(collectingAndThen(toMap(CacheManagerServiceConfigurationParser::getServiceType, identity(),
   (a, b) -> a.getClass().isInstance(b) ? b : a), ServiceCreationConfigurationParser::new));
 serviceConfigurationParser = ConfigurationParser.<CacheServiceConfigurationParser<?>>stream(
  servicesOfType(CacheServiceConfigurationParser.class))
  .collect(collectingAndThen(toMap(CacheServiceConfigurationParser::getServiceType, identity(),
   (a, b) -> a.getClass().isInstance(b) ? b : a), ServiceConfigurationParser::new));
 resourceConfigurationParser = stream(servicesOfType(CacheResourceConfigurationParser.class))
  .flatMap(p -> p.getResourceTypes().stream().map(t -> new AbstractMap.SimpleImmutableEntry<>(t, p)))
  .collect(collectingAndThen(toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a.getClass().isInstance(b) ? b : a),
   m -> new ResourceConfigurationParser(new HashSet<>(m.values()))));
 schema = discoverSchema(new StreamSource(CORE_SCHEMA_URL.openStream()));
 documentBuilder = documentBuilder(schema);
}
origin: ehcache/ehcache3

@Override
public void start(BundleContext context) throws Exception {
 BundleContext currentContext = CORE_BUNDLE.getAndUpdate(current -> current == null ? context : current);
 if (currentContext == null) {
  String greeting = "Detected OSGi Environment (core is in bundle: " + context.getBundle() + ")";
  if ("false".equalsIgnoreCase(context.getProperty(OSGI_LOADING))) {
   SafeOsgi.disableOSGiServiceLoading();
   LOGGER.info(greeting + ": OSGi Based Service Loading Disabled Via System/Framework Property - Extensions Outside This Bundle Will Not Be Detected");
   LOGGER.debug("JDK Service Loading Sees:\n\t" + stream(spliterator(ClassLoading.servicesOfType(ServiceFactory.class).iterator(), Long.MAX_VALUE, 0), false)
    .map(sf -> sf.getServiceType().getName()).collect(joining("\n\t")));
  } else {
   SafeOsgi.enableOSGiServiceLoading();
   LOGGER.info(greeting + ": Using OSGi Based Service Loading");
  }
 } else {
  throw new IllegalStateException("Multiple bundle instances running against the same core classes: existing bundle: " + currentContext.getBundle() + " new bundle: " + context.getBundle());
 }
}
origin: ehcache/ehcache3

/**
 * Ensures the {@link ClusteringCacheManagerServiceConfigurationParser} is locatable as a
 * {@link CacheManagerServiceConfigurationParser} instance.
 */
@Test
public void testServiceLocator() throws Exception {
 assertThat(stream(spliterator(ClassLoading.servicesOfType(CacheManagerServiceConfigurationParser.class).iterator(), Long.MAX_VALUE, 0), false).map(Object::getClass).collect(Collectors.toList()),
  hasItem(ClusteringCacheManagerServiceConfigurationParser.class));
}
origin: ehcache/ehcache3

 @Test
 public void testServiceLocator() throws Exception {
  assertThat(stream(spliterator(ClassLoading.servicesOfType(ServiceFactory.class).iterator(), Long.MAX_VALUE, 0), false).map(Object::getClass).collect(Collectors.toList()),
   hasItem(ClusteringServiceFactory.class));
 }
}
origin: ehcache/ehcache3

 @Test
 public void testNonClustered() throws Exception {

  /*
   * Ensure the cluster provider classes are loadable through the ServiceLoader mechanism.
   */
  assertThat(stream(spliterator(ClassLoading.servicesOfType(ServiceFactory.class).iterator(), Long.MAX_VALUE, 0), false).map(f -> f.getServiceType()).collect(Collectors.toList()),
   hasItems(ClusteredStore.Provider.class, ClusteringService.class));

  CacheConfiguration<String, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(
    String.class,
    String.class,
    ResourcePoolsBuilder.newResourcePoolsBuilder()
      .heap(10, EntryUnit.ENTRIES)
      .offheap(1, MemoryUnit.MB)
      .build())
    .build();


  CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(true);

  cacheManager.createCache("cache-1", cacheConfiguration);
  cacheManager.createCache("cache-2", cacheConfiguration);

  cacheManager.close();
 }
}
origin: ehcache/ehcache3

 @Test
 public void testNonXA() throws Exception {

  /*
   * Ensure the XA provider classes are loadable through the ServiceLoader mechanism.
   */
  assertThat(stream(spliterator(ClassLoading.servicesOfType(ServiceFactory.class).iterator(), Long.MAX_VALUE, 0), false).map(s -> s.getServiceType()).collect(toList()),
   hasItems(XAStore.Provider.class, TransactionManagerProvider.class));

  CacheConfiguration<String, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(
    String.class,
    String.class,
    ResourcePoolsBuilder.newResourcePoolsBuilder()
      .heap(10, EntryUnit.ENTRIES)
      .offheap(1, MemoryUnit.MB)
      .build())
    .build();


  CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(true);

  cacheManager.createCache("cache-1", cacheConfiguration);
  cacheManager.createCache("cache-2", cacheConfiguration);

  cacheManager.close();
 }
}
org.ehcache.core.utilClassLoadingservicesOfType

Popular methods of ClassLoading

  • getDefaultClassLoader
  • delegationChain

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (ScheduledExecutorService)
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now