For DS, I’d suggest that the structure of the configuration class you show 
could be replicated as a configuration annotation, annotated with metatype 
information.  A onfiguration annotation allows for default values.  A netty DS 
component would extend the appropriate Netty class and use this configuration 
to set up a netty instance; the resulting instance would be registered as an 
OSGI service.  If you need constructor injection for a Netty server instance 
you can use R7 DS or delegate.  As I said before, this results effortlessly in 
a server per configuration.  Of course, since I didn’t look at what else camel 
is doing, there might be problems I’m not aware of.

I’m not quite clear on whether or how such an OSGI service could be used in 
camel, since it would be configured and registered as an OSGI service without 
any reference to any camel conventions or notations.

thanks
david jencks

> On Dec 28, 2018, at 12:57 PM, Ranx <[email protected]> wrote:
> 
> The Camel Netty component permits it to be used in Camel routes (I've pasted
> the configuration class below for illustration). In the case of the shared
> configuration and HTTP server in an OSGi context, the server can be exported
> to the registry and then used in Camel routes for REST DSLs. The
> configuration has a number of default values. That works in Camel/Blueprint
> obviously. It may be less than useful for pure OSGi. 
> 
> Unfortunately, Camel itself doesn't have a pure DS implementation. Perhaps I
> misunderstood your use of DS as a factory. It may be that if the developers
> of PAX JDBC were writing it from scratch today they'd use DS but it isn't a
> Camel aware component either. 
> 
> The PAX JDBC source just uses straight up Java which obviously will work for
> the service dynamism. Because the Netty Camel server has Camel annotations
> it may not be a good candidate for this sort of factory though. Dunno. 
> 
> https://github.com/ops4j/org.ops4j.pax.jdbc/blob/master/pax-jdbc-config/src/main/java/org/ops4j/pax/jdbc/config/impl/Activator.java
> 
> @UriParams
> public class NettyServerBootstrapConfiguration implements Cloneable {
>    public static final String DEFAULT_ENABLED_PROTOCOLS =
> "TLSv1,TLSv1.1,TLSv1.2";
> 
>    @UriPath(enums = "tcp,udp") @Metadata(required = "true")
>    protected String protocol;
>    @UriPath @Metadata(required = "true")
>    protected String host;
>    @UriPath @Metadata(required = "true")
>    protected int port;
>    @UriParam(label = "consumer")
>    protected boolean broadcast;
>    @UriParam(label = "advanced", defaultValue = "65536")
>    protected int sendBufferSize = 65536;
>    @UriParam(label = "advanced", defaultValue = "65536")
>    protected int receiveBufferSize = 65536;
>    @UriParam(label = "advanced")
>    protected int receiveBufferSizePredictor;
>    @UriParam(label = "consumer,advanced", defaultValue = "1")
>    protected int bossCount = 1;
>    @UriParam(label = "advanced")
>    protected int workerCount;
>    @UriParam(defaultValue = "true")
>    protected boolean keepAlive = true;
>    @UriParam(defaultValue = "true")
>    protected boolean tcpNoDelay = true;
>    @UriParam(defaultValue = "true")
>    protected boolean reuseAddress = true;
>    @UriParam(label = "producer", defaultValue = "10000")
>    protected int connectTimeout = 10000;
>    @UriParam(label = "consumer,advanced")
>    protected int backlog;
>    @UriParam(label = "consumer,advanced")
>    protected ServerInitializerFactory serverInitializerFactory;
>    @UriParam(label = "consumer,advanced")
>    protected NettyServerBootstrapFactory nettyServerBootstrapFactory;
>    @UriParam(label = "advanced", prefix = "option.", multiValue = true)
>    protected Map<String, Object> options;
>    // SSL options is also part of the server bootstrap as the server
> listener on port X is either plain or SSL
>    @UriParam(label = "security")
>    protected boolean ssl;
>    @UriParam(label = "security")
>    protected boolean sslClientCertHeaders;
>    @UriParam(label = "security")
>    protected SslHandler sslHandler;
>    @UriParam(label = "security")
>    protected SSLContextParameters sslContextParameters;
>    @UriParam(label = "consumer,security")
>    protected boolean needClientAuth;
>    @UriParam(label = "security")
>    protected File keyStoreFile;
>    @UriParam(label = "security")
>    protected File trustStoreFile;
>    @UriParam(label = "security")
>    protected String keyStoreResource;
>    @UriParam(label = "security")
>    protected String trustStoreResource;
>    @UriParam(label = "security")
>    protected String keyStoreFormat;
>    @UriParam(label = "security")
>    protected String securityProvider;
>    @UriParam(defaultValue = DEFAULT_ENABLED_PROTOCOLS, label = "security")
>    protected String enabledProtocols = DEFAULT_ENABLED_PROTOCOLS;
>    @UriParam(label = "security", secret = true)
>    protected String passphrase;
>    @UriParam(label = "advanced")
>    protected boolean nativeTransport;
>    @UriParam(label = "consumer,advanced")
>    protected EventLoopGroup bossGroup;
>    @UriParam(label = "advanced")
>    protected EventLoopGroup workerGroup;
>    @UriParam(label = "advanced")
>    protected ChannelGroup channelGroup;
>    @UriParam(label = "consumer,advanced")
>    protected String networkInterface;
>    @UriParam(label = "consumer", defaultValue = "true")
>    private boolean reconnect = true;
>    @UriParam(label = "consumer", defaultValue = "10000")
>    private int reconnectInterval = 10000;
> 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Reply via email to