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 2014/07/29 14:30:07 UTC
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
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;
* <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 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<String, Object> 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;
+