You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/12/07 17:44:39 UTC
[camel] branch master updated: CAMEL-14263: camel-grpc should use
source code generated configurer to avoid reflection configuration.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new f96ddbc CAMEL-14263: camel-grpc should use source code generated configurer to avoid reflection configuration.
f96ddbc is described below
commit f96ddbc2e358b75c9ade428c3f18d86a80d62303
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Dec 7 18:43:54 2019 +0100
CAMEL-14263: camel-grpc should use source code generated configurer to avoid reflection configuration.
---
.../apache/camel/component/grpc/GrpcComponent.java | 9 +++----
.../camel/component/grpc/GrpcConfiguration.java | 2 +-
.../apache/camel/component/grpc/GrpcEndpoint.java | 29 ++++++++++++++--------
3 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
index 6e81baf..7d84491 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
@@ -32,11 +32,10 @@ public class GrpcComponent extends DefaultComponent {
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
GrpcConfiguration config = new GrpcConfiguration();
-
- config = parseConfiguration(config, uri, parameters);
- setProperties(config, parameters);
+ config = parseConfiguration(config, uri);
Endpoint endpoint = new GrpcEndpoint(uri, this, config);
+ setProperties(endpoint, parameters);
return endpoint;
}
@@ -45,8 +44,8 @@ public class GrpcComponent extends DefaultComponent {
*
* @return the parsed and valid configuration to use
*/
- protected GrpcConfiguration parseConfiguration(GrpcConfiguration configuration, String remaining, Map<String, Object> parameters) throws Exception {
- configuration.parseURI(new URI(remaining), parameters, this);
+ protected GrpcConfiguration parseConfiguration(GrpcConfiguration configuration, String remaining) throws Exception {
+ configuration.parseURI(new URI(remaining));
return configuration;
}
}
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
index 42896b7..be5709a 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
@@ -380,7 +380,7 @@ public class GrpcConfiguration {
return maxConcurrentCallsPerConnection;
}
- public void parseURI(URI uri, Map<String, Object> parameters, GrpcComponent component) {
+ public void parseURI(URI uri) {
setHost(uri.getHost());
if (uri.getPort() != -1) {
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
index e15dad0..aed6f3d 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
@@ -39,16 +39,6 @@ public class GrpcEndpoint extends DefaultEndpoint {
public GrpcEndpoint(String uri, GrpcComponent component, GrpcConfiguration config) throws Exception {
super(uri, component);
this.configuration = config;
-
- // Extract service and package names from the full service name
- serviceName = GrpcUtils.extractServiceName(configuration.getService());
- servicePackage = GrpcUtils.extractServicePackage(configuration.getService());
-
- // Convert method name to the camel case style
- // This requires if method name as described inside .proto file directly
- if (!ObjectHelper.isEmpty(configuration.getMethod())) {
- configuration.setMethod(GrpcUtils.convertMethod2CamelCase(configuration.getMethod()));
- }
}
public GrpcConfiguration getConfiguration() {
@@ -67,7 +57,24 @@ public class GrpcEndpoint extends DefaultEndpoint {
@Override
public Consumer createConsumer(Processor processor) throws Exception {
- return new GrpcConsumer(this, processor, configuration);
+ GrpcConsumer consumer = new GrpcConsumer(this, processor, configuration);
+ configureConsumer(consumer);
+ return consumer;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+
+ // Extract service and package names from the full service name
+ serviceName = GrpcUtils.extractServiceName(configuration.getService());
+ servicePackage = GrpcUtils.extractServicePackage(configuration.getService());
+
+ // Convert method name to the camel case style
+ // This requires if method name as described inside .proto file directly
+ if (!ObjectHelper.isEmpty(configuration.getMethod())) {
+ configuration.setMethod(GrpcUtils.convertMethod2CamelCase(configuration.getMethod()));
+ }
}
public String getServiceName() {