Cave Deployer allows you to manage a "farm" of Apache Karaf instances local or remote from the deployer itself.
Connections
To interact with a Apache Karaf instance, you have to create a connection describing the access to this instance.
A connection has:
-
an unique name for the connection
-
the JMX URL to the given Apache Karaf instance
-
the name of the Apache Karaf instance
-
username and password to connect to the Apache Karaf instance
Create connections
cave:deployer-connection-register shell command
You can add a new Apache Karaf connection using cave:deployer-connection-register shell command:
karaf@root()> cave:deployer-connection-register myconnection service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root root karaf karaf
REST API
You can create a connection via the Cave Deployer REST API on /cave/deployer/api/connections using a JSON description of your connection.
For instance, using curl:
curl -X POST -H "Content-Type: application/json" http://localhost:8181/cave/deployer/api/connections -d '{
"name": "myconnection",
"jmxUrl": "service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root",
"karafName": "root",
"user": "karaf",
"password": "karaf"
}'
JMX MBean
The org.apache.karaf.cave:type=deployer MBean provides the registerConnection(String name, String jmxUrl, String karafName, String user, String password) operation
allowing you to create a new connection.
Service
The org.apache.karaf.cave.deployer.DeployerService service provides the registerConnection(Connection connection) method allowing you to create a new connection.
List connections
cave:deployer-connection-list shell command
You can list available connections using the cave:deployer-connection-list command:
karaf@root()> cave:deployer-connection-list
Name │ JMX URL │ Instance │ Username │ Password
─────────────┼─────────────────────────────────────────────────────────┼──────────┼──────────┼─────────
myconnection │ service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root │ root │ karaf │ *****
REST API
You can list available connections using the Cave Deployer REST API on /cave/deployer/api/connections (GET) URL.
For instance, using curl:
curl -X GET -H "Content-Type: application/json" http://localhost:8181/cave/deployer/api/connections
[{"name":"myconnection","jmxUrl":"service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root","karafName":"root","user":"karaf","password":"karaf"}]
JMX MBean
The org.apache.karaf.cave:type=deployer MBean provides the connections attribute. It’s a tabular data where you can find all connections available.
Service
The org.apache.karaf.cave.deployer.DeployerService service provides the connections() method providing the list of all connections available.
Delete a connection
cave:deployer-connection-delete shell command
You can delete an existing connection with cave:deployer-connection-delete shell command:
karaf@root()> cave:deployer-connection-delete myconnection
REST API
You can delete an existing connection using Cave Deployer Rest API on /cave/deployer/api/connections/{name} URL (DELETE).
For instance, using curl:
curl -X DELETE http://localhost:8181/cave/deployer/api/connections/myconnection
JMX MBean
The org.apache.karaf.cave:type=deployer MBean provides the deleteConnection(String name) operation to delete an existing connection.
Service
The org.apache.karaf.cave.deployer.DeployerService service provides the deleteConnection(String connectionName) method to delete an existing connection.
Artifacts
Download & upload artifacts
Cave Deployer is able to download an artifacts into a target directory.
For instance you can download an artifact using cave:deployer-download shell command:
karaf@root()> cave:deployer-download mvn:commons-lang/commons-lang/2.6 /path/to/my/repo
You can also use Cave Deployer REST API on /cave/deployer/api/download (POST). The artifact URL is passed using artifact header and the directory is passed using directory header.
For instance, using curl:
curl -X POST -H "artifact: mvn:commons-lang/commons-lang/2.6" -H "directory: /path/to/my/repo" http://localhost:8181/cave/deployer/api/download
You can also use the download(String url, String directory) operation on the org.apache.karaf.cave:type=deployer MBean.
On the org.apache.karaf.cave.deployer.DeployerService service, you can also use the download(String artifact, String directory) method.
On the other hand, you can also upload an artifact to a target repository providing the Maven coordinates. It’s exactly the same as doing mvn deploy:deploy-file.
To upload an artifact, you can use the cave:deployer-upload shell command:
karaf@root()> cave:deployer-upload -g groupId -a artifactId -v 1.0-SNAPSHOT mvn:foo/bar/x.x http://host/repository
You can also use the Cave Deployer REST API on /cave/deployer/api/upload (POST) with the following header parameters:
-
groupId -
artifactId -
version -
artifactUrl -
repositoryUrl
For instance, using curl:
curl -X POST -H "groupId: groupId" -H "artifactId: artifactId" -H "version: 1.0-SNAPSHOT" -H "artifactUrl: mvn:foo/bar/x.x" -H "repositoryUrl: http://host/repository" http://localhost:8181/cave/deployer/api/upload
You can also use the upload(String groupId, String artifactId, String version, String artifactUrl, String repositoryUrl) operation on the org.apache.karaf.cave:type=deployer MBean.
The org.apache.karaf.cave.deployer.DeployerService service also provides the upload(String groupId, String artifactId, String version, String artifactUrl, String repositoryUrl) method.
Extract & explode artifacts
Cave Deployer is also able to process zip and kar artifacts.
Cave Deployer is able to extract zip or kar files to a given Maven repository or local directory:
-
explode will download and extract an artifact into a target folder/repository, looking for features repositories XML (typically in KAR files)
-
extract will download and extract an artifact into a target folder/repository
To explode an artifact into a target Maven repository, you can use cave:deployer-explode shell command:
karaf@root()> cave:deployer-explode mvn:foo/bar/1.0/kar /path/to/repository
You can also use the Cave Deployer REST API on /cave/deployer/api/explode URL (POST) with url header for the artifact URL, and repository header for the repository URL. For instance, using curl:
curl -X POST -H "url: mvn:foo/bar/1.0/kar" -H "repository: /path/to/repository" http://localhost:8181/cave/deployer/api/explode
["foo.xml"]
You can also use explode(String url, String repository) operation on the org.apache.karaf.cave:type=deployer MBean.
The org.apache.karaf.cave.deployer.DeployerService also provides the explode(String url, String repository) method.
Similar to explode, you can extract artifact (without looking for features repositories XML).
You can use the cave:deployer-extract shell command to extract an artifact:
karaf@root()> cave:deployer-extract mvn:foo/bar/1.0/zip /path/to/directory
You can also use the Cave Deployer REST API on /cave/deployer/api/extract URL (POST) with url header for the artifact URL, and directory header for the directory. For instance, using curl:
curl -X POST -H "url: mvn:foo/bar/1.0/zip" -H "directory: /path/to/directory" http://localhost:8181/cave/deployer/api/extract
The org.apache.karaf.cave:type=deployer MBean also provides extract(String url, String directory) operation to extract an artifact into a directory.
You can also programmatically use ` extract(String url, String directory)` method on the org.apache.karaf.cave.deployer.DeployerService service.
Features
Assemble features
You can create new Karaf features by composing existing features, configurations or bundles.
For instance, you can create myfeature composed by feature1, feature2, bundle1, bundle2.
-
karaf@root()> cave:deployer-assemble-feature -g groupId -a artifactId -v 1.0-SNAPSHOT myfeature http://myrepo feature1 feature2 -
Using
assembleFeature(String groupId, String artifactId, String version, String repositoryUrl, String feature, List<String> repositories, List<String> features, List<String> bundles)operation on theorg.apache.karaf.cave:type=deployerMBean -
Using
assembleFeature(String groupId, String artifactId, String version, String repositoryUrl, String feature, List<String> featureRepositoryUrls, List<String> features, List<String> bundles, List<Config> configs)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice
Add features repositories
-
karaf@root()> cave:deployer-feature-repo-add myconnection mvn:foo/bar/1.0/xml/features -
curl -X POST -H "artifactUrl: mvn:foo/bar/1.0/xml/features" http://localhost:8181/cave/deployer/api/connections/myconnection/features/repositories -
addFeatureRepository(String url, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
addFeaturesRepository(String featuresRepositoryUrl, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List features repositories
-
karaf@root()> cave:deployer-feature-repo-list myconnection -
curl -X GET http://localhost:8181/cave/deployer/api/connections/myconnection/features/repositories -
getFeatureRepositories(String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
featuresRepositories(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List features provided by a features repository
-
karaf@root()> cave:deployer-feature-repo-provide mvn:foo/bar/1.0/xml/features -
curl -X GET -H "featuresRepositoryUrl: mvn:foo/bar/1.0/xml/features" http://localhost:8181/cave/deployer/api/features/repository -
getProvidedFeatures(String featuresRepositoryUrl)operation on theorg.apache.karaf.cave:type=deployerMBean. -
providedFeatures(String featuresRepositoryUrl)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Remove features repositories
-
karaf@root()> cave:deployer-feature-repo-remove myconnection mvn:foo/bar/1.0/xml/features -
curl -X DELETE -H "artifactUrl: mvn:foo/bar/1.0/xml/features" http://localhost:8181/cave/deployer/api/connections/myconnection/features/repositories -
removeFeatureRepository(String repository, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
removeFeaturesRepository(String featuresRepositoryUrl, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Install features
-
karaf@root()> cave:deployer-feature-install myconnection myfeature -
curl -X POST http://localhost:8181/cave/deployer/api/connections/myconnection/features/myfeature -
installFeature(String feature, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
installFeature(String feature, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List features
-
karaf@root()> cave:deployer-feature-list myconnection -
curl -X GET http://localhost:8181/cave/deployer/api/connections/myconnection/features -
getFeatures(String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
features(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List installed features
-
karaf@root()> cave:deployer-feature-installed-list myconnection -
installedFeatures(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Uninstall features
-
karaf@root()> cave:deployer-feature-uninstall myconnection myfeature -
curl -X DELETE http://localhost:8181/cave/deployer/api/connections/myconnection/features/myfeature -
uninstallFeature(String feature, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
uninstallFeature(String feature, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
KARs
Install KAR
-
karaf@root()> cave:deployer-kar-install myconnection mvn:foo/bar/1.0/kar -
curl -X POST -H "artifactUrl: mvn:foo/bar/1.0/kar" http://localhost:8181/cave/deployer/api/connections/myconnection/kars -
installKar(String url, String connection)operation on theorg.apache.karaf.cave:typye=deployerMBean. -
installKar(String karUrl, String connection)on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List KARs
-
karaf@root()> cave:deployer-kar-list myconnection -
curl -X GET http://localhost:8181/cave/deployer/api/connections/myconnection/kars -
getKars(String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
kars(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Uninstall KAR
-
karaf@root()> cave:deployer-kar-uninstall myconnection mykar -
curl -X DELETE http://localhost:8181/cave/deployer/api/connections/myconnection/kars/mykar -
uninstallKar(String id, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
uninstallKar(String id, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Bundles
Install bundle
-
karaf@root()> cave:deployer-bundle-install myconnection mvn:foo/bar/1.0 -
curl -X POST -H "artifactUrl: mvn:foo/bar/1.0" http://localhost:8181/cave/deployer/api/connections/myconnection/bundles -
installBundle(String url, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
installBundle(String artifactUrl, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List bundles
-
karaf@root()> cave:deployer-bundle-list myconnection -
curl -X GET http://localhost:8181/cave/deployer/api/connections/myconnection/bundles -
getBundles(String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
bundles(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Start bundle
-
karaf@root()> cave:deployer-bundle-start myconnection 81 -
curl -X POST http://localhost:8181/cave/deployer/api/connections/myconnection/bundles/81/start -
startBundle(String id, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
startBundle(String id, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Stop bundle
-
karaf@root()> cave:deployer-bundle-stop myconnection 81 -
curl -X POST http://localhost:8181/cave/deployer/api/connections/myconnection/bundles/81/stop -
stopBundle(String id, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
stopBundle(String id, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Uninstall bundle
-
karaf@root()> cave:deployer-bundle-uninstall myconnection 81 -
curl -X DELETE http://localhost:8181/cave/deployer/api/connections/myconnection/bundles/81 -
uninstallBundle(String id, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
uninstallBundle(String id, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Configurations
Create configuration
-
karaf@root()> cave:deployer-config-create myconnection myconfig -
curl -X POST http://localhost:8181/cave/deployer/api/connections/myconnection/configurations/myconfig -
createConfig(String pid, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
createConfig(String pid, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Create configuration factory
-
karaf@root()> cave:deployer-config-factory-create myconnection myfactory alias -
curl -X POST http://localhost:8181/cave/deployer/api/connections/myconnection/configurations/factories/myfactory -
createConfigFactory(String factoryPid, String alias, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
createConfigurationFactory(String factoryPid, String alias, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List configurations
-
karaf@root()> cave:deployer-config-list myconnection -
curl -X GET http://localhost:8181/cave/deployer/api/connections/myconnection/configurations -
configs(String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
configs(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Set configuration property
-
karaf@root()> cave:deployer-config-property-set myconnection myconfiguration myproperty myvalue -
setConfigProperty(String pid, String key, String value, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
setConfigProperty(String pid, String key, String value, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List configuration properties
-
karaf@root()> cave:deployer-config-property-list myconnection myconfiguration -
curl -X GET http://localhost:8181/cave/deployer/api/connections/myconnection/configurations/myconfiguration/properties -
getConfigProperties(String pid, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
configProperties(String pid, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Delete configuration property
-
karaf@root()> cave:deployer-config-property-delete myconnection myconfiguration myproperty -
deleteConfigProperty(String pid, String key, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
deleteConfigProperty(String pid, String key, String connection)methood on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Delete configuration
-
karaf@root()> cave:deployer-config-delete myconnection myconfiguration -
curl -X DELETE http://localhost:8181/cave/deployer/api/connections/myconnection/configurations/myconfiguration -
deleteConfig(String pid, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
deleteConfig(String pid, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Karaf Cellar cluster
Cave Deployer is able to administrate a Karaf Cellar cluster.
List cluster nodes
-
cave:deployer-cluster-node-list myconnection -
curl -X GET http://localhost:8181/cave/deployer/api/cluster/nodes -
getClusterNodes(String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
clusterNodes(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
List cluster groups
-
cave:deployer-cluster-group-list myconnection -
curl -X GET http://localhost:8181/cave/deployer/api/cluster/groups -
getClusterGroups(String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
clusterGroups(String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Add features repository to cluster group
-
cave:deployer-cluster-feature-repo-add myconnection myclustergroup mvn:foo/bar/1.0/xml/features -
curl -X POST -H "url: mvn:foo/bar/1.0/xml/features" http://localhost:8181/cave/deployer/api/connections/myconnection/cluster/groups/myclustergroup/features/repositories -
clusterFeatureRepositoryAdd(String url, String clusterGroup, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
clusterAddFeaturesRepository(String url, String clusterGroup, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Remove features repository from cluster group
-
cave:cluster-feature-repo-remove myconnection myclustergroup mvn:foo/bar/1.0/xml/features -
curl -X DELETE -H "url: mvn:foo/bar/1.0/xml/features" http://localhost:8181/cave/deployer/api/connections/myconnection/cluster/groups/myclustergroup/features/repositories -
clusterFeatureRepositoryRemove(String url, String clusterGroup, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
clusterRemoveFeaturesRepository(String url, String clusterGroup, String Connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Install feature on cluster group
-
cave:deployer-cluster-feature-install myconnection mygroup myfeature -
curl -X POST http://localhost:8181/cave/deployer/api/connections/myconnection/cluster/groups/mygroup/features/myfeature -
clusterFeatureInstall(String feature, String clusterGroup, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
clusterFeatureInstall(String feature, String clusterGroup, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.
Uninstall feature from cluster group
-
cave:deployer-cluster-feature-uninstall myconnection mygroup myfeature -
curl -X DELETE http://localhost:8181/cave/deployer/api/connections/myconnection/cluster/groups/mygroup/features/myfeature -
clusterFeatureUninstall(String feature, String clusterGroup, String connection)operation on theorg.apache.karaf.cave:type=deployerMBean. -
clusterFeatureUninstall(String feature, String clusterGroup, String connection)method on theorg.apache.karaf.cave.deployer.DeployerServiceservice.