use of org.springframework.beans.factory.BeanFactory in project ignite by apache.
the class GridTestMain method main.
/**
* Main method.
*
* @param args Parameters.
* @throws IgniteCheckedException If failed.
*/
public static void main(String[] args) throws Exception {
BeanFactory ctx = new ClassPathXmlApplicationContext("org/apache/ignite/loadtests/colocation/spring-colocation.xml");
// Initialize Spring factory.
try (Ignite g = G.start((IgniteConfiguration) ctx.getBean("grid.cfg"))) {
final IgniteCache<GridTestKey, Long> cache = g.cache("partitioned");
assert cache != null;
// Uncomment if you plan to load cache using AccentureCacheStore.
// generateAndLoad();
// Uncomment if you plan to load cache from cache store.
// Note that you could also do this automatically from lifecycle bean.
// To configure lifecycle bean, uncomment 'lifecycleBeans' property in
// spring-accenture.xml file.
loadFromStore(cache);
X.println("Number of entries in cache: " + cache.size());
colocateJobs();
//localPoolRun();
}
}
use of org.springframework.beans.factory.BeanFactory in project ignite by apache.
the class SpringCacheManagerContextInjectionTest method testBeanInjectionUsingConfiguration.
/**
* @throws Exception If failed.
*/
public void testBeanInjectionUsingConfiguration() throws Exception {
BeanFactory factory = new AnnotationConfigApplicationContext(TestCfgConfiguration.class);
TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean) factory.getBean("bean1");
TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean) factory.getBean("bean2");
bean1.checkState();
bean2.checkState();
}
use of org.springframework.beans.factory.BeanFactory in project ignite by apache.
the class GridSpringCacheManagerMultiJvmSelfTest method testSyncCache.
/**
* @throws Exception If failed.
*/
public void testSyncCache() throws Exception {
IgniteEx loc = startGrid(0);
final int threads = 4;
final int entries = 100_000;
final int remoteNum = 2;
final CountDownLatch latch = new CountDownLatch(1);
List<IgniteInternalFuture<Integer>> futures = new ArrayList<>(remoteNum);
for (int i = 0; i < remoteNum; i++) {
final int gridIdx = i + 1;
final IgniteEx remote = startGrid(gridIdx);
IgniteInternalFuture<Integer> calledCntFut = GridTestUtils.runAsync(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
latch.await();
return executeRemotely((IgniteProcessProxy) remote, new TestIgniteCallable<Integer>() {
@Override
public Integer call(Ignite ignite) throws Exception {
BeanFactory factory = new ClassPathXmlApplicationContext("org/apache/ignite/cache/spring/spring-caching" + gridIdx + ".xml");
final GridSpringDynamicCacheTestService dynamicSvc = (GridSpringDynamicCacheTestService) factory.getBean("dynamicTestService");
final CyclicBarrier barrier = new CyclicBarrier(threads);
GridTestUtils.runMultiThreaded(new Callable() {
@Override
public Object call() throws Exception {
for (int i = 0; i < entries; i++) {
barrier.await();
assertEquals("value" + i, dynamicSvc.cacheableSync(i));
assertEquals("value" + i, dynamicSvc.cacheableSync(i));
}
return null;
}
}, threads, "get-sync");
return dynamicSvc.called();
}
});
}
});
futures.add(calledCntFut);
}
latch.countDown();
int totalCalledCnt = 0;
for (IgniteInternalFuture<Integer> future : futures) totalCalledCnt += future.get();
IgniteCache<Object, Object> cache = loc.cache("dynamicCache");
assertEquals(entries, cache.size());
assertEquals(entries, totalCalledCnt);
for (int i = 0; i < entries; i++) assertEquals("value" + i, cache.get(i));
}
use of org.springframework.beans.factory.BeanFactory in project ignite by apache.
the class SpringTransactionManagerContextInjectionTest method testBeanInjectionUsingConfig.
/**
* @throws Exception If failed.
*/
public void testBeanInjectionUsingConfig() throws Exception {
BeanFactory factory = new AnnotationConfigApplicationContext(TestCfgConfiguration.class);
TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean) factory.getBean("bean1");
TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean) factory.getBean("bean2");
bean1.checkState();
bean2.checkState();
}
use of org.springframework.beans.factory.BeanFactory in project sakuli by ConSol.
the class BeanLoader method loadMultipleBeans.
/**
* @param classDef class definition of the expected beans
* @param <T> generic type of the returned {@link List}.
* @return all available beans of type {@code <T>}. If no beans are available, the method returns an empty List.
*/
public static <T> java.util.Map<String, T> loadMultipleBeans(Class<T> classDef) {
BeanFactory beanFactory = getBeanFactory();
Map<String, T> beans = null;
if (beanFactory instanceof ListableBeanFactory) {
beans = ((ListableBeanFactory) beanFactory).getBeansOfType(classDef);
}
return beans != null ? beans : Collections.emptyMap();
}
Aggregations