incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1556338 - in /sling/whiteboard/justin/yamf: org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/ org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/ org.apache.sling.yamf.impl/src/main/java/org/apache/sling/y...
Date Tue, 07 Jan 2014 20:03:59 GMT
Author: justin
Date: Tue Jan  7 20:03:59 2014
New Revision: 1556338

URL: http://svn.apache.org/r1556338
Log:
using reference queue / phantom references to track disposal

Added:
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallback.java
      - copied, changed from r1556337, sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallbackRegistry.java
      - copied, changed from r1556337, sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
Modified:
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/YamfAdapterFactory.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/BindingsInjector.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ChildResourceInjector.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/OSGiServiceInjector.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/RequestAttributeInjector.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ValueMapInjector.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/DefaultTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/MultipleInjectorTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/OSGiInjectionTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/PostConstructTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/RequestInjectionTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelClassesTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelInterfacesTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ViaTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/SimpleTest.java
    sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/models/TestModel.java

Copied: sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallback.java
(from r1556337, sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java)
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallback.java?p2=sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallback.java&p1=sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java&r1=1556337&r2=1556338&rev=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallback.java
Tue Jan  7 20:03:59 2014
@@ -16,12 +16,15 @@
  */
 package org.apache.sling.yamf.spi;
 
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Type;
-
-public interface Injector {
+/**
+ * Callback interface which can be implemented by Injectors to perform some action
+ * when a created object is destroyed.
+ */
+public interface DisposalCallback {
 
-    String getName();
+    /**
+     * Callback method for when an object is destroyed.
+     */
+    void onDisposed();
 
-    Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement element);
-}
\ No newline at end of file
+}

Copied: sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallbackRegistry.java
(from r1556337, sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java)
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallbackRegistry.java?p2=sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallbackRegistry.java&p1=sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java&r1=1556337&r2=1556338&rev=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/DisposalCallbackRegistry.java
Tue Jan  7 20:03:59 2014
@@ -16,12 +16,17 @@
  */
 package org.apache.sling.yamf.spi;
 
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Type;
-
-public interface Injector {
-
-    String getName();
+/**
+ * Interface which allows for the registration of DisposalCallback listeners.
+ * This interface should not be implemnted by clients.
+ */
+public interface DisposalCallbackRegistry {
+    
+    /**
+     * Register a callback.
+     * 
+     * @param callback the callback to register
+     */
+    void addDisposalCallback(DisposalCallback callback);
 
-    Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement element);
-}
\ No newline at end of file
+}

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.api/src/main/java/org/apache/sling/yamf/spi/Injector.java
Tue Jan  7 20:03:59 2014
@@ -23,5 +23,5 @@ public interface Injector {
 
     String getName();
 
-    Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement element);
+    Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement element,
DisposalCallbackRegistry callbackRegistry);
 }
\ No newline at end of file

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/YamfAdapterFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/YamfAdapterFactory.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/YamfAdapterFactory.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/YamfAdapterFactory.java
Tue Jan  7 20:03:59 2014
@@ -17,6 +17,8 @@
 package org.apache.sling.yamf.impl;
 
 import java.lang.annotation.Annotation;
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationHandler;
@@ -27,11 +29,14 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
@@ -52,14 +57,43 @@ import org.apache.sling.yamf.annotations
 import org.apache.sling.yamf.annotations.Optional;
 import org.apache.sling.yamf.annotations.Via;
 import org.apache.sling.yamf.annotations.Source;
+import org.apache.sling.yamf.spi.DisposalCallback;
+import org.apache.sling.yamf.spi.DisposalCallbackRegistry;
 import org.apache.sling.yamf.spi.Injector;
 import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Component
