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

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

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

origin: ehcache/ehcache3

/**
 * {@inheritDoc}
 */
@Override
public ClassLoader getDefaultClassLoader() {
 return ClassLoading.getDefaultClassLoader();
}
origin: ehcache/ehcache3

/**
 * Constructs an instance of XmlConfiguration from the given XML DOM.
 * <p>
 * The default ClassLoader will first try to use the thread context class loader, followed by the ClassLoader that
 * loaded the Ehcache classes.
 *
 * @param xml XML Document Object Model
 *
 * @throws XmlConfigurationException if anything went wrong parsing the XML
 */
public XmlConfiguration(Document xml) throws XmlConfigurationException {
 this(xml, ClassLoading.getDefaultClassLoader());
}
origin: ehcache/ehcache3

/**
 * Constructs an instance of XmlConfiguration mapping to the XML file located at {@code url}.
 * <p>
 * The default ClassLoader will first try to use the thread context class loader, followed by the ClassLoader that
 * loaded the Ehcache classes.
 *
 * @param url URL pointing to the XML file's location
 *
 * @throws XmlConfigurationException if anything went wrong parsing the XML
 */
public XmlConfiguration(URL url)
  throws XmlConfigurationException {
 this(url, ClassLoading.getDefaultClassLoader());
}
origin: ehcache/ehcache3

/**
 * Creates a new configuration with the specified {@link CacheConfiguration cache configurations}, class loader and
 * {@link org.ehcache.spi.service.ServiceConfiguration service configurations}.
 *
 * @param caches a map from alias to cache configuration
 * @param classLoader the class loader to use for user types
 * @param services an array of service configurations
 */
public DefaultConfiguration(Map<String, CacheConfiguration<?, ?>> caches, ClassLoader classLoader, ServiceCreationConfiguration<?>... services) {
 this.services = unmodifiableCollection(Arrays.asList(services));
 this.caches = new ConcurrentHashMap<>(caches);
 this.classLoader = classLoader == null ? ClassLoading.getDefaultClassLoader() : classLoader;
}
origin: ehcache/ehcache3

public EhcacheManager(Configuration config, UnaryOperator<ServiceLocator.DependencySet> customization, boolean useLoaderInAtomics) {
 final String simpleName = this.getClass().getSimpleName();
 this.simpleName = (simpleName.isEmpty() ? this.getClass().getName() : simpleName);
 this.configuration = new DefaultConfiguration(config);
 this.cacheManagerClassLoader = config.getClassLoader() != null ? config.getClassLoader() : ClassLoading.getDefaultClassLoader();
 this.useLoaderInAtomics = useLoaderInAtomics;
 validateServicesConfigs();
 this.serviceLocator = resolveServices(customization);
}
origin: ehcache/ehcache3

