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


Java Service类代码示例

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


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

示例1: getBeanName

import org.springframework.stereotype.Service; //导入依赖的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: route

import org.springframework.stereotype.Service; //导入依赖的package包/类
public ThirdPayService route(PayChannel channel, PayType payType) throws Exception {
	if (thirdClassList == null)
		throw new Exception(ErrorMsgConstant.CHANNEL_NOT_SUPPORT);

	for (Class<?> clz : thirdClassList) {
		ChannelValue comment = clz.getAnnotation(ChannelValue.class);
		if (comment == null)
			continue;
		if (comment.channel() != channel)
			continue;

		if (!ArrayUtils.contains(comment.payType(), payType))
			continue;

		Service service = clz.getAnnotation(Service.class);
		if (service == null)
			continue;

		return (ThirdPayService) SpringContextHelper.getBean(service.value());
	}

	throw new Exception(ErrorMsgConstant.CHANNEL_NOT_SUPPORT);

}
 
开发者ID:yi-jun,项目名称:aaden-pay,代码行数:25,代码来源:ThirdPayRoute.java

示例3: route

import org.springframework.stereotype.Service; //导入依赖的package包/类
public ThirdBankVerifyService route(BankRequest request) throws Exception {
	if (request == null || request.getInfo().getChannel() == null) {
		throw new Exception("当前暂不支持的第三方支付渠道");
	}

	if (thirdClassList == null)
		throw new Exception("当前暂不支持的第三方支付渠道");

	for (Class<?> clz : thirdClassList) {
		ChannelValue comment = clz.getAnnotation(ChannelValue.class);
		if (comment == null)
			continue;
		if (comment.channel() != request.getInfo().getChannel())
			continue;

		Service service = clz.getAnnotation(Service.class);
		if (service == null)
			continue;

		return (ThirdBankVerifyService) SpringContextHelper.getBean(service.value());
	}

	throw new Exception("当前暂不支持的第三方支付渠道");
}
 
开发者ID:yi-jun,项目名称:aaden-pay,代码行数:25,代码来源:ThirdBankRoute.java

示例4: parseCacheDuration

