當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonRpcService類代碼示例

本文整理匯總了Java中com.googlecode.jsonrpc4j.JsonRpcService的典型用法代碼示例。如果您正苦於以下問題:Java JsonRpcService類的具體用法?Java JsonRpcService怎麽用?Java JsonRpcService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JsonRpcService類屬於com.googlecode.jsonrpc4j包,在下文中一共展示了JsonRpcService類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: postProcessBeanFactory

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
	SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext);
	DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
	String resolvedPath = resolvePackageToScan();
	logger.debug("Scanning '{}' for JSON-RPC service interfaces.", resolvedPath);
	try {
		for (Resource resource : applicationContext.getResources(resolvedPath)) {
			if (resource.isReadable()) {
				MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
				ClassMetadata classMetadata = metadataReader.getClassMetadata();
				AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
				String jsonRpcPathAnnotation = JsonRpcService.class.getName();
				if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) {
					String className = classMetadata.getClassName();
					String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("value");
					logger.debug("Found JSON-RPC service to proxy [{}] on path '{}'.", className, path);
					registerJsonProxyBean(defaultListableBeanFactory, className, path);
				}
			}
		}
	} catch (IOException e) {
		throw new IllegalStateException(format("Cannot scan package '%s' for classes.", resolvedPath), e);
	}
}
 
開發者ID:briandilley,項目名稱:jsonrpc4j,代碼行數:26,代碼來源:AutoJsonRpcClientProxyCreator.java

示例2: findServiceBeanDefinitions

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
/**
 * Finds the beans to expose and puts them in the {@link #serviceBeanNames}
 * map.
 * <p>
 * Searches parent factories as well.
 */
private void findServiceBeanDefinitions(
	ConfigurableListableBeanFactory beanFactory) {
	for (String beanName : beanFactory.getBeanDefinitionNames()) {
		JsonRpcService jsonRpcPath = beanFactory.findAnnotationOnBean(beanName, JsonRpcService.class);
		if (jsonRpcPath != null) {
			String pathValue = jsonRpcPath.value();
			LOG.debug(format("Found JSON-RPC path '%s' for bean [%s].",
								pathValue, beanName));
			if (serviceBeanNames.containsKey(pathValue)) {
				String otherBeanName = serviceBeanNames.get(pathValue);
				LOG.warn(format(
										"Duplicate JSON-RPC path specification: found %s on both [%s] and [%s].",
										pathValue, beanName, otherBeanName));
			}
			serviceBeanNames.put(pathValue, beanName);
		}
	}
	BeanFactory parentBeanFactory = beanFactory.getParentBeanFactory();
	if (parentBeanFactory != null 
		&& ConfigurableListableBeanFactory.class.isInstance(parentBeanFactory)) {
		findServiceBeanDefinitions((ConfigurableListableBeanFactory) parentBeanFactory);
	}
}
 
開發者ID:esz,項目名稱:jsonrpc,代碼行數:30,代碼來源:AutoJsonRpcServiceExporter.java

示例3: postProcessBeanFactory

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
	SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext);
	DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory;
	String resolvedPath = resolvePackageToScan();
	LOG.debug(format("Scanning '%s' for JSON-RPC service interfaces.", resolvedPath));
	try {
		for (Resource resource : applicationContext.getResources(resolvedPath)) {
			if (resource.isReadable()) {
				MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
				ClassMetadata classMetadata = metadataReader.getClassMetadata();
				AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
				String jsonRpcPathAnnotation = JsonRpcService.class.getName();
				if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) {
					String className = classMetadata.getClassName();
					String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("value");
					boolean useNamedParams = (Boolean) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("useNamedParams");
					LOG.debug(format("Found JSON-RPC service to proxy [%s] on path '%s'.", className, path));
					registerJsonProxyBean(dlbf, className, path, useNamedParams);
				}
			}
		}
	} catch (IOException e) {
		throw new RuntimeException(format("Cannot scan package '%s' for classes.", resolvedPath), e);
	}
}
 
開發者ID:esz,項目名稱:jsonrpc,代碼行數:26,代碼來源:AutoJsonRpcClientProxyCreator.java

示例4: analyzeController

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
/**
 * Analyze controller and search resource
 *
 * @param controllerClazz
 *            class
 * @param resourceMap
 *            map of result
 * @param description
 *            description
 * @return return result map
 */
private Map<String, SpringResource> analyzeController(Class<?> controllerClazz,
        Map<String, SpringResource> resourceMap, String description) {

    JsonRpcService serviceAnnotation =
            AnnotationUtils.findAnnotation(controllerClazz, JsonRpcService.class);
    if (serviceAnnotation != null) {
        String requestUrl = serviceAnnotation.value();
        for (Method method : controllerClazz.getMethods()) {
            JsonRpcMethod jsonRpcMethod =
                    AnnotationUtils.findAnnotation(method, JsonRpcMethod.class);
            if (jsonRpcMethod != null) {
                // It is necessary to modify as few methods able to live on the same url in
                // swagger
                String resourceKey = controllerClazz.getCanonicalName() + requestUrl + ' '
                        + jsonRpcMethod.value();
                if (!resourceMap.containsKey(resourceKey)) {
                    SpringResource springResource = new SpringResource(controllerClazz,
                            requestUrl, resourceKey, description);
                    springResource.setControllerMapping(requestUrl);
                    resourceMap.put(resourceKey, springResource);
                }
                resourceMap.get(resourceKey).addMethod(method);
            }
        }
    }
    return resourceMap;
}
 
開發者ID:uralmax,項目名稱:jsonrpc4j-swagger-maven-plugin-helper,代碼行數:39,代碼來源:JsonRpcSwaggerApiReader.java

