Author: pderop
Date: Tue Oct  9 23:21:17 2018
New Revision: 1843368

URL: http://svn.apache.org/viewvc?rev=1843368&view=rev
Log:
dm r12 updates

Modified:
    
felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/service-scopes.mdtext

Modified: 
felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/service-scopes.mdtext
URL: 
http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/service-scopes.mdtext?rev=1843368&r1=1843367&r2=1843368&view=diff
==============================================================================
--- 
felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/service-scopes.mdtext
 (original)
+++ 
felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/service-scopes.mdtext
 Tue Oct  9 23:21:17 2018
@@ -142,28 +142,33 @@ And when one client will request a compo
 Example of a scoped component which defines an init method:
 
     :::java
-    import org.apache.felix.dm.annotation.api.Component;
-    import org.apache.felix.dm.annotation.api.ServiceScope;
+    public class Activator extends DependencyActivatorBase {
+        @Override
+        public void init(BundleContext context, DependencyManager dm) throws 
Exception {
+            dm.add(createComponent()
+                .setScope(ServiceScope.PROTOTYPE)
+                .setInterface(MyService.class.getName(), null)
+                .setImplementation(MyServiceImpl.class));
+        }
+    }
     
-    @Component(scope=ServiceScope.PROTOTYPE)
     public static class MyServiceImpl implements MyService {
-       
-       @Init
-       void init(Component comp) {
+        void init(Component comp) {
             // add dependencies dynamically
-       }
+        }
     
-        @Start
        void start() {
           // only called on clones, not on the prototype instance
        }
        
-       @Stop
        void stop() {
           // called on each clone, not on the prototype instance singleton
        }
     }
 
+So, if you don't need an init callback then use the 
`Component.setCallbacks(null, "start", "stop", null)` 
+method in order to avoid the creation of the prototype instance.
+
 # Limitation when using DM ServiceDependency from API and ServiceObjects
 
 When using DependencyManager ServiceDependency from the native API (not using 
annotations), 


Reply via email to