当前位置: 首页>>代码示例>>Java>>正文


Java Component类代码示例

本文整理汇总了Java中org.springframework.stereotype.Component的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Component类属于org.springframework.stereotype包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBeanName

import org.springframework.stereotype.Component; //导入依赖的package包/类
private String getBeanName(Class<?> clazz) {
    Component component = clazz.getAnnotation(Component.class);
    if (component != null)
        return component.value();

    Repository repository = clazz.getAnnotation(Repository.class);
    if (repository != null)
        return repository.value();

    Service service = clazz.getAnnotation(Service.class);
    if (service != null)
        return service.value();

    Controller controller = clazz.getAnnotation(Controller.class);
    if (controller != null)
        return controller.value();

    return null;
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:20,代码来源:ClassReloaderImpl.java

示例2: assertExistsPrivateCtor

import org.springframework.stereotype.Component; //导入依赖的package包/类
@Test
public void assertExistsPrivateCtor() {
    reflections.getSubTypesOf(Object.class).stream()
        .filter(clazz -> !clazz.isAnnotationPresent(Configuration.class))
        .filter(clazz -> !clazz.isAnnotationPresent(Component.class))
        .filter(clazz -> !clazz.isAnnotationPresent(SpringBootApplication.class))
        .filter(clazz -> !clazz.getName().endsWith("Test"))
        .filter(clazz -> !clazz.isInterface())
        .filter(clazz ->
            Arrays.stream(clazz.getDeclaredFields())
                .allMatch(field -> Modifier.isStatic(field.getModifiers())))
        .forEach(clazz -> {
            System.out.println("Expecting class "+clazz.getName()+" to :");
            System.out.print("\t-> be final ");
            assertThat(clazz).isFinal();
            System.out.println("[*]");
            System.out.print("\t-> have exactly one constructor ");
            Constructor<?>[] constructors = clazz.getDeclaredConstructors();
            assertThat(constructors).hasSize(1);
            System.out.println("[*]");
            System.out.print("\t-> and that this constructor is private ");
            assertThat(Modifier.isPrivate(constructors[0].getModifiers()));
            System.out.println("[*]");
        });
}
 
开发者ID:Tristan971,项目名称:EasyFXML,代码行数:26,代码来源:PrivateConstructorTest.java

示例3: ManagerStructure

import org.springframework.stereotype.Component; //导入依赖的package包/类
public ManagerStructure(String managerPackage, String entityName, String postfix, String repositoryPackage, String repositoryPostfix) {

        String managerName = entityName + postfix;
        String repositoryName = entityName + repositoryPostfix;
        String repositoryNameAttribute = GeneratorUtils.decapitalize(repositoryName);

        this.objectBuilder = new ObjectBuilder(new ObjectStructure(managerPackage, ScopeValues.PUBLIC, ObjectTypeValues.CLASS, managerName)
                .addImport(repositoryPackage + "." + repositoryName)
                .addImport(Autowired.class)
                .addImport(Component.class)
                .addAnnotation(Component.class)
                .addAttribute(repositoryName, repositoryNameAttribute)
                .addConstructor(new ObjectStructure.ObjectConstructor(ScopeValues.PUBLIC, managerName)
                        .addAnnotation(Autowired.class)
                        .addArgument(repositoryName, repositoryNameAttribute)
                        .addBodyLine(ObjectValues.THIS.getValue() + repositoryNameAttribute + ExpressionValues.EQUAL.getValue() + repositoryNameAttribute)
                )
        ).setAttributeBottom(false);

    }
 
开发者ID:cmeza20,项目名称:spring-data-generator,代码行数:21,代码来源:ManagerStructure.java

示例4: build

import org.springframework.stereotype.Component; //导入依赖的package包/类
public void build(Object control, ViewComponent parentViewComponent) {
	AutoForm autoForm = (AutoForm) control;
	String id = autoForm.getId();
	ViewComponent component = generateViewComponent(id,AutoForm.class);
	if (StringUtils.isEmpty(id)) {
		component.setEnabled(false);
	}
	parentViewComponent.addChildren(component);
	for (com.bstek.dorado.view.widget.Component c : autoForm.getElements()) {
		for (IControlBuilder builder : builders) {
			if (builder.support(c)) {
				builder.build(c, component);
				break;
			}
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:18,代码来源:AutoFormBuilder.java

示例5: build

import org.springframework.stereotype.Component; //导入依赖的package包/类
public void build(Object control, ViewComponent parentViewComponent) {
	Container container=(Container)control;
	String id=container.getId();
	ViewComponent component=new ViewComponent();
	component.setId(id);
	component.setIcon(">dorado/res/"+Container.class.getName().replaceAll("\\.", "/")+".png");
	component.setName(container.getClass().getSimpleName());
	if(StringUtils.isEmpty(id)){
		component.setEnabled(false);
	}
	parentViewComponent.addChildren(component);
	for(com.bstek.dorado.view.widget.Component c:container.getChildren()){
		for(IControlBuilder builder:builders){
			if(builder.support(c)){
				builder.build(c, component);
				break;
			}
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:21,代码来源:ContainerBuilder.java

示例6: build

import org.springframework.stereotype.Component; //导入依赖的package包/类
public void build(Object control, ViewComponent parentViewComponent) {
	Container container=(Container)control;
	String id=container.getId();
	ViewComponent component=new ViewComponent();
	component.setId(id);
	component.setIcon(">dorado/res/"+container.getClass().getName().replaceAll("\\.", "/")+".png");
	component.setName(container.getClass().getSimpleName());
	if(StringUtils.isEmpty(id)){
		component.setEnabled(false);
	}
	parentViewComponent.addChildren(component);
	for(com.bstek.dorado.view.widget.Component c:container.getChildren()){
		for(IControlBuilder builder:builders){
			if(builder.support(c)){
				builder.build(c, component);
				break;
			}
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:21,代码来源:ContainerBuilder.java

示例7: testRefreshableFromTagProxyTargetClass

import org.springframework.stereotype.Component; //导入依赖的package包/类
@Test
// Test for SPR-6268
public void testRefreshableFromTagProxyTargetClass() throws Exception {
	ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml",
			getClass());
	assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("refreshableMessenger"));

	Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");

	assertTrue(AopUtils.isAopProxy(messenger));
	assertTrue(messenger instanceof Refreshable);
	assertEquals("Hello World!", messenger.getMessage());

	assertTrue(ctx.getBeansOfType(ConcreteMessenger.class).values().contains(messenger));

	// Check that AnnotationUtils works with concrete proxied script classes
	assertNotNull(AnnotationUtils.findAnnotation(messenger.getClass(), Component.class));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:GroovyScriptFactoryTests.java

示例8: synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases

import org.springframework.stereotype.Component; //导入依赖的package包/类
@Test
public void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throws Exception {

	// 1) Get an annotation
	Component component = WebController.class.getAnnotation(Component.class);
	assertNotNull(component);

	// 2) Convert the annotation into AnnotationAttributes
	AnnotationAttributes attributes = getAnnotationAttributes(WebController.class, component);
	assertNotNull(attributes);

	// 3) Synthesize the AnnotationAttributes back into an annotation
	Component synthesizedComponent = synthesizeAnnotation(attributes, Component.class, WebController.class);
	assertNotNull(synthesizedComponent);

	// 4) Verify that the original and synthesized annotations are equivalent
	assertNotSame(component, synthesizedComponent);
	assertEquals(component, synthesizedComponent);
	assertEquals("value from component: ", "webController", component.value());
	assertEquals("value from synthesized component: ", "webController", synthesizedComponent.value());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:AnnotationUtilsTests.java

示例9: doTestSubClassAnnotationInfo

import org.springframework.stereotype.Component; //导入依赖的package包/类
private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata) {
	assertThat(metadata.getClassName(), is(AnnotatedComponentSubClass.class.getName()));
	assertThat(metadata.isInterface(), is(false));
	assertThat(metadata.isAnnotation(), is(false));
	assertThat(metadata.isAbstract(), is(false));
	assertThat(metadata.isConcrete(), is(true));
	assertThat(metadata.hasSuperClass(), is(true));
	assertThat(metadata.getSuperClassName(), is(AnnotatedComponent.class.getName()));
	assertThat(metadata.getInterfaceNames().length, is(0));
	assertThat(metadata.isAnnotated(Component.class.getName()), is(false));
	assertThat(metadata.isAnnotated(Scope.class.getName()), is(false));
	assertThat(metadata.isAnnotated(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(Component.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(Scope.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.getAnnotationTypes().size(), is(0));
	assertThat(metadata.getAnnotationAttributes(Component.class.getName()), nullValue());
	assertThat(metadata.getAnnotatedMethods(DirectAnnotation.class.getName()).size(), equalTo(0));
	assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName()), equalTo(false));
	assertThat(metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()), nullValue());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:AnnotationMetadataTests.java

示例10: doTestMetadataForAnnotationClass

import org.springframework.stereotype.Component; //导入依赖的package包/类
private void doTestMetadataForAnnotationClass(AnnotationMetadata metadata) {
	assertThat(metadata.getClassName(), is(Component.class.getName()));
	assertThat(metadata.isInterface(), is(true));
	assertThat(metadata.isAnnotation(), is(true));
	assertThat(metadata.isAbstract(), is(true));
	assertThat(metadata.isConcrete(), is(false));
	assertThat(metadata.hasSuperClass(), is(false));
	assertThat(metadata.getSuperClassName(), nullValue());
	assertThat(metadata.getInterfaceNames().length, is(1));
	assertThat(metadata.getInterfaceNames()[0], is(Annotation.class.getName()));
	assertThat(metadata.isAnnotated(Documented.class.getName()), is(false));
	assertThat(metadata.isAnnotated(Scope.class.getName()), is(false));
	assertThat(metadata.isAnnotated(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(Documented.class.getName()), is(true));
	assertThat(metadata.hasAnnotation(Scope.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.getAnnotationTypes().size(), is(3));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:AnnotationMetadataTests.java

示例11: postProcessBeforeInitialization

import org.springframework.stereotype.Component; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
		throws BeansException {
	Class<?> beanClass = bean.getClass();
	Set<Class<?>> components = new LinkedHashSet<Class<?>>();
	Set<Class<?>> propertyMappings = new LinkedHashSet<Class<?>>();
	while (beanClass != null) {
		for (Annotation annotation : AnnotationUtils.getAnnotations(beanClass)) {
			if (isAnnotated(annotation, Component.class)) {
				components.add(annotation.annotationType());
			}
			if (isAnnotated(annotation, PropertyMapping.class)) {
				propertyMappings.add(annotation.annotationType());
			}
		}
		beanClass = beanClass.getSuperclass();
	}
	if (!components.isEmpty() && !propertyMappings.isEmpty()) {
		throw new IllegalStateException("The @PropertyMapping "
				+ getAnnotationsDescription(propertyMappings)
				+ " cannot be used in combination with the @Component "
				+ getAnnotationsDescription(components));
	}
	return bean;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:PropertyMappingContextCustomizer.java

示例12: resetAndReconfigure

import org.springframework.stereotype.Component; //导入依赖的package包/类
public void resetAndReconfigure(boolean debug) {
    SingularContextSetup.reset();
    ApplicationContextMock applicationContext = new ApplicationContextMock();
    ServiceRegistryLocator.setup(new SpringServiceRegistry());
    new ApplicationContextProvider().setApplicationContext(applicationContext);
    registerBeanFactories(applicationContext);
    registerAnnotated(applicationContext, Named.class);
    registerAnnotated(applicationContext, Service.class);
    registerAnnotated(applicationContext, Component.class);
    registerAnnotated(applicationContext, Repository.class);
    registerMockitoTestClassMocksAndSpies(applicationContext);
    getLogger().info("Contexto configurado com os beans: ");
    if (debug) {
        applicationContext.listAllBeans().forEach(
                b -> getLogger().info(b)
        );
    }
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:19,代码来源:SingularServerSpringMockitoTestConfig.java

示例13: showPostById

import org.springframework.stereotype.Component; //导入依赖的package包/类
public void showPostById(int id, java.awt.Component dialogParent){
    JOptionPane optionPane = new JOptionPane(Localization.format("retrieval_format", String.valueOf(id)), JOptionPane.INFORMATION_MESSAGE);
    JButton button = new JButton(Localization.getString("cancel"));
    optionPane.setOptions(new Object[]{button});
    JDialog dialog = optionPane.createDialog(dialogParent, Localization.getString("retrieving"));
    button.addActionListener(event -> dialog.dispose());
    dialog.setModalityType(ModalityType.MODELESS);
    dialog.setVisible(true);
    executor.execute(() -> {
        List<Post> searchPosts = mapi.listPosts(1, 1, "id:" + id);
        SwingUtilities.invokeLater(() -> {
            if (dialog.isDisplayable()){
                dialog.dispose();
                if (!searchPosts.isEmpty()){
                    showPostFrame.showPost(searchPosts.get(0));
                }else{
                    JOptionPane.showMessageDialog(null, Localization.getString("id_doesnot_exists"),
                        Localization.getString("error"), JOptionPane.ERROR_MESSAGE);
                }
            }
        });
    });
}
 
开发者ID:azige,项目名称:moebooru-viewer,代码行数:24,代码来源:MoebooruViewer.java

示例14: testMarkerInterfaceAndAnnotationScan

import org.springframework.stereotype.Component; //导入依赖的package包/类
@Test
public void testMarkerInterfaceAndAnnotationScan() {
  applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add(
      "markerInterface", MapperInterface.class);
  applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add(
      "annotationClass", Component.class);

  startContext();

  // everything should be loaded but the marker interface
  applicationContext.getBean("annotatedMapper");
  applicationContext.getBean("mapperSubinterface");
  applicationContext.getBean("mapperChildInterface");

  assertBeanNotLoaded("mapperInterface");
}
 
开发者ID:lindzh,项目名称:mybatis-spring-1.2.2,代码行数:17,代码来源:MapperScannerConfigurerTest.java

示例15: generateApiMessageGroovyClass

import org.springframework.stereotype.Component; //导入依赖的package包/类
private void generateApiMessageGroovyClass(StringBuilder sb, List<String> basePkgs) {
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.addIncludeFilter(new AssignableTypeFilter(APIMessage.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(APIReply.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(APIEvent.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
    for (String pkg : basePkgs) {
        for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
            try {
                Class<?> clazz = Class.forName(bd.getBeanClassName());
                //classToApiMessageGroovyClass(sb, clazz);
                classToApiMessageGroovyInformation(sb, clazz);
            } catch (ClassNotFoundException e) {
                logger.warn(String.format("Unable to generate groovy class for %s", bd.getBeanClassName()), e);
            }
        }
    }
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:20,代码来源:ConfigurationManagerImpl.java


注:本文中的org.springframework.stereotype.Component类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。