forked from apache/dubbo
-
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.
Merge pull request #2 from apache/master
21212
- Loading branch information
Showing
1,343 changed files
with
60,728 additions
and
24,534 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
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 |
---|---|---|
|
@@ -222,6 +222,27 @@ This product contains a modified portion of 'Netty', an event-driven asynchronou | |
|
||
For the org.apache.dubbo.common.utils.CIDRUtils : | ||
|
||
This product contains a modified portion of 'edazdarevic.commons.net.CIDRUtils', | ||
under a "MIT License" license, see https://github.com/edazdarevic/CIDRUtils/blob/master/CIDRUtils.java | ||
|
||
This product contains a modified portion of 'edazdarevic.commons.net.CIDRUtils' published at | ||
https://github.com/edazdarevic/CIDRUtils. The project is licensed under a MIT License: | ||
* The MIT License | ||
* | ||
* Copyright (c) 2013 Edin Dazdarevic ([email protected]) | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
|
||
This product contains a modified portion of 'proto-gen-grpc-java' - a protobuf plugin used to generate grpc-java stubs, | ||
under a "Apache License 2.0" license, see https://github.com/grpc/grpc-java/blob/v1.22.1/NOTICE.txt. All files are placed | ||
under '/dubbo/compiler' |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,2 @@ | ||
#Tue Oct 09 11:40:48 CST 2018 | ||
gradle.version=4.9 |
Binary file not shown.
Empty file.
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,12 @@ | ||
cc_binary( | ||
name = "grpc_java_plugin", | ||
srcs = [ | ||
"src/java_plugin/cpp/java_generator.cpp", | ||
"src/java_plugin/cpp/java_generator.h", | ||
"src/java_plugin/cpp/java_plugin.cpp", | ||
], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@com_google_protobuf//:protoc_lib", | ||
], | ||
) |
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,202 @@ | ||
# Dubbo customized version | ||
|
||
## Get Started, how to use | ||
1. Add maven dependency to your project | ||
```xml | ||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>kr.motd.maven</groupId> | ||
<artifactId>os-maven-plugin</artifactId> | ||
<version>1.6.1</version> | ||
</extension> | ||
</extensions> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.xolstice.maven.plugins</groupId> | ||
<artifactId>protobuf-maven-plugin</artifactId> | ||
<version>0.5.1</version> | ||
<configuration> | ||
<protocArtifact>com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}</protocArtifact> | ||
<pluginId>grpc-java</pluginId> | ||
<pluginArtifact>org.apache.dubbo:protoc-gen-dubbo-java:${proto_dubbo_plugin_version}:exe:${os.detected.classifier}</pluginArtifact> | ||
<outputDirectory>build/generated/source/proto/main/java</outputDirectory> | ||
<clearOutputDirectory>false</clearOutputDirectory> | ||
<!-- supports 'dubbo' and 'grpc' --> | ||
<pluginParameter>dubbo</pluginParameter> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
<goal>compile-custom</goal> | ||
<goal>test-compile</goal> | ||
<goal>test-compile-custom</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>build/generated/source/proto/main/java</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
``` | ||
|
||
2. Decide which protocol to use: Dubbo or gRPC | ||
* Dubbo, ` <pluginParameter>dubbo</pluginParameter>` | ||
* gRPC, ` <pluginParameter>grpc</pluginParameter>` | ||
|
||
3. Define service using IDL | ||
```text | ||
syntax = "proto3"; | ||
option java_multiple_files = true; | ||
option java_package = "org.apache.dubbo.demo"; | ||
option java_outer_classname = "DemoServiceProto"; | ||
option objc_class_prefix = "DEMOSRV"; | ||
package demoservice; | ||
// The demo service definition. | ||
service DemoService { | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} | ||
``` | ||
|
||
4. Build | ||
mvn clean compile | ||
|
||
## Customized | ||
|
||
1. Dubbo Interface | ||
```java | ||
public interface IGreeter { | ||
|
||
default public io.grpc.examples.helloworld.HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) { | ||
throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows."); | ||
} | ||
|
||
default public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloReply> sayHelloAsync( | ||
io.grpc.examples.helloworld.HelloRequest request) { | ||
throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows."); | ||
} | ||
|
||
public void sayHello(io.grpc.examples.helloworld.HelloRequest request, | ||
io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> responseObserver); | ||
|
||
} | ||
``` | ||
|
||
2. Dubbo Stub | ||
```java | ||
public static DubboGreeterStub getDubboStub(io.grpc.Channel channel) { | ||
return new DubboGreeterStub(channel); | ||
} | ||
|
||
public static class DubboGreeterStub implements IGreeter { | ||
|
||
private GreeterBlockingStub blockingStub; | ||
private GreeterFutureStub futureStub; | ||
private GreeterStub stub; | ||
|
||
public DubboGreeterStub(io.grpc.Channel channel) { | ||
blockingStub = GreeterGrpc.newBlockingStub(channel); | ||
futureStub = GreeterGrpc.newFutureStub(channel); | ||
stub = GreeterGrpc.newStub(channel); | ||
} | ||
|
||
public io.grpc.examples.helloworld.HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) { | ||
return blockingStub.sayHello(request); | ||
} | ||
|
||
public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloReply> sayHelloAsync( | ||
io.grpc.examples.helloworld.HelloRequest request) { | ||
return futureStub.sayHello(requesthttps://github.com/apache/dubbo-samples.git); | ||
} | ||
|
||
public void sayHello(io.grpc.examples.helloworld.HelloRequest request, | ||
io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> responseObserver){ | ||
stub.sayHello(request, responseObserver); | ||
} | ||
|
||
} | ||
|
||
``` | ||
|
||
3. XxxImplBase implements DubboInterface | ||
```java | ||
public static abstract class GreeterImplBase implements io.grpc.BindableService, IGreeter { | ||
|
||
@java.lang.Override | ||
public final io.grpc.examples.helloworld.HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) { | ||
throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows."); | ||
} | ||
|
||
@java.lang.Override | ||
public final com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloReply> sayHelloAsync( | ||
io.grpc.examples.helloworld.HelloRequest request) { | ||
throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows."); | ||
} | ||
|
||
public void sayHello(io.grpc.examples.helloworld.HelloRequest request, | ||
io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> responseObserver) { | ||
asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver); | ||
} | ||
|
||
... | ||
} | ||
``` | ||
|
||
## Build locally | ||
|
||
To compile the plugin: | ||
``` | ||
$ ./gradlew java_pluginExecutable | ||
``` | ||
|
||
To publish to local repository | ||
``` | ||
$ ./gradlew publishToMavenLocal | ||
``` | ||
|
||
## Publish to maven repository | ||
|
||
Add gradle.properties | ||
```properties | ||
repositoryUser=user | ||
repositoryPasword=pwd | ||
``` | ||
|
||
Then, run | ||
``` | ||
$ ../gradlew publishMavenPublicationToDubboRepository | ||
``` | ||
Notice current groupId is `com.alibaba`. | ||
|
||
|
||
Check [here](https://github.com/grpc/grpc-java/blob/master/compiler/README.md) for basic requirements and usage of protoc plugin. |
Oops, something went wrong.