示例5: findServiceBeanDefinitions

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
/**
 * Finds the beans to expose
 * map.
 * <p>
 * Searches parent factories as well.
 */
private static Map<String, String> findServiceBeanDefinitions(ConfigurableListableBeanFactory beanFactory) {
	final Map<String, String> serviceBeanNames = new HashMap<>();
	for (String beanName : beanFactory.getBeanDefinitionNames()) {
		JsonRpcService jsonRpcPath = beanFactory.findAnnotationOnBean(beanName, JsonRpcService.class);
		if (hasServiceAnnotation(jsonRpcPath)) {
			String pathValue = jsonRpcPath.value();
			logger.debug("Found JSON-RPC path '{}' for bean [{}].", pathValue, beanName);
			if (isNotDuplicateService(serviceBeanNames, beanName, pathValue))
				serviceBeanNames.put(pathValue, beanName);
		}
	}
	collectFromParentBeans(beanFactory, serviceBeanNames);
	return serviceBeanNames;
}
 
開發者ID:briandilley,項目名稱:jsonrpc4j,代碼行數:21,代碼來源:AutoJsonRpcServiceExporter.java

示例6: registerServiceProxy

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
/**
 * Registers the new beans with the bean factory.
 */
private void registerServiceProxy(
	DefaultListableBeanFactory dlbf, String servicePath, String serviceBeanName) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder
		.rootBeanDefinition(JsonServiceExporter.class)
		.addPropertyReference("service", serviceBeanName);
	BeanDefinition serviceBeanDefinition = findBeanDefintion(dlbf, serviceBeanName);
	for (Class<?> iface :
		getBeanInterfaces(serviceBeanDefinition, dlbf.getBeanClassLoader())) {
		if (iface.isAnnotationPresent(JsonRpcService.class)) {
			String serviceInterface = iface.getName();
			LOG.debug(format(
								"Registering interface '%s' for JSON-RPC bean [%s].",
								serviceInterface, serviceBeanName));
			builder.addPropertyValue("serviceInterface", serviceInterface);
			break;
		}
	}
	if (objectMapper != null) {
		builder.addPropertyValue("objectMapper", objectMapper);
	}

	if (errorResolver != null) {
		builder.addPropertyValue("errorResolver", errorResolver);
	}
	builder.addPropertyValue("backwardsComaptible", Boolean.valueOf(backwardsComaptible));
	builder.addPropertyValue("rethrowExceptions", Boolean.valueOf(rethrowExceptions));
	builder.addPropertyValue("allowExtraParams", Boolean.valueOf(allowExtraParams));
	builder.addPropertyValue("allowLessParams", Boolean.valueOf(allowLessParams));
	dlbf.registerBeanDefinition(servicePath, builder.getBeanDefinition());
}
 
開發者ID:esz,項目名稱:jsonrpc,代碼行數:34,代碼來源:AutoJsonRpcServiceExporter.java

示例7: hasServiceAnnotation

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
private static boolean hasServiceAnnotation(JsonRpcService jsonRpcPath) {
	return jsonRpcPath != null;
}
 
開發者ID:briandilley,項目名稱:jsonrpc4j,代碼行數:4,代碼來源:AutoJsonRpcServiceExporter.java

示例8: registerServiceProxy

import com.googlecode.jsonrpc4j.JsonRpcService; //導入依賴的package包/類
/**
 * Registers the new beans with the bean factory.
 */
private void registerServiceProxy(DefaultListableBeanFactory defaultListableBeanFactory, String servicePath, String serviceBeanName) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(JsonServiceExporter.class).addPropertyReference("service", serviceBeanName);
	BeanDefinition serviceBeanDefinition = findBeanDefinition(defaultListableBeanFactory, serviceBeanName);
	for (Class<?> currentInterface : getBeanInterfaces(serviceBeanDefinition, defaultListableBeanFactory.getBeanClassLoader())) {
		if (currentInterface.isAnnotationPresent(JsonRpcService.class)) {
			String serviceInterface = currentInterface.getName();
			logger.debug("Registering interface '{}' for JSON-RPC bean [{}].", serviceInterface, serviceBeanName);
			builder.addPropertyValue("serviceInterface", serviceInterface);
			break;
		}
	}
	if (objectMapper != null) {
		builder.addPropertyValue("objectMapper", objectMapper);
	}

	if (errorResolver != null) {
		builder.addPropertyValue("errorResolver", errorResolver);
	}

	if (invocationListener != null) {
		builder.addPropertyValue("invocationListener", invocationListener);
	}

	if (registerTraceInterceptor != null) {
		builder.addPropertyValue("registerTraceInterceptor", registerTraceInterceptor);
	}

	if (httpStatusCodeProvider != null) {
		builder.addPropertyValue("httpStatusCodeProvider", httpStatusCodeProvider);
	}

	if (convertedParameterTransformer != null) {
		builder.addPropertyValue("convertedParameterTransformer", convertedParameterTransformer);
	}

	builder.addPropertyValue("backwardsCompatible", backwardsCompatible);
	builder.addPropertyValue("rethrowExceptions", rethrowExceptions);
	builder.addPropertyValue("allowExtraParams", allowExtraParams);
	builder.addPropertyValue("allowLessParams", allowLessParams);

	defaultListableBeanFactory.registerBeanDefinition(servicePath, builder.getBeanDefinition());
}
 
開發者ID:briandilley,項目名稱:jsonrpc4j,代碼行數:46,代碼來源:AutoJsonRpcServiceExporter.java


注:本文中的com.googlecode.jsonrpc4j.JsonRpcService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。