blob: 3ef6191c516112960283e4ad5de17f3d10714567 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Mon Mar 31 09:56:26 CEST 2014 -->
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>DeclarationBuilderService (Apache Felix iPOJO ~ JavaDoc 1.11.2 API)</title>
<meta name="date" content="2014-03-31">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="DeclarationBuilderService (Apache Felix iPOJO ~ JavaDoc 1.11.2 API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DeclarationBuilderService.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/felix/ipojo/extender/Declaration.html" title="interface in org.apache.felix.ipojo.extender"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html" title="interface in org.apache.felix.ipojo.extender"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/felix/ipojo/extender/DeclarationBuilderService.html" target="_top">Frames</a></li>
<li><a href="DeclarationBuilderService.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.felix.ipojo.extender</div>
<h2 title="Interface DeclarationBuilderService" class="title">Interface DeclarationBuilderService</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../../../org/apache/felix/ipojo/extender/internal/declaration/service/DefaultDeclarationBuilderService.html" title="class in org.apache.felix.ipojo.extender.internal.declaration.service">DefaultDeclarationBuilderService</a></dd>
</dl>
<hr>
<br>
<pre>public interface <a href="../../../../../src-html/org/apache/felix/ipojo/extender/DeclarationBuilderService.html#line.79">DeclarationBuilderService</a></pre>
<div class="block">This service provides a way for users to manage declarations through code.
Notice that produced declarations are immutable once build. But it is possible to re-use a
builder to share some configuration through instances.
<pre>
// Obtain the service through the service registry
DeclarationBuilderService service = ...
// Get a fresh instance builder
DeclarationBuilder builder = service.newInstance("the.full.name.of.the.component.to.instantiate");
DeclarationHandle handle = builder.name("a-unique-name") // Make sure name is unique for the expected type
.configure()
.property("a-property", "a-value")
.property("another-property", "another-value")
.build();
// Push the InstanceDeclaration service in the registry
handle.publish();
</pre>
Except the <a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html#build()"><code>InstanceBuilder.build()</code></a> call, all methods are optional:
<ul>
<li><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html#name(java.lang.String)"><code>InstanceBuilder.name(String)</code></a>: if no name is provided,
a default one will be generated by iPOJO.</li>
<li><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html#version(java.lang.String)"><code>InstanceBuilder.version(String)</code></a>: if no version is provided,
the first un-versioned type will be used.</li>
<li><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html#configure()"><code>InstanceBuilder.configure()</code></a>: if no configuration is required, can be omitted.</li>
<li><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html#type(java.lang.String)"><code>InstanceBuilder.type(String)</code></a>: can be used to change the <bold>required</bold> component type.</li>
<li><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html#context(org.osgi.framework.BundleContext)"><code>InstanceBuilder.context(org.osgi.framework.BundleContext)</code></a>: by default, the bundle context
used to register the created <a href="../../../../../org/apache/felix/ipojo/extender/Declaration.html" title="interface in org.apache.felix.ipojo.extender"><code>Declaration</code></a> is the one of the
caller. It can be changed though this method.</li>
</ul>
Once an instance handle has been created, its configuration (name, type, version and properties) is immutable. It can
only be <a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html#publish()">published</a> (so that the framework will try to instantiate the
instance) or <a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html#retract()">retracted</a> (framework will remove the instance).
Notice that all created instances will appear as "coming from" the bundle that requires the
<a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html" title="interface in org.apache.felix.ipojo.extender"><code>DeclarationBuilderService</code></a> service. Just like having a metadata.xml file in your
bundle that declares your instances. It is possible to override this default behavior using
<a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html#context(org.osgi.framework.BundleContext)"><code>InstanceBuilder.context(org.osgi.framework.BundleContext)</code></a>.</div>
<dl><dt><span class="strong">Since:</span></dt>
<dd>1.11.2</dd>
<dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../org/apache/felix/ipojo/extender/InstanceDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>InstanceDeclaration</code></a>,
<a href="../../../../../org/apache/felix/ipojo/extender/TypeDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>TypeDeclaration</code></a>,
<a href="../../../../../org/apache/felix/ipojo/extender/ExtensionDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>ExtensionDeclaration</code></a>,
<a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html" title="interface in org.apache.felix.ipojo.extender"><code>InstanceBuilder</code></a>,
<a href="../../../../../org/apache/felix/ipojo/extender/ConfigurationBuilder.html" title="interface in org.apache.felix.ipojo.extender"><code>ConfigurationBuilder</code></a>,
<a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html" title="interface in org.apache.felix.ipojo.extender"><code>DeclarationHandle</code></a></dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html" title="interface in org.apache.felix.ipojo.extender">DeclarationHandle</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html#newExtension(java.lang.String, org.apache.felix.ipojo.extender.builder.FactoryBuilder)">newExtension</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../../../org/apache/felix/ipojo/extender/builder/FactoryBuilder.html" title="interface in org.apache.felix.ipojo.extender.builder">FactoryBuilder</a>&nbsp;builder)</code>
<div class="block">Declares a new extension (supports new types like component, composite, handler).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html" title="interface in org.apache.felix.ipojo.extender">InstanceBuilder</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html#newInstance(java.lang.String)">newInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;type)</code>
<div class="block">Declares a new anonymous instance of a given type.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html" title="interface in org.apache.felix.ipojo.extender">InstanceBuilder</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html#newInstance(java.lang.String, java.lang.String)">newInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;type,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</code>
<div class="block">Declares a new instance of a given type.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html" title="interface in org.apache.felix.ipojo.extender">InstanceBuilder</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html#newInstance(java.lang.String, java.lang.String, java.lang.String)">newInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;type,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;version)</code>
<div class="block">Declares a new instance of a given type.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html" title="interface in org.apache.felix.ipojo.extender">DeclarationHandle</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html#newType(org.apache.felix.ipojo.metadata.Element)">newType</a></strong>(<a href="../../../../../org/apache/felix/ipojo/metadata/Element.html" title="class in org.apache.felix.ipojo.metadata">Element</a>&nbsp;description)</code>
<div class="block">Declares a new type using the given element description.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="newInstance(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newInstance</h4>
<pre><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html" title="interface in org.apache.felix.ipojo.extender">InstanceBuilder</a>&nbsp;<a href="../../../../../src-html/org/apache/felix/ipojo/extender/DeclarationBuilderService.html#line.88">newInstance</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;type)</pre>
<div class="block">Declares a new anonymous instance of a given type.
Invoking this method is equivalent to invoking <code><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html#newInstance(java.lang.String, java.lang.String)">newInstance(type, null)</a></code>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>type</code> - name of the component to be instantiated (cannot be null).</dd>
<dt><span class="strong">Returns:</span></dt><dd>a handle usable to publish / retract the declaration.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../org/apache/felix/ipojo/extender/InstanceDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>InstanceDeclaration</code></a></dd></dl>
</li>
</ul>
<a name="newInstance(java.lang.String, java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newInstance</h4>
<pre><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html" title="interface in org.apache.felix.ipojo.extender">InstanceBuilder</a>&nbsp;<a href="../../../../../src-html/org/apache/felix/ipojo/extender/DeclarationBuilderService.html#line.98">newInstance</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;type,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</pre>
<div class="block">Declares a new instance of a given type.
Invoking this method is equivalent to invoking <code><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationBuilderService.html#newInstance(java.lang.String, java.lang.String, java.lang.String)">newInstance(type, name, null)</a></code>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>type</code> - name of the component to be instantiated.</dd><dd><code>name</code> - name of the new instance (can be null)</dd>
<dt><span class="strong">Returns:</span></dt><dd>a handle usable to publish / retract the declaration.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../org/apache/felix/ipojo/extender/InstanceDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>InstanceDeclaration</code></a></dd></dl>
</li>
</ul>
<a name="newInstance(java.lang.String, java.lang.String, java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newInstance</h4>
<pre><a href="../../../../../org/apache/felix/ipojo/extender/InstanceBuilder.html" title="interface in org.apache.felix.ipojo.extender">InstanceBuilder</a>&nbsp;<a href="../../../../../src-html/org/apache/felix/ipojo/extender/DeclarationBuilderService.html#line.108">newInstance</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;type,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;version)</pre>
<div class="block">Declares a new instance of a given type.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>type</code> - name of the component to be instantiated.</dd><dd><code>name</code> - name of the new instance (can be null)</dd><dd><code>version</code> - version of the expected type (can be null)</dd>
<dt><span class="strong">Returns:</span></dt><dd>a handle usable to publish / retract the declaration.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../org/apache/felix/ipojo/extender/InstanceDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>InstanceDeclaration</code></a></dd></dl>
</li>
</ul>
<a name="newExtension(java.lang.String, org.apache.felix.ipojo.extender.builder.FactoryBuilder)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newExtension</h4>
<pre><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html" title="interface in org.apache.felix.ipojo.extender">DeclarationHandle</a>&nbsp;<a href="../../../../../src-html/org/apache/felix/ipojo/extender/DeclarationBuilderService.html#line.118">newExtension</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../../../org/apache/felix/ipojo/extender/builder/FactoryBuilder.html" title="interface in org.apache.felix.ipojo.extender.builder">FactoryBuilder</a>&nbsp;builder)</pre>
<div class="block">Declares a new extension (supports new types like component, composite, handler).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - name of the type to support (no namespace to be provided)</dd><dd><code>builder</code> - associated factory builder</dd>
<dt><span class="strong">Returns:</span></dt><dd>a handle usable to publish / retract the declaration.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../org/apache/felix/ipojo/IPojoFactory.html" title="class in org.apache.felix.ipojo"><code>IPojoFactory</code></a>,
<a href="../../../../../org/apache/felix/ipojo/extender/ExtensionDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>ExtensionDeclaration</code></a></dd></dl>
</li>
</ul>
<a name="newType(org.apache.felix.ipojo.metadata.Element)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>newType</h4>
<pre><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html" title="interface in org.apache.felix.ipojo.extender">DeclarationHandle</a>&nbsp;<a href="../../../../../src-html/org/apache/felix/ipojo/extender/DeclarationBuilderService.html#line.126">newType</a>(<a href="../../../../../org/apache/felix/ipojo/metadata/Element.html" title="class in org.apache.felix.ipojo.metadata">Element</a>&nbsp;description)</pre>
<div class="block">Declares a new type using the given element description.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>description</code> - description of the component type</dd>
<dt><span class="strong">Returns:</span></dt><dd>a handle usable to publish / retract the declaration.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../org/apache/felix/ipojo/extender/TypeDeclaration.html" title="interface in org.apache.felix.ipojo.extender"><code>TypeDeclaration</code></a></dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DeclarationBuilderService.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/felix/ipojo/extender/Declaration.html" title="interface in org.apache.felix.ipojo.extender"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/felix/ipojo/extender/DeclarationHandle.html" title="interface in org.apache.felix.ipojo.extender"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/felix/ipojo/extender/DeclarationBuilderService.html" target="_top">Frames</a></li>
<li><a href="DeclarationBuilderService.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2014. All rights reserved.</small></p>
</body>
</html>