Reputation: 194
I am new to OSGI. I have developed a student rest service using cxf and blueprint .Deployed it in karaf. By default karaf has cxf in its URL. I have found that i can configure the property(org.apache.cxf.servlet.context=/student) in etc folder or I can run config:edit/setprop/update/ commands in karaf. So that i can replace cxf in the url with some custom value. But now I want to remove the CXF from my url without doing any above mentioned changes in karaf. Is there any other way I can do the same? I found that using admin config service and configuration I can update the above property but it is not working.
I referred following link: How can I get properties stored in ConfigAdmin? -It didn't work for me.
As am using blueprint do I need to add anything extra? and what is exactly factorypid and location which I have to pass to createFactoryConfiguration.
Thanks in advance.
Upvotes: 0
Views: 529
Reputation: 194
I had found solution for my issue. Add following code to activator's start method.
Dictionary<String, String> props = new Hashtable<String, String>();
props.put( "org.apache.cxf.servlet.context", "/student" );
// Use OSGI admin configuration to update CXF url
ServiceReference reference = context.getServiceReference( ConfigurationAdmin.class.getName() );
ConfigurationAdmin admin = (ConfigurationAdmin) context.getService( reference );
try
{
Configuration config = admin.getConfiguration( "org.apache.cxf.osgi", null );
config.update( props );
}
catch ( Exception exception )
{
throw exception;
}
No need to do any changes in blueprint.xml. It works in both karaf and equinox. Initially i was trying in equinox without passing location argument to getConfiguration() hence it was not working.
Upvotes: 0