jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r900491 - in /jackrabbit/commons/jcr-rmi/trunk/src/main: java/org/apache/jackrabbit/rmi/repository/ resources/META-INF/services/
Date Mon, 18 Jan 2010 18:14:50 GMT
Author: jukka
Date: Mon Jan 18 18:14:50 2010
New Revision: 900491

URL: http://svn.apache.org/viewvc?rev=900491&view=rev
Log:
JSR-283: Implement RepositoryFactory

Added:
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
  (with props)
    jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
      - copied, changed from r896362, jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/org.apache.jackrabbit.api.jsr283.RepositoryFactory
Removed:
    jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/org.apache.jackrabbit.api.jsr283.RepositoryFactory
Modified:
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java?rev=900491&r1=900490&r2=900491&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java
(original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java
Mon Jan 18 18:14:50 2010
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.rmi.repository;
 
+import org.apache.jackrabbit.rmi.client.ClientAdapterFactory;
 import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
-import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitClientAdapterFactory;
 
 /**
  * Proxy for a remote repository bound in RMI. The configured repository is
@@ -48,7 +48,7 @@
      * @param url URL of the remote repository
      */
     public RMIRemoteRepository(String url) {
-        this(new JackrabbitClientAdapterFactory(), url);
+        this(new ClientAdapterFactory(), url);
     }
 
 }

Added: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java?rev=900491&view=auto
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
(added)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
Mon Jan 18 18:14:50 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.rmi.repository;
+
+import java.net.URI;
+import java.rmi.Naming;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.naming.InitialContext;
+
+import org.apache.jackrabbit.rmi.client.ClientAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+
+public class RmiRepositoryFactory implements RepositoryFactory {
+
+    private static final String REPOSITORY_URI =
+        "org.apache.jackrabbit.repository.uri";
+
+    @SuppressWarnings("unchecked")
+    public Repository getRepository(Map parameters) throws RepositoryException {
+        if (parameters != null && parameters.containsKey(REPOSITORY_URI)) {
+            Object parameter = parameters.get(REPOSITORY_URI);
+            try {
+                URI uri = new URI(parameter.toString().trim());
+                String scheme = uri.getScheme();
+                if ("rmi".equalsIgnoreCase(scheme)) {
+                    return getRepository((RemoteRepository) Naming.lookup(
+                            uri.getSchemeSpecificPart()));
+                } else if ("jndi".equalsIgnoreCase(scheme)) {
+                    Hashtable environment = new Hashtable(parameters);
+                    environment.remove(REPOSITORY_URI);
+                    Object value = new InitialContext(environment).lookup(
+                            uri.getSchemeSpecificPart());
+                    if (value instanceof RemoteRepository) {
+                        return getRepository((RemoteRepository) value);
+                    } else {
+                        return null;
+                    }
+                } else {
+                    return null;
+                }
+            } catch (Exception e) {
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    private Repository getRepository(RemoteRepository remote) {
+        return new ClientAdapterFactory().getRepository(remote);
+    }
+
+}

Propchange: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
(from r896362, jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/org.apache.jackrabbit.api.jsr283.RepositoryFactory)
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory?p2=jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory&p1=jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/org.apache.jackrabbit.api.jsr283.RepositoryFactory&r1=896362&r2=900491&rev=900491&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/org.apache.jackrabbit.api.jsr283.RepositoryFactory
(original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
Mon Jan 18 18:14:50 2010
@@ -13,9 +13,4 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-#
-# This file lists the repository factory implementation for jackrabbit-jcr-rmi
-#
-
-org.apache.jackrabbit.rmi.repository.RepositoryFactoryImpl
-
+org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory



Mime
View raw message