-public class YamfAdapterFactory implements AdapterFactory {
+public class YamfAdapterFactory implements AdapterFactory, Runnable {
+
+    public static class DisposalCallbackRegistryImpl implements DisposalCallbackRegistry
{
+
+        private List<DisposalCallback> callbacks = new ArrayList<DisposalCallback>();
+
+        @Override
+        public void addDisposalCallback(DisposalCallback callback) {
+            callbacks.add(callback);
+        }
+
+        private void lock() {
+            callbacks = Collections.unmodifiableList(callbacks);
+        }
+
+        private void onDisposed() {
+            for (DisposalCallback callback : callbacks) {
+                callback.onDisposed();
+            }
+        }
+
+    }
+
+    private ReferenceQueue<Object> queue;
+
+    private ConcurrentMap<java.lang.ref.Reference<Object>, DisposalCallbackRegistryImpl>
disposalCallbacks;
 
     public static class MapBackedInvocationHandler implements InvocationHandler {
 
@@ -75,6 +109,16 @@ public class YamfAdapterFactory implemen
 
     }
 
+    @Override
+    public void run() {
+        java.lang.ref.Reference<? extends Object> ref = queue.poll();
+        if (ref != null) {
+            log.info("calling disposal for " + ref.toString());
+            DisposalCallbackRegistryImpl registry = disposalCallbacks.remove(ref);
+            registry.onDisposed();
+        }
+    }
+
     private static final Logger log = LoggerFactory.getLogger(YamfAdapterFactory.class);
 
     @Reference(name = "injector", referenceInterface = Injector.class,
@@ -85,6 +129,8 @@ public class YamfAdapterFactory implemen
 
     private ModelPackageBundleListener listener;
 
+    private ServiceRegistration jobRegistration;
+
     @SuppressWarnings("unchecked")
     public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType>
type) {
         Model modelAnnotation = type.getAnnotation(Model.class);
@@ -154,6 +200,9 @@ public class YamfAdapterFactory implemen
     private InvocationHandler createInvocationHandler(final Object adaptable, final Class<?>
type) {
         Set<Method> injectableMethods = collectInjectableMethods(type);
         Map<Method, Object> methods = new HashMap<Method, Object>();
+        MapBackedInvocationHandler handler = new MapBackedInvocationHandler(methods);
+
+        DisposalCallbackRegistryImpl registry = createAndRegisterCallbackRegistry(handler);
 
         for (Injector injector : sortedInjectors) {
             Iterator<Method> it = injectableMethods.iterator();
@@ -165,7 +214,7 @@ public class YamfAdapterFactory implemen
                     Type returnType = mapPrimitiveClasses(method.getGenericReturnType());
                     Object injectionAdaptable = getAdaptable(adaptable, method);
                     if (injectionAdaptable != null) {
-                        Object value = injector.getValue(injectionAdaptable, name, returnType,
method);
+                        Object value = injector.getValue(injectionAdaptable, name, returnType,
method, registry);
                         if (setMethod(method, methods, value)) {
                             it.remove();
                         }
@@ -188,7 +237,7 @@ public class YamfAdapterFactory implemen
         }
 
         if (injectableMethods.isEmpty()) {
-            return new MapBackedInvocationHandler(methods);
+            return handler;
         } else {
             Set<Method> requiredMethods = new HashSet<Method>();
             for (Method method : injectableMethods) {
@@ -202,11 +251,18 @@ public class YamfAdapterFactory implemen
                         type);
                 return null;
             } else {
-                return new MapBackedInvocationHandler(methods);
+                return handler;
             }
         }
     }
 
+    private DisposalCallbackRegistryImpl createAndRegisterCallbackRegistry(Object object)
{
+        PhantomReference<Object> reference = new PhantomReference<Object>(object,
queue);
+        DisposalCallbackRegistryImpl registry = new DisposalCallbackRegistryImpl();
+        disposalCallbacks.put(reference, registry);
+        return registry;
+    }
+
     private String getSource(AnnotatedElement element) {
         Source source = element.getAnnotation(Source.class);
         if (source != null) {
@@ -228,6 +284,8 @@ public class YamfAdapterFactory implemen
 
         AdapterType object = type.newInstance();
 
+        DisposalCallbackRegistryImpl registry = createAndRegisterCallbackRegistry(object);
+
         for (Injector injector : sortedInjectors) {
             Iterator<Field> it = injectableFields.iterator();
             while (it.hasNext()) {
@@ -238,7 +296,7 @@ public class YamfAdapterFactory implemen
                     Type fieldType = mapPrimitiveClasses(field.getGenericType());
                     Object injectionAdaptable = getAdaptable(adaptable, field);
                     if (injectionAdaptable != null) {
-                        Object value = injector.getValue(injectionAdaptable, name, fieldType,
field);
+                        Object value = injector.getValue(injectionAdaptable, name, fieldType,
field, registry);
                         if (setField(field, object, value)) {
                             it.remove();
                         }
@@ -447,7 +505,7 @@ public class YamfAdapterFactory implemen
     private boolean setField(Field field, Object createdObject, Object value) {
         if (value != null) {
             if (!isAcceptableType(field.getClass(), value) && value instanceof Adaptable)
{
-                value = ((Adaptable)value).adaptTo(field.getClass());
+                value = ((Adaptable) value).adaptTo(field.getClass());
                 if (value == null) {
                     return false;
                 }
@@ -475,7 +533,7 @@ public class YamfAdapterFactory implemen
     private boolean setMethod(Method method, Map<Method, Object> methods, Object value)
{
         if (value != null) {
             if (!isAcceptableType(method.getReturnType(), value) && value instanceof
Adaptable) {
-                value = ((Adaptable)value).adaptTo(method.getReturnType());
+                value = ((Adaptable) value).adaptTo(method.getReturnType());
                 if (value == null) {
                     return false;
                 }
@@ -518,13 +576,26 @@ public class YamfAdapterFactory implemen
     }
 
     @Activate
-    protected void activate(final ComponentContext ctx) throws InvalidSyntaxException {
+    protected void activate(final ComponentContext ctx) {
+        this.queue = new ReferenceQueue<Object>();
+        this.disposalCallbacks = new ConcurrentHashMap<java.lang.ref.Reference<Object>,
DisposalCallbackRegistryImpl>();
+        Hashtable<Object, Object> properties = new Hashtable<Object, Object>();
+        properties.put("scheduler.concurrent", false);
+        properties.put("scheduler.period", Long.valueOf(30));
+
+        this.jobRegistration = ctx.getBundleContext().registerService(Runnable.class.getName(),
this,
+                properties);
+
         this.listener = new ModelPackageBundleListener(ctx.getBundleContext(), this);
     }
 
     @Deactivate
     protected void deactivate() {
         this.listener.unregisterAll();
+        if (jobRegistration != null) {
+            jobRegistration.unregister();
+            jobRegistration = null;
+        }
     }
 
     protected void bindInjector(final Injector injector, final Map<String, Object>
props) {

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/BindingsInjector.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/BindingsInjector.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/BindingsInjector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/BindingsInjector.java
Tue Jan  7 20:03:59 2014
@@ -24,6 +24,7 @@ import javax.servlet.ServletRequest;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.scripting.SlingBindings;
+import org.apache.sling.yamf.spi.DisposalCallbackRegistry;
 import org.apache.sling.yamf.spi.Injector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,7 +49,7 @@ public class BindingsInjector implements
         }
     }
 
-    public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element)
{
+    public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element,
DisposalCallbackRegistry callbackRegistry) {
         SlingBindings bindings = getBindings(adaptable);
         if (bindings == null) {
             return null;
@@ -56,7 +57,7 @@ public class BindingsInjector implements
         if (type instanceof Class<?>) {
             return getValue(bindings, name, (Class<?>) type);
         } else {
-            log.warn("BindingsInjector doesn't support non-class types");
+            log.debug("BindingsInjector doesn't support non-class type {}", type);
             return null;
         }
 

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ChildResourceInjector.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ChildResourceInjector.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ChildResourceInjector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ChildResourceInjector.java
Tue Jan  7 20:03:59 2014
@@ -22,6 +22,7 @@ import java.lang.reflect.Type;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.yamf.spi.DisposalCallbackRegistry;
 import org.apache.sling.yamf.spi.Injector;
 
 @Component
@@ -34,7 +35,7 @@ public class ChildResourceInjector imple
     }
 
     @Override
-    public Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement
element) {
+    public Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement
element, DisposalCallbackRegistry callbackRegistry) {
         if (adaptable instanceof Resource) {
             return ((Resource) adaptable).getChild(name);
         } else {

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/OSGiServiceInjector.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/OSGiServiceInjector.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/OSGiServiceInjector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/OSGiServiceInjector.java
Tue Jan  7 20:03:59 2014
@@ -30,10 +30,11 @@ import javax.servlet.ServletRequest;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.yamf.annotations.Filter;
+import org.apache.sling.yamf.spi.DisposalCallback;
+import org.apache.sling.yamf.spi.DisposalCallbackRegistry;
 import org.apache.sling.yamf.spi.Injector;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
@@ -49,7 +50,7 @@ public class OSGiServiceInjector impleme
     private static final Logger log = LoggerFactory.getLogger(OSGiServiceInjector.class);
 
     private BundleContext bundleContext;
-    
+
     @Override
     public String getName() {
         return "osgi-services";
@@ -60,17 +61,17 @@ public class OSGiServiceInjector impleme
         this.bundleContext = ctx.getBundleContext();
     }
 
-    public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element)
{
+    public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element,
DisposalCallbackRegistry callbackRegistry) {
         Filter filter = element.getAnnotation(Filter.class);
         String filterString = null;
         if (filter != null) {
             filterString = filter.value();
         }
 
-        return getValue(adaptable, type, filterString);
+        return getValue(adaptable, type, filterString, callbackRegistry);
     }
 
-    private <T> Object getService(Object adaptable, Class<T> type, String filter)
{
+    private <T> Object getService(Object adaptable, Class<T> type, String filter,
DisposalCallbackRegistry callbackRegistry) {
         SlingScriptHelper helper = getScriptHelper(adaptable);
 
         if (helper != null) {
@@ -86,6 +87,7 @@ public class OSGiServiceInjector impleme
                 if (refs == null || refs.length == 0) {
                     return null;
                 } else {
+                    callbackRegistry.addDisposalCallback(new Callback(refs, bundleContext));
                     return bundleContext.getService(refs[0]);
                 }
             } catch (InvalidSyntaxException e) {
@@ -95,7 +97,7 @@ public class OSGiServiceInjector impleme
         }
     }
 
-    private <T> Object[] getServices(Object adaptable, Class<T> type, String
filter) {
+    private <T> Object[] getServices(Object adaptable, Class<T> type, String
filter, DisposalCallbackRegistry callbackRegistry) {
         SlingScriptHelper helper = getScriptHelper(adaptable);
 
         if (helper != null) {
@@ -107,6 +109,7 @@ public class OSGiServiceInjector impleme
                 if (refs == null || refs.length == 0) {
                     return null;
                 } else {
+                    callbackRegistry.addDisposalCallback(new Callback(refs, bundleContext));
                     List<Object> services = new ArrayList<Object>();
                     for (ServiceReference ref : refs) {
                         Object service = bundleContext.getService(ref);
@@ -126,7 +129,7 @@ public class OSGiServiceInjector impleme
     private SlingScriptHelper getScriptHelper(Object adaptable) {
         if (adaptable instanceof ServletRequest) {
             ServletRequest request = (ServletRequest) adaptable;
-            SlingBindings bindings =  (SlingBindings) request.getAttribute(SlingBindings.class.getName());
+            SlingBindings bindings = (SlingBindings) request.getAttribute(SlingBindings.class.getName());
             if (bindings != null) {
                 return bindings.getSling();
             } else {
@@ -137,18 +140,18 @@ public class OSGiServiceInjector impleme
         }
     }
 
-    private Object getValue(Object adaptable, Type type, String filterString) {
+    private Object getValue(Object adaptable, Type type, String filterString, DisposalCallbackRegistry
callbackRegistry) {
         if (type instanceof Class) {
             Class<?> injectedClass = (Class<?>) type;
             if (injectedClass.isArray()) {
-                Object[] services = getServices(adaptable, injectedClass.getComponentType(),
filterString);
+                Object[] services = getServices(adaptable, injectedClass.getComponentType(),
filterString, callbackRegistry);
                 Object arr = Array.newInstance(injectedClass.getComponentType(), services.length);
                 for (int i = 0; i < services.length; i++) {
                     Array.set(arr, i, services[i]);
                 }
                 return arr;
             } else {
-                return getService(adaptable, injectedClass, filterString);
+                return getService(adaptable, injectedClass, filterString, callbackRegistry);
             }
         } else if (type instanceof ParameterizedType) {
             ParameterizedType ptype = (ParameterizedType) type;
@@ -161,12 +164,31 @@ public class OSGiServiceInjector impleme
             }
 
             Class<?> serviceType = (Class<?>) ptype.getActualTypeArguments()[0];
-            Object[] services = getServices(adaptable, serviceType, filterString);
+            Object[] services = getServices(adaptable, serviceType, filterString, callbackRegistry);
             return Arrays.asList(services);
         } else {
             log.warn("Cannot handle type {}", type);
             return null;
         }
     }
+    
+    private static class Callback implements DisposalCallback {
+        private final ServiceReference[] refs;
+        private final BundleContext context;
+        
+        public Callback(ServiceReference[] refs, BundleContext context) {
+            this.refs = refs;
+            this.context = context;
+        }
+        
+        @Override
+        public void onDisposed() {
+            if (refs != null) {
+                for (ServiceReference ref : refs) {
+                    context.ungetService(ref);
+                }
+            }
+        }
+    }
 
 }

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/RequestAttributeInjector.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/RequestAttributeInjector.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/RequestAttributeInjector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/RequestAttributeInjector.java
Tue Jan  7 20:03:59 2014
@@ -23,6 +23,7 @@ import javax.servlet.ServletRequest;
 
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.yamf.spi.DisposalCallbackRegistry;
 import org.apache.sling.yamf.spi.Injector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,7 +40,7 @@ public class RequestAttributeInjector im
     }
 
     @Override
-    public Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement
element) {
+    public Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement
element, DisposalCallbackRegistry callbackRegistry) {
         if (!(adaptable instanceof ServletRequest)) {
             return null;
         } else if (declaredType instanceof Class<?>) {
@@ -51,7 +52,7 @@ public class RequestAttributeInjector im
                 return null;
             }
         } else {
-            log.warn("BindingsInjector doesn't support non-class types");
+            log.debug("BindingsInjector doesn't support non-class type {}", declaredType);
             return null;
         }
     }

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ValueMapInjector.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ValueMapInjector.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ValueMapInjector.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/main/java/org/apache/sling/yamf/impl/injectors/ValueMapInjector.java
Tue Jan  7 20:03:59 2014
@@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.adapter.Adaptable;
 import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.yamf.spi.DisposalCallbackRegistry;
 import org.apache.sling.yamf.spi.Injector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,14 +39,14 @@ public class ValueMapInjector implements
         return "valuemap";
     }
 
-    public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element)
{
+    public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element,
DisposalCallbackRegistry callbackRegistry) {
         ValueMap map = getMap(adaptable);
         if (map == null) {
             return null;
         } else if (type instanceof Class<?>) {
             return map.get(name, (Class<?>) type);
         } else {
-            log.warn("ValueMapInjector doesn't support non-class types");
+            log.debug("ValueMapInjector doesn't support non-class types {}", type);
             return null;
         }
     }

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/DefaultTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/DefaultTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/DefaultTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/DefaultTest.java
Tue Jan  7 20:03:59 2014
@@ -23,20 +23,35 @@ import java.util.Collections;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.api.wrappers.ValueMapDecorator;
 import org.apache.sling.yamf.impl.injectors.ValueMapInjector;
 import org.apache.sling.yamf.testmodels.classes.DefaultStringModel;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentContext;
 
+@RunWith(MockitoJUnitRunner.class)
 public class DefaultTest {
 
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
     private YamfAdapterFactory factory;
 
     @Before
     public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
         factory = new YamfAdapterFactory();
+        factory.activate(componentCtx);
         factory.bindInjector(new ValueMapInjector(),
                 Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 0L));
     }

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/MultipleInjectorTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/MultipleInjectorTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/MultipleInjectorTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/MultipleInjectorTest.java
Tue Jan  7 20:03:59 2014
@@ -35,7 +35,9 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Spy;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentContext;
 
 @RunWith(MockitoJUnitRunner.class)
 public class MultipleInjectorTest {
@@ -49,15 +51,23 @@ public class MultipleInjectorTest {
     @Mock
     private SlingHttpServletRequest request;
 
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
     private YamfAdapterFactory factory;
 
     private SlingBindings bindings;
 
     @Before
     public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
         bindings = new SlingBindings();
 
         factory = new YamfAdapterFactory();
+        factory.activate(componentCtx);
         factory.bindInjector(bindingsInjector, Collections.<String, Object> singletonMap(Constants.SERVICE_ID,
2L));
         factory.bindInjector(attributesInjector,
                 Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 1L));

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/OSGiInjectionTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/OSGiInjectionTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/OSGiInjectionTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/OSGiInjectionTest.java
Tue Jan  7 20:03:59 2014
@@ -20,6 +20,7 @@ import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
 import java.util.Collections;
+import java.util.Dictionary;
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
@@ -36,10 +37,10 @@ import org.apache.sling.yamf.testmodels.
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleListener;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
@@ -61,8 +62,9 @@ public class OSGiInjectionTest {
 
     @Before
     public void setup() {
-        factory = new YamfAdapterFactory();
         when(componentCtx.getBundleContext()).thenReturn(bundleContext);
+        factory = new YamfAdapterFactory();
+        factory.activate(componentCtx);
 
         OSGiServiceInjector injectorFactory = new OSGiServiceInjector();
         injectorFactory.activate(componentCtx);
@@ -103,6 +105,9 @@ public class OSGiInjectionTest {
         assertNotNull(model.getService());
         assertEquals(service, model.getService());
 
+        verify(bundleContext).registerService(eq(Runnable.class.getName()), eq(factory),
any(Dictionary.class));
+        verify(bundleContext).addBundleListener(any(BundleListener.class));
+        verify(bundleContext).getBundles();
         verifyNoMoreInteractions(bundleContext);
     }
 
@@ -196,6 +201,9 @@ public class OSGiInjectionTest {
         SetOSGiModel model = factory.getAdapter(res, SetOSGiModel.class);
         assertNull(model);
 
+        verify(bundleContext).registerService(eq(Runnable.class.getName()), eq(factory),
any(Dictionary.class));
+        verify(bundleContext).addBundleListener(any(BundleListener.class));
+        verify(bundleContext).getBundles();
         verifyNoMoreInteractions(res, bundleContext);
     }
 }

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/PostConstructTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/PostConstructTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/PostConstructTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/PostConstructTest.java
Tue Jan  7 20:03:59 2014
@@ -16,19 +16,38 @@
  */
 package org.apache.sling.yamf.impl;
 
-import static org.mockito.Mockito.*;
 import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.yamf.testmodels.classes.SubClass;
+import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
 
+@RunWith(MockitoJUnitRunner.class)
 public class PostConstructTest {
 
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
+    @Before
+    public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
+    }
+
     @Test
     public void testClassOrder() {
         Resource r = mock(Resource.class);
         YamfAdapterFactory factory = new YamfAdapterFactory();
+        factory.activate(componentCtx);
         // no injectors are necessary
         
         SubClass sc = factory.getAdapter(r, SubClass.class);

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/RequestInjectionTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/RequestInjectionTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/RequestInjectionTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/RequestInjectionTest.java
Tue Jan  7 20:03:59 2014
@@ -31,11 +31,19 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentContext;
 
 @RunWith(MockitoJUnitRunner.class)
 public class RequestInjectionTest {
 
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
     private YamfAdapterFactory factory;
 
     @Mock
@@ -46,12 +54,16 @@ public class RequestInjectionTest {
 
     @Before
     public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
+
         SlingBindings bindings = new SlingBindings();
         bindings.setSling(sling);
         when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);
-        
+
         factory = new YamfAdapterFactory();
-        factory.bindInjector(new BindingsInjector(), Collections.<String, Object> singletonMap(Constants.SERVICE_ID,
0L));
+        factory.activate(componentCtx);
+        factory.bindInjector(new BindingsInjector(),
+                Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 0L));
     }
 
     @Test

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelClassesTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelClassesTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelClassesTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelClassesTest.java
Tue Jan  7 20:03:59 2014
@@ -37,17 +37,32 @@ import org.apache.sling.yamf.testmodels.
 import org.apache.sling.yamf.testmodels.interfaces.ParentModel;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
 import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
 import org.mockito.stubbing.Answer;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentContext;
 
+@RunWith(MockitoJUnitRunner.class)
 public class ResourceModelClassesTest {
 
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
     private YamfAdapterFactory factory;
 
     @Before
     public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
+
         factory = new YamfAdapterFactory();
+        factory.activate(componentCtx);
         factory.bindInjector(new ValueMapInjector(),
                 Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 1L));
         factory.bindInjector(new ChildResourceInjector(),

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelInterfacesTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelInterfacesTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelInterfacesTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ResourceModelInterfacesTest.java
Tue Jan  7 20:03:59 2014
@@ -31,15 +31,29 @@ import org.apache.sling.yamf.testmodels.
 import org.apache.sling.yamf.testmodels.interfaces.SimplePropertyModel;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentContext;
 
+@RunWith(MockitoJUnitRunner.class)
 public class ResourceModelInterfacesTest {
 
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
     private YamfAdapterFactory factory;
 
     @Before
     public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
         factory = new YamfAdapterFactory();
+        factory.activate(componentCtx);
         factory.bindInjector(new ValueMapInjector(),
                 Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 0L));
     }

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ViaTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ViaTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ViaTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.impl/src/test/java/org/apache/sling/yamf/impl/ViaTest.java
Tue Jan  7 20:03:59 2014
@@ -33,7 +33,9 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentContext;
 
 @RunWith(MockitoJUnitRunner.class)
 public class ViaTest {
@@ -43,13 +45,21 @@ public class ViaTest {
 
     @Mock
     private SlingHttpServletRequest request;
+
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
     
     private YamfAdapterFactory factory;
 
     @Before
     public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
         when(request.getResource()).thenReturn(resource);
         factory = new YamfAdapterFactory();
+        factory.activate(componentCtx);
         factory.bindInjector(new ValueMapInjector(),
                 Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 0L));
     }

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/SimpleTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/SimpleTest.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/SimpleTest.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/SimpleTest.java
Tue Jan  7 20:03:59 2014
@@ -42,6 +42,7 @@ public class SimpleTest {
 
             assertNotNull("Model is null", model);
             assertEquals("Test Property is not set correctly", value, model.getTestProperty());
+            assertNotNull("Filters is null", model.getFilters());
         } finally {
             if (resolver != null) {
                 resolver.close();

Modified: sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/models/TestModel.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/models/TestModel.java?rev=1556338&r1=1556337&r2=1556338&view=diff
==============================================================================
--- sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/models/TestModel.java
(original)
+++ sling/whiteboard/justin/yamf/org.apache.sling.yamf.server-side-tests/src/main/java/org/apache/sling/yamf/it/models/TestModel.java
Tue Jan  7 20:03:59 2014
@@ -1,6 +1,9 @@
 package org.apache.sling.yamf.it.models;
 
+import java.util.List;
+
 import javax.inject.Inject;
+import javax.servlet.Filter;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.yamf.annotations.Model;
@@ -11,7 +14,14 @@ public class TestModel {
     @Inject
     private String testProperty;
     
+    @Inject
+    private List<Filter> filters;
+    
     public String getTestProperty() {
         return testProperty;
     }
+    
+    public List<Filter> getFilters() {
+        return filters;
+    }
 }



Mime
View raw message