本文整理汇总了Java中org.springframework.context.annotation.Import类的典型用法代码示例。如果您正苦于以下问题:Java Import类的具体用法?Java Import怎么用?Java Import使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Import类属于org.springframework.context.annotation包,在下文中一共展示了Import类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfigurationImportsFor
import org.springframework.context.annotation.Import; //导入依赖的package包/类
private static List<Class<?>> getConfigurationImportsFor(Class<?> clazz) {
List<Class<?>> list= new ArrayList<>();
for(Annotation annotation : clazz.getAnnotations()) {
Class<? extends Annotation> type = annotation.annotationType();
if(Import.class.equals(type)) {
try {
Method method = type.getMethod("value");
Class<?>[] imports = (Class<?>[]) method.invoke(annotation, (Object[]) null);
if(imports != null && imports.length > 0) {
for(Class<?> c: imports) {
list.add(c);
}
}
} catch (Throwable e) {
throw new IllegalStateException(e);
}
}
}
return list;
}
示例2: create
import org.springframework.context.annotation.Import; //导入依赖的package包/类
public PolicyContextProvider create(PolicyContext policyContext) {
Import importAnnotation = policyContext.getClass().getAnnotation(Import.class);
List<Class<?>> importClasses = Arrays.asList(importAnnotation.value());
LOGGER.info("Initializing a Spring context provider from @Import annotation: {}",
String.join(",",
importClasses
.stream()
.map(Class::getName)
.collect(Collectors.toSet())));
AnnotationConfigApplicationContext policyApplicationContext = new AnnotationConfigApplicationContext();
policyApplicationContext.setClassLoader(policyContext.getClass().getClassLoader());
importClasses.forEach(policyApplicationContext::register);
// TODO: set the parent application context ?
// pluginContext.setEnvironment(applicationContextParent.getEnvironment());
// pluginContext.setParent(applicationContextParent);
policyApplicationContext.refresh();
return new SpringPolicyContextProvider(policyApplicationContext);
}
示例3: getConfigImports
import org.springframework.context.annotation.Import; //导入依赖的package包/类
/**
* Reads file import locations from Spring bean application context.
* @param project
* @return
*/
public List<Class<?>> getConfigImports(Class<?> configFile, Project project) {
Import importAnnotation = configFile.getAnnotation(Import.class);
if (importAnnotation != null) {
return Arrays.asList(importAnnotation.value());
}
return new ArrayList<>();
}
示例4: createContextCustomizer
import org.springframework.context.annotation.Import; //导入依赖的package包/类
@Override
public ContextCustomizer createContextCustomizer(Class<?> testClass,
List<ContextConfigurationAttributes> configAttributes) {
if (AnnotatedElementUtils.findMergedAnnotation(testClass, Import.class) != null) {
assertHasNoBeanMethods(testClass);
return new ImportsContextCustomizer(testClass);
}
return null;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ImportsContextCustomizerFactory.java
示例5: getCompleteConfiguration
import org.springframework.context.annotation.Import; //导入依赖的package包/类
/**
* Utility operation to return an array of configuration classes
* defined in {@link EnableBinding} annotation.
* Typically used for tests that do not rely on creating an SCSt boot
* application annotated with {@link EnableBinding}, yet require
* full {@link Binder} configuration.
*/
public static Class<?>[] getCompleteConfiguration() {
List<Class<?>> configClasses = new ArrayList<>();
configClasses.add(SpringIntegrationBinderConfiguration.class);
Import annotation = AnnotationUtils.getAnnotation(EnableBinding.class, Import.class);
Map<String, Object> annotationAttributes = AnnotationUtils.getAnnotationAttributes(annotation);
configClasses.addAll(Arrays.asList((Class<?>[])annotationAttributes.get("value")));
return configClasses.toArray(new Class<?>[] {});
}
示例6: create0
import org.springframework.context.annotation.Import; //导入依赖的package包/类
private <T> T create0(Plugin plugin, Class<T> certificateClass, CertificateConfiguration certificateConfiguration) {
if (certificateClass == null) {
return null;
}
try {
T certificateObj = createInstance(certificateClass);
final Import annImport = certificateClass.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 ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add certificate configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(
new CertificateConfigurationBeanFactoryPostProcessor(certificateConfiguration));
return configurableApplicationContext;
}
});
idpApplicationContext.getAutowireCapableBeanFactory().autowireBean(certificateObj);
if (certificateObj instanceof InitializingBean) {
((InitializingBean) certificateObj).afterPropertiesSet();
}
return certificateObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading certificate", ex);
return null;
}
}
示例7: create0
import org.springframework.context.annotation.Import; //导入依赖的package包/类
private <T> T create0(Plugin plugin, Class<T> extensionGrantClass, ExtensionGrantConfiguration extensionGrantConfiguration, AuthenticationProvider authenticationProvider) {
if (extensionGrantClass == null) {
return null;
}
try {
T extensionGrantObj = createInstance(extensionGrantClass);
final Import annImport = extensionGrantClass.getAnnotation(Import.class);
Set<Class<?>> configurations = (annImport != null) ?
new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext extensionGrantApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Class<?>> configurations() {
return configurations;
}
@Override
public ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add extension grant configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(
new ExtensionGrantConfigurationBeanFactoryPostProcessor(extensionGrantConfiguration));
// Add extension grant identity provider bean
configurableApplicationContext.addBeanFactoryPostProcessor(
new ExtensionGrantIdentityProviderFactoryPostProcessor(authenticationProvider != null ? authenticationProvider : new NoAuthenticationProvider()));
return configurableApplicationContext;
}
});
extensionGrantApplicationContext.getAutowireCapableBeanFactory().autowireBean(extensionGrantObj);
if (extensionGrantObj instanceof InitializingBean) {
((InitializingBean) extensionGrantObj).afterPropertiesSet();
}
return extensionGrantObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading extension grant", ex);
return null;
}
}
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:46,代码来源:ExtensionGrantPluginManagerImpl.java
示例8: create0
import org.springframework.context.annotation.Import; //导入依赖的package包/类
private <T> T create0(Plugin plugin, Class<T> identityClass, IdentityProviderConfiguration identityProviderConfiguration,
IdentityProviderMapper identityProviderMapper, IdentityProviderRoleMapper identityProviderRoleMapper) {
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 ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add identity provider configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(
new IdentityProviderConfigurationBeanFactoryPostProcessor(identityProviderConfiguration));
// Add identity provider mapper bean
configurableApplicationContext.addBeanFactoryPostProcessor(
new IdentityProviderMapperBeanFactoryPostProcessor(identityProviderMapper));
// Add identity provider role mapper bean
configurableApplicationContext.addBeanFactoryPostProcessor(
new IdentityProviderRoleMapperBeanFactoryPostProcessor(identityProviderRoleMapper));
return configurableApplicationContext;
}
});
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;
}
}
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:51,代码来源:IdentityProviderPluginManagerImpl.java
示例9: create
import org.springframework.context.annotation.Import; //导入依赖的package包/类
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;
}
}
示例10: canHandle
import org.springframework.context.annotation.Import; //导入依赖的package包/类
@Override
public boolean canHandle(PolicyContext policyContext) {
return policyContext.getClass().getAnnotation(Import.class) != null;
}