Using the maven-bundle-plugin, you can deploy a preexisting jar bundle from your local maven repository to your remote OBR. For this you use the deploy-file
target of the maven-bundle-plugin directly, with a command line like:
mvn org.apache.felix:maven-bundle-plugin:2.4.0:deploy-file
-DrepositoryId=my-repository-id
-Durl=scp://url/to/my/repository
-DpomFile=C:\Users\myuser\.m2\repository\com\...\the-bundle-to-deploy-1.0.0.pom
where my-repository-id
is the id you also use in your settings.xml for storing the access data (username, private key, passphrase etc).
In my case, this simple command failed with the error:
[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:2.4.0:deploy-file (default-cli) on project standalone-pom: Unsupported protocol: 'scp': Cannot find wagon which supports the requested protocol: scp: java.util.NoSuchElementException
[ERROR] role: org.apache.maven.wagon.Wagon
[ERROR] roleHint: scp
and later
Error injecting: org.apache.maven.wagon.providers.ssh.jsch.ScpWagon
and even later
Error injecting: org.apache.maven.wagon.providers.ssh.jsch.interactive.PrompterUIKeyboardInteractive
To resolve this, I had to add the following jars to the %M2_HOME/lib directory (so they are added to the classpath).
- wagon-ssh-2.5.jar
- wagon-ssh-common-2.5.jar
- jsch-0.1.51.jar
- plexus-interactivity-api-1.0-alpha-6.jar
M2_HOME is where the maven executable are located, in my case C:\springsource\apache-maven-3.0.3\lib
and which can be found (on windows) by executing:
where mvn
java, maven, osgi
A short overview of frequently used Felix Gogo OSGi commands with examples.
- List all installed bundles on the system (nb. lb is short for list-bundles)
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (4.2.1)
1|Active | 1|Apache Felix Bundle Repository (1.6.6)
...
- Get the current framework startlevel and then sets it. When setting a new level, all levels in between the current and the new level are activated in between.
g! frameworklevel
Level is 1
g! frameworklevel 2
g! frameworklevel
Level is 2
- For bundles which will be newly installed, set which bundle start level they will have assigned (here level 3) after install
g! bundlelevel -i 3
- For bundles already installed, set the bundle start level, here to level 5 for bundles 94 and 172
g! bundlelevel -s 5 94 172
- Set bundle 23 to be started, when the frameworklevel gets equal or above the bundle’s start level (resp stop)
g! start 23
g! stop 23
- Install a bundle from a local file or a remote location. (note using a repository instead of direct links is described below)
g! install file:///path/to/bundle.jar
Bundle ID: 173
g! install http://www.example.com/path/to/bundle.jar
Bundle ID: 174
- Update a bundle from it’s default location (here bundle 174)
g! update 174
- Uninstall a bundle
g! uninstall 174
- Get detailed infos on a bundles headers (basically the manifest content)
g! headers 3
Apache Felix EventAdmin (3)
---------------------------
Bnd-LastModified = 1349073346464
...
Bundle-SymbolicName = org.apache.felix.eventadmin
...
Bundle-Version = 1.3.2
...
Export-Package = org.osgi.service.event;uses:="org.osgi.framework";version="1.3"
...
- Get list of services offered by a bundle (here bundle 2)
g! inspect capability service 2
org.apache.felix.configadmin [2] provides:
------------------------------------------
service; org.apache.felix.cm.PersistenceManager with properties:
service.description = Platform Filesystem Persistence Manager
service.id = 5
service.pid = org.apache.felix.cm.file.FilePersistenceManager
service.ranking = -2147483648
service.vendor = Apache Software Foundation
Used by:
org.apache.felix.configadmin [2]
...
- Refresh bundles, so that they let go of old packages and surely use the new ones you just updated. If neceessary this will restart the bundles
g! refresh
- Print the System properties
g! system:getproperties
java.vm.version 24.51-b03
sun.jnu.encoding ANSI_X3.4-1968
...
Interaction with an OBR, a remote OSGi bundle repository
- List all and add remote repositories
g! repos list
No repository URLs are set.
g! repos add http://updates.example.com/repository/repository.xml
g! repos list
http://updates.example.com/repository/repository.xml
- Refresh the list of provided bundle of a repository
repos refresh http://updates.example.com/repository/repository.xml
- List content of remote repositories
g! list
My First Bundle (0.0.1.SNAPSHOT)
My Second Bundle (0.0.3.SNAPSHOT, ...)
- Install from remote repository
g! deploy "My First Bundle"
Target resource(s):
-------------------
My First Bundle (0.0.1.SNAPSHOT)
Deploying...
done.
Built-in commands
Using registered services
- Get a service and call methods on it
_sref = $.context getServiceReference "com.example.MyServiceInterface"
_srv = $.context getService $_sref
$_srv getFooBar
...
$.context ungetService $_sref
or with a filter
_srefs = $.context getServiceReferences "com.example.MyServiceInterface" "(filterKey=filterValue)";
_srv = $.context getService ($_srefs 0)
$_srv getFooBar
...
_srv = $.context ungetService ($_srefs 0)
osgi, Uncategorized