felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Felix > Apache Felix File Install
Date Fri, 16 Mar 2012 09:25:01 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+File+Install">Apache
Felix File Install</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~gnodet">Guillaume
Nodet</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >|{{felix.fileinstall.bundles.startTransient}}|false|If
{{true}}, File Install will start the bundles transiently.| <br>|{{felix.fileinstall.start.level}}|false|If
set to a value different from {{0}}, File Install will set the start level for deployed bundles
to that value.| <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">|{{felix.fileinstall.disableConfigSave}}|true|If</span>
<span class="diff-added-words"style="background-color: #dfd;">|{{felix.fileinstall.enableConfigSave}}|true|If</span>
{{false}}, File Install will not write back in the file configurations changes.| <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Once started, the values
of these properties are printed to the console. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="ApacheFelixFileInstall-ApacheFelixFileInstall"></a>Apache
Felix File Install</h1>

<p>File Install is a directory based OSGi management agent. It uses a directory in the
file system to install and start a bundle when it is first placed there. It updates the bundle
when you update the bundle file in the directory and, when the file is deleted, it will stop
and uninstall the bundle.</p>

<p>File Install can do the same for configuration configuration files. This surprisingly
simple bundle is very powerful because there are so many programs that work with the file
system. For example:</p>

<ul>
	<li>If you use Ant, you can just copy the resulting bundle to the watched directory.</li>
	<li>You can download bundles from the web and directly install them without any extra
effort.</li>
	<li>You can easily drag and drop bundles in and out of the framework.</li>
</ul>


<h2><a name="ApacheFelixFileInstall-Setup"></a>Setup</h2>

<p>The bundle runs on any framework. For its configuration, it will use the following
system properties:</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Property</th>
<th class='confluenceTh'>Default</th>
<th class='confluenceTh'>Description</th>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.poll</tt></td>
<td class='confluenceTd'>2000 ms</td>
<td class='confluenceTd'>Number of milliseconds between 2 polls of the directory</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.dir</tt></td>
<td class='confluenceTd'>./load</td>
<td class='confluenceTd'>The name of the directory to watch. Several directories can
be specified by using a comma separated list.</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.log.level</tt></td>
<td class='confluenceTd'>0</td>
<td class='confluenceTd'>Threshold of logging information</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.bundles.new.start</tt></td>
<td class='confluenceTd'>true</td>
<td class='confluenceTd'>Automatically start newly discovered bundles</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.filter</tt></td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>A regular expression to be used to filter file names</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.tmpdir</tt></td>
<td class='confluenceTd'>./tmp</td>
<td class='confluenceTd'>The name of the temporary directory to use with exploded or
transformed bundles</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.noInitialDelay</tt></td>
<td class='confluenceTd'>false</td>
<td class='confluenceTd'>Determines if File Install waits <tt>felix.fileinstall.poll</tt>
milliseconds before doing an initial scan or not.</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.bundles.startTransient</tt></td>
<td class='confluenceTd'>false</td>
<td class='confluenceTd'>If <tt>true</tt>, File Install will start the bundles
transiently.</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.start.level</tt></td>
<td class='confluenceTd'>false</td>
<td class='confluenceTd'>If set to a value different from <tt>0</tt>, File
Install will set the start level for deployed bundles to that value.</td>
</tr>
<tr>
<td class='confluenceTd'><tt>felix.fileinstall.enableConfigSave</tt></td>
<td class='confluenceTd'>true</td>
<td class='confluenceTd'>If <tt>false</tt>, File Install will not write
back in the file configurations changes.</td>
</tr>
</tbody></table>
</div>


<p>Once started, the values of these properties are printed to the console.</p>

<h2><a name="ApacheFelixFileInstall-Configurations"></a>Configurations</h2>

<p>Configuration files are plain property files (<tt>java.util.Property</tt>).
The format is simple:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>file ::= ( header | comment ) *
header ::= &lt;header&gt; ( ':' | '=' ) &lt;value&gt; ( '\&lt;nl&gt;
&lt;value&gt; ) *
comment ::= '#' &lt;any&gt;
</pre>
</div></div>

