本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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());
}
示例7: hasServiceAnnotation
import com.googlecode.jsonrpc4j.JsonRpcService; //导入依赖的package包/类
private static boolean hasServiceAnnotation(JsonRpcService jsonRpcPath) {
return jsonRpcPath != null;
}
示例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());
}