Merge branch 'SLING-7015'
authorJustin Edelson <justin@apache.org>
Thu, 20 Jul 2017 15:14:15 +0000 (15:14 +0000)
committerJustin Edelson <justin@apache.org>
Thu, 20 Jul 2017 15:14:15 +0000 (15:14 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1802505 13f79535-47bb-0310-9956-ffa450edef68

pom.xml
src/main/java/org/apache/sling/models/impl/ExportServlet.java
src/main/java/org/apache/sling/models/impl/ExporterScriptEngineFactory.java [deleted file]
src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
src/main/java/org/apache/sling/models/impl/ModelPackageBundleListener.java
src/main/java/org/apache/sling/models/impl/ResourceOverridingRequestWrapper.java [new file with mode: 0644]
src/main/java/org/apache/sling/models/impl/SlingModelsScriptEngineFactory.java [new file with mode: 0644]
src/test/java/org/apache/sling/models/impl/RequestWrapperTest.java [new file with mode: 0644]
src/test/java/org/apache/sling/models/impl/StaticInjectionAPFLoadOrderTest.java

diff --git a/pom.xml b/pom.xml
index 080c5a3..c8d12c6 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <dependency>\r
             <groupId>org.apache.sling</groupId>\r
             <artifactId>org.apache.sling.models.api</artifactId>\r
-            <version>1.3.4</version>\r
+            <version>1.3.5-SNAPSHOT</version>\r
             <scope>provided</scope>\r
         </dependency>\r
         <dependency>\r
index 6fceed2..f766c0f 100644 (file)
@@ -54,27 +54,17 @@ class ExportServlet extends SlingSafeMethodsServlet {
 
     private final Logger logger;
 
-    /** The context string to use to select BindingsValuesProviders */
-    private static final String BINDINGS_CONTEXT = BindingsValuesProvider.DEFAULT_CONTEXT;
-
-    /** embed this value so as to avoid a dependency on a newer Sling API than otherwise necessary. */
-    private static final String RESOLVER = "resolver";
-
-    /** The set of protected keys. */
-    private static final Set<String> PROTECTED_KEYS =
-            new HashSet<String>(Arrays.asList(REQUEST, RESPONSE, READER, SLING, RESOURCE, RESOLVER, OUT, LOG));
-
     private final String exporterName;
     private final String registeredSelector;
     private final BundleContext bundleContext;
     private final ModelFactory modelFactory;
     private final BindingsValuesProvidersByContext bindingsValuesProvidersByContext;
-    private final ScriptEngineFactory scriptEngineFactory;
+    private final SlingModelsScriptEngineFactory scriptEngineFactory;
     private final ExportedObjectAccessor accessor;
     private final Map<String, String> baseOptions;
 
     public ExportServlet(BundleContext bundleContext, ModelFactory modelFactory,
-                         BindingsValuesProvidersByContext bindingsValuesProvidersByContext, ScriptEngineFactory scriptFactory,
+                         BindingsValuesProvidersByContext bindingsValuesProvidersByContext, SlingModelsScriptEngineFactory scriptFactory,
                          Class<?> annotatedClass, String registeredSelector, String exporterName, ExportedObjectAccessor accessor,
                          Map<String, String> baseOptions) {
         this.bundleContext = bundleContext;
@@ -128,26 +118,14 @@ class ExportServlet extends SlingSafeMethodsServlet {
         SimpleBindings bindings = new SimpleBindings();
         bindings.put(SLING, scriptHelper);
         bindings.put(RESOURCE, request.getResource());
-        bindings.put(RESOLVER, request.getResource().getResourceResolver());
+        bindings.put(SlingModelsScriptEngineFactory.RESOLVER, request.getResource().getResourceResolver());
         bindings.put(REQUEST, request);
         bindings.put(RESPONSE, response);
         bindings.put(READER, request.getReader());
         bindings.put(OUT, response.getWriter());
         bindings.put(LOG, logger);
 
-        final Collection<BindingsValuesProvider> bindingsValuesProviders =
-                bindingsValuesProvidersByContext.getBindingsValuesProviders(scriptEngineFactory, BINDINGS_CONTEXT);
-
-        if (!bindingsValuesProviders.isEmpty()) {
-            Set<String> protectedKeys = new HashSet<String>();
-            protectedKeys.addAll(PROTECTED_KEYS);
-
-            ProtectedBindings protectedBindings = new ProtectedBindings(bindings, protectedKeys);
-            for (BindingsValuesProvider provider : bindingsValuesProviders) {
-                provider.addBindings(protectedBindings);
-            }
-
-        }
+        scriptEngineFactory.invokeBindingsValuesProviders(bindingsValuesProvidersByContext, bindings);
 
         SlingBindings slingBindings = new SlingBindings();
         slingBindings.putAll(bindings);
diff --git a/src/main/java/org/apache/sling/models/impl/ExporterScriptEngineFactory.java b/src/main/java/org/apache/sling/models/impl/ExporterScriptEngineFactory.java
deleted file mode 100644 (file)
index bb0988b..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.models.impl;
-
-import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-
-/**
- * Essentially fake ScriptEngineFactory needed for accessing BindingsValuesProviders in the ExportServlet
- */
-class ExporterScriptEngineFactory extends AbstractScriptEngineFactory implements ScriptEngineFactory {
-
-    ExporterScriptEngineFactory(Bundle bundle) {
-        super();
-        setEngineName("Apache Sling Models Exporter");
-        // really the only time this is null is during testing
-        if (bundle != null && bundle.getHeaders() != null && bundle.getHeaders().get(Constants.BUNDLE_VERSION) != null) {
-            setEngineVersion(bundle.getHeaders().get(Constants.BUNDLE_VERSION).toString());
-        }
-        setNames("sling-models-exporter");
-    }
-
-    @Override
-    public String getLanguageName() {
-        return null;
-    }
-
-    @Override
-    public String getLanguageVersion() {
-        return null;
-    }
-
-    @Override
-    public ScriptEngine getScriptEngine() {
-        return null;
-    }
-}
index d92644e..698fa11 100644 (file)
@@ -56,6 +56,7 @@ import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.adapter.Adaptable;
 import org.apache.sling.api.adapter.AdapterFactory;
+import org.apache.sling.api.adapter.AdapterManager;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.commons.osgi.RankedServices;
@@ -204,6 +205,9 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
     @Reference
     private BindingsValuesProvidersByContext bindingsValuesProvidersByContext;
 
+    @Reference
+    private AdapterManager adapterManager;
+
     ModelPackageBundleListener listener;
 
     final AdapterImplementations adapterImplementations = new AdapterImplementations();
@@ -217,6 +221,8 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
 
     private Map<Object, Map<Class, Object>> adapterCache;
 
+    private SlingModelsScriptEngineFactory scriptEngineFactory;
+
     // use a smaller initial capacity than the default as we expect a relatively small number of
     // adapters per adaptable
     private final int INNER_CACHE_INITIAL_CAPACITY = 4;
@@ -1022,7 +1028,8 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
 
         this.jobRegistration = bundleContext.registerService(Runnable.class.getName(), this, properties);
 
-        this.listener = new ModelPackageBundleListener(ctx.getBundleContext(), this, this.adapterImplementations, bindingsValuesProvidersByContext);
+        this.scriptEngineFactory = new SlingModelsScriptEngineFactory(bundleContext.getBundle());
+        this.listener = new ModelPackageBundleListener(ctx.getBundleContext(), this, this.adapterImplementations, bindingsValuesProvidersByContext, scriptEngineFactory);
 
         Hashtable<Object, Object> printerProps = new Hashtable<Object, Object>();
         printerProps.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
@@ -1247,4 +1254,10 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
         }
     }
 
+    @Override
+    public <T> T getModelFromWrappedRequest(@Nonnull SlingHttpServletRequest request, @Nonnull Resource resource, @Nonnull Class<T> targetClass) {
+        return new ResourceOverridingRequestWrapper(request, resource, adapterManager,
+                scriptEngineFactory, bindingsValuesProvidersByContext).adaptTo(targetClass);
+    }
+
 }
index 770e4f1..f7f0b42 100644 (file)
@@ -85,17 +85,18 @@ public class ModelPackageBundleListener implements BundleTrackerCustomizer {
 
     private final BindingsValuesProvidersByContext bindingsValuesProvidersByContext;
 
-    private final ScriptEngineFactory scriptEngineFactory;
+    private final SlingModelsScriptEngineFactory scriptEngineFactory;
     
     public ModelPackageBundleListener(BundleContext bundleContext,
                                       ModelAdapterFactory factory,
                                       AdapterImplementations adapterImplementations,
-                                      BindingsValuesProvidersByContext bindingsValuesProvidersByContext) {
+                                      BindingsValuesProvidersByContext bindingsValuesProvidersByContext,
+                                      SlingModelsScriptEngineFactory scriptEngineFactory) {
         this.bundleContext = bundleContext;
         this.factory = factory;
         this.adapterImplementations = adapterImplementations;
         this.bindingsValuesProvidersByContext = bindingsValuesProvidersByContext;
-        this.scriptEngineFactory = new ExporterScriptEngineFactory(bundleContext.getBundle());
+        this.scriptEngineFactory = scriptEngineFactory;
         this.bundleTracker = new BundleTracker(bundleContext, Bundle.ACTIVE, this);
         this.bundleTracker.open();
     }
diff --git a/src/main/java/org/apache/sling/models/impl/ResourceOverridingRequestWrapper.java b/src/main/java/org/apache/sling/models/impl/ResourceOverridingRequestWrapper.java
new file mode 100644 (file)
index 0000000..cd44f93
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.adapter.AdapterManager;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.scripting.SlingBindings;
+import org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper;
+import org.apache.sling.scripting.api.BindingsValuesProvider;
+import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
+import org.apache.sling.scripting.core.impl.helper.ProtectedBindings;
+
+import javax.script.ScriptEngineFactory;
+import javax.script.SimpleBindings;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.apache.sling.api.scripting.SlingBindings.*;
+
+/**
+ * This request wrapper allows to adapt the given resource and request to a Sling Model
+ */
+class ResourceOverridingRequestWrapper extends SlingHttpServletRequestWrapper {
+
+    private final Resource resource;
+    private final AdapterManager adapterManager;
+    private final SlingBindings bindings;
+
+    ResourceOverridingRequestWrapper(SlingHttpServletRequest wrappedRequest, Resource resource,
+                                            AdapterManager adapterManager, SlingModelsScriptEngineFactory scriptEngineFactory,
+                                            BindingsValuesProvidersByContext bindingsValuesProvidersByContext) {
+        super(wrappedRequest);
+        this.resource = resource;
+        this.adapterManager = adapterManager;
+
+        SlingBindings existingBindings = (SlingBindings) wrappedRequest.getAttribute(SlingBindings.class.getName());
+
+        SimpleBindings bindings = new SimpleBindings();
+        if (existingBindings != null) {
+            bindings.put(SLING, existingBindings.getSling());
+            bindings.put(RESPONSE, existingBindings.getResponse());
+            bindings.put(READER, existingBindings.getReader());
+            bindings.put(OUT, existingBindings.getOut());
+            bindings.put(LOG, existingBindings.getLog());
+        }
+        bindings.put(REQUEST, this);
+        bindings.put(RESOURCE, resource);
+        bindings.put(SlingModelsScriptEngineFactory.RESOLVER, resource.getResourceResolver());
+
+        scriptEngineFactory.invokeBindingsValuesProviders(bindingsValuesProvidersByContext, bindings);
+
+        SlingBindings slingBindings = new SlingBindings();
+        slingBindings.putAll(bindings);
+
+        this.bindings = slingBindings;
+
+    }
+
+    @Override
+    public Object getAttribute(String name) {
+        if (SlingBindings.class.getName().equals(name)) {
+            return bindings;
+        } else {
+            return super.getAttribute(name);
+        }
+    }
+    @Override
+    public Resource getResource() {
+        return resource;
+    }
+
+    @Override
+    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
+        return adapterManager.getAdapter(this, type);
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/models/impl/SlingModelsScriptEngineFactory.java b/src/main/java/org/apache/sling/models/impl/SlingModelsScriptEngineFactory.java
new file mode 100644 (file)
index 0000000..0b81609
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl;
+
+import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
+import org.apache.sling.scripting.api.BindingsValuesProvider;
+import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
+import org.apache.sling.scripting.core.impl.helper.ProtectedBindings;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.SimpleBindings;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.apache.sling.api.scripting.SlingBindings.*;
+
+/**
+ * Essentially fake ScriptEngineFactory needed for accessing BindingsValuesProviders in the ExportServlet
+ */
+class SlingModelsScriptEngineFactory extends AbstractScriptEngineFactory implements ScriptEngineFactory {
+
+    /** The context string to use to select BindingsValuesProviders */
+    private static final String BINDINGS_CONTEXT = BindingsValuesProvider.DEFAULT_CONTEXT;
+
+    /** embed this value so as to avoid a dependency on a newer Sling API than otherwise necessary. */
+    static final String RESOLVER = "resolver";
+
+    /** The set of protected keys. */
+    private static final Set<String> PROTECTED_KEYS =
+            new HashSet<String>(Arrays.asList(REQUEST, RESPONSE, READER, SLING, RESOURCE, RESOLVER, OUT, LOG));
+
+    SlingModelsScriptEngineFactory(Bundle bundle) {
+        super();
+        setEngineName("Apache Sling Models");
+        // really the only time this is null is during testing
+        if (bundle != null && bundle.getHeaders() != null && bundle.getHeaders().get(Constants.BUNDLE_VERSION) != null) {
+            setEngineVersion(bundle.getHeaders().get(Constants.BUNDLE_VERSION).toString());
+        }
+        setNames("sling-models-exporter", "sling-models");
+    }
+
+    @Override
+    public String getLanguageName() {
+        return null;
+    }
+
+    @Override
+    public String getLanguageVersion() {
+        return null;
+    }
+
+    @Override
+    public ScriptEngine getScriptEngine() {
+        return null;
+    }
+
+    void invokeBindingsValuesProviders(BindingsValuesProvidersByContext bindingsValuesProvidersByContext, SimpleBindings bindings) {
+        final Collection<BindingsValuesProvider> bindingsValuesProviders =
+                bindingsValuesProvidersByContext.getBindingsValuesProviders(this, SlingModelsScriptEngineFactory.BINDINGS_CONTEXT);
+
+        if (!bindingsValuesProviders.isEmpty()) {
+            Set<String> protectedKeys = new HashSet<String>();
+            protectedKeys.addAll(SlingModelsScriptEngineFactory.PROTECTED_KEYS);
+
+            ProtectedBindings protectedBindings = new ProtectedBindings(bindings, protectedKeys);
+            for (BindingsValuesProvider provider : bindingsValuesProviders) {
+                provider.addBindings(protectedBindings);
+            }
+
+        }
+    }
+}
diff --git a/src/test/java/org/apache/sling/models/impl/RequestWrapperTest.java b/src/test/java/org/apache/sling/models/impl/RequestWrapperTest.java
new file mode 100644 (file)
index 0000000..ae8fd2a
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.adapter.AdapterManager;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.scripting.SlingBindings;
+import org.apache.sling.scripting.api.BindingsValuesProvider;
+import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+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.service.component.ComponentContext;
+
+import javax.script.Bindings;
+import javax.script.ScriptEngineFactory;
+import java.util.Collections;
+import java.util.Hashtable;
+
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+import static org.junit.Assert.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RequestWrapperTest {
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
+    @Mock
+    private AdapterManager adapterManager;
+
+    @Mock
+    private BindingsValuesProvidersByContext bindingsValuesProvidersByContext;
+
+    @Mock
+    private BindingsValuesProvider bindingsValuesProvider;
+
+    @Mock
+    private Resource resource;
+
+    @Mock
+    private SlingHttpServletRequest request;
+
+    @InjectMocks
+    private ModelAdapterFactory factory;
+
+    @Before
+    public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
+        when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());
+        factory.activate(componentCtx);
+        when(bindingsValuesProvidersByContext.getBindingsValuesProviders(any(ScriptEngineFactory.class), eq(BindingsValuesProvider.DEFAULT_CONTEXT))).
+                thenReturn(Collections.singleton(bindingsValuesProvider));
+    }
+
+    @Test
+    public void testWrapper() {
+        Target expected = new Target();
+        when(adapterManager.getAdapter(any(SlingHttpServletRequest.class), eq(Target.class))).thenReturn(expected);
+
+        Target actual = factory.getModelFromWrappedRequest(request, resource, Target.class);
+        assertEquals(expected, actual);
+
+        verify(adapterManager, times(1)).getAdapter(argThat(requestHasResource(resource)), eq(Target.class));
+        verify(bindingsValuesProvider, times(1)).addBindings(argThat(bindingsHasResource(resource)));
+    }
+
+    private Matcher<Bindings> bindingsHasResource(final Resource resource) {
+        return new TypeSafeMatcher<Bindings>() {
+            @Override
+            protected boolean matchesSafely(Bindings bindings) {
+                return bindings.get(SlingBindings.RESOURCE) == resource;
+            }
+
+            @Override
+            public void describeTo(Description description) {
+                description.appendText("a bindings object with the resource " + resource);
+            }
+        };
+    }
+
+    private Matcher<SlingHttpServletRequest> requestHasResource(final Resource resource) {
+        return new TypeSafeMatcher<SlingHttpServletRequest>() {
+            @Override
+            protected boolean matchesSafely(SlingHttpServletRequest slingHttpServletRequest) {
+                return slingHttpServletRequest.getResource().equals(resource);
+            }
+
+            @Override
+            public void describeTo(Description description) {
+                description.appendText("a request with the resource " + resource);
+            }
+        };
+    }
+
+    class Target {
+
+    }
+
+}
index 41334e0..88ec8f3 100644 (file)
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
 
 import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.adapter.AdapterManager;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.models.annotations.Model;
 import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
@@ -54,6 +55,9 @@ public class StaticInjectionAPFLoadOrderTest {
 
     @Mock
     private BindingsValuesProvidersByContext bindingsValuesProvidersByContext;
+
+    @Mock
+    private AdapterManager adapterManager;
     
     private ModelAdapterFactory factory;
     
@@ -118,6 +122,7 @@ public class StaticInjectionAPFLoadOrderTest {
     
     private void registerServices() {
         context.registerService(BindingsValuesProvidersByContext.class, bindingsValuesProvidersByContext);
+        context.registerService(AdapterManager.class, adapterManager);
         factory = context.registerInjectActivateService(new ModelAdapterFactory());
     }