How to get a system bundle fragment version at runtime - osgi

I've created a system bundle fragment for a host bundle using this:
Fragment-Host: system.bundle;extension:=framework
I would like to know the version of the fragment inside the system bundle activator method. there is way to get that ?
If I use the context parameter of the activator method I can get the system bundle but couldn't find how to get its fragments...
thanks in advance.

Check OSGi Core Spec 5.0 (7.2.x chapter)
BundleWiring wA = systemBundleContext.getBundle().adapt( BundleWiring.class );
for ( BundleWire wire : wA.getProvidedWires(HOST_NAMESPACE)) {
// fragment bundle version
wire.getRequirerWiring().getResource().getVersion();
}

Related

Can't make code_ownership and code_teams gems to work

The gems code_teams, code_ownership should allow one to tag files/whole folders by team name but after adding them to my project, running bundle install etc, I still encounter the same error
Passed `nil` into T.must
sample team file (placed in config/teams as advised) is as following
name: Smurfs
owned_globs:
- folder/folder2/**/*
The code where I try to use the info is :
x = CodeOwnership.for_backtrace(e.backtrace)
Turns out the path was not in the format expected.
The path should not end with /*

x/mobile: Launch a android application with given package name [String] in go

Following is the function written in go:
func LaunchApplication(packageName string) {
Query :
how can I execute application with given packageName
}
Generated the java binding [.aar] using gomobile.
I want to include .aar generated in my android application and call LaunchApplication("com.package.name") from java layer to native go layer and go layer should run the application.
In java application, following is the way to run apk using package name:
Process process = Runtime.getRuntime().exec("am start -n com.package.name/com.package.name.ActivityName");
I tried the same in go using:
os.exec() function but it is giving error that "am not found in the $PATH"
Is there is any other way to do that ?
In android, you should specify the path "/system/bin/"(/system/bin/am). Please make sure there are "am" in this path.

Use Puppet Apache class to install Apache1 on CentOS

I'm trying to create a Vagrant setup using CentOS 6.4 and Apache 1.3 (this is for a legacy application). I am using Puppet (though if an answer in Chef is easier, I'd be happy to use it) and the Puppetlabs Apache class. The issue I'm having is that it installs Apache 2.2, but I don't see how to make it install Apache 1.3 instead.
What am I doing wrong and how can I do it right? (Answers of "Upgrade your app" will be downvoted - I don't have the authority to make that decision.)
The module you're using doesn't explicitly expose a parameter to specify which version of the httpd package you want to install.
Instead of using Puppetlabs module, you could use the Apache module from Alessandro Franceschi (source here - also on the forge)). If the package you need to install has a different name than httpd, the module exposes a package parameter which you can override like this:
class { 'apache':
package => 'apache13',
}
If, instead, Apache 1.3 is provided by the same httpd package by declaring the specific version you want, you can rely on the version parameter:
class { 'apache':
version => '1.3.39',
}
Clearly, you can also combine the two parameters together.
using those modules return the following error on Redhat:
Error 400 on SERVER: Illegal expression.
A Type-Name is unacceptable as function name in a Function Call at /etc/puppet/modules/apache/man.

OSGi bundle as external webservice client

I need to call an external webservice from my bundle which is deployed in apache felix container ( I can not use ServiceMix, fuse...)
I added the bundle cxf-dosgi (which can be downloaded from here) and put the following lines in my pom.xml:
<Require-Bundle>cxf-dosgi-ri-singlebundle-distribution</Require-Bundle>
<Import-Package>
javax.jws,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.namespace,
javax.xml.ws,
META-INF.cxf,
org.apache.cxf,
org.apache.cxf.binding,
org.apache.cxf.binding.soap,
org.apache.cxf.binding.soap.spring,
org.apache.cxf.bus,
org.apache.cxf.bus.resource,
org.apache.cxf.bus.spring,
org.apache.cxf.buslifecycle,
org.apache.cxf.catalog,
org.apache.cxf.configuration,
org.apache.cxf.configuration.spring,
org.apache.cxf.endpoint,
org.apache.cxf.headers,
org.apache.cxf.management,
org.apache.cxf.phase,
org.apache.cxf.resource,
org.apache.cxf.transport,
org.apache.cxf.transport.http,
org.apache.cxf.transport.http.policy,
org.apache.cxf.transport.http_jetty,
org.apache.cxf.transports.http,
org.apache.cxf.workqueue,
org.apache.cxf.ws.policy.builder.jaxb,
org.apache.cxf.wsdl,
org.apache.cxf.wsdl11,
org.apache.cxf.jaxws.*,
*
</Import-Package>
I use the jaxws way to establish the communication:
QName SERVICE_NAME = new QName("http://test.com/", "MockImplService");
Service service = Service.create(new URL(endpointAddress + "?wsdl"), SERVICE_NAME);
mockService= service.getPort(IMock.class);
When I run the example I have the following exception:
Caused by: javax.xml.ws.spi.FactoryFinder$ConfigurationError: Provider org.apache.axis2.jaxws.spi.Provider not found
at javax.xml.ws.spi.FactoryFinder$2.run(FactoryFinder.java:138)
at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:282)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:125)
at javax.xml.ws.spi.FactoryFinder.access$200(FactoryFinder.java:42)
at javax.xml.ws.spi.FactoryFinder$3.run(FactoryFinder.java:273)
at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:282)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:168)
at javax.xml.ws.spi.Provider.provider(Provider.java:39)
at javax.xml.ws.Service.<init>(Service.java:36)
at javax.xml.ws.Service.create(Service.java:116)
any idea please ?
Apache DOSGi is designed for exposing services as webservices, not for calling other webservices. Though, it probably contains some api to call other webservices.
Somehow the axis jaxws implementation is used. You probably have a axis2-jaxws-xxx.jar on your classpath. Try to remove it. The JRA jaxws will be used instead (which should be fine for axis and better for cxf).

Felix/Karaf dev:watch

I am using "dev:watch *" in a karaf container to simplify my testing.
At the moment I deploy all my bundles as "xyz.SNAPSHOT" - and they are picked up correctly.
Question: If I make released bundles (without this ".SNAPSHOT" - will this dev:watch work too?
It won't work with this command:
karaf#root> dev:watch *
From the help of this command:
It will actually monitor all bundles that have a location matching
mvn:* that have '-SNAPSHOT' in their url.
So you need to pass the bundle IDs or urls to the watch command, instead of *. Then Karaf will start watching this non "snapshot" bundles.
Short answer: yes!
The dev:* commands are really useful (dynamic-import is another good one). If you see wiring errors when using dev:watch (i.e. starts referring to two versions of the same bundle, eg. bundle 37.0 and 37.1) then it's a good hint that packages from the original bundle are still being used - this indicates that references aren't being released properly.

Resources