You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2018/09/30 21:05:18 UTC

svn commit: r1842412 - /felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-aspect.mdtext

Author: pderop
Date: Sun Sep 30 21:05:18 2018
New Revision: 1842412

URL: http://svn.apache.org/viewvc?rev=1842412&view=rev
Log:
Updated dm doc for api improvements (FELIX-5941)

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

Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-aspect.mdtext
URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-aspect.mdtext?rev=1842412&r1=1842411&r2=1842412&view=diff
==============================================================================
--- felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-aspect.mdtext (original)
+++ felix/site/trunk/content/documentation/subprojects/apache-felix-dependency-manager/reference/component-aspect.mdtext Sun Sep 30 21:05:18 2018
@@ -6,20 +6,32 @@ Aspects allow you to define an "intercep
 
 ## Usage example using annotation
 
-The *@AspectService* annotation allows you to create an aspect service. It supports the following attributes mentioned below.
+The *@AspectService* annotation allows you to create an aspect service. In this example, a "DatabaseCache" aspect service is used to add caching functionality to an existing Database service:
 
 ### Sample code
 
-     @AspectService(ranking=10)
-     @Property(name="param", value="value")
-     class AspectService implements InterceptedService {
-         // The service we are intercepting (injected by reflection)
-         protected volatile InterceptedService intercepted;
-       
-         public void doWork() {
-            intercepted.doWork();
-         }
-     }
+    :::java
+    interface Database {
+        String get(String key);
+    }
+ 
+    @AspectService(ranking=10)
+    class DatabaseCache implements Database {
+        volatile Database originalDatabase; // injected
+
+        @ServiceDependency(required=false)
+        volatile LogService log;
+     
+        String get(String key) {
+            String value = cache.get(key);
+            if (value == null) {
+                value = this.originalDatabase.get(key);
+                store(key, value);
+            }
+            return value;
+        }
+        ... 
+    }
 
 ### Annotation attributes
 
@@ -93,25 +105,6 @@ The AspectComponent can be created using
          }
     }
  
-    interface Database {
-        String get(String key);
-    }
- 
-    class DatabaseCache implements Database {
-        volatile Database originalDatabase; // injected
-        volatile LogService log; Osgi LogService, optional dependency
-     
-        String get(String key) {
-            String value = cache.get(key);
-            if (value == null) {
-                value = this.originalDatabase.get(key);
-                store(key, value);
-            }
-            return value;
-        }
-        ... 
-    }
-
 ## Usage example using Lambda API
 
 When using the Dependency Manager Lambda API, the ogr.apache.felix.dm.lambda.DependencyManagerActivator.aspect() method can be used to define an aspect service.