org.apache.sling.maven.bundlesupport
Class BundleInstallMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.sling.maven.bundlesupport.BundleInstallMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

public class BundleInstallMojo
extends org.apache.maven.plugin.AbstractMojo

Install an OSGi bundle to a running Sling instance.


Field Summary
protected  java.lang.String mimeType
          The content type / mime type used for the HTTP PUT (if sling.usePut=true).
protected  org.apache.maven.project.MavenProject project
          The Maven project.
protected  java.lang.String slingUrl
          The URL of the running Sling instance.
protected  java.lang.String slingUrlSuffix
          An optional url suffix which will be appended to the sling.url for use as the real target url.
protected  boolean usePut
          If a simple HTTP PUT should be used instead of the standard POST to the felix console.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
BundleInstallMojo()
           
 
Method Summary
protected  void addConfiguration(org.apache.commons.httpclient.HttpClient client, java.lang.String targetURL, java.lang.String dir, java.lang.String path)
          Add a new configuration for the file system provider
protected  java.lang.String checkWebConsoleVersion(java.lang.String targetUrl)
          Try to get the version of the web console
protected  void configure(java.lang.String targetURL, java.io.File file)
          Add configurations to a running OSGi instance for initial content.
 void execute()
           
protected  java.lang.String getBundleFileName()
           
protected  java.lang.String getBundleSymbolicName(java.io.File jarFile)
          Returns the symbolic name of the given bundle.
protected  java.util.Map getCurrentFileProviderConfigs(java.lang.String targetURL, org.apache.commons.httpclient.HttpClient client)
          Return all file provider configs for this project
protected  org.apache.commons.httpclient.HttpClient getHttpClient()
          Get the http client
protected  java.util.jar.Manifest getManifest(java.io.File bundleFile)
          Get the manifest from the File.
protected  java.lang.String getPutURL(java.lang.String targetURL, java.lang.String fileName)
          Returns the URL for PUT or DELETE by appending the filename to the targetURL.
protected  java.lang.String getTargetURL()
          Returns the combination of sling.url and sling.urlSuffix.
protected  void post(java.lang.String targetURL, java.io.File file)
           
protected  void put(java.lang.String targetURL, java.io.File file)
           
protected  void removeConfiguration(org.apache.commons.httpclient.HttpClient client, java.lang.String targetURL, java.lang.String pid)
           
protected  void throwWebConsoleTooOldException()
          Helper method to throw a meaningful exception for an outdated felix web console.
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

slingUrl

protected java.lang.String slingUrl
The URL of the running Sling instance.


slingUrlSuffix

protected java.lang.String slingUrlSuffix
An optional url suffix which will be appended to the sling.url for use as the real target url. This allows to configure different target URLs in each POM, while using the same common sling.url in a parent POM (eg. sling.url=http://localhost:8080 and sling.urlSuffix=/project/specific/path). This is typically used in conjunction with a HTTP PUT (sling.usePut=true).


usePut

protected boolean usePut
If a simple HTTP PUT should be used instead of the standard POST to the felix console. In the uninstall goal, a HTTP DELETE will be used.


mimeType

protected java.lang.String mimeType
The content type / mime type used for the HTTP PUT (if sling.usePut=true).


project

protected org.apache.maven.project.MavenProject project
The Maven project.

Constructor Detail

BundleInstallMojo

public BundleInstallMojo()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException
Specified by:
execute in interface org.apache.maven.plugin.Mojo
Throws:
org.apache.maven.plugin.MojoExecutionException

getBundleFileName

protected java.lang.String getBundleFileName()

getTargetURL

protected java.lang.String getTargetURL()
Returns the combination of sling.url and sling.urlSuffix.


getPutURL

protected java.lang.String getPutURL(java.lang.String targetURL,
                                     java.lang.String fileName)
Returns the URL for PUT or DELETE by appending the filename to the targetURL.


throwWebConsoleTooOldException

protected void throwWebConsoleTooOldException()
                                       throws org.apache.maven.plugin.MojoExecutionException
Helper method to throw a meaningful exception for an outdated felix web console.

Throws:
org.apache.maven.plugin.MojoExecutionException

getHttpClient

protected org.apache.commons.httpclient.HttpClient getHttpClient()
Get the http client


post

protected void post(java.lang.String targetURL,
                    java.io.File file)
             throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

put

protected void put(java.lang.String targetURL,
                   java.io.File file)
            throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

configure

protected void configure(java.lang.String targetURL,
                         java.io.File file)
                  throws org.apache.maven.plugin.MojoExecutionException
Add configurations to a running OSGi instance for initial content.

Parameters:
targetURL - The web console base url
file - The artifact (bundle)
Throws:
org.apache.maven.plugin.MojoExecutionException

removeConfiguration

protected void removeConfiguration(org.apache.commons.httpclient.HttpClient client,
                                   java.lang.String targetURL,
                                   java.lang.String pid)
                            throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

addConfiguration

protected void addConfiguration(org.apache.commons.httpclient.HttpClient client,
                                java.lang.String targetURL,
                                java.lang.String dir,
                                java.lang.String path)
                         throws org.apache.maven.plugin.MojoExecutionException
Add a new configuration for the file system provider

Throws:
org.apache.maven.plugin.MojoExecutionException

getCurrentFileProviderConfigs

protected java.util.Map getCurrentFileProviderConfigs(java.lang.String targetURL,
                                                      org.apache.commons.httpclient.HttpClient client)
                                               throws org.apache.maven.plugin.MojoExecutionException
Return all file provider configs for this project

Parameters:
targetURL - The targetURL of the webconsole
client - The http client
Returns:
A map (may be empty) with the pids as keys and a string array containing the path and the root
Throws:
org.apache.maven.plugin.MojoExecutionException

getManifest

protected java.util.jar.Manifest getManifest(java.io.File bundleFile)
                                      throws java.io.IOException
Get the manifest from the File.

Parameters:
bundleFile - The bundle jar
Returns:
The manifest.
Throws:
java.io.IOException

checkWebConsoleVersion

protected java.lang.String checkWebConsoleVersion(java.lang.String targetUrl)
Try to get the version of the web console

Returns:
The version or null if version is not detectable.

getBundleSymbolicName

protected java.lang.String getBundleSymbolicName(java.io.File jarFile)
Returns the symbolic name of the given bundle. If the jarFile does not contain a manifest with a Bundle-SymbolicName header null is returned. Otherwise the value of the Bundle-SymbolicName header is returned.

This method may also be used to check whether the file is a bundle at all as it is assumed, that only if the file contains an OSGi bundle will the Bundle-SymbolicName manifest header be set.

Parameters:
jarFile - The file providing the bundle whose symbolic name is requested.
Returns:
The bundle's symbolic name from the Bundle-SymbolicName manifest header or null if no manifest exists in the file or the header is not contained in the manifest. However, if null is returned, the file may be assumed to not contain an OSGi bundle.


Copyright © 2007-2009. All Rights Reserved.