Author: cziegeler
Date: Mon Jun 15 08:54:02 2015
New Revision: 1685515
URL: http://svn.apache.org/r1685515
Log:
SLING-4750 : New resource provider API. Add lifecycle methods and a provider
context
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ProviderContext.java
(with props)
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java?rev=1685515&r1=1685514&r2=1685515&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
Mon Jun 15 08:54:02 2015
@@ -28,7 +28,8 @@ import aQute.bnd.annotation.ProviderType
/**
* A {@code ResourceProvider} must use an observation reporter
- * to report changes to resources.
+ * to report changes to resources. The resource provider gets
+ * an instance of this reporter through the {@link ProviderContext}.
*/
@ProviderType
public interface ObservationReporter {
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ProviderContext.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ProviderContext.java?rev=1685515&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ProviderContext.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ProviderContext.java
Mon Jun 15 08:54:02 2015
@@ -0,0 +1,38 @@
+/*
+ * 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.spi.resource.provider;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * The provider context...
+ */
+@ProviderType
+public interface ProviderContext {
+
+ /**
+ * Get the observation reporter for this instance.
+ * @return The observation reporter.
+ */
+ @Nonnull ObservationReporter getObservationReporter();
+
+
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ProviderContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ProviderContext.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java?rev=1685515&r1=1685514&r2=1685515&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
Mon Jun 15 08:54:02 2015
@@ -50,6 +50,13 @@ import aQute.bnd.annotation.ConsumerType
* is not intended to be used by client applications directly. A resource
* provider implements this service by extending this class.
* <p>
+ * If a provider is used in the resource tree, it gets activated through
+ * a call of the {@link #activate(ProviderContext)} method. If the
+ * provider is not used anymore within the resource tree, the
+ * {@link #deactivate(ProviderContext)} method is called. Whenever
+ * information concerning the provider is changed while the provider
+ * is used, the {@link #update(ProviderContext)} method is called.
+ *
* TODO - authentication / logout (Closeable)
* TODO - context support
* TODO - query
@@ -130,6 +137,48 @@ public abstract class ResourceProvider<T
*/
public static final String AUTH_SERVICE_BUNDLE = "sling.service.bundle";
+ /** The context for this provider. */
+ private volatile ProviderContext ctx;
+
+ /**
+ * With a call to this method, the provider implementation is notified that
+ * it is used in the resource tree.
+ * @param ctx The context for this provider.
+ */
+ public void activate(@Nonnull ProviderContext ctx) {
+ this.ctx = ctx;
+ }
+
+ /**
+ * With a call to this method, the provider implementation is notified
+ * that it is not used anymore in the resource tree.
+ * @param ctx The context for this provider.
+ */
+ public void deactivate(@Nonnull ProviderContext ctx) {
+ this.ctx = null;
+ }
+
+ /**
+ * With a call to this method, the provider implementation is notified
+ * that any information regarding the registration of the provider
+ * has changed. For example, observation listeners might have changed.
+ * This method is only called while the provider is used in the resource
+ * tree.
+ * @param ctx The context for this provider.
+ */
+ public void update(@Nonnull ProviderContext ctx) {
+ this.ctx = ctx;
+ }
+
+ /**
+ * Get the current provider context.
+ * @return The provider context or {@code null} if the provider is
currently
+ * not used in the resource tree.
+ */
+ protected ProviderContext getProviderContext() {
+ return this.ctx;
+ }
+
/**
* Authenticate against the resource provider.
* <p>