Skip to content
Permalink
Browse files
add rat and checkstyle plugin (#34)
* modify poms

* dubbo-samples-annotation:change groupId and package to org.apache.dubbo

* dubbo-samples-api:change groupId and package to org.apache.dubbo

* dubbo-samples-async:change groupId and package to org.apache.dubbo

* dubbo-samples-async-consumer-future:change groupId and package to org.apache.dubbo

* dubbo-samples-async-original-future:change groupId and package to org.apache.dubbo

* dubbo-samples-async-provider:change groupId and package to org.apache.dubbo

* dubbo-samples-attachment:change groupId and package to org.apache.dubbo

* dubbo-samples-basic:change groupId and package to org.apache.dubbo

* dubbo-samples-basic:change groupId and package to org.apache.dubbo

* dubbo-samples-callback:change groupId and package to org.apache.dubbo

* dubbo-samples-compatible:change groupId and package to org.apache.dubbo

* dubbo-samples-context:change groupId and package to org.apache.dubbo

* dubbo-samples-direct:change groupId and package to org.apache.dubbo

* dubbo-samples-docker:change groupId and package to org.apache.dubbo

* dubbo-samples-echo:change groupId and package to org.apache.dubbo

* dubbo-samples-generic:change groupId and package to org.apache.dubbo

* dubbo-samples-group:change groupId and package to org.apache.dubbo

* dubbo-samples-http:change groupId and package to org.apache.dubbo

* dubbo-samples-merge:change groupId and package to org.apache.dubbo

* dubbo-samples-mock:change groupId and package to org.apache.dubbo

* dubbo-samples-notify:change groupId and package to org.apache.dubbo

* dubbo-samples-spring-hystrix:change groupId and package to org.apache.dubbo

* dubbo-samples-stub:change groupId and package to org.apache.dubbo

* dubbo-samples-validation:change groupId and package to org.apache.dubbo

* dubbo-samples-version:change groupId and package to org.apache.dubbo

* change groupId and package to org.apache.dubbo

* fix README

* dubbo-samples-rest:change groupId and package to org.apache.dubbo

* add rat and checkstyle plugin
  • Loading branch information
leyou240 authored and jerrick-zhu committed Oct 24, 2018
1 parent d715410 commit 723ffb3ae50bc88d85f677d12c2f3323ee4f63fa
Showing 29 changed files with 239 additions and 90 deletions.
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]com[\\/]alibaba[\\/]com[\\/]caucho[\\/]hessian" checks=".*"/>
<suppress files="Yylex\.java" checks="AvoidEscapedUnicodeCharacters"/>
</suppressions>
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="fileExtensions" value="java"/>

<!-- TreeWalker Checks -->
<module name="TreeWalker">
<module name="SuppressWarningsHolder"/>

