Java Code Examples for org.springframework.core.type.AnnotationMetadata#getClassName()

The following examples show how to use org.springframework.core.type.AnnotationMetadata#getClassName() . 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: AbstractRetrofitClientsRegistrar.java    From spring-cloud-square with Apache License 2.0 6 votes vote down vote up
private void registerDefaultConfiguration(AnnotationMetadata metadata,
		BeanDefinitionRegistry registry) {
	Map<String, Object> defaultAttrs = metadata
			.getAnnotationAttributes(getAnnotationClass().getName(), true);

	if (defaultAttrs != null && defaultAttrs.containsKey("defaultConfiguration")) {
		String name;
		if (metadata.hasEnclosingClass()) {
			name = "default." + metadata.getEnclosingClassName();
		}
		else {
			name = "default." + metadata.getClassName();
		}
		registerClientConfiguration(registry, name,
				defaultAttrs.get("defaultConfiguration"));
	}
}
 
Example 2
Source File: RestApiClentRegistrar.java    From onetwo with Apache License 2.0 6 votes vote down vote up
@Override
	protected BeanDefinitionBuilder createApiClientFactoryBeanBuilder(AnnotationMetadata annotationMetadata, AnnotationAttributes attributes) {
		String className = annotationMetadata.getClassName();
		BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(DefaultApiClientFactoryBean.class);

		definition.addPropertyValue("url", resolveUrl(attributes));
		definition.addPropertyValue("path", resolvePath(attributes));
//		definition.addPropertyValue("name", name);
		definition.addPropertyValue("interfaceClass", className);
//		definition.addPropertyValue("restExecutor", getRestExecutor());
		definition.addPropertyReference("restExecutor", RestExecutorFactory.REST_EXECUTOR_FACTORY_BEAN_NAME);
//		definition.addPropertyValue("decode404", attributes.get("decode404"));
//		definition.addPropertyValue("fallback", attributes.get("fallback"));
		definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
		
		return definition;
	}
 
Example 3
Source File: FeignClientsRegistrar.java    From spring-cloud-openfeign with Apache License 2.0 6 votes vote down vote up
private void registerDefaultConfiguration(AnnotationMetadata metadata,
		BeanDefinitionRegistry registry) {
	Map<String, Object> defaultAttrs = metadata
			.getAnnotationAttributes(EnableFeignClients.class.getName(), true);

	if (defaultAttrs != null && defaultAttrs.containsKey("defaultConfiguration")) {
		String name;
		if (metadata.hasEnclosingClass()) {
			name = "default." + metadata.getEnclosingClassName();
		}
		else {
			name = "default." + metadata.getClassName();
		}
		registerClientConfiguration(registry, name,
				defaultAttrs.get("defaultConfiguration"));
	}
}
 
Example 4
Source File: Simple2RestApiClentRegistrar.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Override
protected BeanDefinitionBuilder createApiClientFactoryBeanBuilder(AnnotationMetadata annotationMetadata, AnnotationAttributes attributes) {
	String className = annotationMetadata.getClassName();
	BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(DefaultApiClientFactoryBean.class);

	definition.addPropertyValue("url", resolveUrl(attributes));
	definition.addPropertyValue("path", resolvePath(attributes));
	definition.addPropertyValue("interfaceClass", className);
	definition.addPropertyReference("restExecutor", RestExecutorFactory.REST_EXECUTOR_FACTORY_BEAN_NAME);
	definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
	
	return definition;
}
 
