davsclaus commented on a change in pull request #153: Support Knative broker/trigger model URL: https://github.com/apache/camel-k-runtime/pull/153#discussion_r334266569
########## File path: camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java ########## @@ -111,6 +125,66 @@ public void setTransportOptions(Map<String, Object> transportOptions) { configuration.setTransportOptions(transportOptions); } + public Knative.Protocol getProtocol() { + return protocol; + } + + /** + * Protocol. + */ + public KnativeComponent setProtocol(Knative.Protocol protocol) { + this.protocol = protocol; + return this; + } + + public KnativeTransport getTransport() { + return transport; + } + + /** + * The transport implementation. + */ + public void setTransport(KnativeTransport transport) { + this.transport = transport; + } + + // ************************ + // + // Lifecycle + // + // ************************ + + @Override + protected void doInit() throws Exception { + if (transport == null) { + this.transport = getCamelContext().getRegistry().lookupByNameAndType(protocol.name(), KnativeTransport.class); + + if (this.transport == null) { + this.transport = getCamelContext() + .adapt(ExtendedCamelContext.class) + .getFactoryFinder(Knative.KNATIVE_TRANSPORT_RESOURCE_PATH) + .newInstance(protocol.name(), KnativeTransport.class) + .orElseThrow(() -> new RuntimeException("Error creating knative transport for protocol: " + protocol.name())); + + CamelContextAware.trySetCamelContext(transport, getCamelContext()); + } + } + } + + @Override + protected void doStart() throws Exception { + if (this.transport != null && managedTransport) { + this.transport.start(); + } + } + + @Override + protected void doStop() throws Exception { + if (this.transport != null && managedTransport) { + this.transport.stop(); Review comment: ServiceHelper.doStop is better to use ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services