Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5B22E119D3 for ; Tue, 29 Jul 2014 12:30:29 +0000 (UTC) Received: (qmail 31262 invoked by uid 500); 29 Jul 2014 12:30:29 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 31219 invoked by uid 500); 29 Jul 2014 12:30:29 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 31208 invoked by uid 99); 29 Jul 2014 12:30:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jul 2014 12:30:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jul 2014 12:30:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2D6B02388831; Tue, 29 Jul 2014 12:30:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1614324 - in /sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration: AbstractRegistrationSupport.java impl/JndiRegistrationSupport.java impl/RmiRegistrationSupport.java package-info.java Date: Tue, 29 Jul 2014 12:30:07 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140729123007.2D6B02388831@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Tue Jul 29 12:30:06 2014 New Revision: 1614324 URL: http://svn.apache.org/r1614324 Log: Clean up usage of SCR annotations Modified: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java Modified: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java?rev=1614324&r1=1614323&r2=1614324&view=diff ============================================================================== --- sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java (original) +++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java Tue Jul 29 12:30:06 2014 @@ -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; *

* 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 AbstractRegistrati * 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 AbstractRegistrati /** Unbinds the LogService */ protected void unbindLog(LogService log) { - this.log = null; + if ( this.log == log ) { + this.log = null; + } } //---------- internal ----------------------------------------------------- Modified: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java?rev=1614324&r1=1614323&r2=1614324&view=diff ============================================================================== --- sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java (original) +++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java Tue Jul 29 12:30:06 2014 @@ -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 props = this.getComponentContext().getProperties(); @@ -104,6 +119,7 @@ public class JndiRegistrationSupport ext return false; } + @Override protected void doDeactivate() { if (this.jndiContext != null) { try { @@ -136,6 +152,7 @@ public class JndiRegistrationSupport ext } } + @Override protected Object bindRepository(String name, Repository repository) { if (this.jndiContext != null) { @@ -153,6 +170,7 @@ public class JndiRegistrationSupport ext return null; } + @Override protected void unbindRepository(String name, Object data) { if (this.jndiContext != null) { try { Modified: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java?rev=1614324&r1=1614323&r2=1614324&view=diff ============================================================================== --- sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java (original) +++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java Tue Jul 29 12:30:06 2014 @@ -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 exte * 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 exte * 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 exte 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(); Modified: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java?rev=1614324&r1=1614323&r2=1614324&view=diff ============================================================================== --- sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java (original) +++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java Tue Jul 29 12:30:06 2014 @@ -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; +