List of usage examples for org.springframework.context ApplicationContext getBeansOfType
<T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException;
From source file:org.geowebcache.io.ImageDecoderContainer.java
public void setApplicationContext(ApplicationContext context) throws BeansException { decoders = context.getBeansOfType(ImageDecoder.class).values(); if (decoders == null || decoders.isEmpty()) { throw new IllegalArgumentException("No Encoder found"); }/*w ww . j ava2 s . c o m*/ mapDecoders = new HashMap<String, ImageDecoder>(); for (ImageDecoder encoder : decoders) { List<String> supportedMimeTypes = encoder.getSupportedMimeTypes(); for (String mimeType : supportedMimeTypes) { if (!mapDecoders.containsKey(mimeType)) { mapDecoders.put(mimeType, encoder); } } } }
From source file:org.tangram.spring.TangramServlet.java
/** * Obtain view handler and expose application scope to the servlet context. * * resolves the view handler instance from the application context and exposes any bean on that context * to the servleet context scope if the servlet layer. * * @param context (spring) application context *///from w ww . j a va 2s. c o m @Override protected void initStrategies(ApplicationContext context) { super.initStrategies(context); viewHandler = context.getBeansOfType(ViewHandler.class).values().iterator().next(); for (String name : context.getBeanNamesForType(Object.class)) { getServletContext().setAttribute(name, context.getBean(name)); } // for if (viewHandler == null) { throw new RuntimeException("no view handler"); } // if }
From source file:org.geowebcache.io.ImageEncoderContainer.java
public void setApplicationContext(ApplicationContext context) throws BeansException { encoders = context.getBeansOfType(ImageEncoder.class).values(); if (encoders == null || encoders.isEmpty()) { throw new IllegalArgumentException("No Encoder found"); }/* ww w. j av a 2s.c o m*/ mapEncoders = new HashMap<String, ImageEncoder>(); for (ImageEncoder encoder : encoders) { List<String> supportedMimeTypes = encoder.getSupportedMimeTypes(); for (String mimeType : supportedMimeTypes) { if (!mapEncoders.containsKey(mimeType)) { mapEncoders.put(mimeType, encoder); } } } }
From source file:org.infinitest.eclipse.PluginContextIntegrationTest.java
@Test public void shouldWireComponentsTogetherByTypeUsingSpringAutowiring() { ApplicationContext ctx = new AnnotationConfigApplicationContext(TestInfinitestConfig.class); assertThat(ctx.getBeansOfType(IResourceChangeListener.class)).isNotEmpty(); assertThat(ctx.getBeansOfType(ResourceFinder.class)).isNotEmpty(); }
From source file:org.obiba.onyx.print.impl.DefaultPrintableReportsRegistry.java
@SuppressWarnings("unchecked") public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { Map<String, IPrintableReport> printableReports = applicationContext.getBeansOfType(IPrintableReport.class); availableReports = new HashSet<IPrintableReport>(); availableReports.addAll(printableReports.values()); }
From source file:org.iternine.jeppetto.testsupport.DynamoDBDatabaseProvider.java
@Override public Database getDatabase(Properties properties, ApplicationContext applicationContext) { Map<String, AmazonDynamoDB> amazonDynamoDBBeans = applicationContext.getBeansOfType(AmazonDynamoDB.class); if (amazonDynamoDBBeans.size() != 1) { throw new RuntimeException( "Expected one 'AmazonDynamoDB' definition. Found " + amazonDynamoDBBeans.size()); }//from w ww.j a va 2 s . c om return new DynamoDBDatabase((AmazonDynamoDB) amazonDynamoDBBeans.values().toArray()[0], createTableRequests); }
From source file:org.iternine.jeppetto.testsupport.JdbcDatabaseProvider.java
private ConnectionSource getConnectionSource(Properties properties, ApplicationContext applicationContext) { Map datasourceBeans = applicationContext.getBeansOfType(DataSource.class); if (datasourceBeans.size() == 0) { return null; }//from w ww . java 2 s . c o m if (datasourceBeans.size() > 1) { logger.warn( "NOTE: Found more than one bean of type 'DataSource'. Selecting random from the following: {}", datasourceBeans); } DataSource dataSource = (DataSource) datasourceBeans.values().iterator().next(); return new DataSourceConnectionSource(dataSource, (String) properties.get(driverClassNameProperty)); }
From source file:be.ugent.maf.cellmissy.analysis.factory.TrackInterpolatorFactory.java
/** * Private constructor./* w ww . j av a2s. c o m*/ */ private TrackInterpolatorFactory() { ApplicationContext context = ApplicationContextProvider.getInstance().getApplicationContext(); interpolators = context.getBeansOfType(TrackInterpolator.class); }
From source file:org.apache.archiva.redback.rest.services.utils.EnvironmentChecker.java
@Inject public EnvironmentChecker(ApplicationContext applicationContext) { Collection<EnvironmentCheck> checkers = applicationContext.getBeansOfType(EnvironmentCheck.class).values(); StopWatch stopWatch = new StopWatch(); stopWatch.reset();//from w w w. j a v a2 s. c o m stopWatch.start(); if (checkers != null) { List<String> violations = new ArrayList<String>(); for (EnvironmentCheck check : checkers) { check.validateEnvironment(violations); } if (!violations.isEmpty()) { StringBuilder msg = new StringBuilder(); msg.append("EnvironmentCheck Failure.\n"); msg.append("======================================================================\n"); msg.append(" ENVIRONMENT FAILURE !! \n"); msg.append("\n"); for (String v : violations) { msg.append(v).append("\n"); } msg.append("\n"); msg.append("======================================================================"); log.error(msg.toString()); } } stopWatch.stop(); log.info("time to execute all EnvironmentCheck: {} ms", stopWatch.getTime()); }
From source file:org.jspringbot.keyword.expression.engine.function.SupportedFunctionsManager.java
public SupportedFunctionsManager(ApplicationContext context) { Map<String, SupportedFunctionRegistryBean> beans = context .getBeansOfType(SupportedFunctionRegistryBean.class); for (SupportedFunctionRegistryBean registryBean : beans.values()) { try {/*from ww w .j a va 2 s. c o m*/ addResources(registryBean.getResources()); } catch (IOException ignore) { } } }