org.springframework.stereotype.Service Java Examples
The following examples show how to use
org.springframework.stereotype.Service.
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: CopyAndAddTransactional.java From AthenaServing with Apache License 2.0 | 6 votes |
/** * 复制集群 * * @param body * @return */ @Transactional public Cluster copyAndAddCluster(CopyClusterRequestBody body) { AddClusterRequestBody addClusterRequestBody = new AddClusterRequestBody(body.getClusterName(), body.getDesc(), body.getProjectId()); // (一)新增集群 Cluster cluster = this.clusterConditionImpl.add(addClusterRequestBody); String newClusterId = cluster.getId(); // (二)根据被复制的集群id查询tb_service表,若该集群下存在服务,则复制服务 String oldClusterId = body.getOldClusterId(); List<String> clusterIds = new ArrayList<>(); clusterIds.add(oldClusterId); List<com.iflytek.ccr.polaris.cynosure.domain.Service> serviceList = this.serviceConditionImpl.findList(clusterIds); if (null != serviceList && !serviceList.isEmpty()) { for (com.iflytek.ccr.polaris.cynosure.domain.Service service : serviceList) { CopyServiceRequestBody body1 = new CopyServiceRequestBody(newClusterId, service.getId(), service.getName(), service.getDescription()); copyAndAddService(body1); } } return cluster; }
Example #2
Source File: ClusterServiceImpl.java From AthenaServing with Apache License 2.0 | 6 votes |
@Override public Response<String> delete(IdRequestBody body) { //通过id查询服务列表 String id = body.getId(); Cluster cluster = this.clusterConditionImpl.findServiceListById(id); if (null == cluster) { //不存在该集群 return new Response<>(SystemErrCode.ERRCODE_CLUSTER_NOT_EXISTS, SystemErrCode.ERRMSG_CLUSTER_NOT_EXISTS); } List<com.iflytek.ccr.polaris.cynosure.domain.Service> serviceList = cluster.getServiceList(); if (null != serviceList && !serviceList.isEmpty()) { //该用户已创建服务 return new Response<>(SystemErrCode.ERRCODE_SERVICE_CREATE, SystemErrCode.ERRMSG_SERVICE_CREATE); } //通过id删除集群 this.clusterConditionImpl.deleteById(id); return new Response<>(null); }
Example #3
Source File: MonitorServiceImpl.java From paas with Apache License 2.0 | 6 votes |
@Override public ResultVO getDockerInfo() { try { Info info = dockerClient.info(); List<Node> nodes = dockerSwarmClient.listNodes(); List<com.spotify.docker.client.messages.swarm.Service> services = dockerSwarmClient.listServices(); DockerInfoVO infoVO = genDockerInfoVO(info); infoVO.setNodes(genDockerNodeInfoVO(nodes)); infoVO.setServiceNum(services.size()); return ResultVOUtils.success(infoVO); } catch (Exception e) { log.error("读取Docker宿主机信息错误,错误位置:{},错误栈:{}", "MonitorServiceImpl.getDockerInfo()", HttpClientUtils.getStackTraceAsString(e)); return ResultVOUtils.error(ResultEnum.DOCKER_EXCEPTION); } }
Example #4
Source File: ThirdBankRoute.java From aaden-pay with Apache License 2.0 | 6 votes |
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("当前暂不支持的第三方支付渠道"); }
Example #5
Source File: ServiceVersionImpl.java From AthenaServing with Apache License 2.0 | 6 votes |
@Override public Response<ServiceVersionDetailResponseBody> add(AddServiceVersionRequestBody body) { // 通过id查询服务 String serviceId = body.getServiceId(); com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionimpl.findById(serviceId); if (null == service) { // 不存在该服务 return new Response<>(SystemErrCode.ERRCODE_SERVICE_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_NOT_EXISTS); } // 根据版本和服务id查询服务版本 String version = body.getVersion(); ServiceVersion serviceVersion = this.serviceVersionConditionImpl.find(version, serviceId); if (null != serviceVersion) { return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_EXISTS, SystemErrCode.ERRMSG_SERVICE_VERSION_EXISTS); } // 创建版本 ServiceVersion newServiceVersion = this.serviceVersionConditionImpl.add(body); // 创建版本结果 ServiceVersionDetailResponseBody result = this.createServiceVersionResult(newServiceVersion); return new Response<>(result); }
Example #6
Source File: ServiceApiVersionImpl.java From AthenaServing with Apache License 2.0 | 6 votes |
@Override public Response<ServiceApiVersionDetailResponseBody> add(AddServiceApiVersionRequestBody body) { //通过id查询服务 String serviceId = body.getServiceId(); com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionimpl.findById(serviceId); if (null == service) { //不存在该服务 return new Response<>(SystemErrCode.ERRCODE_SERVICE_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_NOT_EXISTS); } //根据版本和服务id查询服务版本 String apiVersion = body.getApiVersion(); ServiceApiVersion serviceApiVersion = this.serviceApiVersionConditionImpl.find(apiVersion, serviceId); if (null != serviceApiVersion) { return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_EXISTS, SystemErrCode.ERRMSG_SERVICE_VERSION_EXISTS); } //创建版本 ServiceApiVersion newServiceApiVersion = this.serviceApiVersionConditionImpl.add(body); //创建版本结果 ServiceApiVersionDetailResponseBody result = this.createServiceApiVersionResult(newServiceApiVersion); return new Response<>(result); }
Example #7
Source File: ServiceImpl.java From AthenaServing with Apache License 2.0 | 6 votes |
@Override public Response<ServiceDetailResponseBody> add(AddServiceRequestBody body) { //根据id查询集群信息 String clusterId = body.getClusterId(); Cluster cluster = this.clusterConditionImpl.findById(clusterId); if (null == cluster) { return new Response<>(SystemErrCode.ERRCODE_CLUSTER_NOT_EXISTS, SystemErrCode.ERRMSG_CLUSTER_NOT_EXISTS); } //根据服务名和集群id查询服务 String name = body.getName(); com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionImpl.find(name, clusterId); if (null != service) { //已存在该服务 return new Response<>(SystemErrCode.ERRCODE_SERVICE_EXISTS, SystemErrCode.ERRMSG_SERVICE_EXISTS); } //创建服务 com.iflytek.ccr.polaris.cynosure.domain.Service newService = this.serviceConditionImpl.add(body); //创建服务结果 ServiceDetailResponseBody result = this.createServiceResult(newService); return new Response<>(result); }
Example #8
Source File: MetaAnnotationUtilsTests.java From java-technology-stack with MIT License | 6 votes |
@Test @SuppressWarnings("unchecked") public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() { 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()); }
Example #9
Source File: ServiceImpl.java From AthenaServing with Apache License 2.0 | 6 votes |
@Override public Response<String> delete(IdRequestBody body) { //通过id查询版本列表 String id = body.getId(); com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionImpl.findServiceVersionListById(id); if (null == service) { //不存在该服务 return new Response<>(SystemErrCode.ERRCODE_SERVICE_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_NOT_EXISTS); } List<ServiceVersion> serviceVersionList = service.getServiceVersionList(); if (null != serviceVersionList && !serviceVersionList.isEmpty()) { //该用户已经创建版本 return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_CREATE, SystemErrCode.ERRMSG_SERVICE_VERSION_CREATE); } //根据id删除服务 this.serviceConditionImpl.deleteById(id); return new Response<>(null); }
Example #10
Source File: MetaAnnotationUtilsTests.java From java-technology-stack with MIT License | 6 votes |
@SuppressWarnings("unchecked") private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(Class<?> startClass, Class<?> rootDeclaringClass, Class<?> declaringClass, String name, Class<? extends Annotation> composedAnnotationType) { Class<Component> annotationType = Component.class; UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes( startClass, Service.class, annotationType, Order.class, Transactional.class); assertNotNull("UntypedAnnotationDescriptor should not be null", descriptor); assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass()); assertEquals("declaringClass", declaringClass, descriptor.getDeclaringClass()); assertEquals("annotationType", annotationType, descriptor.getAnnotationType()); assertEquals("component name", name, ((Component) descriptor.getAnnotation()).value()); assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation()); assertEquals("composedAnnotationType", composedAnnotationType, descriptor.getComposedAnnotationType()); }
Example #11
Source File: ServiceConditionImpl.java From AthenaServing with Apache License 2.0 | 6 votes |
@Override public com.iflytek.ccr.polaris.cynosure.domain.Service add(AddServiceRequestBody body) { String name = body.getName(); String desc = body.getDesc(); String userId = this.getUserId(); String clusterId = body.getClusterId(); //新增 Date now = new Date(); com.iflytek.ccr.polaris.cynosure.domain.Service service = new com.iflytek.ccr.polaris.cynosure.domain.Service(); service.setId(SnowflakeIdWorker.getId()); service.setName(name); service.setDescription(desc); service.setUserId(userId); service.setGroupId(clusterId); service.setCreateTime(now); try { this.serviceMapper.insert(service); return service; } catch (DuplicateKeyException ex) { logger.warn("service duplicate key " + ex.getMessage()); return this.find(name, clusterId); } }
Example #12
Source File: MetaAnnotationUtilsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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()); }
Example #13
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 6 votes |
@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(3, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertFalse(containsBeanClass(candidates, FooServiceImpl.class)); assertFalse(containsBeanClass(candidates, StubFooDao.class)); assertFalse(containsBeanClass(candidates, NamedStubDao.class)); }
Example #14
Source File: K8SCoreRuntime.java From jhipster-operator with Apache License 2.0 | 6 votes |
private String tryIstioGatewayApproach() { String istioIP = "N/A"; ServiceList list = kubernetesClient.services().inNamespace("istio-system").list(); for (io.fabric8.kubernetes.api.model.Service s : list.getItems()) { if (s.getMetadata().getName().equals("istio-ingressgateway")) { List<LoadBalancerIngress> ingress = s.getStatus().getLoadBalancer().getIngress(); if (ingress.size() == 1) { istioIP = ingress.get(0).getIp(); } } else { logger.error(">> Trying to resolve External IP from istio-ingressgateway failed. There will be no external IP for your apps."); logger.error(">> Trying to use port-forward: 'kubectl port-forward svc/jhipster-operator 8081:80 " + "-n jhipster' and then access using http://localhost:8081/apps/"); } } return istioIP; }
Example #15
Source File: MockUserManagementService.java From cloudbreak with Apache License 2.0 | 6 votes |
/** * NOTE: This is a mock implementation and meant only for testing. * This implementation returns hard coded pre-defined set of response for workload credentials. * For any integration test of debugging purpose, this should not be used and intent is purely mock. * Hashed value used internally is sha256 hash of <i>Password123!</i>. */ @Override public void getActorWorkloadCredentials(GetActorWorkloadCredentialsRequest request, io.grpc.stub.StreamObserver<GetActorWorkloadCredentialsResponse> responseObserver) { GetActorWorkloadCredentialsResponse.Builder builder = GetActorWorkloadCredentialsResponse.newBuilder(actorWorkloadCredentialsResponse); builder.setPasswordHashExpirationDate(System.currentTimeMillis() + PASSWORD_LIFETIME); if (sshPublicKey.isPresent()) { Crn actorCrn = Crn.safeFromString(request.getActorCrn()); builder.addSshPublicKey(SshPublicKey.newBuilder(sshPublicKey.get()) .setCrn(Crn.builder() .setAccountId(actorCrn.getAccountId()) .setPartition(actorCrn.getPartition()) .setService(Crn.Service.IAM) .setResourceType(ResourceType.PUBLIC_KEY) .setResource(UUID.randomUUID().toString()) .build() .toString()) .build()); } responseObserver.onNext(builder.build()); responseObserver.onCompleted(); }
Example #16
Source File: SpringRedisCacheManager.java From Mykit with Apache License 2.0 | 5 votes |
private void parseCacheDuration(ApplicationContext applicationContext) { final Map<String, Long> cacheExpires = new HashMap<String, Long>(); 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.info(cacheExpires.toString()); //设置有效期 super.setExpires(cacheExpires); }
Example #17
Source File: KerberosMgmtV1Service.java From cloudbreak with Apache License 2.0 | 5 votes |
private com.sequenceiq.freeipa.client.model.Service serviceAdd(String canonicalPrincipal, FreeIpaClient ipaClient) throws FreeIpaClientException { com.sequenceiq.freeipa.client.model.Service service = null; try { Optional<com.sequenceiq.freeipa.client.model.Service> optionalService = fetchServiceIfAlreadyExist(canonicalPrincipal, ipaClient); service = optionalService.isEmpty() ? ipaClient.addService(canonicalPrincipal) : optionalService.get(); } catch (FreeIpaClientException e) { if (!FreeIpaClientExceptionUtil.isDuplicateEntryException(e)) { throw e; } } service = fetchServiceIfNull(canonicalPrincipal, ipaClient, service); return service; }
Example #18
Source File: CmdValidator.java From rocketmq with Apache License 2.0 | 5 votes |
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { Class<?> clazz = bean.getClass(); if (clazz.isAnnotationPresent(Service.class)) { Method[] methodArr = clazz.getDeclaredMethods(); for (Method method : methodArr) { if (method.isAnnotationPresent(CmdTrace.class)) { CmdTrace cmdTrace = method.getAnnotation(CmdTrace.class); Class<? extends SubCommand> cmdClazz = cmdTrace.cmdClazz(); String methodName = clazz.getSimpleName() + "." + method.getName(); if (method2cmd.get(methodName) == null) { method2cmd.put(methodName, cmdClazz); } else { throw new IllegalStateException(methodName + " = {" + method2cmd.get(methodName).getName() + "," + cmdClazz.getName() + "}"); } if (cmd2method.get(cmdClazz) == null) { cmd2method.put(cmdClazz, methodName); } else { throw new IllegalStateException(cmdClazz + " = {" + cmd2method.get(cmdClazz) + "," + methodName + "}"); } } } } return bean; }
Example #19
Source File: K8SCoreRuntime.java From jhipster-operator with Apache License 2.0 | 5 votes |
private String tryLoadBalancerApproach() { String loadBalancerIP = "N/A"; ServiceList list = kubernetesClient.services().inNamespace(getNamespace()).list(); for (io.fabric8.kubernetes.api.model.Service s : list.getItems()) { if (s.getMetadata().getName().equals("gateway")) { if (s.getSpec().getType().equals("LoadBalancer")) { if (!s.getSpec().getExternalIPs().isEmpty()) { loadBalancerIP = s.getSpec().getExternalIPs().get(0); } else { logger.error(">> LoadBalancer type service is being used, but there is no External IP available, " + "you need to use port-forward: 'kubectl port-forward svc/jhipster-operator 8081:80 -n jhipster' " + "and then access using http://localhost:8081/apps/"); loadBalancerIP = "localhost:8081"; } } if (s.getSpec().getType().equals("NodePort")) { logger.error(">> NodePort type service is being used, you need to use port-forward: 'kubectl port-forward svc/jhipster-operator 8080:80 " + "-n jhipster' and then access using http://localhost:8081/apps/"); loadBalancerIP = "localhost:8081"; } } else { logger.error(">> Trying to resolve External IP from LoadBalancer service \"jhipster-operator\" failed. There will be no external IP for your apps."); logger.error(">> Trying to use port-forward: 'kubectl port-forward svc/jhipster-operator 8081:80 " + "-n jhipster' and then access using http://localhost:8081/apps/"); } } return loadBalancerIP; }
Example #20
Source File: ModuleClassLoader.java From TrackRay with GNU General Public License v3.0 | 5 votes |
/** * 方法描述 判断class对象是否带有spring的注解 * @method isSpringBeanClass * @param cla jar中的每一个class * @return true 是spring bean false 不是spring bean */ public boolean isSpringBeanClass(Class<?> cla){ if(cla==null){ return false; } //是否是接口 if(cla.isInterface()){ return false; } //是否是抽象类 if( Modifier.isAbstract(cla.getModifiers())){ return false; } if(cla.getAnnotation(Component.class)!=null){ return true; } if(cla.getAnnotation(Repository.class)!=null){ return true; } if(cla.getAnnotation(Service.class)!=null){ return true; } return false; }
Example #21
Source File: K8SCoreRuntime.java From jhipster-operator with Apache License 2.0 | 5 votes |
public boolean isServiceAvailable(String serviceName) { //@TODO: i should check that the k8s deployment exist before adding the microservice //@TODO: i should update the k8s deployment to make sure that services are configured for the app io.fabric8.kubernetes.api.model.Service service = kubernetesClient.services().withName(serviceName).get(); if (service != null) { logger.debug(">> K8s Service " + serviceName + " found."); return true; } logger.error(">> K8s Service " + serviceName + " not found."); return false; }
Example #22
Source File: BaseService.java From AthenaServing with Apache License 2.0 | 5 votes |
/** * 创建服务结果 * * @param service * @return */ protected ServiceDetailResponseBody createServiceResult(com.iflytek.ccr.polaris.cynosure.domain.Service service) { ServiceDetailResponseBody result = new ServiceDetailResponseBody(); result.setId(service.getId()); result.setName(service.getName()); result.setDesc(service.getDescription()); result.setClusterId(service.getGroupId()); result.setCreateTime(service.getCreateTime()); result.setUpdateTime(service.getUpdateTime()); return result; }
Example #23
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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)); }
Example #24
Source File: EnableTransactionManagementTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void transactionProxyIsCreatedWithEnableOnSuperclass() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(InheritedEnableTxConfig.class, TxManagerConfig.class); TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class); assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean)); Map<?,?> services = ctx.getBeansWithAnnotation(Service.class); assertTrue("Stereotype annotation not visible", services.containsKey("testBean")); ctx.close(); }
Example #25
Source File: MetaAnnotationUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
/** * @since 4.0.3 */ @Test @SuppressWarnings("unchecked") public void findAnnotationDescriptorForTypesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes( MetaCycleAnnotatedClass.class, Service.class, Component.class, Order.class); assertNull("Should not find @Component on MetaCycleAnnotatedClass", descriptor); }
Example #26
Source File: MetaAnnotationUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
/** * @since 4.0.3 */ @Test @SuppressWarnings("unchecked") public void findAnnotationDescriptorForTypesOnAnnotatedClassWithMissingTargetMetaAnnotation() { // InheritedAnnotationClass is NOT annotated or meta-annotated with @Component, // @Service, or @Order, but it is annotated with @Transactional. UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes( InheritedAnnotationClass.class, Service.class, Component.class, Order.class); assertNull("Should not find @Component on InheritedAnnotationClass", descriptor); }
Example #27
Source File: MetaAnnotationUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void findAnnotationDescriptorForTypesForClassWithMetaAnnotatedInterface() { Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class, Component.class); UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes( ClassWithMetaAnnotatedInterface.class, Service.class, Component.class, Order.class, Transactional.class); assertNotNull(descriptor); assertEquals(ClassWithMetaAnnotatedInterface.class, descriptor.getRootDeclaringClass()); assertEquals(Meta1.class, descriptor.getDeclaringClass()); assertEquals(rawAnnotation, descriptor.getAnnotation()); assertEquals(Meta1.class, descriptor.getComposedAnnotation().annotationType()); }
Example #28
Source File: MetaAnnotationUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() { 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()); }
Example #29
Source File: RpcDefinitionPostProcessor.java From joyrpc with Apache License 2.0 | 5 votes |
/** * 获取组件名称 * * @param providerClass 服务提供接口类 * @return 服务名称 */ protected String getComponentName(final Class<?> providerClass) { String name = null; Component component = findAnnotation(providerClass, Component.class); if (component != null) { name = component.value(); } if (isEmpty(name)) { Service service = findAnnotation(providerClass, Service.class); if (service != null) { name = service.value(); } } return name; }
Example #30
Source File: KerberosMgmtV1Service.java From cloudbreak with Apache License 2.0 | 5 votes |
private com.sequenceiq.freeipa.client.model.Service fetchServiceIfNull(String canonicalPrincipal, FreeIpaClient ipaClient, com.sequenceiq.freeipa.client.model.Service service) throws FreeIpaClientException { if (service == null) { service = ipaClient.showService(canonicalPrincipal); } return service; }