blob: 4395df2fd66a0554881b263b4569b7ad156f654e [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>ManagedServiceFactory (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="ManagedServiceFactory (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/ManagedServiceFactory.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/ManagedService.html" title="interface in org.osgi.service.cm"><span class="strong">Prev Class</span></a></li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/osgi/service/cm/ManagedServiceFactory.html" target="_top">Frames</a></li>
<li><a href="ManagedServiceFactory.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 ManagedServiceFactory" class="title">Interface ManagedServiceFactory</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public interface <span class="strong">ManagedServiceFactory</span></pre>
<div class="block">Manage multiple service instances.
Bundles registering this interface are giving the Configuration Admin service
the ability to create and configure a number of instances of a service that
the implementing bundle can provide. For example, a bundle implementing a
DHCP server could be instantiated multiple times for different interfaces
using a factory.
<p>
Each of these <i>service instances </i> is represented, in the persistent
storage of the Configuration Admin service, by a factory
<code>Configuration</code> object that has a PID. When such a
<code>Configuration</code> is updated, the Configuration Admin service
calls the <code>ManagedServiceFactory</code> updated method with the new
properties. When <code>updated</code> is called with a new PID, the Managed
Service Factory should create a new factory instance based on these
configuration properties. When called with a PID that it has seen before, it
should update that existing service instance with the new configuration
information.
<p>
In general it is expected that the implementation of this interface will
maintain a data structure that maps PIDs to the factory instances that it has
created. The semantics of a factory instance are defined by the Managed
Service Factory. However, if the factory instance is registered as a service
object with the service registry, its PID should match the PID of the
corresponding <code>Configuration</code> object (but it should <b>not </b>
be registered as a Managed Service!).
<p>
An example that demonstrates the use of a factory. It will create serial
ports under command of the Configuration Admin service.
<pre>
class SerialPortFactory
implements ManagedServiceFactory {
ServiceRegistration registration;
Hashtable ports;
void start(BundleContext context) {
Hashtable properties = new Hashtable();
properties.put( Constants.SERVICE_PID,
&quot;com.acme.serialportfactory&quot; );
registration = context.registerService(
ManagedServiceFactory.class.getName(),
this,
properties
);
}
public void updated( String pid,
Dictionary properties ) {
String portName = (String) properties.get(&quot;port&quot;);
SerialPortService port =
(SerialPort) ports.get( pid );
if ( port == null ) {
port = new SerialPortService();
ports.put( pid, port );
port.open();
}
if ( port.getPortName().equals(portName) )
return;
port.setPortName( portName );
}
public void deleted( String pid ) {
SerialPortService port =
(SerialPort) ports.get( pid );
port.close();
ports.remove( pid );
}
...
}
</pre></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/ManagedServiceFactory.html#deleted(java.lang.String)">deleted</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;pid)</code>
<div class="block">Remove a factory instance.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><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></code></td>
<td class="colLast"><code><strong><a href="../../../../org/osgi/service/cm/ManagedServiceFactory.html#getName()">getName</a></strong>()</code>
<div class="block">Return a descriptive name of this factory.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/osgi/service/cm/ManagedServiceFactory.html#updated(java.lang.String, java.util.Dictionary)">updated</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;pid,
<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">Create a new instance, or update the configuration of an existing
instance.</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="getName()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getName</h4>
<pre><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;getName()</pre>
<div class="block">Return a descriptive name of this factory.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the name for the factory, which might be localized</dd></dl>
</li>
</ul>
<a name="updated(java.lang.String, java.util.Dictionary)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>updated</h4>
<pre>void&nbsp;updated(<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;pid,
<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">Create a new instance, or update the configuration of an existing
instance.
If the PID of the <code>Configuration</code> object is new for the
Managed Service Factory, then create a new factory instance, using the
configuration <code>properties</code> provided. Else, update the
service instance with the provided <code>properties</code>.
<p>
If the factory instance is registered with the Framework, then the
configuration <code>properties</code> should be copied to its registry
properties. This is not mandatory and security sensitive properties
should obviously not be copied.
<p>
If this method throws any <code>Exception</code>, the Configuration
Admin service must catch it and should log it.
<p>
When the implementation of updated detects any kind of error in the
configuration properties, it should create a new
<a href="../../../../org/osgi/service/cm/ConfigurationException.html" title="class in org.osgi.service.cm"><code>ConfigurationException</code></a> which describes the problem.
<p>
The Configuration Admin service must call this method asynchronously.
This implies that implementors of the <code>ManagedServiceFactory</code>
class 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>pid</code> - The PID for this configuration.</dd><dd><code>properties</code> - A copy of the configuration properties. 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 configuration properties are
invalid.</dd></dl>
</li>
</ul>
<a name="deleted(java.lang.String)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>deleted</h4>
<pre>void&nbsp;deleted(<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;pid)</pre>
<div class="block">Remove a factory instance.
Remove the factory instance associated with the PID. If the instance was
registered with the service registry, it should be unregistered.
<p>
If this method throws any <code>Exception</code>, the Configuration
Admin service must catch it and should log it.
<p>
The Configuration Admin service must call this method asynchronously.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pid</code> - the PID of the service to be removed</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/ManagedServiceFactory.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/ManagedService.html" title="interface in org.osgi.service.cm"><span class="strong">Prev Class</span></a></li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/osgi/service/cm/ManagedServiceFactory.html" target="_top">Frames</a></li>
<li><a href="ManagedServiceFactory.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>