You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2012/06/14 12:06:31 UTC
svn commit: r1350171 [2/2] - in /sling/trunk/bundles: jcr/resource/
jcr/resource/src/main/appended-resources/
jcr/resource/src/main/java/org/apache/sling/jcr/resource/
jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/
jcr/resource/src/...
Added: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java?rev=1350171&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java (added)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java Thu Jun 14 10:06:30 2012
@@ -0,0 +1,302 @@
+/*
+ * 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.jcr.resource.internal.helper.jcr;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.api.resource.ResourceProviderFactory;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.resource.JcrResourceConstants;
+import org.osgi.framework.Constants;
+
+/**
+ * The <code>JcrResourceProviderFactory</code> creates
+ * resource providers based on JCR.
+ */
+@Component
+@Service(value = ResourceProviderFactory.class )
+@Properties({
+ @Property(name=ResourceProviderFactory.PROPERTY_REQUIRED, boolValue=true),
+ @Property(name=ResourceProvider.ROOTS, value="/"),
+ @Property(name = Constants.SERVICE_DESCRIPTION, value = "Apache Sling JCR Resource Provider Factory"),
+ @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software Foundation")
+})
+public class JcrResourceProviderFactory implements ResourceProviderFactory {
+
+ /** The dynamic class loader */
+ @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC)
+ private DynamicClassLoaderManager dynamicClassLoaderManager;
+
+ @Reference
+ private SlingRepository repository;
+
+ /** Get the dynamic class loader if available */
+ ClassLoader getDynamicClassLoader() {
+ final DynamicClassLoaderManager dclm = this.dynamicClassLoaderManager;
+ if (dclm != null) {
+ return dclm.getDynamicClassLoader();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.sling.api.resource.ResourceProviderFactory#getResourceProvider(java.util.Map)
+ */
+ public ResourceProvider getResourceProvider(final Map<String, Object> authenticationInfo)
+ throws LoginException {
+ return getResourceProviderInternal(authenticationInfo, false);
+ }
+
+ /**
+ * @see org.apache.sling.api.resource.ResourceProviderFactory#getAdministrativeResourceProvider(java.util.Map)
+ */
+ public ResourceProvider getAdministrativeResourceProvider(final Map<String, Object> authenticationInfo)
+ throws LoginException {
+ return getResourceProviderInternal(authenticationInfo, true);
+ }
+
+ /**
+ * Create a new ResourceResolver wrapping a Session object. Carries map of
+ * authentication info in order to create a new resolver as needed.
+ */
+ private ResourceProvider getResourceProviderInternal(
+ final Map<String, Object> authenticationInfo, final boolean isAdmin)
+ throws LoginException {
+
+ // by default any session used by the resource resolver returned is
+ // closed when the resource resolver is closed
+ boolean logoutSession = true;
+
+ // derive the session to be used
+ Session session;
+ try {
+ if (isAdmin) {
+ // requested admin session to any workspace (or default)
+ session = repository.loginAdministrative(null);
+
+ } else {
+
+ session = getSession(authenticationInfo);
+ if (session == null) {
+ // requested non-admin session to any workspace (or default)
+ final Credentials credentials = getCredentials(authenticationInfo);
+ session = repository.login(credentials, null);
+
+ } else {
+ // session provided; no special workspace; just make sure
+ // the session is not logged out when the resolver is closed
+ logoutSession = false;
+ }
+ }
+ } catch (RepositoryException re) {
+ throw getLoginException(re);
+ }
+
+ session = handleImpersonation(session, authenticationInfo, logoutSession);
+
+ return new JcrResourceProvider(session, this.getDynamicClassLoader(), logoutSession);
+ }
+
+ /**
+ * Return the sudo user information.
+ * If the sudo user info is provided, it is returned, otherwise
+ * <code>null</code> is returned.
+ * @param authenticationInfo Optional authentication info.
+ * @return The configured sudo user information or <code>null</code>
+ */
+ private String getSudoUser(final Map<String, Object> authenticationInfo) {
+ if (authenticationInfo != null) {
+ final Object sudoObject = authenticationInfo.get(ResourceResolverFactory.USER_IMPERSONATION);
+ if (sudoObject instanceof String) {
+ return (String) sudoObject;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Handle the sudo if configured. If the authentication info does not
+ * contain a sudo info, this method simply returns the passed in session. If
+ * a sudo user info is available, the session is tried to be impersonated.
+ * The new impersonated session is returned. The original session is closed.
+ * The session is also closed if the impersonation fails.
+ *
+ * @param session The session.
+ * @param authenticationInfo The optional authentication info.
+ * @param logoutSession whether to logout the <code>session</code> after
+ * impersonation or not.
+ * @return The original session or impersonated session.
+ * @throws LoginException If something goes wrong.
+ */
+ private Session handleImpersonation(final Session session,
+ final Map<String, Object> authenticationInfo,
+ final boolean logoutSession)
+ throws LoginException {
+ final String sudoUser = getSudoUser(authenticationInfo);
+ if (sudoUser != null && !session.getUserID().equals(sudoUser)) {
+ try {
+ final SimpleCredentials creds = new SimpleCredentials(sudoUser,
+ new char[0]);
+ copyAttributes(creds, authenticationInfo);
+ creds.setAttribute(ResourceResolver.USER_IMPERSONATOR,
+ session.getUserID());
+ return session.impersonate(creds);
+ } catch (final RepositoryException re) {
+ throw getLoginException(re);
+ } finally {
+ if (logoutSession) {
+ session.logout();
+ }
+ }
+ }
+ return session;
+ }
+
+ /**
+ * Create a login exception from a repository exception.
+ * If the repository exception is a {@link javax.jcr.LoginException}
+ * a {@link LoginException} is created with the same information.
+ * Otherwise a {@link LoginException} is created which wraps the
+ * repository exception.
+ * @param re The repository exception.
+ * @return The login exception.
+ */
+ private LoginException getLoginException(final RepositoryException re) {
+ if ( re instanceof javax.jcr.LoginException ) {
+ return new LoginException(re.getMessage(), re.getCause());
+ }
+ return new LoginException("Unable to login " + re.getMessage(), re);
+ }
+
+ /**
+ * Create a credentials object from the provided authentication info.
+ * If no map is provided, <code>null</code> is returned.
+ * If a map is provided and contains a credentials object, this object is
+ * returned.
+ * If a map is provided but does not contain a credentials object nor a
+ * user, <code>null</code> is returned.
+ * if a map is provided with a user name but without a credentials object
+ * a new credentials object is created and all values from the authentication
+ * info are added as attributes.
+ * @param authenticationInfo Optional authentication info
+ * @return A credentials object or <code>null</code>
+ */
+ private Credentials getCredentials(final Map<String, Object> authenticationInfo) {
+ if (authenticationInfo == null) {
+ return null;
+ }
+
+ final Object credentialsObject = authenticationInfo.get(JcrResourceConstants.AUTHENTICATION_INFO_CREDENTIALS);
+ if (credentialsObject instanceof Credentials) {
+ return (Credentials) credentialsObject;
+ }
+
+ // otherwise try to create SimpleCredentials if the userId is set
+ final Object userId = authenticationInfo.get(ResourceResolverFactory.USER);
+ if (userId instanceof String) {
+ final Object password = authenticationInfo.get(ResourceResolverFactory.PASSWORD);
+ final SimpleCredentials credentials = new SimpleCredentials(
+ (String) userId, ((password instanceof char[])
+ ? (char[]) password
+ : new char[0]));
+
+ // add attributes
+ copyAttributes(credentials, authenticationInfo);
+
+ return credentials;
+ }
+
+ // no user id (or not a String)
+ return null;
+ }
+
+ /**
+ * Copies the contents of the source map as attributes into the target
+ * <code>SimpleCredentials</code> object with the exception of the
+ * <code>user.jcr.credentials</code> and <code>user.password</code>
+ * attributes to prevent leaking passwords into the JCR Session attributes
+ * which might be used for break-in attempts.
+ *
+ * @param target The <code>SimpleCredentials</code> object whose attributes
+ * are to be augmented.
+ * @param source The map whose entries (except the ones listed above) are
+ * copied as credentials attributes.
+ */
+ private void copyAttributes(final SimpleCredentials target,
+ final Map<String, Object> source) {
+ final Iterator<Map.Entry<String, Object>> i = source.entrySet().iterator();
+ while (i.hasNext()) {
+ final Map.Entry<String, Object> current = i.next();
+ if (isAttributeVisible(current.getKey())) {
+ target.setAttribute(current.getKey(), current.getValue());
+ }
+ }
+ }
+
+ /**
+ * Returns <code>true</code> unless the name is
+ * <code>user.jcr.credentials</code> (
+ * {@link JcrResourceConstants#AUTHENTICATION_INFO_CREDENTIALS}) or contains
+ * the string <code>password</code> as in <code>user.password</code> (
+ * {@link org.apache.sling.api.resource.ResourceResolverFactory#PASSWORD})
+ *
+ * @param name The name to check whether it is visible or not
+ * @return <code>true</code> if the name is assumed visible
+ * @throws NullPointerException if <code>name</code> is <code>null</code>
+ */
+ public static boolean isAttributeVisible(final String name) {
+ return !name.equals(JcrResourceConstants.AUTHENTICATION_INFO_CREDENTIALS)
+ && !name.contains("password");
+ }
+
+ /**
+ * Returns the session provided as the user.jcr.session property of the
+ * <code>authenticationInfo</code> map or <code>null</code> if the
+ * property is not contained in the map or is not a <code>javax.jcr.Session</code>.
+ * @param authenticationInfo Optional authentication info.
+ * @return The user.jcr.session property or <code>null</code>
+ */
+ private Session getSession(final Map<String, Object> authenticationInfo) {
+ if (authenticationInfo != null) {
+ final Object sessionObject = authenticationInfo.get(JcrResourceConstants.AUTHENTICATION_INFO_SESSION);
+ if (sessionObject instanceof Session) {
+ return (Session) sessionObject;
+ }
+ }
+ return null;
+ }
+}
Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java?rev=1350171&r1=1350170&r2=1350171&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/scripting/JcrObjectsBindingsValuesProvider.java Thu Jun 14 10:06:30 2012
@@ -34,28 +34,27 @@ import org.osgi.framework.Constants;
@Component
@Service
@Properties({
- @Property(name=Constants.SERVICE_DESCRIPTION, value="Apache Sling CurrentNode BindingsValuesProvider"),
- @Property(name=Constants.SERVICE_VENDOR, value="The Apache Software Foundation")
-})
+ @Property(name = Constants.SERVICE_DESCRIPTION, value = "Apache Sling CurrentNode BindingsValuesProvider"),
+ @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software Foundation") })
public class JcrObjectsBindingsValuesProvider implements BindingsValuesProvider {
-
private static final String PROP_CURRENT_NODE = "currentNode";
private static final String PROP_CURRENT_SESSION = "currentSession";
/**
* {@inheritDoc}
*/
- public void addBindings(Bindings bindings) {
- Resource resource = (Resource) bindings.get("resource");
+ public void addBindings(final Bindings bindings) {
+ final Resource resource = (Resource) bindings.get("resource");
if (resource != null) {
- Node node = resource.adaptTo(Node.class);
+ final Node node = resource.adaptTo(Node.class);
if (node != null) {
bindings.put(PROP_CURRENT_NODE, node);
}
- if ( bindings.get(PROP_CURRENT_SESSION) == null ) {
- final Session session = resource.getResourceResolver().adaptTo(Session.class);
- if ( session != null ) {
+ if (bindings.get(PROP_CURRENT_SESSION) == null) {
+ final Session session = resource.getResourceResolver().adaptTo(
+ Session.class);
+ if (session != null) {
bindings.put(PROP_CURRENT_SESSION, session);
}
}
Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java?rev=1350171&r1=1350170&r2=1350171&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java Thu Jun 14 10:06:30 2012
@@ -16,24 +16,27 @@
*/
package org.apache.sling.jcr.resource.internal;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-
-import junitx.util.PrivateAccessor;
+import javax.servlet.http.HttpServletRequest;
import org.apache.sling.api.SlingConstants;
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.commons.testing.jcr.EventHelper;
import org.apache.sling.commons.testing.jcr.RepositoryTestBase;
+import org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
-import org.osgi.util.tracker.ServiceTracker;
/**
* Test of JcrResourceListener.
@@ -66,40 +69,6 @@ public class JcrResourceListenerTest ext
}
- public void testInWs2() throws Exception {
- List<Event> events = generateEvents("ws2");
-
- assertTrue("Received: " + events, events.size() >= 3);
- Event event = events.get(0);
- assertEquals(SlingConstants.TOPIC_RESOURCE_ADDED, event.getTopic());
- assertEquals("ws2:" + createdPath, event.getProperty(SlingConstants.PROPERTY_PATH));
- assertNotNull(event.getProperty(SlingConstants.PROPERTY_USERID));
-
- event = events.get(1);
- assertEquals(SlingConstants.TOPIC_RESOURCE_CHANGED, event.getTopic());
- assertEquals("ws2:" + pathToModify, event.getProperty(SlingConstants.PROPERTY_PATH));
- assertNotNull(event.getProperty(SlingConstants.PROPERTY_USERID));
-
- event = events.get(2);
- assertEquals(SlingConstants.TOPIC_RESOURCE_REMOVED, event.getTopic());
- assertEquals("ws2:" + pathToDelete, event.getProperty(SlingConstants.PROPERTY_PATH));
- assertNotNull(event.getProperty(SlingConstants.PROPERTY_USERID));
-
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- try {
- getSession().getWorkspace().createWorkspace("ws2");
- } catch (Exception e) {
- if (!e.getMessage().equals("workspace 'ws2' already exists.")) {
- throw e;
- }
- }
-
- }
-
private static void createNode(Session session, String path) throws RepositoryException {
session.getRootNode().addNode(path.substring(1), "nt:unstructured");
session.save();
@@ -133,9 +102,117 @@ public class JcrResourceListenerTest ext
addNodeToModify(session);
addNodeToDelete(session);
- final JcrResourceResolverFactoryImpl factory = new JcrResourceResolverFactoryImpl();
- PrivateAccessor.setField(factory, "repository", getRepository());
- PrivateAccessor.setField(factory, "useMultiWorkspaces", Boolean.TRUE);
+ final ResourceResolver resolver = new ResourceResolver() {
+
+ public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
+ return (AdapterType)session;
+ }
+
+ public Resource resolve(HttpServletRequest request, String absPath) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Resource resolve(String absPath) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Resource resolve(HttpServletRequest request) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String map(String resourcePath) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String map(HttpServletRequest request, String resourcePath) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Resource getResource(String path) {
+ // TODO Auto-generated method stub
+ try {
+ return new JcrNodeResource(this, session.getNode(path), null);
+ } catch (PathNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (RepositoryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public Resource getResource(Resource base, String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String[] getSearchPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Iterator<Resource> listChildren(Resource parent) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Iterator<Resource> findResources(String query, String language) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Iterator<Map<String, Object>> queryResources(String query, String language) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ResourceResolver clone(Map<String, Object> authenticationInfo) throws LoginException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isLive() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getUserID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Iterator<String> getAttributeNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getAttribute(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ };
+ final ResourceResolverFactory factory = new ResourceResolverFactory() {
+
+ public ResourceResolver getResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
+ return null;
+ }
+
+ public ResourceResolver getAdministrativeResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
+ return resolver;
+ }
+ };
final EventAdmin mockEA = new EventAdmin() {
@@ -147,11 +224,8 @@ public class JcrResourceListenerTest ext
events.add(event);
}
};
- final ServiceTracker tracker = mock(ServiceTracker.class);
- when(tracker.getService()).thenReturn(mockEA);
- JcrResourceListener listener = new SynchronousJcrResourceListener(workspaceName, factory, "/",
- "/", tracker);
+ SynchronousJcrResourceListener listener = new SynchronousJcrResourceListener(factory, mockEA);
createdPath = createTestPath();
createNode(session, createdPath);
Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/SynchronousJcrResourceListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/SynchronousJcrResourceListener.java?rev=1350171&r1=1350170&r2=1350171&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/SynchronousJcrResourceListener.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/SynchronousJcrResourceListener.java Thu Jun 14 10:06:30 2012
@@ -18,10 +18,12 @@ package org.apache.sling.jcr.resource.in
import javax.jcr.RepositoryException;
+import junitx.util.PrivateAccessor;
+
import org.apache.jackrabbit.core.observation.SynchronousEventListener;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.service.event.EventAdmin;
/**
* This class is used to ensure that events are handled during the test.
@@ -32,10 +34,15 @@ import org.osgi.util.tracker.ServiceTrac
*/
public class SynchronousJcrResourceListener extends JcrResourceListener implements SynchronousEventListener {
- public SynchronousJcrResourceListener(String workspaceName,
- ResourceResolverFactory factory, String startPath, String mountPrefix, ServiceTracker eventAdminTracker)
- throws LoginException, RepositoryException {
- super(workspaceName, factory, startPath, mountPrefix, eventAdminTracker);
+ public SynchronousJcrResourceListener(
+ ResourceResolverFactory factory, EventAdmin eventAdmin)
+ throws LoginException, RepositoryException, NoSuchFieldException {
+ PrivateAccessor.setField(this, "resourceResolverFactory", factory);
+ PrivateAccessor.setField(this, "eventAdmin", eventAdmin);
+ this.activate();
}
+ public void dispose() {
+ this.deactivate();
+ }
}
Modified: sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1350171&r1=1350170&r2=1350171&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties (original)
+++ sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties Thu Jun 14 10:06:30 2012
@@ -24,9 +24,9 @@
# the SCR plugin
#
-# Localizations for JcrResourceResolverFactoryImpl configuration
-resource.resolver.name = Apache Sling JCR Resource Resolver
-resource.resolver.description = Configures the JCR Resource Resolver for request \
+# Localizations for Resource Resolver Factory configuration
+resource.resolver.name = Apache Sling Resource Resolver Factory
+resource.resolver.description = Configures the Resource Resolver for request \
URL and resource path rewriting.
resource.resolver.map.location.name = Mapping Location
@@ -71,8 +71,3 @@ resource.resolver.manglenamespaces.descr
containing colons, even though they are perfectly valid characters in the \
path part of URI references with a scheme. The default value of this property \
if no configuration is provided is "true".
-
-resource.resolver.multiworkspace.name=Enable Multi Workspaces
-resource.resolver.multiworkspace.description=If this is enabled, multiple workspaces are supported \
- This includes registering observation listeners for all workspaces and allows to \
- resolve resources from other workspaces than the default one.