forked from dangdangdotcom/dubbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create new module of maven-archetype from the dubbo-demo-lite project.
- Loading branch information
Showing
63 changed files
with
3,275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!-- | ||
- Copyright 1999-2011 Alibaba Group. | ||
- | ||
- Licensed under the Apache License, Version 2.0 (the "License"); | ||
- you may not use this file except in compliance with the License. | ||
- You may obtain a copy of the License at | ||
- | ||
- http://www.apache.org/licenses/LICENSE-2.0 | ||
- | ||
- Unless required by applicable law or agreed to in writing, software | ||
- distributed under the License is distributed on an "AS IS" BASIS, | ||
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
- See the License for the specific language governing permissions and | ||
- limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>dubbo-demo-lite</artifactId> | ||
<version>2.8.3</version> | ||
</parent> | ||
<artifactId>dubbo-demo-lite-api</artifactId> | ||
<packaging>jar</packaging> | ||
<name>${project.artifactId}</name> | ||
<description>The demo module of dubbo project</description> | ||
<properties> | ||
<skip_maven_deploy>true</skip_maven_deploy> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>dubbo</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.validation</groupId> | ||
<artifactId>validation-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
37 changes: 37 additions & 0 deletions
37
...bo-demo-lite-api/src/main/java/com/alibaba/dubbo/demolite/SerializationOptimizerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite; | ||
|
||
import com.alibaba.dubbo.common.serialize.support.SerializationOptimizer; | ||
import com.alibaba.dubbo.demolite.user.User; | ||
|
||
import java.util.Collection; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
/** | ||
* This class must be accessible from both the provider and consumer | ||
* | ||
* @author lishen | ||
*/ | ||
public class SerializationOptimizerImpl implements SerializationOptimizer { | ||
|
||
public Collection<Class> getSerializableClasses() { | ||
List<Class> classes = new LinkedList<Class>(); | ||
classes.add(User.class); | ||
return classes; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...o-demo-lite-api/src/main/java/com/alibaba/dubbo/demolite/extension/ClientTraceFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite.extension; | ||
|
||
import javax.ws.rs.client.ClientRequestContext; | ||
import javax.ws.rs.client.ClientRequestFilter; | ||
import javax.ws.rs.client.ClientResponseContext; | ||
import javax.ws.rs.client.ClientResponseFilter; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author lishen | ||
*/ | ||
public class ClientTraceFilter implements ClientRequestFilter, ClientResponseFilter { | ||
|
||
public void filter(ClientRequestContext requestContext) throws IOException { | ||
System.out.println("Client request filter invoked"); | ||
} | ||
|
||
public void filter(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) throws IOException { | ||
System.out.println("Client response filter invoked"); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...mo-lite-api/src/main/java/com/alibaba/dubbo/demolite/extension/CustomExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite.extension; | ||
|
||
import com.alibaba.dubbo.rpc.RpcContext; | ||
|
||
import javax.ws.rs.NotFoundException; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
|
||
/** | ||
* @author lishen | ||
*/ | ||
public class CustomExceptionMapper implements ExceptionMapper<NotFoundException> { | ||
|
||
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()); | ||
return Response.status(Response.Status.NOT_FOUND).entity("Oops! the requested resource is not found!").type("text/plain").build(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...demo-lite-api/src/main/java/com/alibaba/dubbo/demolite/extension/DynamicTraceBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite.extension; | ||
|
||
import javax.ws.rs.container.DynamicFeature; | ||
import javax.ws.rs.container.ResourceInfo; | ||
import javax.ws.rs.core.FeatureContext; | ||
|
||
/** | ||
* @author lishen | ||
*/ | ||
public class DynamicTraceBinding implements DynamicFeature { | ||
|
||
public void configure(ResourceInfo resourceInfo, FeatureContext context) { | ||
context.register(DynamicTraceInterceptor.class); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...-lite-api/src/main/java/com/alibaba/dubbo/demolite/extension/DynamicTraceInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite.extension; | ||
|
||
import javax.annotation.Priority; | ||
import javax.ws.rs.Priorities; | ||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.ext.ReaderInterceptor; | ||
import javax.ws.rs.ext.ReaderInterceptorContext; | ||
import javax.ws.rs.ext.WriterInterceptor; | ||
import javax.ws.rs.ext.WriterInterceptorContext; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author lishen | ||
*/ | ||
@Priority(Priorities.USER) | ||
public class DynamicTraceInterceptor implements ReaderInterceptor, WriterInterceptor { | ||
|
||
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException { | ||
System.out.println("Dynamic reader interceptor invoked"); | ||
return readerInterceptorContext.proceed(); | ||
} | ||
|
||
public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException { | ||
System.out.println("Dynamic writer interceptor invoked"); | ||
writerInterceptorContext.proceed(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...e/dubbo-demo-lite-api/src/main/java/com/alibaba/dubbo/demolite/extension/TraceFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite.extension; | ||
|
||
import javax.annotation.Priority; | ||
import javax.ws.rs.Priorities; | ||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerRequestFilter; | ||
import javax.ws.rs.container.ContainerResponseContext; | ||
import javax.ws.rs.container.ContainerResponseFilter; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author lishen | ||
*/ | ||
@Priority(Priorities.USER) | ||
public class TraceFilter implements ContainerRequestFilter, ContainerResponseFilter { | ||
|
||
public void filter(ContainerRequestContext requestContext) throws IOException { | ||
System.out.println("Request filter invoked"); | ||
} | ||
|
||
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException { | ||
System.out.println("Response filter invoked"); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...bo-demo-lite-api/src/main/java/com/alibaba/dubbo/demolite/extension/TraceInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite.extension; | ||
|
||
import javax.annotation.Priority; | ||
import javax.ws.rs.Priorities; | ||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.ext.ReaderInterceptor; | ||
import javax.ws.rs.ext.ReaderInterceptorContext; | ||
import javax.ws.rs.ext.WriterInterceptor; | ||
import javax.ws.rs.ext.WriterInterceptorContext; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author lishen | ||
*/ | ||
@Priority(Priorities.USER) | ||
public class TraceInterceptor implements ReaderInterceptor, WriterInterceptor { | ||
|
||
public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException { | ||
System.out.println("Reader interceptor invoked"); | ||
return readerInterceptorContext.proceed(); | ||
} | ||
|
||
public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException { | ||
System.out.println("Writer interceptor invoked"); | ||
writerInterceptorContext.proceed(); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...bbo-demo-lite/dubbo-demo-lite-api/src/main/java/com/alibaba/dubbo/demolite/user/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright 1999-2014 dangdang.com. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.dubbo.demolite.user; | ||
|
||
import org.codehaus.jackson.annotate.JsonProperty; | ||
|
||
import javax.validation.constraints.Min; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Size; | ||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* @author lishen | ||
*/ | ||
@XmlRootElement | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public class User implements Serializable { | ||
|
||
@NotNull | ||
@Min(1L) | ||
private Long id; | ||
|
||
@JsonProperty("username") | ||
@XmlElement(name = "username") | ||
@NotNull | ||
@Size(min = 6, max = 50) | ||
private String name; | ||
|
||
public User() { | ||
} | ||
|
||
public User(Long id, String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User (" + | ||
"id=" + id + | ||
", name='" + name + '\'' + | ||
')'; | ||
} | ||
} |
Oops, something went wrong.