You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2012/05/02 15:22:32 UTC

svn commit: r1333033 - in /sling/trunk/bundles/jcr/registration: ./ src/main/java/org/apache/sling/jcr/registration/ src/main/java/org/apache/sling/jcr/registration/impl/ src/main/resources/OSGI-INF/ src/main/resources/OSGI-INF/metatype/

Author: fmeschbe
Date: Wed May  2 13:22:32 2012
New Revision: 1333033

URL: http://svn.apache.org/viewvc?rev=1333033&view=rev
Log:
SLING-2352 Finish migration of the Repository Registration Support out of jackrabbit-jcr-server into its own bundle

Added:
    sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java
      - copied, changed from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/AbstractRegistrationSupport.java
    sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java
      - copied, changed from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/JndiRegistrationSupport.java
    sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java
      - copied, changed from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/RmiRegistrationSupport.java
    sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java
    sling/trunk/bundles/jcr/registration/src/main/resources/OSGI-INF/
    sling/trunk/bundles/jcr/registration/src/main/resources/OSGI-INF/metatype/
    sling/trunk/bundles/jcr/registration/src/main/resources/OSGI-INF/metatype/metatype.properties
      - copied, changed from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties
Modified:
    sling/trunk/bundles/jcr/registration/pom.xml

Modified: sling/trunk/bundles/jcr/registration/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/registration/pom.xml?rev=1333033&r1=1333032&r2=1333033&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/registration/pom.xml (original)
+++ sling/trunk/bundles/jcr/registration/pom.xml Wed May  2 13:22:32 2012
@@ -51,23 +51,23 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.7</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
                         <Bundle-Category>
                             sling,jcr
                         </Bundle-Category>
-                        <Private-Package>
-                            org.apache.sling.jcr.registrar.impl.*
-                        </Private-Package>
-                        <Export-Package>
-                            org.apache.sling.jcr.registrar
-                        </Export-Package>
+                        <Import-Package>
+                            javax.transaction.xa;resolution:=optional,
+                            *
+                        </Import-Package>
                         <DynamicImport-Package>
                             *
                         </DynamicImport-Package>
                         <Embed-Dependency>
-                            jackrabbit-core;inline:=org/apache/jackrabbit/core/jndi/provider/*.class
+                            jackrabbit-core;inline=org/apache/jackrabbit/core/jndi/provider/*.class,
+                            jackrabbit-jcr-rmi;inline=org/apache/jackrabbit/rmi/iterator/**|org/apache/jackrabbit/rmi/observation/**|org/apache/jackrabbit/rmi/remote/**|org/apache/jackrabbit/rmi/server/**|org/apache/jackrabbit/rmi/value/**|org/apache/jackrabbit/rmi/server/**
                         </Embed-Dependency>
                     </instructions>
                 </configuration>
@@ -79,11 +79,19 @@
         <dependency>
             <groupId>javax.jcr</groupId>
             <artifactId>jcr</artifactId>
+            <version>2.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.scr.annotations</artifactId>
         </dependency>
+        <dependency>
+            <groupId>biz.aQute</groupId>
+            <artifactId>bndlib</artifactId>
+            <version>1.50.0</version>
+            <scope>provided</scope>
+        </dependency>
+        
         <!-- OSGi Libraries -->
         <dependency>
             <groupId>org.osgi</groupId>
@@ -101,6 +109,12 @@
             <version>2.2.9</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-rmi</artifactId>
+            <version>2.0.0</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
 </project>

Copied: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java (from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/AbstractRegistrationSupport.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java?p2=sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java&p1=sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/AbstractRegistrationSupport.java&r1=1332970&r2=1333033&rev=1333033&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/AbstractRegistrationSupport.java (original)
+++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/AbstractRegistrationSupport.java Wed May  2 13:22:32 2012
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.jcr.jackrabbit.server.impl;
+package org.apache.sling.jcr.registration;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -22,6 +22,11 @@ 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;
@@ -40,13 +45,30 @@ import org.osgi.service.log.LogService;
  * <p>
  * To ensure this thread-safeness, said methods should not be overwritten.
  */
