Considering that RoSe already implements the protocol you will to use, the only thing you have to do is to perform a machine registration and then you are ready to go.
This process is required in order to import or export a service. Although this process remains the same is logical that the parameters for each of them change accordingly.
Consider you have a webservice, you know everything that is necessary to make use of it. Now, you wish to integrate this service into other applications that have been deployed in a OSGi Service Platform. Well there are two flavours of doing that:
In order to use Rose DSL file, its required to deploy the fileinstall bundle.
After that, its enough to create a directory named load in the root of your OSGi Service Platform (we use felix)
So the Rose DSL file is correctly detected by Rose platform is has to be named according to some rules, which are:
For the more experts, the regular expression to be respect is ‘^rose-conf(-[a-zA-Z_0-9]+|).(json|rose)$’
{ "machine" : { "id" : "server1", "host" : "192.168.1.1", "connection" : [ { "out" : { "service_filter" : "(objectClass=org.osgi.service.log.LogService)", "properties" : { "tag" : ["log","service","id"] } } }, "in" : { "endpoint_filter" : "(endpoint.id=*)" } } ], "component" : [ { "factory" : "RoSe_importer.jabsorb" }, { "factory" : "RoSe_exporter.jabsorb" }, { "factory" : "Rose_Pubsubhubbub.hub", "properties" : { "hub.url" : "/hub" } }, { "factory" : "Rose_Pubsubhubbub.publisher", "properties" : { "hub.url" : "192.168.1.1:8080/hub/hub:8080/hub", "rss.url":"/roserss" } }, { "factory" : "Rose_Pubsubhubbub.subscriber", "properties" : { "callback.url" : "/sub1", "hub.url":"192.168.1.1:8080/hub", "endpoint.filter":"(endpoint.id=*)" } } ], } }
{ "machine": { "id": "server1", "host": "localhost", "connection": [ { "out": { "service_filter": "(jaxrs=*)" } } ], "component": [ { "factory": "RoSe_exporter.jersey", "properties": { "jersey.servlet.name": "/rest" } } ] } }
{ "machine": { "id": "server1", "host": "localhost", "connection": [ { "out": { "service_filter": "(jaxrs=*)" } } ], "component": [ { "factory": "RoSe_exporter.jabsorb", "properties": { "jersey.servlet.name": "/rest" } } ] } }
In order to register a Rose Machine programatically, it is necessary to create an OSGi component instance that will be responsible to access Rose and deploy the desired configuration.
Below is an example of how to register an Rose machine programatically.
@Component @Instantiate public class RoseMachineRegister { BundleContext bc; Machine m; public RoseStarter(BundleContext bc) { this.bc = bc; } @Validate public void start() { System.out.println("starting service rose.."); m = MachineBuilder.machine(bc, "example_helloworld-1") .host("localhost").create(); try { m.out("(jaxrs=*)").add(); } catch (InvalidSyntaxException e) { e.printStackTrace(); } m.instance("RoSe_exporter.jersey").withProperty("jersey.servlet.name", "/rest").create(); m.start(); } @Invalidate public void stop(){ if(m!=null){ System.out.println("removing machine rose"); m.stop(); } } }