io.gravitee.plugin.core.internal.AnnotationBasedPluginContextConfigurer Java Examples
The following examples show how to use
io.gravitee.plugin.core.internal.AnnotationBasedPluginContextConfigurer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepositoryPluginHandler.java From gravitee-management-rest-api with Apache License 2.0 | 6 votes |
private boolean loadRepository(Scope scope, Repository repository, Plugin plugin) { LOGGER.info("Repository [{}] loaded by {}", scope, repository.type()); // Not yet loaded, let's mount the repository in application context try { ApplicationContext repoApplicationContext = pluginContextFactory.create( new AnnotationBasedPluginContextConfigurer(plugin) { @Override public Set<Class<?>> configurations() { return Collections.singleton(repository.configuration(scope)); } }); registerRepositoryDefinitions(repository, repoApplicationContext); repositories.put(scope, repository); return true; } catch (Exception iae) { LOGGER.error("Unexpected error while creating context for repository instance", iae); pluginContextFactory.remove(plugin); return false; } }
Example #2
Source File: RepositoryPluginHandler.java From gravitee-gateway with Apache License 2.0 | 6 votes |
private boolean loadRepository(Scope scope, Repository repository, Plugin plugin) { LOGGER.info("Repository [{}] loaded by {}", scope, repository.type()); // Not yet loaded, let's mount the repository in application context try { ApplicationContext repoApplicationContext = pluginContextFactory.create( new AnnotationBasedPluginContextConfigurer(plugin) { @Override public Set<Class<?>> configurations() { return Collections.singleton(repository.configuration(scope)); } }); registerRepositoryDefinitions(repository, repoApplicationContext); repositories.put(scope, repository); return true; } catch (Exception iae) { LOGGER.error("Unexpected error while creating context for repository instance", iae); pluginContextFactory.remove(plugin); return false; } }
Example #3
Source File: ServiceDiscoveryFactoryImpl.java From gravitee-gateway with Apache License 2.0 | 5 votes |
@Override public <T extends ServiceDiscovery> T create(ServiceDiscoveryPlugin sdPlugin, String sdConfiguration) { LOGGER.debug("Create a new service discovery instance for {}", sdPlugin.serviceDiscovery().getName()); ApplicationContext sdContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(sdPlugin) { @Override public ClassLoader classLoader() { return sdPlugin.serviceDiscovery().getClassLoader(); } @Override public void registerBeans() { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(sdPlugin.clazz()); if (sdPlugin.configuration() != null) { builder.addConstructorArgValue(serviceDiscoveryConfigurationFactory.create(sdPlugin.configuration(), sdConfiguration)); } pluginContext.registerBeanDefinition(sdPlugin.clazz(), builder.getBeanDefinition()); } }); try { return (T) sdContext.getBean(sdPlugin.clazz()); } catch (Exception ex) { LOGGER.error("Unable to get service discovery {}", sdPlugin.serviceDiscovery().getName(), ex); return null; } }
Example #4
Source File: ExtensionGrantPluginManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
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; } }
Example #5
Source File: CertificatePluginManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
private <T> T create0(Plugin plugin, Class<T> certificateClass, CertificateConfiguration certificateConfiguration, CertificateMetadata metadata) { 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)); // Add certificate metadata bean configurableApplicationContext.addBeanFactoryPostProcessor( new CertificateMetadataBeanFactoryPostProcessor(metadata)); 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; } }
Example #6
Source File: ReporterPluginManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
private <T> T create0(Plugin plugin, Class<T> auditReporterClass, ReporterConfiguration reporterConfiguration) { if (auditReporterClass == null) { return null; } try { T auditReporterObj = createInstance(auditReporterClass); final Import annImport = auditReporterClass.getAnnotation(Import.class); Set<Class<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet(); ApplicationContext reporterApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) { @Override public Set<Class<?>> configurations() { return configurations; } @Override public ConfigurableApplicationContext applicationContext() { ConfigurableApplicationContext configurableApplicationContext = super.applicationContext(); // Add reporter configuration bean configurableApplicationContext.addBeanFactoryPostProcessor( new ReporterConfigurationBeanFactoryPostProcessor(reporterConfiguration)); return configurableApplicationContext; } }); reporterApplicationContext.getAutowireCapableBeanFactory().autowireBean(auditReporterObj); if (auditReporterObj instanceof InitializingBean) { ((InitializingBean) auditReporterObj).afterPropertiesSet(); } return auditReporterObj; } catch (Exception ex) { logger.error("An unexpected error occurs while loading reporter", ex); return null; } }
Example #7
Source File: FactorPluginManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
private <T> T create0(Plugin plugin, Class<T> identityClass, FactorConfiguration factorConfiguration) { 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 authenticator configuration bean configurableApplicationContext.addBeanFactoryPostProcessor( new FactorConfigurationBeanFactoryPostProcessor(factorConfiguration)); 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 factor", ex); return null; } }
Example #8
Source File: IdentityProviderPluginManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
private <T> T create0(Plugin plugin, Class<T> identityClass, IdentityProviderConfiguration identityProviderConfiguration, IdentityProviderMapper identityProviderMapper, IdentityProviderRoleMapper identityProviderRoleMapper, CertificateManager certificateManager) { 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 gravitee properties configurableApplicationContext.addBeanFactoryPostProcessor( new PropertiesBeanFactoryPostProcessor(properties)); // Add Vert.x instance configurableApplicationContext.addBeanFactoryPostProcessor( new VertxBeanFactoryPostProcessor(vertx)); // Add identity provider configuration bean configurableApplicationContext.addBeanFactoryPostProcessor( new IdentityProviderConfigurationBeanFactoryPostProcessor(identityProviderConfiguration)); // Add identity provider mapper bean configurableApplicationContext.addBeanFactoryPostProcessor( new IdentityProviderMapperBeanFactoryPostProcessor(identityProviderMapper != null ? identityProviderMapper : new NoIdentityProviderMapper())); // Add identity provider role mapper bean configurableApplicationContext.addBeanFactoryPostProcessor( new IdentityProviderRoleMapperBeanFactoryPostProcessor(identityProviderRoleMapper != null ? identityProviderRoleMapper : new NoIdentityProviderRoleMapper())); if (certificateManager != null) { // Add certificate manager bean configurableApplicationContext.addBeanFactoryPostProcessor(new CertificateManagerBeanFactoryPostProcessor(certificateManager)); } 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; } }
Example #9
Source File: IdentityProviderPluginManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
private <T> T create0(Plugin plugin, Class<T> userProvider, IdentityProviderConfiguration identityProviderConfiguration) { try { T identityObj = createInstance(userProvider); final Import annImport = userProvider.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 gravitee properties configurableApplicationContext.addBeanFactoryPostProcessor( new PropertiesBeanFactoryPostProcessor(properties)); // Add Vert.x instance configurableApplicationContext.addBeanFactoryPostProcessor( new VertxBeanFactoryPostProcessor(vertx)); // Add identity provider configuration bean configurableApplicationContext.addBeanFactoryPostProcessor( new IdentityProviderConfigurationBeanFactoryPostProcessor(identityProviderConfiguration)); 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 user provider", ex); return null; } }
Example #10
Source File: IdentityProviderManagerImpl.java From gravitee-management-rest-api with Apache License 2.0 | 4 votes |
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 RelaxedPropertySource(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; } }