<module name="AvoidStarImport"/>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="NoLineWrap"/>
<module name="OuterTypeFilename"/>
<module name="UnusedImports"/>
</module>
</module>
@@ -28,7 +28,7 @@ We can use two steps to export Rest Service in Dubbo:
Step 1: Add dependency to the pom file in our project:
```
<dependency>
<groupId>com.alibaba</groupId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-rest</artifactId>
<version>${dubbo.rpc.version}</version>
</dependency>
@@ -52,10 +52,10 @@ Step 2: copy these config to your spring config file:

```
<!-- SwaggerUI -->
<bean id="swaggerService" class="com.alibaba.dubbo.integration.swagger.DubboSwaggerApiListingResource" />
<bean id="swaggerService" class="DubboSwaggerApiListingResource" />
<bean id="beanConfig" class="io.swagger.jaxrs.config.BeanConfig">
<property name="schemes" value="http" />
<property name="resourcePackage" value="com.alibaba.dubbo.samples.rest.api"/>
<property name="resourcePackage" value="org.apache.dubbo.samples.rest.api"/>
<property name="version" value="2.0"/>
<property name="host" value="localhost:8888"/>
<property name="basePath" value="/services/"/>
@@ -66,7 +66,7 @@ Step 2: copy these config to your spring config file:
<property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
<property name="scan" value="true" />
</bean>
<dubbo:service interface="com.alibaba.dubbo.integration.swagger.DubboSwaggerService" ref="swaggerService" protocol="rest" />
<dubbo:service interface="DubboSwaggerService" ref="swaggerService" protocol="rest" />
```

@@ -29,12 +29,11 @@
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<artifactId>dubbo-samples-rest</artifactId>

<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>hessian-lite</artifactId>
<version>3.2.3</version>
<version>3.2.4</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
@@ -55,12 +54,22 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
</dependency>

<dependency>
@@ -1,12 +1,16 @@
package com.alibaba.dubbo.integration.swagger;
package org.apache.dubbo.integration.swagger;

import com.alibaba.dubbo.config.annotation.Service;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.jaxrs.listing.BaseApiListingResource;
import org.apache.dubbo.config.annotation.Service;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.ws.rs.core.*;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

/**
* Created by kimmking on 2017-6-13.
@@ -19,7 +23,7 @@ public class DubboSwaggerApiListingResource extends BaseApiListingResource imple

@Override
public Response getListingJson(Application app, ServletConfig sc,
HttpHeaders headers, UriInfo uriInfo) throws JsonProcessingException {
HttpHeaders headers, UriInfo uriInfo) {
Response response = getListingJsonResponse(app, context, sc, headers, uriInfo);
response.getHeaders().add("Access-Control-Allow-Origin", "*");
response.getHeaders().add("Access-Control-Allow-Headers", "x-requested-with, ssi-token");
@@ -1,4 +1,4 @@
package com.alibaba.dubbo.integration.swagger;
package org.apache.dubbo.integration.swagger;

import com.fasterxml.jackson.core.JsonProcessingException;

@@ -7,7 +7,12 @@
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.*;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;


/**
@@ -20,6 +25,6 @@ public interface DubboSwaggerService {

@GET
@Path("swagger")
public Response getListingJson(@Context Application app,@Context ServletConfig sc,
@Context HttpHeaders headers, @Context UriInfo uriInfo) throws JsonProcessingException;
Response getListingJson(@Context Application app, @Context ServletConfig sc,
@Context HttpHeaders headers, @Context UriInfo uriInfo) throws JsonProcessingException;
}
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.samples.rest;
package org.apache.dubbo.samples.rest;

import java.io.File;
import java.lang.reflect.Method;
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest;
package org.apache.dubbo.samples.rest;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -25,7 +25,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.alibaba.dubbo.samples.rest.api.User;
import org.apache.dubbo.samples.rest.api.User;

public class NonDubboRestConsumer {

@@ -16,10 +16,10 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest;
package org.apache.dubbo.samples.rest;

import com.alibaba.dubbo.samples.rest.api.User;
import com.alibaba.dubbo.samples.rest.api.facade.AnotherUserRestService;
import org.apache.dubbo.samples.rest.api.User;
import org.apache.dubbo.samples.rest.api.facade.AnotherUserRestService;

import org.apache.dubbo.rpc.RpcContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest;
package org.apache.dubbo.samples.rest;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.Configuration;
@@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception {
}

@Configuration
@EnableDubbo(scanBasePackages = "com.alibaba.dubbo.samples.rest.impl.facade")
@EnableDubbo(scanBasePackages = "org.apache.dubbo.samples.rest.impl.facade")
static public class ProviderConfiguration {

}
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api;
package org.apache.dubbo.samples.rest.api;

import java.io.Serializable;

@@ -16,19 +16,16 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api;
package org.apache.dubbo.samples.rest.api;


import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.dubbo.rpc.protocol.rest.support.ContentType;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -16,9 +16,7 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api.extension;

import java.io.IOException;
package org.apache.dubbo.samples.rest.api.extension;

import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
@@ -27,12 +25,13 @@

public class ClientTraceFilter implements ClientRequestFilter, ClientResponseFilter {

public void filter(ClientRequestContext requestContext) throws IOException {
@Override
public void filter(ClientRequestContext requestContext) {
System.out.println("Client request filter invoked");
}

public void filter(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) throws
IOException {
@Override
public void filter(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) {
System.out.println("Client response filter invoked");
}
}
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api.extension;
package org.apache.dubbo.samples.rest.api.extension;

import org.apache.dubbo.rpc.RpcContext;

@@ -26,6 +26,7 @@

public class CustomExceptionMapper implements ExceptionMapper<NotFoundException> {

@Override
public Response toResponse(NotFoundException e) {
System.out.println("Exception mapper successfully got an exception: " + e + ":" + e.getMessage());
System.out.println("Client IP is " + RpcContext.getContext().getRemoteAddressString());
@@ -16,14 +16,15 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api.extension;
package org.apache.dubbo.samples.rest.api.extension;

import javax.ws.rs.container.DynamicFeature;
import javax.ws.rs.container.ResourceInfo;
import javax.ws.rs.core.FeatureContext;

public class DynamicTraceBinding implements DynamicFeature {

@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
context.register(DynamicTraceInterceptor.class);
}
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api.extension;
package org.apache.dubbo.samples.rest.api.extension;

import java.io.IOException;

@@ -31,11 +31,13 @@
@Priority(Priorities.USER)
public class DynamicTraceInterceptor implements ReaderInterceptor, WriterInterceptor {

@Override
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException {
System.out.println("Dynamic reader interceptor invoked");
return readerInterceptorContext.proceed();
}

@Override
public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException {
System.out.println("Dynamic writer interceptor invoked");
writerInterceptorContext.proceed();
@@ -16,15 +16,17 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api.extension;
package org.apache.dubbo.samples.rest.api.extension;

import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcException;

import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcException;

public class LogFilter implements Filter {
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
System.out.println(invocation.getMethodName() + "is invoked");
return invoker.invoke(invocation);
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
package com.alibaba.dubbo.samples.rest.api.extension;
package org.apache.dubbo.samples.rest.api.extension;

import java.io.IOException;

@@ -30,10 +30,12 @@
@Priority(Priorities.USER)
public class TraceFilter implements ContainerRequestFilter, ContainerResponseFilter {

@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
System.out.println("Request filter invoked: " + requestContext.getUriInfo().getAbsolutePath());
}

@Override
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws

IOException {

0 comments on commit 723ffb3

Please sign in to comment.