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 Dependency Manager - Getting Started
Date Tue, 22 Dec 2009 00:54:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Dependency+Manager+-+Getting+Started">Apache
Felix Dependency Manager - Getting Started</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~marrs">Marcel
Offermans</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="ApacheFelixDependencyManager-GettingStarted-GettingStarted"></a>Getting
Started</h2>

<p>When developing an OSGi bundle that has dependencies and possibly registers services,
there are two classes in particular we need to implement:</p>
<ol>
	<li>The bundle activator which controls the life-cycle of the bundle.</li>
	<li>The actual service implementation, which can be a POJO.</li>
</ol>


<p>When using the dependency manager, your bundle activator is a subclass of DependencyActivatorBase.
It needs to implement two life cycle methods: init and destroy. Both methods take two arguments:
BundleContext and DependencyManager. The latter is your interface to the declarative API you
can use to define your services and dependencies.</p>

<p>The following paragraphs will show various examples that explain how to do this.
Subsequently, some more advanced scenarios will be covered that involve listening to dependency
and service state changes and interacting with the OSGi framework from within your service
implementation.</p>

<h3><a name="ApacheFelixDependencyManager-GettingStarted-Registeringaservice"></a>Registering
a service</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> class Activator <span class="code-keyword">extends</span>
DependencyActivatorBase {
    <span class="code-comment">// TODO :)
</span>}
</pre>
</div></div>

<h3><a name="ApacheFelixDependencyManager-GettingStarted-Dependingonaservice"></a>Depending
on a service</h3>

<h3><a name="ApacheFelixDependencyManager-GettingStarted-Trackingserviceswithcallbacks"></a>Tracking
services with callbacks</h3>

<h3><a name="ApacheFelixDependencyManager-GettingStarted-Dependingonaconfiguration"></a>Depending
on a configuration</h3>

<h3><a name="ApacheFelixDependencyManager-GettingStarted-..."></a>...</h3>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Dependency+Manager+-+Getting+Started">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=9374243&revisedVersion=2&originalVersion=1">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Dependency+Manager+-+Getting+Started?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message