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 - Using Annotations - Quick Start
Date Thu, 12 May 2011 21:25:00 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+Dependency+Manager+-+Using+Annotations+-+Quick+Start">Apache
Felix Dependency Manager - Using Annotations - Quick Start</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~pderop">Pierre
De Rop</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" >			&lt;version&gt;3.0.0&lt;/version&gt;
<br>		&lt;/dependency&gt; <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
	&lt;dependency&gt; <br>			&lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
<br>			&lt;artifactId&gt;org.apache.felix.gogo.runtime&lt;/artifactId&gt;
<br>			&lt;version&gt;0.6.0&lt;/version&gt; <br>		&lt;/dependency&gt;
<br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;/dependencies&gt; <br>
&lt;build&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="ApacheFelixDependencyManager-UsingAnnotations-QuickStart-QuickStart"></a>Quick
Start</h1>

<p>This sections presents a simple "Hello World" component defined using annotations,
and also explains how to build the bundle using either Bnd or Maven.</p>

<h2><a name="ApacheFelixDependencyManager-UsingAnnotations-QuickStart-HelloWorldComponent"></a>Hello
World Component</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> org.apache.felix.dependencymanager.samples.annotation.hello;

<span class="code-keyword">import</span> org.apache.felix.dm.annotation.api.Component;
<span class="code-keyword">import</span> org.apache.felix.dm.annotation.api.Start;

@Component
<span class="code-keyword">public</span> class HelloWorld {
    @Start
    <span class="code-keyword">public</span> void activate() {
       <span class="code-object">System</span>.out.println(<span class="code-quote">"Hello
world !"</span>);
    }
}
</pre>
</div></div>

<h2><a name="ApacheFelixDependencyManager-UsingAnnotations-QuickStart-CompilingwithBnd%3A"></a>Compiling
with Bnd:</h2>

<p>The annotations must be processed at compilation phase and you have to use a special
Bnd plugin (declared using the "-plugin" bnd directive):</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>Bundle-Name: Hello World Using Dependency Manager Annotations
Bundle-SymbolicName: org.apache.felix.dependencymanager.samples.annotation.hello
Import-Package: *
Private-Package: org.apache.felix.dependencymanager.samples.annotation.hello
-plugin org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn
</pre>
</div></div>

<h2><a name="ApacheFelixDependencyManager-UsingAnnotations-QuickStart-CompilingwithMaven%3A"></a>Compiling
with Maven:</h2>

<p>When compiling with Maven, you have to use the Dependency Manager Maven annotation
plugin:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>&lt;?xml version="1.0"?&gt;
&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;properties&gt;
		&lt;osgi.version&gt;4.2.0&lt;/osgi.version&gt;
	&lt;/properties&gt;
	&lt;name&gt;Hello World Using Dependency Manager Annotations&lt;/name&gt;
	&lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
	&lt;artifactId&gt;org.apache.felix.dependencymanager.samples.annotation.hello&lt;/artifactId&gt;
	&lt;version&gt;3.0.0-SNAPSHOT&lt;/version&gt;
	&lt;packaging&gt;bundle&lt;/packaging&gt;
	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
			&lt;artifactId&gt;org.apache.felix.dependencymanager.annotation&lt;/artifactId&gt;
			&lt;version&gt;3.0.0&lt;/version&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;
	&lt;build&gt;
		&lt;plugins&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
				&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
				&lt;configuration&gt;
					&lt;source&gt;1.5&lt;/source&gt;
					&lt;target&gt;1.5&lt;/target&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
				&lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
				&lt;version&gt;2.3.4&lt;/version&gt;
				&lt;extensions&gt;true&lt;/extensions&gt;
				&lt;configuration&gt;
					&lt;instructions&gt;
						&lt;Bundle-Name&gt;Hello World Using Dependency Manager Annotations&lt;/Bundle-Name&gt;
						&lt;Bundle-SymbolicName&gt;org.apache.felix.dependencymanager.samples.annotation.hello&lt;/Bundle-SymbolicName&gt;
						&lt;Import-Package&gt;*&lt;/Import-Package&gt;
						&lt;Private-Package&gt;org.apache.felix.dependencymanager.samples.annotation.hello&lt;/Private-Package&gt;
					&lt;/instructions&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
				&lt;artifactId&gt;org.apache.felix.dependencymanager.annotation&lt;/artifactId&gt;
				&lt;version&gt;3.0.0&lt;/version&gt;
				&lt;executions&gt;
					&lt;execution&gt;
						&lt;goals&gt;
							&lt;goal&gt;scan&lt;/goal&gt;
						&lt;/goals&gt;
						&lt;configuration&gt;
							&lt;log&gt;info&lt;/log&gt;
						&lt;/configuration&gt;
					&lt;/execution&gt;
				&lt;/executions&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/build&gt;
&lt;/project&gt;
</pre>
</div></div>
    </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+Dependency+Manager+-+Using+Annotations+-+Quick+Start">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=26119924&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Dependency+Manager+-+Using+Annotations+-+Quick+Start?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message