This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.discovery.api-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-api.git
commit 2a2a3e75899b319244c7ae6c9d454f1ccc4b8268 Author: Carsten Ziegeler <[email protected]> AuthorDate: Mon Apr 22 08:56:00 2013 +0000 Rename DiscoveryAware to TopologyEventListener git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/discovery/api@1470413 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/sling/discovery/DiscoveryService.java | 6 +-- .../sling/discovery/InstanceDescription.java | 2 +- .../org/apache/sling/discovery/TopologyEvent.java | 2 +- ...coveryAware.java => TopologyEventListener.java} | 9 ++-- .../discovery/impl/NoClusterDiscoveryService.java | 49 +++++++++++----------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/apache/sling/discovery/DiscoveryService.java b/src/main/java/org/apache/sling/discovery/DiscoveryService.java index 6e655d0..3477650 100644 --- a/src/main/java/org/apache/sling/discovery/DiscoveryService.java +++ b/src/main/java/org/apache/sling/discovery/DiscoveryService.java @@ -36,9 +36,9 @@ public interface DiscoveryService { * has noticed a potential change in the topology and is in the process of * settling the change in the topology (eg with peers, ie voting). * <p> - * Note that this call is synchronized with <code>DiscoveryAware.handleTopologyEvent()</code> - * calls: ie if calls to <code>DiscoveryAware.handleTopologyEvent()</code> are currently - * ongoing, then the call to this method will block until all <code>DiscoveryAware</code>s + * Note that this call is synchronized with <code>TopologyEventListener.handleTopologyEvent()</code> + * calls: ie if calls to <code>TopologyEventListener.handleTopologyEvent()</code> are currently + * ongoing, then the call to this method will block until all <code>TopologyEventListener</code>s * have been called. Be careful not to cause deadlock situations. * <p> * @return the topology that was last discovered by this service. This will never diff --git a/src/main/java/org/apache/sling/discovery/InstanceDescription.java b/src/main/java/org/apache/sling/discovery/InstanceDescription.java index 4e471f2..0c714a3 100644 --- a/src/main/java/org/apache/sling/discovery/InstanceDescription.java +++ b/src/main/java/org/apache/sling/discovery/InstanceDescription.java @@ -68,7 +68,7 @@ public interface InstanceDescription { * Only one instance of a cluster is guaranteed to be the leader at any time. * This guarantee is provided by this service. * If the leader goes down, the service elects a new leader and announces it to - * DiscoveryAware listeners. + * TopologyEventListener listeners. * @return true if this instance is the - only - leader in this cluster, * false if it is one of the slaves, or true if it is not at all part of a cluster */ diff --git a/src/main/java/org/apache/sling/discovery/TopologyEvent.java b/src/main/java/org/apache/sling/discovery/TopologyEvent.java index 5f1568f..fb9bcdd 100644 --- a/src/main/java/org/apache/sling/discovery/TopologyEvent.java +++ b/src/main/java/org/apache/sling/discovery/TopologyEvent.java @@ -23,7 +23,7 @@ package org.apache.sling.discovery; * * This event object might be extended in the future with new event types * and methods. - * @see DiscoveryAware + * @see TopologyEventListener */ public class TopologyEvent { diff --git a/src/main/java/org/apache/sling/discovery/DiscoveryAware.java b/src/main/java/org/apache/sling/discovery/TopologyEventListener.java similarity index 89% rename from src/main/java/org/apache/sling/discovery/DiscoveryAware.java rename to src/main/java/org/apache/sling/discovery/TopologyEventListener.java index 01a3da1..aed95c6 100644 --- a/src/main/java/org/apache/sling/discovery/DiscoveryAware.java +++ b/src/main/java/org/apache/sling/discovery/TopologyEventListener.java @@ -19,14 +19,13 @@ package org.apache.sling.discovery; /** - * The <code>DiscoveryAware</code> service interface may be implemented by - * components interested in being made aware of the cluster state or changes - * thereof. + * The <code>TopologyEventListener</code> service interface may be implemented by + * components interested in being made aware of changes in the topology. * <p> * Upon registration and whenever changes in the topology occur, this * service is informed. */ -public interface DiscoveryAware { +public interface TopologyEventListener { /** * Inform the service about an event in the topology - or in the discovery @@ -35,7 +34,7 @@ public interface DiscoveryAware { * The <code>TopologyEvent</code> contains details about what changed. * The supported event types are: * <ul> - * <li><code>TOPOLOGY_INIT</code> sent when the <code>DiscoveryAware</code> + * <li><code>TOPOLOGY_INIT</code> sent when the <code>TopologyEventListener</code> * was first bound to the discovery service - represents the initial state * of the topology at that time.</li> * <li><code>TOPOLOGY_CHANGING</code> sent when the discovery service diff --git a/src/main/java/org/apache/sling/discovery/impl/NoClusterDiscoveryService.java b/src/main/java/org/apache/sling/discovery/impl/NoClusterDiscoveryService.java index dfb6976..cfb3c6b 100644 --- a/src/main/java/org/apache/sling/discovery/impl/NoClusterDiscoveryService.java +++ b/src/main/java/org/apache/sling/discovery/impl/NoClusterDiscoveryService.java @@ -39,13 +39,13 @@ 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.discovery.ClusterView; -import org.apache.sling.discovery.DiscoveryAware; import org.apache.sling.discovery.DiscoveryService; import org.apache.sling.discovery.InstanceDescription; import org.apache.sling.discovery.InstanceFilter; import org.apache.sling.discovery.PropertyProvider; import org.apache.sling.discovery.TopologyEvent; import org.apache.sling.discovery.TopologyEvent.Type; +import org.apache.sling.discovery.TopologyEventListener; import org.apache.sling.discovery.TopologyView; import org.apache.sling.settings.SlingSettingsService; import org.osgi.framework.Constants; @@ -53,8 +53,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * This is a simple implementation of the cluster service - * which can be used for a cluster less installation. + * This is a simple implementation of the discovery service + * which can be used for a cluster less installation (= single instance). + * It is disabled by default and can be enabled through a OSGi configuration. */ @Component(policy = ConfigurationPolicy.REQUIRE, immediate=true) @Service(value = {DiscoveryService.class}) @@ -70,10 +71,10 @@ public class NoClusterDiscoveryService implements DiscoveryService { private SlingSettingsService settingsService; /** - * All cluster aware instances. + * All topology event listeners. */ @Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC) - private DiscoveryAware[] clusterAwares = new DiscoveryAware[0]; + private TopologyEventListener[] listeners = new TopologyEventListener[0]; /** * All property providers. @@ -138,9 +139,9 @@ public class NoClusterDiscoveryService implements DiscoveryService { final Set<InstanceDescription> instances = new HashSet<InstanceDescription>(); instances.add(myDescription); - final DiscoveryAware[] registeredServices; + final TopologyEventListener[] registeredServices; synchronized ( lock ) { - registeredServices = this.clusterAwares; + registeredServices = this.listeners; final ClusterView clusterView = new ClusterView() { public InstanceDescription getLeader() { @@ -188,7 +189,7 @@ public class NoClusterDiscoveryService implements DiscoveryService { }; } - for(final DiscoveryAware da: registeredServices) { + for(final TopologyEventListener da: registeredServices) { da.handleTopologyEvent(new TopologyEvent(Type.TOPOLOGY_INIT, null, topologyView)); } } @@ -209,7 +210,7 @@ public class NoClusterDiscoveryService implements DiscoveryService { private void bindPropertyProvider(final PropertyProvider propertyProvider, final Map<String, Object> props) { logger.debug("bindPropertyProvider: Binding PropertyProvider {}", propertyProvider); - final DiscoveryAware[] awares; + final TopologyEventListener[] awares; synchronized (lock) { final ProviderInfo info = new ProviderInfo(propertyProvider, props); this.providerInfos.add(info); @@ -218,11 +219,11 @@ public class NoClusterDiscoveryService implements DiscoveryService { if ( this.topologyView == null ) { awares = null; } else { - awares = this.clusterAwares; + awares = this.listeners; } } if ( awares != null ) { - for(final DiscoveryAware da : awares) { + for(final TopologyEventListener da : awares) { da.handleTopologyEvent(new TopologyEvent(Type.PROPERTIES_CHANGED, this.topologyView, this.topologyView)); } } @@ -256,7 +257,7 @@ public class NoClusterDiscoveryService implements DiscoveryService { final boolean inform) { logger.debug("unbindPropertyProvider: Releasing PropertyProvider {}", propertyProvider); - final DiscoveryAware[] awares; + final TopologyEventListener[] awares; synchronized (lock) { final ProviderInfo info = new ProviderInfo(propertyProvider, props); this.providerInfos.remove(info); @@ -264,11 +265,11 @@ public class NoClusterDiscoveryService implements DiscoveryService { if ( this.topologyView == null ) { awares = null; } else { - awares = this.clusterAwares; + awares = this.listeners; } } if ( inform && awares != null ) { - for(final DiscoveryAware da : awares) { + for(final TopologyEventListener da : awares) { da.handleTopologyEvent(new TopologyEvent(Type.PROPERTIES_CHANGED, this.topologyView, this.topologyView)); } } @@ -286,16 +287,16 @@ public class NoClusterDiscoveryService implements DiscoveryService { } @SuppressWarnings("unused") - private void bindDiscoveryAware(final DiscoveryAware clusterAware) { + private void bindTopologyEventListener(final TopologyEventListener clusterAware) { - logger.debug("bindDiscoveryAware: Binding DiscoveryAware {}", clusterAware); + logger.debug("bindTopologyEventListener: Binding TopologyEventListener {}", clusterAware); boolean inform = true; synchronized (lock) { - List<DiscoveryAware> currentList = new ArrayList<DiscoveryAware>( - Arrays.asList(clusterAwares)); + List<TopologyEventListener> currentList = new ArrayList<TopologyEventListener>( + Arrays.asList(listeners)); currentList.add(clusterAware); - this.clusterAwares = currentList.toArray(new DiscoveryAware[currentList.size()]); + this.listeners = currentList.toArray(new TopologyEventListener[currentList.size()]); if ( this.topologyView == null ) { inform = false; } @@ -307,15 +308,15 @@ public class NoClusterDiscoveryService implements DiscoveryService { } @SuppressWarnings("unused") - private void unbindDiscoveryAware(final DiscoveryAware clusterAware) { + private void unbindTopologyEventListener(final TopologyEventListener clusterAware) { - logger.debug("unbindDiscoveryAware: Releasing DiscoveryAware {}", clusterAware); + logger.debug("unbindTopologyEventListener: Releasing TopologyEventListener {}", clusterAware); synchronized (lock) { - List<DiscoveryAware> currentList = new ArrayList<DiscoveryAware>( - Arrays.asList(clusterAwares)); + List<TopologyEventListener> currentList = new ArrayList<TopologyEventListener>( + Arrays.asList(listeners)); currentList.remove(clusterAware); - this.clusterAwares = currentList.toArray(new DiscoveryAware[currentList.size()]); + this.listeners = currentList.toArray(new TopologyEventListener[currentList.size()]); } } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