<p>Notice that this model only supports string properties. For example:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre># default port
ftp.port = 21
</pre>
</div></div>

<p>Configuration file names are related to the PID and factory PID. The structure of
the file name is as follows:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>filename ::= &lt;pid&gt; ( '-' &lt;subname&gt; )? '.cfg'
</pre>
</div></div>

<p>If the form is <tt>&lt;pid&gt;.cfg</tt>, the file contains the
properties for a Managed Service. The <tt>&lt;pid&gt;</tt> is then the
PID of the Managed Service. See the Configuration Admin service for details.</p>

<p>When a Managed Service Factory is used, the situation is different. The <tt>&lt;pid&gt;</tt>
part then describes the PID of the Managed Service Factory. You can pick any <tt>&lt;subname&gt;</tt>,
this bundle will then create an instance for the factory for each unique name. For example:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>com.acme.xyz.cfg // configuration for Managed Service
// com.acme.xyz
com.acme.abc-default.cfg // Managed Service Factory,
// creates an instance for com.acme.abc
</pre>
</div></div>

<p>If a configuration managed by File Install is modified, File Install will write the
configuration back to a property file to ensure peristence across restarts.</p>

<h2><a name="ApacheFelixFileInstall-Propertysubstitutioninconfigurationfiles"></a>Property
substitution in configuration files</h2>

<p>It is possible to use system properties to specify the values of properties in configuration
files. This is achieved through system property substitution, which is instigated by using
<tt>${&lt;property&gt;</tt>} syntax, where &lt;property&gt; is
the name of a system property to substitute.  Bundle context properties will take precedence
over system properties if available.<br/>
Example:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>ftp.port = ${system.ftp.port}
</pre>
</div></div>

<h2><a name="ApacheFelixFileInstall-WatchingmultipledirectorieswithFileInstall"></a>Watching
multiple directories with File Install</h2>

<p>Starting with version 3.1.0 it is possible to specify several directories to watch
with the system property <tt>felix.fileinstall.dir</tt>; this property can either
point to a single directory or a comma separated list of directories. In addition, Apache
Felix File Install provides a ManagedServiceFactory to create multiple instances of File Install.
Asuming you have a File Install bundle watching a <tt>bundles</tt> folder, creating
a new instance is as simple as creating a new configuration file <tt>org.apache.felix.fileinstall-&lt;pid&gt;.cfg</tt>
in that folder (substitute &lt;pid&gt; with a unique Id for the new service instance):</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>org.apache.felix.fileinstall-configDir.cfg</b></div><div
class="codeContent panelContent">
<pre class="code-java">
felix.fileinstall.poll=2000
felix.fileinstall.dir=/configDir
felix.fileinstall.debug=-1
felix.fileinstall.filter=.*\\.cfg
felix.fileinstall.bundles.<span class="code-keyword">new</span>.start=<span
class="code-keyword">false</span>
</pre>
</div></div>

<h2><a name="ApacheFelixFileInstall-Explodedbundles"></a>Exploded bundles</h2>

<p>Apache Felix File Install has the ability to watch for exploded bundles and automatically
update such bundles if the content is changed in any way.  If a watched directory contains
a sub directory, its content will be jar'ed and deployed to the OSGi framework.  Any change
to a file in this directory or one of its subdirectories will result in the directory to be
jar'ed again and the corresponding bundle to be updated.</p>

<h2><a name="ApacheFelixFileInstall-Customartifacts"></a>Custom artifacts</h2>

<p>Apache Felix File Install can support deployment of custom artifacts.  By default,
configurations and plain OSGi bundles are supported, but other kind of artifacts can be deployed
through custom artifact handlers.</p>

<p>To add support for a custom artifact, a service implementing one of <tt>org.apache.felix.fileinstall.ArtifactListener</tt>'s
sub interfaces must be registered in the OSGi registry.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+File+Install">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=79725&revisedVersion=12&originalVersion=11">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+File+Install?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message