for (String className : optionalAnnotation.value()) {
 try {
  Class<?> dependencyClass = delegationChain(getDefaultClassLoader(), clazz.getClassLoader()).loadClass(className);
  if (Service.class.isAssignableFrom(dependencyClass)) {
   @SuppressWarnings("unchecked")
origin: ehcache/ehcache3

@Override
public final ClassLoader getClassLoader() {
 ClassLoader classLoader = cacheBinding.getCache().getRuntimeConfiguration().getClassLoader();
 return classLoader == null ? ClassLoading.getDefaultClassLoader() : classLoader;
}
origin: ehcache/ehcache3

@Test
public void testDefaultClassLoader() throws Exception {
 String resource = getClass().getName().replace('.', '/').concat(".class");
 ClassLoader thisLoader = getClass().getClassLoader();
 ClassLoader defaultClassLoader = ClassLoading.getDefaultClassLoader();
 Thread.currentThread().setContextClassLoader(null);
 assertSame(thisLoader.loadClass(getClass().getName()), defaultClassLoader.loadClass(getClass().getName()));
 assertEquals(thisLoader.getResource(resource), defaultClassLoader.getResource(resource));
 assertThat(list(defaultClassLoader.getResources(resource)), is(list(thisLoader.getResources(resource))));
 Thread.currentThread().setContextClassLoader(new FindNothingLoader());
 assertSame(thisLoader.loadClass(getClass().getName()), defaultClassLoader.loadClass(getClass().getName()));
 assertEquals(thisLoader.getResource(resource), defaultClassLoader.getResource(resource));
 assertThat(list(defaultClassLoader.getResources(resource)), is(list(thisLoader.getResources(resource))));
 URL url = new URL("file:///tmp");
 ClassLoader tc = new TestClassLoader(url);
 Thread.currentThread().setContextClassLoader(tc);
 Class<?> c = defaultClassLoader.loadClass(getClass().getName());
 assertNotSame(getClass(), c);
 assertSame(tc, c.getClassLoader());
 assertEquals(url, defaultClassLoader.getResource(resource));
 assertThat(list(defaultClassLoader.getResources(resource)), contains(url, thisLoader.getResource(resource)));
}
origin: ehcache/ehcache3

 cacheClassLoader = classLoader;
} else {
 cacheClassLoader = ClassLoading.getDefaultClassLoader();
origin: ehcache/ehcache3

@Test
public void testNoClassLoaderSpecified() {
 Map<String, CacheConfiguration<?, ?>> caches = newCacheMap();
 caches.put("foo", new BaseCacheConfiguration<>(Object.class, Object.class, null, null, null, ResourcePoolsHelper.createHeapOnlyPools()));
 DefaultConfiguration config = new DefaultConfiguration(caches, null);
 final Store.Provider storeProvider = mock(Store.Provider.class);
 when(storeProvider.rank(any(Set.class), any(Collection.class))).thenReturn(1);
 final Store mock = mock(Store.class);
 final CacheEventDispatcherFactory cenlProvider = mock(CacheEventDispatcherFactory.class);
 final CacheEventDispatcher<Object, Object> cenlServiceMock = mock(CacheEventDispatcher.class);
 when(cenlProvider.createCacheEventDispatcher(mock)).thenReturn(cenlServiceMock);
 final Collection<Service> services = getServices(storeProvider, cenlProvider);
 when(storeProvider
   .createStore(ArgumentMatchers.<Store.Configuration>any(), ArgumentMatchers.<ServiceConfiguration[]>any())).thenReturn(mock);
 EhcacheManager cacheManager = new EhcacheManager(config, services);
 cacheManager.init();
 assertSame(ClassLoading.getDefaultClassLoader(), cacheManager.getClassLoader());
 assertSame(cacheManager.getClassLoader(), cacheManager.getCache("foo", Object.class, Object.class).getRuntimeConfiguration().getClassLoader());
}
origin: ehcache/ehcache3

@Test
public void testNoClassLoaderSpecified() throws Exception {
 URL resource = XmlConfigurationTest.class.getResource("/configs/one-cache.xml");
 XmlConfiguration config = new XmlConfiguration(new XmlConfiguration(resource));
 assertSame(config.getClassLoader(), ClassLoading.getDefaultClassLoader());
 assertNull(config.getCacheConfigurations().get("bar").getClassLoader());
}
origin: ehcache/ehcache3

 @Test
 public void unparseServiceConfigurationWithInstance() {
  TestSerializer3<Integer> testSerializer3 = new TestSerializer3<>(ClassLoading.getDefaultClassLoader());
  TestSerializer4<Integer> testSerializer4 = new TestSerializer4<>(ClassLoading.getDefaultClassLoader());

  DefaultSerializerConfiguration<Integer> config1 = new DefaultSerializerConfiguration<>(testSerializer3, DefaultSerializerConfiguration.Type.KEY);
  DefaultSerializerConfiguration<Integer> config2 = new DefaultSerializerConfiguration<>(testSerializer4, DefaultSerializerConfiguration.Type.VALUE);
  CacheConfiguration<?, ?> cacheConfig = newCacheConfigurationBuilder(Description.class, Person.class, heap(10))
   .add(config1).add(config2).build();

  CacheType cacheType = new CacheType();
  CacheEntryType keyType = new CacheEntryType();
  keyType.setValue("foo");
  cacheType.setKeyType(keyType);
  CacheEntryType valueType = new CacheEntryType();
  valueType.setValue("bar");
  cacheType.setValueType(valueType);
  assertThatExceptionOfType(XmlConfigurationException.class).isThrownBy(() ->
   new DefaultSerializerConfigurationParser().unparseServiceConfiguration(cacheConfig, cacheType))
   .withMessage("%s", "XML translation for instance based initialization for " +
             "DefaultSerializerConfiguration is not supported");
 }
}
org.ehcache.core.utilClassLoadinggetDefaultClassLoader

Popular methods of ClassLoading

  • servicesOfType
  • delegationChain

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (Timer)
  • compareTo (BigDecimal)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top Sublime Text plugins
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