import org.springframework.stereotype.Service; //导入依赖的package包/类
private void parseCacheDuration(ApplicationContext applicationContext) {
    final Map<String, Long> cacheExpires = new HashMap<>();
    String[] beanNames = applicationContext.getBeanNamesForType(Object.class);
    for (String beanName : beanNames) {
        final Class clazz = applicationContext.getType(beanName);
        Service service = findAnnotation(clazz, Service.class);
        if (null == service) {
            continue;
        }
        addCacheExpires(clazz, cacheExpires);
    }
    logger.debug("初始化redisCacheManager, 配置有过期时间的key, 内容如下:" + cacheExpires);
    //设置有效期
    super.setExpires(cacheExpires);
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:16,代码来源:CustomerRedisCacheManager.java

示例5: init

import org.springframework.stereotype.Service; //导入依赖的package包/类
@PostConstruct
public void init() {

    List<Class<?>> classList = ClassUtil.getClasses(ArcticleService.class.getPackage().getName());
    for (Class<?> aClass : classList) {
        if (aClass.isAnnotationPresent(Service.class)) {
            for (Method method : aClass.getDeclaredMethods()) {
                if (method.isAnnotationPresent(ValidateGroup.class)) {
                    String key = method.toString();
                    LOGGER.info("init validators of method {}", key);
                    validateConcurrentMap.put(key, getFiledValidators(key, method));
                }
            }
        }
    }
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:17,代码来源:ValidateAspectHandel.java

示例6: findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes

import org.springframework.stereotype.Service; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes() throws Exception {
	Class<?> startClass = MetaConfigWithDefaultAttributesTestCase.class;
	Class<ContextConfiguration> annotationType = ContextConfiguration.class;

	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
		ContextConfiguration.class, Order.class, Transactional.class);

	assertNotNull(descriptor);
	assertEquals(startClass, descriptor.getRootDeclaringClass());
	assertEquals(annotationType, descriptor.getAnnotationType());
	assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
	assertArrayEquals(new Class[] { MetaConfig.DevConfig.class, MetaConfig.ProductionConfig.class },
		descriptor.getAnnotationAttributes().getClassArray("classes"));
	assertNotNull(descriptor.getComposedAnnotation());
	assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:MetaAnnotationUtilsTests.java

示例7: findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes

import org.springframework.stereotype.Service; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() throws Exception {
	Class<?> startClass = MetaConfigWithOverriddenAttributesTestCase.class;
	Class<ContextConfiguration> annotationType = ContextConfiguration.class;

	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
		ContextConfiguration.class, Order.class, Transactional.class);

	assertNotNull(descriptor);
	assertEquals(startClass, descriptor.getRootDeclaringClass());
	assertEquals(annotationType, descriptor.getAnnotationType());
	assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
	assertArrayEquals(new Class[] { MetaAnnotationUtilsTests.class },
		descriptor.getAnnotationAttributes().getClassArray("classes"));
	assertNotNull(descriptor.getComposedAnnotation());
	assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:MetaAnnotationUtilsTests.java

示例8: resetAndReconfigure

import org.springframework.stereotype.Service; //导入依赖的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

示例9: getHandlers

import org.springframework.stereotype.Service; //导入依赖的package包/类
@Override
public List<MaraAnnotationHandler> getHandlers() throws ToolException {

    List<MaraAnnotationHandler> handlers = new ArrayList<>();

    Reflections reflections = initReflections(getBasePackagesToScanForComponents());
    Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(Service.class);
    for (Class<?> handlerClass : handlerClasses) {
        if (MaraAnnotationHandler.class.isAssignableFrom(handlerClass)) {
            try {
                MaraAnnotationHandler handler = (MaraAnnotationHandler) handlerClass.newInstance();
                handlers.add(handler);
            } catch (InstantiationException | IllegalAccessException e) {
                throw new ToolException(e);
            }
        }
    }
    return handlers;
}
 
开发者ID:conversant,项目名称:mara,代码行数:20,代码来源:ReflectionAnnotationHandlerProvider.java

示例10: setup

import org.springframework.stereotype.Service; //导入依赖的package包/类
@Before
public void setup() throws ToolException {
	annotationUtil = MaraAnnotationUtil.INSTANCE;
	// Initialize our annotations handlers

	Configuration conf = new Configuration();
	this.job = mock(Job.class);
	when(job.getConfiguration()).thenReturn(conf);

	AnnotatedTool tool = mock(AnnotatedTool.class);
	AnnotatedToolContext context = mock(AnnotatedToolContext.class);
	when(tool.getContext()).thenReturn(context);

	try {
		Reflections reflections = new Reflections("com.conversantmedia.mapreduce.tool.annotation");
		Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(Service.class);
		for (Class<?> handlerClass : handlerClasses) {
			if (MaraAnnotationHandler.class.isAssignableFrom(handlerClass)) {
				MaraAnnotationHandler handler = (MaraAnnotationHandler) handlerClass.newInstance();
				annotationUtil.registerAnnotationHandler(handler, tool);
			}
		}
	} catch (InstantiationException | IllegalAccessException e) {
		throw new ToolException(e);
	}
}
 
开发者ID:conversant,项目名称:mara,代码行数:27,代码来源:JobAnnotationUtilTest.java

示例11: getBeanName

import org.springframework.stereotype.Service; //导入依赖的package包/类
private String getBeanName(final Class<?> clazz) {
    
    final Component componentAnno = clazz.getAnnotation(Component.class);
    if(componentAnno != null && !componentAnno.value().isEmpty()) {
        return componentAnno.value();
    }
    
    final Service serviceAnno = clazz.getAnnotation(Service.class);
    if(serviceAnno != null && !serviceAnno.value().isEmpty()) {
        return serviceAnno.value();
    }
    
    final Repository repositoryAnno = clazz.getAnnotation(Repository.class);
    if(repositoryAnno != null && !repositoryAnno.value().isEmpty()) {
        return repositoryAnno.value();
    }
    
    final Controller controllerAnno = clazz.getAnnotation(Controller.class);
    if(controllerAnno != null && !controllerAnno.value().isEmpty()) {
        return controllerAnno.value();
    }
    
    // ステレオタイプのアノテーションでBean名の指定がない場合は、クラス名の先頭を小文字にした名称とする。
    return uncapitalize(clazz.getSimpleName());
}
 
开发者ID:mygreen,项目名称:super-csv-annotation,代码行数:26,代码来源:SpringBeanFactory.java

示例12: getSpringClassAnnotation

import org.springframework.stereotype.Service; //导入依赖的package包/类
private Annotation getSpringClassAnnotation(Class clazz) {
    Annotation classAnnotation = AnnotationUtils.findAnnotation(clazz, Component.class);

    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Controller.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, RestController.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Service.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Repository.class);
    }

    return classAnnotation;
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:19,代码来源:SpringReloader.java

示例13: process

import org.springframework.stereotype.Service; //导入依赖的package包/类
@Nullable
@Override
public <T> AnnotatedComponent<T> process(Scope scope, Class<T> clazz) {
    Controller controller = clazz.getAnnotation(Controller.class);
    if (controller != null) {
        return new AnnotatedComponent(clazz, controller.value(), ComponentType.CONTROLLER);
    }

    Service service = clazz.getAnnotation(Service.class);
    if (service != null) {
        return new AnnotatedComponent(clazz, service.value(), ComponentType.CONTROLLER);
    }

    return null;
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:16,代码来源:SPRComponentController.java

示例14: DwrClassPathBeanDefinitionScanner

import org.springframework.stereotype.Service; //导入依赖的package包/类
public DwrClassPathBeanDefinitionScanner(BeanDefinitionRegistry registry)
{
    super(registry, false);
    addExcludeFilter(new AnnotationTypeFilter(Component.class));
    addExcludeFilter(new AnnotationTypeFilter(Service.class));
    addExcludeFilter(new AnnotationTypeFilter(Repository.class));
    addExcludeFilter(new AnnotationTypeFilter(Controller.class));
    setScopedProxyMode(ScopedProxyMode.INTERFACES);
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:10,代码来源:DwrClassPathBeanDefinitionScanner.java

示例15: testWithComponentAnnotationOnly

import org.springframework.stereotype.Service; //导入依赖的package包/类
@Test
public void testWithComponentAnnotationOnly() {
	ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
	provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Service.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
	Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
	assertEquals(2, candidates.size());
	assertTrue(containsBeanClass(candidates, NamedComponent.class));
	assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class));
	assertFalse(containsBeanClass(candidates, FooServiceImpl.class));
	assertFalse(containsBeanClass(candidates, StubFooDao.class));
	assertFalse(containsBeanClass(candidates, NamedStubDao.class));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:ClassPathScanningCandidateComponentProviderTests.java


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