Example 5
Source File: LoadTimeWeavingConfiguration.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	this.enableLTW = AnnotationConfigUtils.attributesFor(importMetadata, EnableLoadTimeWeaving.class);
	if (this.enableLTW == null) {
		throw new IllegalArgumentException(
				"@EnableLoadTimeWeaving is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 6
Source File: AbstractSchedulerLockConfiguration.java    From ShedLock with Apache License 2.0 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    this.annotationAttributes = AnnotationAttributes.fromMap(
        importMetadata.getAnnotationAttributes(EnableSchedulerLock.class.getName(), false));
    if (this.annotationAttributes == null) {
        throw new IllegalArgumentException(
            "@EnableSchedulerLock is not present on importing class " + importMetadata.getClassName());
    }
}
 
Example 7
Source File: LoadTimeWeavingConfiguration.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	this.enableLTW = AnnotationConfigUtils.attributesFor(importMetadata, EnableLoadTimeWeaving.class);
	if (this.enableLTW == null) {
		throw new IllegalArgumentException(
				"@EnableLoadTimeWeaving is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 8
Source File: JetCacheProxyConfiguration.java    From jetcache with Apache License 2.0 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    this.enableMethodCache = AnnotationAttributes.fromMap(
            importMetadata.getAnnotationAttributes(EnableMethodCache.class.getName(), false));
    if (this.enableMethodCache == null) {
        throw new IllegalArgumentException(
                "@EnableMethodCache is not present on importing class " + importMetadata.getClassName());
    }
}
 
Example 9
Source File: AbstractLimiterConfiguration.java    From Limiter with Apache License 2.0 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    this.enableLimiter = AnnotationAttributes.fromMap(
            importMetadata.getAnnotationAttributes(EnableLimiter.class.getName(), false));
    if (this.enableLimiter == null) {
        throw new IllegalArgumentException(
                "@EnableLimiter is not present on importing class " + importMetadata.getClassName());
    }
}
 
Example 10
Source File: NettyRpcRegistrar.java    From BootNettyRpc with Apache License 2.0 5 votes vote down vote up
private void registerRpcClient(BeanDefinitionRegistry registry, AnnotationMetadata annotationMetadata, Map<String, Object> attributes) {
    String className = annotationMetadata.getClassName();
    BeanDefinitionBuilder definition = BeanDefinitionBuilder
            .genericBeanDefinition( RpcClientEntity.class );
    definition.addPropertyValue( "name", attributes.get( "name" ) );
    definition.addPropertyValue( "isSyn", attributes.get( "isSyn" ) );
    definition.addPropertyValue( "host", attributes.get( "host" ) );
    definition.addPropertyValue( "port", attributes.get( "port" ) );
    definition.addPropertyValue( "rpcClz", attributes.get( "rpcClz" ) );
    definition.addPropertyValue( "traceIdIndex", attributes.get( "traceIdIndex" ) );
    definition.setAutowireMode( AbstractBeanDefinition.AUTOWIRE_BY_NAME );

    try {
        definition.addPropertyValue( "interfaze", Class.forName( className ) );
    } catch (ClassNotFoundException e) {
        LOG.error( "Get interface for name error", e );
    }
    // definition.setAutowireMode( AbstractBeanDefinition.AUTOWIRE_BY_TYPE );
    String alias = className;
    AbstractBeanDefinition beanDefinition = definition.getBeanDefinition();
    beanDefinition.setPrimary( false );
    definition.addPropertyValue( "interceptor", getInterceptor( beanDefinition.getPropertyValues() ) );

    BeanDefinitionHolder holder = new BeanDefinitionHolder( beanDefinition, className,
            new String[]{alias} );
    LOG.info( "registerRpcClient:" + className );
    BeanDefinitionReaderUtils.registerBeanDefinition( holder, registry );

}
 
Example 11
Source File: GeneircApiClentRegistrar.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Override
protected BeanDefinitionBuilder createApiClientFactoryBeanBuilder(AnnotationMetadata annotationMetadata, AnnotationAttributes attributes) {
	String className = annotationMetadata.getClassName();
	BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(DefaultApiClientFactoryBean.class);

	definition.addPropertyValue("url", resolveUrl(attributes, annotationMetadata));
	definition.addPropertyValue("path", resolvePath(attributes));
	definition.addPropertyValue("interfaceClass", className);
	definition.addPropertyValue("responseHandler", responseHandler);
	definition.addPropertyReference("restExecutor", RestExecutorFactory.REST_EXECUTOR_FACTORY_BEAN_NAME);
	definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
	
	return definition;
}
 
Example 12
Source File: AbstractImportRegistrar.java    From onetwo with Apache License 2.0 5 votes vote down vote up
protected void registerComponent(BeanDefinitionRegistry registry, AnnotationMetadata annotationMetadata, AnnotationAttributes tagAttributes) {
	String className = annotationMetadata.getClassName();
	String beanName = resolveName(tagAttributes, className);
	if(logger.isInfoEnabled()){
		logger.info("register api client beanName: {}, class: {}", beanName, className);
	}
	
	BeanDefinitionBuilder definition = createComponentFactoryBeanBuilder(annotationMetadata, tagAttributes);
	
	String alias = beanName + "-" + getComponentAnnotationClass().getSimpleName();
	AbstractBeanDefinition beanDefinition = definition.getBeanDefinition();
	beanDefinition.setPrimary(true);
	BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, beanName, new String[] { alias });
	BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
}
 
Example 13
Source File: AbstractCachingConfiguration.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	this.enableCaching = AnnotationAttributes.fromMap(
			importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));
	if (this.enableCaching == null) {
		throw new IllegalArgumentException(
				"@EnableCaching is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 14
Source File: MBeanExportConfiguration.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName());
	this.enableMBeanExport = AnnotationAttributes.fromMap(map);
	if (this.enableMBeanExport == null) {
		throw new IllegalArgumentException(
				"@EnableMBeanExport is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 15
Source File: ConfigurationClass.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Create a new {@link ConfigurationClass} with the given name.
 * @param metadata the metadata for the underlying class to represent
 * @param beanName name of the {@code @Configuration} class bean
 * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
 */
public ConfigurationClass(AnnotationMetadata metadata, String beanName) {
	Assert.notNull(beanName, "Bean name must not be null");
	this.metadata = metadata;
	this.resource = new DescriptiveResource(metadata.getClassName());
	this.beanName = beanName;
}
 
Example 16
Source File: AbstractAsyncConfiguration.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	this.enableAsync = AnnotationAttributes.fromMap(
			importMetadata.getAnnotationAttributes(EnableAsync.class.getName(), false));
	if (this.enableAsync == null) {
		throw new IllegalArgumentException(
				"@EnableAsync is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 17
Source File: AbstractCachingConfiguration.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	this.enableCaching = AnnotationAttributes.fromMap(
			importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));
	if (this.enableCaching == null) {
		throw new IllegalArgumentException(
				"@EnableCaching is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 18
Source File: AbstractCachingConfiguration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	this.enableCaching = AnnotationAttributes.fromMap(
			importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));
	if (this.enableCaching == null) {
		throw new IllegalArgumentException(
				"@EnableCaching is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 19
Source File: LoadTimeWeavingConfiguration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	this.enableLTW = AnnotationConfigUtils.attributesFor(importMetadata, EnableLoadTimeWeaving.class);
	if (this.enableLTW == null) {
		throw new IllegalArgumentException(
				"@EnableLoadTimeWeaving is not present on importing class " + importMetadata.getClassName());
	}
}
 
Example 20
Source File: MBeanExportConfiguration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
	Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName());
	this.enableMBeanExport = AnnotationAttributes.fromMap(map);
	if (this.enableMBeanExport == null) {
		throw new IllegalArgumentException(
				"@EnableMBeanExport is not present on importing class " + importMetadata.getClassName());
	}
}