This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.registration-1.0.2 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-registration.git
commit d67e8f29807c880c8566dfc3431c32a372b5b2a1 Author: Carsten Ziegeler <[email protected]> AuthorDate: Tue Jul 29 12:30:06 2014 +0000 Clean up usage of SCR annotations git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/registration@1614324 13f79535-47bb-0310-9956-ffa450edef68 --- .../jcr/registration/AbstractRegistrationSupport.java | 18 +++--------------- .../jcr/registration/impl/JndiRegistrationSupport.java | 18 ++++++++++++++++++ .../jcr/registration/impl/RmiRegistrationSupport.java | 18 ++++++++++++++++++ .../apache/sling/jcr/registration/package-info.java | 3 ++- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java b/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java index 95803b2..9ab9db4 100644 --- a/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java +++ b/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java @@ -22,11 +22,6 @@ import java.util.Map; import javax.jcr.Repository; -import org.apache.felix.scr.annotations.Component; -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.References; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; import org.osgi.service.component.ComponentConstants; @@ -45,14 +40,6 @@ import org.osgi.service.log.LogService; * <p> * To ensure this thread-safeness, said methods should not be overwritten. */ -@Component(componentAbstract = true) -@References({ - @Reference( - name = "Repository", - policy = ReferencePolicy.DYNAMIC, - cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, - referenceInterface = Repository.class) -}) public abstract class AbstractRegistrationSupport { /** @@ -68,7 +55,6 @@ public abstract class AbstractRegistrationSupport { * service as a reference or call the {@link #bindLog(LogService)} to enable * logging correctly. */ - @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC) private volatile LogService log; /** @@ -363,7 +349,9 @@ public abstract class AbstractRegistrationSupport { /** Unbinds the LogService */ protected void unbindLog(LogService log) { - this.log = null; + if ( this.log == log ) { + this.log = null; + } } //---------- internal ----------------------------------------------------- diff --git a/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java b/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java index 081473a..9b21241 100644 --- a/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java +++ b/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java @@ -31,6 +31,10 @@ import javax.naming.NamingException; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.ConfigurationPolicy; 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.References; import org.apache.sling.jcr.registration.AbstractRegistrationSupport; import org.osgi.service.log.LogService; @@ -67,12 +71,23 @@ import org.osgi.service.log.LogService; @Property(name = "service.vendor", value = "The Apache Software Foundation", propertyPrivate = true), @Property(name = "service.description", value = "JNDI Repository Registration", propertyPrivate = true) }) +@References({ + @Reference( + name = "Repository", + policy = ReferencePolicy.DYNAMIC, + cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, + referenceInterface = Repository.class), + @Reference(referenceInterface=LogService.class, + bind="bindLog", unbind="unbindLog", + cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC) +}) public class JndiRegistrationSupport extends AbstractRegistrationSupport { private Context jndiContext; // ---------- SCR intergration --------------------------------------------- + @Override protected boolean doActivate() { @SuppressWarnings("unchecked") Dictionary<String, Object> props = this.getComponentContext().getProperties(); @@ -104,6 +119,7 @@ public class JndiRegistrationSupport extends AbstractRegistrationSupport { return false; } + @Override protected void doDeactivate() { if (this.jndiContext != null) { try { @@ -136,6 +152,7 @@ public class JndiRegistrationSupport extends AbstractRegistrationSupport { } } + @Override protected Object bindRepository(String name, Repository repository) { if (this.jndiContext != null) { @@ -153,6 +170,7 @@ public class JndiRegistrationSupport extends AbstractRegistrationSupport { return null; } + @Override protected void unbindRepository(String name, Object data) { if (this.jndiContext != null) { try { diff --git a/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java b/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java index faf0583..0894e60 100644 --- a/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java +++ b/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java @@ -30,6 +30,10 @@ import javax.jcr.Repository; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.ConfigurationPolicy; 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.References; import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory; import org.apache.jackrabbit.rmi.server.ServerAdapterFactory; import org.apache.sling.jcr.registration.AbstractRegistrationSupport; @@ -54,6 +58,16 @@ import org.osgi.service.log.LogService; @Property(name = "service.vendor", value = "The Apache Software Foundation", propertyPrivate = true), @Property(name = "service.description", value = "RMI based Repository Registration", propertyPrivate = true) }) +@References({ + @Reference( + name = "Repository", + policy = ReferencePolicy.DYNAMIC, + cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, + referenceInterface = Repository.class), + @Reference(referenceInterface=LogService.class, + bind="bindLog", unbind="unbindLog", + cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC) +}) public class RmiRegistrationSupport extends AbstractRegistrationSupport { @Property(intValue = 1099, label = "%rmi.port.name", description = "%rmi.port.description") @@ -74,6 +88,7 @@ public class RmiRegistrationSupport extends AbstractRegistrationSupport { * registry is disabled, if the port property is negative. If the port is * zero or not a number, the default port (1099) is assumed. */ + @Override protected boolean doActivate() { Object portProp = this.getComponentContext().getProperties().get( @@ -112,6 +127,7 @@ public class RmiRegistrationSupport extends AbstractRegistrationSupport { * If a private registry has been acquired this method unexports the * registry object to free the RMI registry OID for later use. */ + @Override protected void doDeactivate() { // if we have a private RMI registry, unexport it here to free // the RMI registry OID @@ -130,10 +146,12 @@ public class RmiRegistrationSupport extends AbstractRegistrationSupport { this.registry = null; } + @Override protected Object bindRepository(String name, Repository repository) { return new RmiRegistration(name, repository); } + @Override protected void unbindRepository(String name, Object data) { RmiRegistration rr = (RmiRegistration) data; rr.unregister(); diff --git a/src/main/java/org/apache/sling/jcr/registration/package-info.java b/src/main/java/org/apache/sling/jcr/registration/package-info.java index 1a1f77f..86981fd 100644 --- a/src/main/java/org/apache/sling/jcr/registration/package-info.java +++ b/src/main/java/org/apache/sling/jcr/registration/package-info.java @@ -23,9 +23,10 @@ * class which may be extended by service exposing JCR Repository services * in any one non-OSGi registry such as RMI or JNDI. */ -@Version("1.0") +@Version("1.1") @Export(optional = "provide:=true") package org.apache.sling.jcr.registration; import aQute.bnd.annotation.Export; import aQute.bnd.annotation.Version; + -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
