use of org.springframework.beans.factory.InitializingBean in project Activiti by Activiti.
the class Application method usersAndGroupsInitializer.
@Bean
InitializingBean usersAndGroupsInitializer(final IdentityService identityService) {
return new InitializingBean() {
@Override
public void afterPropertiesSet() throws Exception {
// install groups & users
Group group = identityService.newGroup("user");
group.setName("users");
group.setType("security-role");
identityService.saveGroup(group);
User joram = identityService.newUser("jbarrez");
joram.setFirstName("Joram");
joram.setLastName("Barrez");
joram.setPassword("password");
identityService.saveUser(joram);
User josh = identityService.newUser("jlong");
josh.setFirstName("Josh");
josh.setLastName("Long");
josh.setPassword("password");
identityService.saveUser(josh);
identityService.createMembership("jbarrez", "user");
identityService.createMembership("jlong", "user");
}
};
}
use of org.springframework.beans.factory.InitializingBean in project opennms by OpenNMS.
the class ReportDefinition method createReport.
/**
* <p>createReport</p>
*
* @param resourceDao a {@link org.opennms.netmgt.dao.api.ResourceDao} object.
* @param fetchStrategy an object.
* @param filterDao a {@link org.opennms.netmgt.filter.api.FilterDao} object.
* @return a {@link org.opennms.netmgt.statsd.ReportInstance} object.
* @throws java.lang.Exception if any.
*/
public ReportInstance createReport(NodeDao nodeDao, ResourceDao resourceDao, MeasurementFetchStrategy fetchStrategy, FilterDao filterDao) throws Exception {
Assert.notNull(resourceDao, "resourceDao argument must not be null");
Assert.notNull(fetchStrategy, "fetchStrategy argument must not be null");
Assert.notNull(filterDao, "filterDao argument must not be null");
AttributeStatisticVisitorWithResults visitor;
try {
visitor = getReportClass().newInstance();
} catch (Throwable e) {
throw new DataAccessResourceFailureException("Could not instantiate visitor object; nested exception: " + e, e);
}
ReportInstance report;
if (getReport().getPackage().getFilter() != null) {
FilteredReportInstance thisReport = new FilteredReportInstance(visitor);
thisReport.setNodeDao(nodeDao);
thisReport.setResourceDao(resourceDao);
thisReport.setFetchStrategy(fetchStrategy);
thisReport.setFilterDao(filterDao);
thisReport.setFilter(getReport().getPackage().getFilter());
report = thisReport;
} else {
UnfilteredReportInstance thisReport = new UnfilteredReportInstance(visitor);
thisReport.setResourceDao(resourceDao);
thisReport.setFetchStrategy(fetchStrategy);
report = thisReport;
}
report.setReportDefinition(this);
report.setStartTime(getRelativeTime().getStart().getTime());
report.setEndTime(getRelativeTime().getEnd().getTime());
report.setCount(getCount());
report.setConsolidationFunction(getConsolidationFunction());
report.setResourceTypeMatch(getResourceTypeMatch());
report.setAttributeMatch(getAttributeMatch());
report.setResourceAttributeKey(m_resourceAttributeKey);
report.setResourceAttributeValueMatch(m_resourceAttributeValueMatch);
if (report instanceof InitializingBean) {
((InitializingBean) report).afterPropertiesSet();
}
return report;
}
use of org.springframework.beans.factory.InitializingBean in project gravitee-management-rest-api by gravitee-io.
the class IdentityProviderManagerImpl method create.
private <T> T create(Plugin plugin, Class<T> identityClass, Map<String, Object> properties) {
if (identityClass == null) {
return null;
}
try {
T identityObj = createInstance(identityClass);
final Import annImport = identityClass.getAnnotation(Import.class);
Set<Class<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext idpApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Class<?>> configurations() {
return configurations;
}
@Override
public ConfigurableEnvironment environment() {
return new StandardEnvironment() {
@Override
protected void customizePropertySources(MutablePropertySources propertySources) {
propertySources.addFirst(new MapPropertySource(plugin.id(), properties));
super.customizePropertySources(propertySources);
}
};
}
});
idpApplicationContext.getAutowireCapableBeanFactory().autowireBean(identityObj);
if (identityObj instanceof InitializingBean) {
((InitializingBean) identityObj).afterPropertiesSet();
}
return identityObj;
} catch (Exception ex) {
LOGGER.error("An unexpected error occurs while loading identity provider", ex);
return null;
}
}
use of org.springframework.beans.factory.InitializingBean in project mica2 by obiba.
the class ExceptionHandlingAsyncTaskExecutor method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
use of org.springframework.beans.factory.InitializingBean in project cuba by cuba-platform.
the class DesktopComponentsFactory method autowireContext.
protected void autowireContext(Component instance) {
AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
autowireBeanFactory.autowireBean(instance);
if (instance instanceof ApplicationContextAware) {
((ApplicationContextAware) instance).setApplicationContext(applicationContext);
}
if (instance instanceof InitializingBean) {
try {
((InitializingBean) instance).afterPropertiesSet();
} catch (Exception e) {
throw new RuntimeException("Unable to initialize Component - calling afterPropertiesSet for " + instance.getClass());
}
}
}
Aggregations