blob: 4685839e52d80d1cd4d7272d45206dc96141fa6a [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="de">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Mon Jul 01 14:53:20 CEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>ManagedService (Apache Felix Configuration Admin Service 1.2.4 API)</title>
<meta name="date" content="2013-07-01">
<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="ManagedService (Apache Felix Configuration Admin Service 1.2.4 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/ManagedService.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>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/osgi/service/cm/ConfigurationPlugin.html" title="interface in org.osgi.service.cm"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/osgi/service/cm/ManagedServiceFactory.html" title="interface in org.osgi.service.cm"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/osgi/service/cm/ManagedService.html" target="_top">Frames</a></li>
<li><a href="ManagedService.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.osgi.service.cm</div>
<h2 title="Interface ManagedService" class="title">Interface ManagedService</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public interface <span class="strong">ManagedService</span></pre>
<div class="block">A service that can receive configuration data from a Configuration Admin
service.
<p>
A Managed Service is a service that needs configuration data. Such an object
should be registered with the Framework registry with the
<code>service.pid</code> property set to some unique identifier called a
PID.
<p>
If the Configuration Admin service has a <code>Configuration</code> object
corresponding to this PID, it will callback the <code>updated()</code>
method of the <code>ManagedService</code> object, passing the properties of
that <code>Configuration</code> object.
<p>
If it has no such <code>Configuration</code> object, then it calls back
with a <code>null</code> properties argument. Registering a Managed Service
will always result in a callback to the <code>updated()</code> method
provided the Configuration Admin service is, or becomes active. This callback
must always be done asynchronously.
<p>
Else, every time that either of the <code>updated()</code> methods is
called on that <code>Configuration</code> object, the
<code>ManagedService.updated()</code> method with the new properties is
called. If the <code>delete()</code> method is called on that
<code>Configuration</code> object, <code>ManagedService.updated()</code>
is called with a <code>null</code> for the properties parameter. All these
callbacks must be done asynchronously.
<p>
The following example shows the code of a serial port that will create a port
depending on configuration information.
<pre>
class SerialPort implements ManagedService {
ServiceRegistration registration;
Hashtable configuration;
CommPortIdentifier id;
synchronized void open(CommPortIdentifier id,
BundleContext context) {
this.id = id;
registration = context.registerService(
ManagedService.class.getName(),
this,
getDefaults()
);
}
Hashtable getDefaults() {
Hashtable defaults = new Hashtable();
defaults.put( &quot;port&quot;, id.getName() );
defaults.put( &quot;product&quot;, &quot;unknown&quot; );
defaults.put( &quot;baud&quot;, &quot;9600&quot; );
defaults.put( Constants.SERVICE_PID,
&quot;com.acme.serialport.&quot; + id.getName() );
return defaults;
}
public synchronized void updated(
Dictionary configuration ) {
if ( configuration ==
<code>
null
</code>
)
registration.setProperties( getDefaults() );
else {
setSpeed( configuration.get(&quot;baud&quot;) );
registration.setProperties( configuration );
}
}
...
}
</pre>
<p>
As a convention, it is recommended that when a Managed Service is updated, it
should copy all the properties it does not recognize into the service
registration properties. This will allow the Configuration Admin service to
set properties on services which can then be used by other applications.</div>
<dl><dt><span class="strong">Version:</span></dt>
<dd>$Revision: 809193 $</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>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/osgi/service/cm/ManagedService.html#updated(java.util.Dictionary)">updated</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/util/Dictionary.html?is-external=true" title="class or interface in java.util">Dictionary</a>&nbsp;properties)</code>
<div class="block">Update the configuration for a Managed Service.</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="updated(java.util.Dictionary)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>updated</h4>
<pre>void&nbsp;updated(<a href="http://docs.oracle.com/javase/7/docs/api/java/util/Dictionary.html?is-external=true" title="class or interface in java.util">Dictionary</a>&nbsp;properties)
throws <a href="../../../../org/osgi/service/cm/ConfigurationException.html" title="class in org.osgi.service.cm">ConfigurationException</a></pre>
<div class="block">Update the configuration for a Managed Service.
<p>
When the implementation of <code>updated(Dictionary)</code> detects any
kind of error in the configuration properties, it should create a new
<code>ConfigurationException</code> which describes the problem. This
can allow a management system to provide useful information to a human
administrator.
<p>
If this method throws any other <code>Exception</code>, the
Configuration Admin service must catch it and should log it.
<p>
The Configuration Admin service must call this method asynchronously
which initiated the callback. This implies that implementors of Managed
Service can be assured that the callback will not take place during
registration when they execute the registration in a synchronized method.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>properties</code> - A copy of the Configuration properties, or
<code>null</code>. This argument must not contain the
"service.bundleLocation" property. The value of this property may
be obtained from the <code>Configuration.getBundleLocation</code>
method.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../org/osgi/service/cm/ConfigurationException.html" title="class in org.osgi.service.cm">ConfigurationException</a></code> - when the update fails</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/ManagedService.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>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/osgi/service/cm/ConfigurationPlugin.html" title="interface in org.osgi.service.cm"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/osgi/service/cm/ManagedServiceFactory.html" title="interface in org.osgi.service.cm"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/osgi/service/cm/ManagedService.html" target="_top">Frames</a></li>
<li><a href="ManagedService.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; 2006&#x2013;2013 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>