| <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html><head> |
| |
| |
| |
| <title>Apache Felix - How to use iPOJO Annotations</title> |
| <link rel="stylesheet" href="how-to-use-ipojo-annotations_files/site.css" type="text/css" media="all"> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| </head><body> |
| <div class="title"><div class="logo"><a href="http://felix.apache.org/site/index.html"><img alt="Apache Felix" src="how-to-use-ipojo-annotations_files/logo.png" border="0"></a></div><div class="header"><a href="http://www.apache.org/"><img alt="Apache" src="how-to-use-ipojo-annotations_files/apache.png" border="0"></a></div></div> |
| <div class="menu"> |
| <ul> |
| <li><a href="http://felix.apache.org/site/news.html" title="news">news</a></li> |
| <li><a href="http://felix.apache.org/site/license.html" title="license">license</a></li> |
| <li><a href="http://felix.apache.org/site/downloads.cgi" rel="nofollow">downloads</a></li> |
| <li><a href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</a></li> |
| <li><a href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</a></li> |
| <li><a href="http://felix.apache.org/site/contributing.html" title="Contributing">contributing</a></li> |
| <li><a href="http://www.apache.org/" rel="nofollow">asf</a></li> |
| <li><a href="http://www.apache.org/foundation/sponsorship.html" rel="nofollow">sponsorship</a></li> |
| <li><a href="http://www.apache.org/foundation/thanks.html" rel="nofollow">sponsors</a> |
| <!-- ApacheCon Ad --> |
| <iframe src="how-to-use-ipojo-annotations_files/button.html" style="border-width: 0pt; float: left;" scrolling="no" frameborder="0" height="135" width="135"></iframe> |
| <p style="height: 100px;"> |
| <!-- ApacheCon Ad --> |
| </p></li></ul> </div> |
| <div class="main"> |
| <style type="text/css"> |
| @import url(http://people.apache.org/~clement/ipojo/site/superfish.css); |
| </style> |
| |
| <style type="text/css"> |
| @import url(http://people.apache.org/~clement/ipojo/site/style.css); |
| </style> |
| |
| <p> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shCore.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushCSharp.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushPhp.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushJScript.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushVb.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushSql.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushXml.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushShell.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushDelphi.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushPython.js"></script> |
| <script class="javascript" src="how-to-use-ipojo-annotations_files/shBrushJava.js"></script> |
| |
| <script type="text/javascript" src="how-to-use-ipojo-annotations_files/jquery-1.js"></script> |
| <script type="text/javascript" src="how-to-use-ipojo-annotations_files/hoverIntent.js"></script> |
| <script type="text/javascript" src="how-to-use-ipojo-annotations_files/superfish.js"></script> |
| <script type="text/javascript" src="how-to-use-ipojo-annotations_files/supersubs.js"></script> |
| |
| <script type="text/javascript"> |
| |
| $(document).ready(function(){ |
| $("ul.sf-menu").supersubs({ |
| minWidth: 14, // minimum width of sub-menus in em units |
| maxWidth: 30, // maximum width of sub-menus in em units |
| extraWidth: 1 // extra width can ensure lines don't sometimes turn over |
| // due to slight rounding differences and font-family |
| }).superfish(); // call supersubs first, then superfish, so that subs are |
| // not display:none when measuring. Call before initialising |
| // containing tabs for same reason. |
| }); |
| |
| </script> |
| </p><div class="main"> |
| <div class="page-header"> |
| <img src="how-to-use-ipojo-annotations_files/header.png" class="header"> |
| <a href="http://ipojo.org/"><img src="how-to-use-ipojo-annotations_files/ipojo.png" class="header-logo" width="225"></a> |
| <ul class="sf-menu sf-js-enabled sf-shadow" id="ipojo-menu"> |
| <li class="current"> |
| <!-- Menu Overview --> |
| <a href="" class="sf-with-ul">Overview<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| <li style="white-space: normal; float: left; width: 100%;"> |
| <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo.html" title="Apache Felix iPOJO">Home</a> |
| </li> |
| <li style="white-space: normal; float: left; width: 100%;"> |
| <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-why-choose-ipojo.html" title="apache-felix-ipojo-why-choose-ipojo">Why choose iPOJO</a> |
| </li> |
| <li style="white-space: normal; float: left; width: 100%;"> |
| <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-successstories.html" title="apache-felix-ipojo-successstories">Success stories</a> |
| </li> |
| <li style="white-space: normal; float: left; width: 100%;"> |
| <a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-feature-overview.html" title="Apache Felix iPOJO Feature Overview">Features</a> |
| </li> |
| </ul> |
| </li> |
| |
| <li class=""> |
| <!-- Menu download --> |
| </li><li> |
| <a href="http://felix.apache.org/site/download.html" title="Download">Download </a> |
| </li> |
| |
| <li class=""> |
| <!-- Menu Documentation --> |
| <a href="" class="sf-with-ul">Documentation<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| <!-- sub- menu : getting started --> |
| <li style="white-space: normal; float: left; width: 100%;" class=""> |
| <a style="float: none; width: auto;" href="" class="sf-with-ul">Getting Started<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-in-10-minutes.html" title="iPOJO in 10 minutes">iPOJO in 10 minutes</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="" title="How to use iPOJO Annotations">Using Annotations</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-hello-word-maven-based-tutorial.html" title="iPOJO Hello Word (Maven-Based) tutorial">Maven tutorial</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-advanced-tutorial.html" title="iPOJO Advanced Tutorial">Advanced tutorial</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-dosgi.html" title="apache-felix-ipojo-dosgi">Using Distributed OSGi</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-composition-tutorial.html" title="iPOJO Composition Tutorial">Application Composition</a></li> |
| </ul> |
| </li> <!-- end of getting started --> |
| <!-- sub menu : Describing Components --> |
| <li style="white-space: normal; float: left; width: 100%;" class=""> |
| <a style="float: none; width: auto;" href="http://felix.apache.org/site/describing-components.html" class="sf-with-ul">Describing components<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/service-requirement-handler.html" title="Service Requirement Handler">Requiring a service</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/providing-osgi-services.html" title="Providing OSGi services">Providing a service</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/lifecycle-callback-handler.html" title="Lifecycle Callback Handler">Lifecycle management</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/configuration-handler.html" title="Configuration Handler">Configuration</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/architecture-handler.html" title="Architecture Handler">Introspection</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/controller-lifecycle-handler.html" title="Controller Lifecycle Handler">Impacting the lifecycle</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/event-admin-handlers.html" title="Event Admin Handlers">Asynchronous communication</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-jmx-handler.html" title="iPOJO JMX Handler">JMX management</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/extender-pattern-handler.html" title="Extender Pattern Handler">Extender pattern</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/white-board-pattern-handler.html" title="White Board Pattern Handler">Whiteboard pattern</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/temporal-service-dependency.html" title="Temporal Service Dependency">Temporal dependencies</a></li> |
| </ul> |
| </li> <!-- End of describing components --> |
| <!-- sub- menu : User Guide --> |
| <li style="white-space: normal; float: left; width: 100%;" class=""> |
| <a style="float: none; width: auto;" href="" class="sf-with-ul">User Guide<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/using-xml-schemas.html" title="Using XML Schemas">XML Schemas</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-api.html" title="apache-felix-ipojo-api">API</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-testing-components.html" title="apache-felix-ipojo-testing-components">Testing components</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-eclipse-integration.html" title="apache-felix-ipojo-eclipse-integration">Eclipse Integration</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-faq.html" title="iPOJO FAQ">FAQ</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-reference-card.html" title="iPOJO-Reference-Card">Reference Card</a></li> |
| </ul> |
| </li> <!-- end of user guide --> |
| <!-- sub- menu : Dev Guide --> |
| <li class="" style="white-space: normal; float: left; width: 100%;"> |
| <a style="float: none; width: auto;" href="" class="sf-with-ul">Advanced Topics<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="left: 14em; float: none; width: 14em; display: none; visibility: hidden;"> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/ipojo/api/1.2.0" rel="nofollow">Javadoc</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/how-to-write-your-own-handler.html" title="How to write your own handler">Handler guide</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/how-to-use-ipojo-manipulation-metadata.html" title="How to use iPOJO Manipulation Metadata">Manipulation Metadata </a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/dive-into-the-ipojo-manipulation-depths.html" title="Dive into the iPOJO Manipulation depths">Dive into the iPOJO Manipulation depths</a></li> |
| </ul> |
| </li> <!-- End of Dev guide --> |
| </ul> |
| </li> <!-- End of doc --> |
| <!-- Menu 4 : Tools --> |
| <li class=""> |
| <a href="" class="sf-with-ul">Tools<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-ant-task.html" title="iPOJO Ant Task">Ant Task</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-eclipse-plug-in.html" title="iPOJO Eclipse Plug-in">Eclipse Plugin</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-maven-plug-in.html" title="iPOJO Maven Plug-in">Maven Plugin</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-online-manipulator.html" title="apache-felix-ipojo-online-manipulator">Online Manipulator</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/ipojo-webconsole-plugin.html" title="iPOJO Webconsole Plugin">Webconsole plugin</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-junit4osgi.html" title="apache-felix-ipojo-junit4osgi">Junit4OSGi</a></li> |
| </ul> |
| </li><!-- End of tools --> |
| <!-- Menu 5 : Misc --> |
| <li class=""> |
| <a href="" class="sf-with-ul">Misc<span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span><span class="sf-sub-indicator"> »</span></a> |
| <ul style="float: none; width: 14em; display: none; visibility: hidden;"> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-issuestracker.html" title="apache-felix-ipojo-issuestracker">Issues Tracker</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-supportedvms.html" title="apache-felix-ipojo-supportedVMs">Supported JVMs</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/apache-felix-ipojo-supportedosgi.html" title="apache-felix-ipojo-supportedOSGi">Supported OSGi Implementations</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://ipojo-dark-side.blogspot.com/" rel="nofollow">iPOJO's Dark Side Blog</a></li> |
| <li style="white-space: normal; float: left; width: 100%;"><a style="float: none; width: auto;" href="http://felix.apache.org/site/article-presentations.html" title="Article & Presentations">Article & Presentations</a></li> |
| </ul> |
| </li><!-- End of misc --> |
| </ul> <!-- End of the menu --> |
| </div> <!-- Page header --> |
| |
| |
| <div class="content"> |
| |
| <h1><a name="HowtouseiPOJOAnnotations-HowtouseiPOJOannotations"></a>How to use iPOJO annotations</h1> |
| |
| <p><em>You can use annotations to define your component types. This page presents supported iPOJO annotations.</em></p> |
| |
| <div class="toc"> |
| <ul> |
| <li><a href="#HowtouseiPOJOAnnotations-GettingiPOJOAnnotations%253A">Getting iPOJO Annotations:</a></li> |
| <ul> |
| <li><a href="#HowtouseiPOJOAnnotations-InEclipse">In Eclipse</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-InMaven">In Maven</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-InAnt">In Ant</a></li> |
| </ul> |
| <li><a href="#HowtouseiPOJOAnnotations-Anexampleofusage">An example of usage</a></li> |
| <ul> |
| <li><a href="#HowtouseiPOJOAnnotations-HelloServiceProvider">Hello Service Provider</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-HelloServiceConsumer">Hello Service Consumer</a></li> |
| </ul> |
| <li><a href="#HowtouseiPOJOAnnotations-DefinedAnnotations">Defined Annotations</a></li> |
| <ul> |
| <li><a href="#HowtouseiPOJOAnnotations-@Component">@Component</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Provides">@Provides</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Requires">@Requires</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@ServiceProperty">@ServiceProperty</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Property">@Property</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Updated%255CNewsinthe1.3.0SNAPSHOTversion%255C">@Updated <b>[ News in the 1.3.0-SNAPSHOT version ]</b></a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Bind">@Bind</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Unbind">@Unbind</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Validate">@Validate</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-@Invalidate">@Invalidate</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-TemporalDependencies%2528externalhandler%2529">Temporal Dependencies (external handler)</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-ExposinginstancesasaJMXMBean%2528externalhandler%2529">Exposing instances as a JMX MBean (external handler)</a></li> |
| </ul> |
| <li><a href="#HowtouseiPOJOAnnotations-AdvancedtopicsandFAQ">Advanced topics and FAQ</a></li> |
| <ul> |
| <li><a href="#HowtouseiPOJOAnnotations-Metadatafileandannotationmerge">Metadata file and annotation merge</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-Instancecreation">Instance creation</a></li> |
| <li><a href="#HowtouseiPOJOAnnotations-UsingCustomAnnotations">Using Custom Annotations</a></li> |
| </ul> |
| </ul></div> |
| |
| <h2><a name="HowtouseiPOJOAnnotations-GettingiPOJOAnnotations:"></a>Getting iPOJO Annotations:</h2> |
| |
| <p>iPOJO Annotations are defines inside the |
| org.apache.felix.ipojo.annotations project. You can download the Jar |
| file of this project from the <a href="http://felix.apache.org/site/download.html" title="Download">download</a> page. Sources are available on the <a href="http://felix.apache.org/site/sourcecode.html" rel="nofollow">Felix trunk</a>.<br> |
| Once added to your class path / build path / dependencies, you can use |
| the annotations as normal annotations. These annotations are |
| automatically processed by the iPOJO manipulator.</p> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-InEclipse"></a>In Eclipse</h3> |
| |
| <p>Add the org.apache.felix.ipojo.annotations jar file in your build |
| path. Do not forget to use a Java compiler accepting annotations (1.5 |
| or higher).</p> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-InMaven"></a>In Maven</h3> |
| |
| <p>Add the following dependency:</p> |
| <div class="code"> |
| <div class="dp-highlighter"><table class="dp-xml" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="tag"><</span><span>dependency</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>groupId</span><span class="tag">></span><span>org.apache.felix</span><span class="tag"></</span><span>groupId</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>artifactId</span><span class="tag">></span><span>org.apache.felix.ipojo.annotations</span><span class="tag"></</span><span>artifactId</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>version</span><span class="tag">></span><span>1.2.0</span><span class="tag"></</span><span>version</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"><span class="tag"></</span><span>dependency</span><span class="tag">></span><span> </span></td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><dependency> |
| <groupId>org.apache.felix</groupId> |
| <artifactId>org.apache.felix.ipojo.annotations</artifactId> |
| <version>1.2.0</version> |
| </dependency></textarea> |
| <script class="javascript"> |
| if(!window.newcodemacro_initialised) |
| { |
| window.newcodemacro_initialised = true; |
| window.oldonloadmethod = window.onload; |
| window.onload = function(){ |
| dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| if(window.oldonloadmethod) |
| { |
| window.oldonloadmethod(); |
| } |
| } |
| } |
| |
| </script> |
| </div> |
| |
| <p>Moreover, you need to set that the source code and the target code |
| are Java 1.5 code. To achieve this, just add the following plugin in |
| your plugins section:</p> |
| <div class="code"> |
| <div class="dp-highlighter"><table class="dp-xml" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="tag"><</span><span>plugin</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>groupId</span><span class="tag">></span><span>org.apache.maven.plugins</span><span class="tag"></</span><span>groupId</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>artifactId</span><span class="tag">></span><span>maven-compiler-plugin</span><span class="tag"></</span><span>artifactId</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>configuration</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"> <span class="tag"><</span><span>source</span><span class="tag">></span><span>1.5</span><span class="tag"></</span><span>source</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"> <span class="tag"><</span><span>target</span><span class="tag">></span><span>1.5</span><span class="tag"></</span><span>target</span><span class="tag">></span><span> </span></td></tr><tr><td class="line1"> <span class="tag"></</span><span>configuration</span><span class="tag">></span><span> </span></td></tr><tr><td class="line2"><span class="tag"></</span><span>plugin</span><span class="tag">></span><span> </span></td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-compiler-plugin</artifactId> |
| <configuration> |
| <source>1.5</source> |
| <target>1.5</target> |
| </configuration> |
| </plugin></textarea> |
| <script class="javascript"> |
| if(!window.newcodemacro_initialised) |
| { |
| window.newcodemacro_initialised = true; |
| window.oldonloadmethod = window.onload; |
| window.onload = function(){ |
| dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| if(window.oldonloadmethod) |
| { |
| window.oldonloadmethod(); |
| } |
| } |
| } |
| |
| </script> |
| </div> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-InAnt"></a>In Ant</h3> |
| |
| <p>Just add the org.apache.felix.ipojo.annotations jar file in your class path.</p> |
| |
| <h2><a name="HowtouseiPOJOAnnotations-Anexampleofusage"></a>An example of usage</h2> |
| |
| <p>To illustrate annotations usage, let taking the tutorial example. In this tutorial, there are two components:</p> |
| <ul> |
| <li>The first one provides the hello service</li> |
| <li>The second one uses the provided hello service<br> |
| You can download the archive containing the examples and a preconfigured version of Felix <a href="http://people.apache.org/%7Eclement/ipojo/tutorials/annotations/annotation-tutorial.zip" rel="nofollow">here</a>.</li> |
| </ul> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-HelloServiceProvider"></a>Hello Service Provider</h3> |
| |
| <p>The provider uses two annotations. The "component" annotation is |
| mandatory and defines that the class defines a component type. Then the |
| "provides" annotation just declare that the defined component type |
| provides a service.</p> |
| <div class="code"> |
| <div class="dp-highlighter"><table class="dp-c" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="keyword">package</span><span> ipojo.example.hello.impl; </span></td></tr><tr><td class="line2"> </td></tr><tr><td class="line1"><span class="keyword">import</span><span> ipojo.example.hello.Hello; </span></td></tr><tr><td class="line2"> </td></tr><tr><td class="line1"><span class="keyword">import</span><span> org.apache.felix.ipojo.annotations.Component; </span></td></tr><tr><td class="line2"><span class="keyword">import</span><span> org.apache.felix.ipojo.annotations.Provides; </span></td></tr><tr><td class="line1"> </td></tr><tr><td class="line2"><span class="comment">/**</span></td></tr><tr><td class="line1"><span class="comment"> * Component implementing the Hello service.</span></td></tr><tr><td class="line2"><span class="comment"> **/</span><span> </span></td></tr><tr><td class="line1"><span class="preprocessor">@Component</span><span> </span></td></tr><tr><td class="line2"><span class="preprocessor">@Provides</span><span> </span></td></tr><tr><td class="line1"><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> HelloImpl </span><span class="keyword">implements</span><span> Hello { </span></td></tr><tr><td class="line2"> <span class="keyword">public</span><span> String sayHello(String name) { </span></td></tr><tr><td class="line1"> <span class="keyword">return</span><span> </span><span class="string">"hello "</span><span> + name; </span></td></tr><tr><td class="line2"> } </td></tr><tr><td class="line1">} </td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">package ipojo.example.hello.impl; |
| |
| import ipojo.example.hello.Hello; |
| |
| import org.apache.felix.ipojo.annotations.Component; |
| import org.apache.felix.ipojo.annotations.Provides; |
| |
| /** |
| * Component implementing the Hello service. |
| **/ |
| @Component |
| @Provides |
| public class HelloImpl implements Hello { |
| public String sayHello(String name) { |
| return "hello " + name; |
| } |
| }</textarea> |
| <script class="javascript"> |
| if(!window.newcodemacro_initialised) |
| { |
| window.newcodemacro_initialised = true; |
| window.oldonloadmethod = window.onload; |
| window.onload = function(){ |
| dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| if(window.oldonloadmethod) |
| { |
| window.oldonloadmethod(); |
| } |
| } |
| } |
| |
| </script> |
| </div> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-HelloServiceConsumer"></a>Hello Service Consumer</h3> |
| |
| <p>The Hello Service Consumer use more annotations. First it used the |
| component annotation. To defines its "immediate" behavior, it add the |
| 'immediate' attribute.<br> |
| Then, it uses the requires annotation to define a service dependency. |
| Finally, it uses the validate and invalidate annotations to define |
| lifecycle callbacks.</p> |
| <div class="code"> |
| <div class="dp-highlighter"><table class="dp-c" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="keyword">package</span><span> ipojo.example.hello.client; </span></td></tr><tr><td class="line2"> </td></tr><tr><td class="line1"><span class="keyword">import</span><span> org.apache.felix.ipojo.annotations.Component; </span></td></tr><tr><td class="line2"><span class="keyword">import</span><span> org.apache.felix.ipojo.annotations.Invalidate; </span></td></tr><tr><td class="line1"><span class="keyword">import</span><span> org.apache.felix.ipojo.annotations.Requires; </span></td></tr><tr><td class="line2"><span class="keyword">import</span><span> org.apache.felix.ipojo.annotations.Validate; </span></td></tr><tr><td class="line1"> </td></tr><tr><td class="line2"><span class="keyword">import</span><span> ipojo.example.hello.Hello; </span></td></tr><tr><td class="line1"><span class="preprocessor"></span></td></tr><tr><td class="line2"><span class="preprocessor">@Component(name="AnnotedHelloClient", immediate=true)</span><span> </span></td></tr><tr><td class="line1"><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> HelloClient </span><span class="keyword">implements</span><span> Runnable { </span></td></tr><tr><td class="line2"><span class="preprocessor"></span></td></tr><tr><td class="line1"><span class="preprocessor">@Requires</span><span> </span></td></tr><tr><td class="line2"><span class="keyword">private</span><span> Hello[] m_hello; </span><span class="comment">// Service Dependency</span><span> </span></td></tr><tr><td class="line1"> </td></tr><tr><td class="line2"><span class="keyword">private</span><span> </span><span class="keyword">final</span><span> </span><span class="keyword">static</span><span> int DELAY=10000; </span></td></tr><tr><td class="line1"><span class="keyword">private</span><span> </span><span class="keyword">boolean</span><span> end; </span></td></tr><tr><td class="line2"> </td></tr><tr><td class="line1"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> run() { </span></td></tr><tr><td class="line2"> <span class="keyword">while</span><span> (!end) { </span></td></tr><tr><td class="line1"> <span class="keyword">try</span><span> { </span></td></tr><tr><td class="line2"> invoke(); </td></tr><tr><td class="line1"> Thread.sleep(DELAY); </td></tr><tr><td class="line2"> } <span class="keyword">catch</span><span> (InterruptedException ie) { } </span></td></tr><tr><td class="line1"> <span class="comment">/* will recheck end */</span><span> </span></td></tr><tr><td class="line2"> } </td></tr><tr><td class="line1">} </td></tr><tr><td class="line2"> </td></tr><tr><td class="line1"><span class="keyword">public</span><span> </span><span class="keyword">void</span><span> invoke() { </span></td></tr><tr><td class="line2"> for (int i = 0; i < m_hello.length; i++) { </td></tr><tr><td class="line1"> System.out.println(m_hello[i]. </td></tr><tr><td class="line2"> sayHello(<span class="string">"Clement"</span><span>)); </span></td></tr><tr><td class="line1"> } </td></tr><tr><td class="line2">} </td></tr><tr><td class="line1"><span class="preprocessor"></span></td></tr><tr><td class="line2"><span class="preprocessor"> @Validate</span><span> </span></td></tr><tr><td class="line1"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> starting() { </span></td></tr><tr><td class="line2"> Thread T = new Thread(<span class="keyword">this</span><span>); </span></td></tr><tr><td class="line1"> end = <span class="keyword">false</span><span>; </span></td></tr><tr><td class="line2"> T.start(); </td></tr><tr><td class="line1"> } </td></tr><tr><td class="line2"><span class="preprocessor"></span></td></tr><tr><td class="line1"><span class="preprocessor"> @Invalidate</span><span> </span></td></tr><tr><td class="line2"> <span class="keyword">public</span><span> </span><span class="keyword">void</span><span> stopping() { </span></td></tr><tr><td class="line1"> end = <span class="keyword">true</span><span>; </span></td></tr><tr><td class="line2"> } </td></tr><tr><td class="line1">} </td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">package ipojo.example.hello.client; |
| |
| import org.apache.felix.ipojo.annotations.Component; |
| import org.apache.felix.ipojo.annotations.Invalidate; |
| import org.apache.felix.ipojo.annotations.Requires; |
| import org.apache.felix.ipojo.annotations.Validate; |
| |
| import ipojo.example.hello.Hello; |
| |
| @Component(name="AnnotedHelloClient", immediate=true) |
| public class HelloClient implements Runnable { |
| |
| @Requires |
| private Hello[] m_hello; // Service Dependency |
| |
| private final static int DELAY=10000; |
| private boolean end; |
| |
| public void run() { |
| while (!end) { |
| try { |
| invoke(); |
| Thread.sleep(DELAY); |
| } catch (InterruptedException ie) { } |
| /* will recheck end */ |
| } |
| } |
| |
| public void invoke() { |
| for (int i = 0; i < m_hello.length; i++) { |
| System.out.println(m_hello[i]. |
| sayHello("Clement")); |
| } |
| } |
| |
| @Validate |
| public void starting() { |
| Thread T = new Thread(this); |
| end = false; |
| T.start(); |
| } |
| |
| @Invalidate |
| public void stopping() { |
| end = true; |
| } |
| }</textarea> |
| <script class="javascript"> |
| if(!window.newcodemacro_initialised) |
| { |
| window.newcodemacro_initialised = true; |
| window.oldonloadmethod = window.onload; |
| window.onload = function(){ |
| dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| if(window.oldonloadmethod) |
| { |
| window.oldonloadmethod(); |
| } |
| } |
| } |
| |
| </script> |
| </div> |
| |
| |
| <h2><a name="HowtouseiPOJOAnnotations-DefinedAnnotations"></a>Defined Annotations</h2> |
| |
| <p>This section lists defined annotations and how to use them.</p> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Component"></a>@Component</h3> |
| |
| <p><b>Goal:</b> Defines a component type<br> |
| <b>Target:</b> The component implementation class<br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>name : defines the component type name (optional, default = the class name)</li> |
| <li>immediate: defines the component type as immediate (optional, default = "false")</li> |
| <li>architecture: enable the architecture exposition (optional, default = "false")</li> |
| <li>propagation: enable configuration property propagation (on provided services) (optional, default = "false")</li> |
| <li>managedservice : set the Managed Service PID. (optional, default = no PID (i.e. the managed service will not be exposed)).</li> |
| <li>factory_method |
| : set the factory-method. The specified method must be a static method |
| and return a pojo object.(optional, default = iPOJO uses the 'regular' |
| constructor).</li> |
| <li>public_factory : set if the component type is public. (optional, default = true).</li> |
| </ul> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Provides"></a>@Provides</h3> |
| |
| <p><b>Goal:</b> Defines that the component type provide services<br> |
| <b>Target:</b> The component implementation class<br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>specifications: defines the provided interface (optional, default = all implemented interfaces)</li> |
| <li>strategy |
| : the service object creation strategy. Possible values : SINGLETON, |
| SERVICE, METHOD, INSTANCE or the strategy class name. With SINGLETON |
| there is only one POJO per component instance, SERVICE means OSGi |
| Service factory, METHOD delegates the creation to the factory-method of |
| the component, INSTANCE creates one service object per requiring |
| instance. For other strategies, specify the qualified name of the |
| CreationStrategy class. (optional, default = SINGLETON)</li> |
| </ul> |
| |
| |
| |
| <div class="box"> |
| <div class="box-blue-header"> |
| <div class="box-blue-title"> |
| <img src="how-to-use-ipojo-annotations_files/information.gif"> <b>OSGi Service Factory</b> |
| </div> |
| </div> |
| <div class="box-blue-content"> |
| The <tt>SERVICE</tt> strategy means OSGi service factory. So, one service object per asking bundle will be created. |
| </div> |
| <div class="box-blue-footer"></div> |
| </div> |
| |
| |
| |
| |
| <div class="box"> |
| <div class="box-blue-header"> |
| <div class="box-blue-title"> |
| <img src="how-to-use-ipojo-annotations_files/information.gif"> <b>Changes between the 1.0.0 and the 1.2.0</b> |
| </div> |
| </div> |
| <div class="box-blue-content"> |
| The <tt>factory</tt> attribute became <tt>strategy</tt>. A third policy is now available (<tt>instance</tt>) allowing to create one service object per asking instance. Moreover, it is also possible to indicates the <tt>CreationStrategy</tt> class name. |
| </div> |
| <div class="box-blue-footer"></div> |
| </div> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Requires"></a>@Requires</h3> |
| |
| <p><b>Goal:</b> Defines a service dependency<br> |
| <b>Target:</b> Field<br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>Filter: defines the LDAP filter (optional)</li> |
| <li>Optional: defines if the dependency is optional (optional, default = "false")</li> |
| <li>Id: |
| defines the dependency Id (useful to identify bind & unbind |
| methods) (optional, default = field name) (if a dependency with the |
| same id is already created (by a @bind or @unbind annotation), it |
| merges the dependencies).</li> |
| <li>Nullable: enable or disable the |
| Null Object injection when the dependency is optional and no providers |
| are available (optional, default = "true")</li> |
| <li>Default-Implementation: set the Default-Implmentation (optional, by default iPOJO uses a Null object)</li> |
| <li>Policy: defines the binding policy (accepted value : dynamic, static, dynamic-priority) (optional, default = "dynamic")</li> |
| <li>Comparator: defines the comparator to use to sort service references (optional, default = OSGi Service Reference Comparator)</li> |
| <li>From : defines the specific provider to use</li> |
| <li>Specification |
| : the required service specification. This attribute is required for |
| Collection field. (optional, default = annotated field type).</li> |
| </ul> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@ServiceProperty"></a>@ServiceProperty</h3> |
| |
| <p><b>Goal:</b> Defines a service property<br> |
| <b>Target:</b> Field<br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>name: property name (optional, default=field name</li> |
| <li>value: property value (optional, default=no value)</li> |
| <li>mandatory : is the property mandatory? (optional, default=false)</li> |
| </ul> |
| |
| |
| |
| <div class="box"> |
| <div class="box-blue-header"> |
| <div class="box-blue-title"> |
| <img src="how-to-use-ipojo-annotations_files/information.gif"> <b>Mandatory property</b> |
| </div> |
| </div> |
| <div class="box-blue-content"> |
| A mandatory property must receive a value either from the component type description (<tt>value</tt> attribute, or the instance configuration. |
| </div> |
| <div class="box-blue-footer"></div> |
| </div> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Property"></a>@Property</h3> |
| |
| <p><b>Goal:</b> Defines a property<br> |
| <b>Target:</b> Field or Method<br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>name: property name (optional, default=field name computed by |
| removing "set" from the method name (for instance setFoo(String ff) |
| will get the Foo name))</li> |
| <li>value: property value (optional, default=no value)</li> |
| <li>mandatory : is the property mandatory? (optional, default=false)</li> |
| </ul> |
| |
| |
| |
| <div class="box"> |
| <div class="box-blue-header"> |
| <div class="box-blue-title"> |
| <img src="how-to-use-ipojo-annotations_files/information.gif"> <b>Field and Method</b> |
| </div> |
| </div> |
| <div class="box-blue-content"> |
| If another property with the same name is defined the method or the field is added to the existing property. |
| </div> |
| <div class="box-blue-footer"></div> |
| </div> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Updated\Newsinthe1.3.0SNAPSHOTversion\"></a>@Updated <b>[ News in the 1.3.0-SNAPSHOT version ]</b></h3> |
| <p><b>Goal:</b> Defines method called when a reconfiguration is completed.<br> |
| <b>Target:</b> a method (receiving a dictionary in argument)</p> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Bind"></a>@Bind</h3> |
| |
| <p><b>Goal:</b> Defines a bind method<br> |
| <b>Target:</b> Method<br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>Id: Dependency Id, if the id is already defines in a |
| "@requires " or "@unbind" annotation, it adds this method as a bind |
| method of the already created dependency. (optional, default= no id, |
| compute an id if the method name begin by "bind" (for instance |
| "bindFoo" will have the "Foo" id))</li> |
| <li>Specification : required dependency (optional)</li> |
| <li>Aggregate : is the dependency an aggregate dependency (optional, default= "false")</li> |
| <li>Optional: is the dependency an optional dependency (optional, default= "false")</li> |
| <li>Filter: dependency LDAP filter (optional)</li> |
| <li>Policy: defines the binding policy (accepted value : dynamic, static, dynamic-priority) (optional, default = "dynamic")</li> |
| <li>Comparator: defines the comparator to use to sort service references (optional, default = OSGi Service Reference Comparator)</li> |
| <li>From : defines the specific provider to use</li> |
| </ul> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Unbind"></a>@Unbind</h3> |
| |
| <p><b>Goal:</b> Defines an unbind method<br> |
| <b>Target:</b> Method<br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>Id: Dependency Id, if the id is already defines in a |
| "@requires" or "@bind" annotation, it adds this method as an unbind |
| method of the already created dependency. (optional, default= no id, |
| compute an id if the method name begin by "unbind" (for instance |
| "unbindFoo" will have the "Foo" id))</li> |
| <li>Specification : required dependency (optional)</li> |
| <li>Aggregate : is the dependency an aggregate dependency (optional, default= "false")</li> |
| <li>Optional: is the dependency an optional dependency (optional, default= "false")</li> |
| <li>Filter: dependency LDAP filter (optional)</li> |
| <li>Policy: defines the binding policy (accepted value : dynamic, static, dynamic-priority) (optional, default = "dynamic")</li> |
| <li>Comparator: defines the comparator to use to sort service references (optional, default = OSGi Service Reference Comparator)</li> |
| <li>From : defines the specific provider to use</li> |
| </ul> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Validate"></a>@Validate</h3> |
| |
| <p><b>Goal:</b> defines a validate lifecycle callback<br> |
| <b>Target:</b> method</p> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-@Invalidate"></a>@Invalidate</h3> |
| |
| <p><b>Goal:</b> defines a validate lifecycle callback<br> |
| <b>Target:</b> method</p> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-TemporalDependencies(externalhandler)"></a>Temporal Dependencies (external handler)</h3> |
| |
| <p>The temporal dependency handler is an external handler. However, it |
| can be used with an annotation defined in the iPOJO annotations jar |
| file. <br> |
| The annotation is org.apache.felix.ipojo.handler.temporal.Requires and targets a field. <br> |
| <b>Attributes:</b></p> |
| <ul> |
| <li>filter : specify the dependency filter</li> |
| <li>timeout : specify the dependency timeout (optional)</li> |
| <li>onTimeout |
| : specify the onTimeout action (null, nullable, empty-array, |
| default-implementation (specify the class name in this case) (optional).</li> |
| <li>specification |
| : the required service specification. This attribute is required for |
| Collection field. (optional, default = annotated field type).</li> |
| <li>Proxy : Inject a proxy instead of the real object. This allows passing this reference to collaborators. (Default = false)</li> |
| </ul> |
| |
| |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-ExposinginstancesasaJMXMBean(externalhandler)"></a>Exposing instances as a JMX MBean (external handler)</h3> |
| |
| <p>The JMX Handler allows exposing an instance as a JMX MBean. To |
| configure the JMX handler directly from your code, three annotations |
| are provided. They are in the <tt>org.apache.felix.ipojo.handlers.jmx</tt> package</p> |
| |
| <p>The <tt>@org.apache.felix.ipojo.handlers.jmx.Config</tt> (<tt>@Config</tt> if the package it correctly imported) annotation is a type annotation (so placed on the <tt>class</tt> element. This annotation indicates that the instance will be exposed as an MBean. This annotation supports:</p> |
| <ul> |
| <li>usesMOSGi: set to <tt>true</tt> to use MOSGi. Otherwise, the MBean will be exposed in the MBean Platform Server (default: <tt>false</tt>).</li> |
| <li>objectname: set the MBean objectname. The objectname must follow JMX specification. (default: <tt>package-name:factory-name:instance-name</tt>)</li> |
| <li>domain: set the MBean domain. (default: <tt>package-name</tt>)</li> |
| <li>name: set the MBean name. (default: <tt>instance-name</tt>).</li> |
| </ul> |
| |
| |
| <p>The <tt>@org.apache.felix.ipojo.handlers.jmx.Property</tt> (<tt>@Property</tt>) annotation is a field annotation indicating that the field is exposed in the MBean. The supported attributes are:</p> |
| <ul> |
| <li>name: set the property name</li> |
| <li>rights: set the access permission. Possible values are <tt>r</tt> (read only) and <tt>w</tt> (read and write). By default, properties are in read-only mode.</li> |
| <li>notification: enables notification on this property. By default notifications are disabled.</li> |
| </ul> |
| |
| |
| <p>The <tt>@org.apache.felix.ipojo.handlers.jmx.Method</tt> (<tt>@Method</tt>) annotation is a method annotation indicating that the method is exposed in the MBean. Only one attribute can be customized:</p> |
| <ul> |
| <li>description: set the method description.</li> |
| </ul> |
| |
| |
| |
| <h2><a name="HowtouseiPOJOAnnotations-AdvancedtopicsandFAQ"></a>Advanced topics and FAQ</h2> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-Metadatafileandannotationmerge"></a>Metadata file and annotation merge</h3> |
| |
| <p>It is possible to defines component type both in the metadata file |
| (in XML) and by using annotation. However, if a component type defined |
| by using annotations has the same name than a type define in the XML |
| file, the XML descriptor override the annotation defined type. However, |
| a warning message is launched during the manipulation.</p> |
| |
| <h3><a name="HowtouseiPOJOAnnotations-Instancecreation"></a>Instance creation</h3> |
| |
| <p>Annotation can only be used to define component type. To define |
| instances, you need to use the XML descriptor. Instance can refer to |
| annotated types by referring to their names.</p> |
| <div class="code"> |
| <div class="dp-highlighter"><table class="dp-xml" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="line1"><span></span><span class="tag"><</span><span>instance </span><span class="attribute">component</span><span>=</span><span class="attribute-value">"ipojo.example.hello.impl.HelloImpl"</span><span>/> </span></td></tr><tr><td class="line2"><span class="tag"><</span><span>instance </span><span class="attribute">component</span><span>=</span><span class="attribute-value">"AnnotedHelloClient"</span><span>/> </span></td></tr></tbody></table></div><textarea style="display: none;" name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><instance component="ipojo.example.hello.impl.HelloImpl"/> |
| <instance component="AnnotedHelloClient"/></textarea> |
| <script class="javascript"> |
| if(!window.newcodemacro_initialised) |
| { |
| window.newcodemacro_initialised = true; |
| window.oldonloadmethod = window.onload; |
| window.onload = function(){ |
| dp.SyntaxHighlighter.HighlightAll('newcodemacro'); |
| if(window.oldonloadmethod) |
| { |
| window.oldonloadmethod(); |
| } |
| } |
| } |
| |
| </script> |
| </div> |
| |
| |
| <h3><a name="HowtouseiPOJOAnnotations-UsingCustomAnnotations"></a>Using Custom Annotations</h3> |
| |
| <p>External handlers can provides their own annotations. Using these |
| annotations just requires to add them to your build path. To external |
| handlers annotations, please refer to the external handler |
| documentation. |
| <br clear="all"> |
| <br clear="all"></p> |
| |
| </div> |
| <img src="how-to-use-ipojo-annotations_files/footer.png" class="footer"> |
| </div> |
| |
| <script type="text/javascript"> |
| var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); |
| document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); |
| </script><script src="how-to-use-ipojo-annotations_files/ga.js" type="text/javascript"></script> |
| <script type="text/javascript"> |
| try{ |
| var pageTracker = _gat._getTracker("UA-1518442-4"); |
| pageTracker._trackPageview(); |
| } catch(err) {} |
| </script> |
| |
| </div> |
| </body><div FirebugVersion="1.4.0" style="display: none;" id="_firebugConsole"></div></html> |