-abstract public class AbstractRegistrationSupport {
+@Component(componentAbstract = true)
+@References({
+    @Reference(
+            name = "Repository",
+            policy = ReferencePolicy.DYNAMIC,
+            cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
+            referenceInterface = Repository.class)
+})
+public abstract class AbstractRegistrationSupport {
+
+    /**
+     * The JCR Repository service registration property used to create
+     * the registration name. If this service registration property
+     * (assumed to be a single string) does not exist, the repository is
+     * not registered.
+     */
+    public static final String REPOSITORY_REGISTRATION_NAME = "name";
 
     /**
      * The LogService for logging. Extensions of this class must declare the log
      * service as a reference or call the {@link #bindLog(LogService)} to enable
      * logging correctly.
      */
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC)
     private LogService log;
 
     /**
@@ -190,7 +212,7 @@ abstract public class AbstractRegistrati
      * @return The non-empty name property or <code>null</code>.
      */
     protected String getName(ServiceReference reference) {
-        String name = (String) reference.getProperty(SlingServerRepository.REPOSITORY_REGISTRATION_NAME);
+        String name = (String) reference.getProperty(REPOSITORY_REGISTRATION_NAME);
         if (name == null || name.length() == 0) {
             this.log.log(LogService.LOG_DEBUG,
                 "registerRepository: Repository not to be registered");

Copied: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java (from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/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?p2=sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java&p1=sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/JndiRegistrationSupport.java&r1=1332970&r2=1333033&rev=1333033&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/JndiRegistrationSupport.java (original)
+++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java Wed May  2 13:22:32 2012
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.jcr.jackrabbit.server.impl;
+package org.apache.sling.jcr.registration.impl;
 
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
@@ -28,6 +28,9 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.sling.jcr.registration.AbstractRegistrationSupport;
 import org.osgi.service.log.LogService;
 
 
@@ -40,24 +43,27 @@ import org.osgi.service.log.LogService;
  * Note: Currently, only these two properties are declared to be configurable,
  * in the future a mechanism should be devised to support declaration of more
  * properties.
- *
- * @scr.component immediate="true" label="%jndi.name"
- *                description="%jndi.description"
- *                name="org.apache.sling.jcr.jackrabbit.server.JndiRegistrationSupport"
- * @scr.reference name="Repository" interface="javax.jcr.Repository"
- *                policy="dynamic" cardinality="0..n"
- * @scr.reference name="Log" interface="org.osgi.service.log.LogService"
- *                policy="dynamic" cardinality="0..1"
- * @scr.property name="java.naming.factory.initial"
- *               value="org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory"
- *               label="%jndi.factory.name"
- *               description="%jndi.factory.description"
- * @scr.property name="java.naming.provider.url" value="http://sling.apache.org"
- *               label="%jndi.providerurl.name"
- *               description="%jndi.providerurl.description"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- * @scr.property name="service.description" value="JNDI Repository Registration"
  */
+@Component(
+        immediate = true,
+        metatype = true,
+        label = "%jndi.name",
+        description = "%jndi.description",
+        name = "org.apache.sling.jcr.jackrabbit.server.JndiRegistrationSupport")
+@org.apache.felix.scr.annotations.Properties({
+    @Property(
+            name = "java.naming.factory.initial",
+            value = "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory",
+            label = "%jndi.factory.name",
+            description = "%jndi.factory.description"),
+    @Property(
+            name = "java.naming.provider.url",
+            value = "http://sling.apache.org",
+            label = "%jndi.providerurl.name",
+            description = "%jndi.providerurl.description"),
+    @Property(name = "service.vendor", value = "The Apache Software Foundation", propertyPrivate = true),
+    @Property(name = "service.description", value = "JNDI Repository Registration", propertyPrivate = true)
+})
 public class JndiRegistrationSupport extends AbstractRegistrationSupport {
 
     private Context jndiContext;

Copied: sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java (from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/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?p2=sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java&p1=sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/RmiRegistrationSupport.java&r1=1332970&r2=1333033&rev=1333033&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/RmiRegistrationSupport.java (original)
+++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/impl/RmiRegistrationSupport.java Wed May  2 13:22:32 2012
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.jcr.jackrabbit.server.impl;
+package org.apache.sling.jcr.registration.impl;
 
 import java.io.IOException;
 import java.net.InetAddress;
@@ -27,8 +27,11 @@ import java.rmi.server.UnicastRemoteObje
 
 import javax.jcr.Repository;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
 import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
 import org.apache.jackrabbit.rmi.server.ServerAdapterFactory;
+import org.apache.sling.jcr.registration.AbstractRegistrationSupport;
 import org.osgi.service.log.LogService;
 
 /**
@@ -38,23 +41,20 @@ import org.osgi.service.log.LogService;
  * <p>
  * Note: Currently only registries in this Java VM are supported. In the future
  * support for external registries may be added.
- *
- * @scr.component immediate="true" label="%rmi.name"
- *                description="%rmi.description"
- *                name="org.apache.sling.jcr.jackrabbit.server.RmiRegistrationSupport"
- * @scr.reference name="Repository" interface="javax.jcr.Repository"
- *                policy="dynamic" cardinality="0..n"
- * @scr.reference name="Log" interface="org.osgi.service.log.LogService"
- *                policy="dynamic" cardinality="0..1"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- * @scr.property name="service.description" value="RMI based Repository Registration"
  */
+@Component(
+        immediate = true,
+        metatype = true,
+        label = "%rmi.name",
+        description = "%rmi.description",
+        name = "org.apache.sling.jcr.jackrabbit.server.RmiRegistrationSupport")
+@org.apache.felix.scr.annotations.Properties({
+    @Property(name = "service.vendor", value = "The Apache Software Foundation", propertyPrivate = true),
+    @Property(name = "service.description", value = "RMI based Repository Registration", propertyPrivate = true)
+})
 public class RmiRegistrationSupport extends AbstractRegistrationSupport {
 
-    /**
-     * @scr.property value="1099" type="Integer" label="%rmi.port.name"
-     *               description="%rmi.port.description"
-     */
+    @Property(intValue = 1099, label = "%rmi.port.name", description = "%rmi.port.description")
     public static final String PROP_REGISTRY_PORT = "port";
 
     private int registryPort;

Added: 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=1333033&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java (added)
+++ sling/trunk/bundles/jcr/registration/src/main/java/org/apache/sling/jcr/registration/package-info.java Wed May  2 13:22:32 2012
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/**
+ * The <code>org.apache.sling.jcr.registration</code> package exports
+ * the {@link org.apache.sling.jcr.registration.AbstractRegistrationSupport}
+ * 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")
+@Export(optional = "provide:=true")
+package org.apache.sling.jcr.registration;
+
+import aQute.bnd.annotation.Export;
+import aQute.bnd.annotation.Version;

Copied: sling/trunk/bundles/jcr/registration/src/main/resources/OSGI-INF/metatype/metatype.properties (from r1332970, sling/trunk/bundles/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/registration/src/main/resources/OSGI-INF/metatype/metatype.properties?p2=sling/trunk/bundles/jcr/registration/src/main/resources/OSGI-INF/metatype/metatype.properties&p1=sling/trunk/bundles/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties&r1=1332970&r2=1333033&rev=1333033&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties (original)
+++ sling/trunk/bundles/jcr/registration/src/main/resources/OSGI-INF/metatype/metatype.properties Wed May  2 13:22:32 2012
@@ -22,83 +22,9 @@
 # descriptions as used in the metatype.xml descriptor generated by the
 # the Sling SCR plugin
 
-repository.name = Apache Sling Embedded JCR Repository
-repository.description = Configuration to launch an embedded JCR Repository \
- and provide it as a SlingRepository and a standard JCR Repository. \
- In addition, if the registration URL is not empty, the repository is registered \
- as defined.
-
-admin.name.name = Administator	
-admin.name.description = The user name of the administrative user. This user \
- name is used to implement the SlingRepository.loginAdministrative(String) \
- method. It is intended for this user to provide full read/write access to \
- repository.
- 
-admin.password.name = Administrator Password	
-admin.password.description = This property is not used by the Embedded \
- Jackrabbit Repository.
-
-anonymous.name.name = Anonymous	
-anonymous.name.description = The user name of the anonymous user. This user \
- name is used to implement the Repository.login methods without a Credentials \
- instance.
- 
-anonymous.password.name = Anonymous Password	
-anonymous.password.description = This property is not used by the Embedded \
- Jackrabbit Repository.
-
-autostart.name = Autostart
-autostart.description = Check to have the embedded JCR repository started as \
- soon as the configuration is activated. If not checked, the respository is \
- only started when used the first time.
- 
-config.name = Configuration File	
-config.description = Filename or URL of the configuration file for the embedded \
- JCR repository. The name is first checked, whether it points to a readable file. \
- If no, the name is assumed to be an URL which must be accessible from the Sling \
- Server. \
- 
-defaultWorkspace.name = Default Workspace
-defaultWorkspace.description = Name of the workspace to use by default if not \
- is given in any of the login methods. This name is used to implement the \
- SlingRepository.getDefaultWorkspace() method. If this name is empty, a null \
- value is used in JCR calls so that the default workspace provided by the \
- JCR repository is used.
- 
-home.name = Repository Home	
-home.description = Name of a filesystem directory in which to launch the \
- embedded JCR Repository.
-
-poll.active.name = Poll Intervall Active        
-poll.active.description = The interval in seconds between two consecutive \
- checks whether the repository is still accessbible, once it has been acquired.\
- The default value is 10 seconds, the minimum allowed value is 2 seconds, \
- smaller values are corected to the minimum. 
- 
-poll.inactive.name = Poll Intervall Inactive
-poll.inactive.description = The interval in seconds between two consecutive \
- checks whether the repository has become accessbible if the repository is \
- not immediately accessible or connection to the repository has been lost. \
- The default value is 10 seconds, the minimum allowed value is 2 seconds, \
- smaller values are corected to the minimum.
- 
-name.name = Embedded JCR Repository Name
-name.description = The name under which the embedded repository will be \
- registered JNDI and RMI registries. The respective registry services listen \
- for embedded repositories to be launched and register each under the name \
- configured. If no name is configured, the repository will not be registered.
- 
-repository.url.override.property.name = Repository URL override property
-repository.url.override.property.description = Name of the system or \
- configuration Property that provides a repository connection URL to replace \
- the embedded JCR Repository. \
- If the corresponding System Property value is not empty, it is used to acquire \
- a Repository via JNDI or RMI, instead of using the embedded one. \
- Leave this value empty to force the use of the embedded Repository. 
-
 #
 # JNDI Registration Support
-jndi.name = Apache Sling Embedded JCR Repository JNDI Registrar
+jndi.name = Apache Sling JCR Repository JNDI Registrar
 jndi.description = The JNDI Registrar listens for embedded repositories \
  to be registered as services and registers them in the JNDI context under the \
  name specified in the "name" service property.
@@ -113,7 +39,7 @@ jndi.providerurl.description =  An URL s
      
 #
 # RMI Registration Support
-rmi.name = Apache Sling Embedded JCR Repository RMI Registrar
+rmi.name = Apache Sling JCR Repository RMI Registrar
 rmi.description = The RMI Registrar listens for embedded repositories \
  to be registered as services and registers them in an RMI registry under the \
  name specified in the "name" service property.