Hello Ranx.

ECF does not yet have a complete Netty-based RSA distribution provider (one was started some time ago, but remains incomplete).

We would welcome some of your work with Netty as a contribution to ECF's RS/RSA impl [1] or more probably via github [2].

Scott

[1] http://www.eclipse.org/ecf/

[2] https://github.com/ECF

On 12/27/2018 3:17 PM, Ranx wrote:
I've been kicking the tires on Fuse 7 and took at Camel's REST DSL along with
Netty.  I've found that Netty as an OSGi service feels very natural and
somehow right for Fuse/OSGi. The question I'm getting to is (1) would it
make sense to create a bundle/factory like PAX JDBC for Netty and (2) what
project would be interested in that?

While it isn't difficult to set this up in a Blueprint file and export it,
it really feels like a good candidate for the sort of mechanism we have with
PAX JDBC. Just drop in the configuration file and a NettyHttpServer is
configured and exported to the registry. If that configuration is modified,
it is restarted. Different ports and security set ups would be relatively
easy in this case and wouldn't require modification or creation of specific
Blueprint files.

While I've worked with PAX JDBC and looked at the source, I haven't actually
worked on it or extended it. This would seem extremely useful and easy to
understand but I thought I'd ask to see what others thought. In some ways
this would be simpler than PAX JDBC though it could become a bit more
complex. For example, one might have separate security configurations that
are exported as services that could be shared.

A bit of the background. Here's a snippet of setting up a server and
exporting it based on a configuration. I'll leave the configuration out
right now but it is a large bean with properties that map well to a .cfg
file. This is now exported to whatever bundle wants to come and go and be
exposed. You could also just instantiate the class and at it via the
addServiceOnStartup method instead.


<bean id="httpServer"
class="org.apache.camel.component.netty4.http.DefaultNettySharedHttpServer"
init-method="start" destroy-method="stop">
        <property name="nettyServerBootstrapConfiguration" ref="configuration" 
/>
</bean>


<service ref="httpServer"
interface="org.apache.camel.component.netty4.http.NettySharedHttpServer" />

To use that is relatively simple. In the bundle where you want to use it you
simply grab the reference.

<reference id="sharedNettyHttpServer"
interface="org.apache.camel.component.netty4.http.NettySharedHttpServer"/>


In the Java DSL then you have the following configuration. It indicates to
use the OSGi service which you grabbed in Blueprint as
sharedNettyHttpServer. When the bundle is installed it adds the new REST
endpoints and when uninstalled it removes them. Camel Blueprint Test becomes
very simple in this case as you can just have a test scoped bundle that sets
up a basic 0.0.0.0 and port and the REST DSL is good to go.

   @Override
     public void configure()  {
                restConfiguration().component("netty4-http")
                        
.endpointProperty("nettySharedHttpServer","#sharedNettyHttpServer")
                        .bindingMode(RestBindingMode.json);
                

The CBTS just points at your local Blueprint file and because you've listed
the test scoped bundle that exports the OSGi service it works (the
myMockedService is just a Mockito mock of an OSGi service the route is
calling.)
     @Test
     public void testGetByParticipantID() throws Exception {
        SomeModel model = TestDataFactory.createSomeModel();
        //If the id requested matches the  model's id, we'll return it.
                
when(myMockedService.getByID(model.getSomeID())).thenReturn(model);
                //Make sure we're requesting the id that is defined on the data 
model via
a REST Get call
                //and unmarshal it to a MemberIDModel.
                SomeModel id = 
doGet(formAddress("foo/id/bar",model.getSomeID()),
SomeModel.class);

         assertNotNull(id);
         //The models are not identical as the id model went through
marhsaling/unmarshaling.
         assertFalse(id==model);
         //The model's data is, however, identical content.
         assertEquals(id.toString(),model.toString());

     }






--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Reply via email to