You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2007/06/03 22:55:09 UTC
svn commit: r543987 - in
/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi:
client/ repository/ servlet/
Author: jukka
Date: Sun Jun 3 13:55:08 2007
New Revision: 543987
URL: http://svn.apache.org/viewvc?view=rev&rev=543987
Log:
JCR-956: Clarified naming and packaging of the new classes
Added:
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/AbstractRemoteRepositoryFactory.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepository.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepositoryFactory.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepositoryFactory.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepository.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepositoryFactory.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteBindingServlet.java
- copied, changed from r543865, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIBindingServlet.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteRepositoryServlet.java
- copied, changed from r543865, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIRepositoryServlet.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteBindingServlet.java
- copied, changed from r543865, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteRepositoryServlet.java
- copied, changed from r543871, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteBindingServlet.java (with props)
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteRepositoryServlet.java (with props)
Removed:
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/JNDIRMIRepository.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/JNDIRMIRepositoryFactory.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepository.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepositoryFactory.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/URLRMIRepository.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/URLRMIRepositoryFactory.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIBindingServlet.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIRepositoryServlet.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/AbstractRemoteRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/AbstractRemoteRepositoryFactory.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/AbstractRemoteRepositoryFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/AbstractRemoteRepositoryFactory.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,71 @@
+/*
+ * 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 javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.commons.repository.RepositoryFactory;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+
+/**
+ * Abstract base class for repository factories that make a remote repository
+ * available locally. Subclasses need to implement the
+ * {@link #getRemoteRepository()} method to actually retrieve the remote
+ * repository reference.
+ *
+ * @since 1.4
+ */
+public abstract class AbstractRemoteRepositoryFactory
+ implements RepositoryFactory {
+
+ /**
+ * Local adapter factory.
+ */
+ private final LocalAdapterFactory factory;
+
+ /**
+ * Creates a factory for looking up a repository from the given RMI URL.
+ *
+ * @param factory local adapter factory
+ * @param url RMI URL of the repository
+ */
+ protected AbstractRemoteRepositoryFactory(LocalAdapterFactory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * Returns a local adapter for the remote repository.
+ *
+ * @return local adapter for the remote repository
+ * @throws RepositoryException if the remote repository is not available
+ */
+ public Repository getRepository() throws RepositoryException {
+ return factory.getRepository(getRemoteRepository());
+ }
+
+ /**
+ * Returns the remote repository reference.
+ *
+ * @return remote repository reference
+ * @throws RepositoryException if the remote repository is not available
+ */
+ protected abstract RemoteRepository getRemoteRepository()
+ throws RepositoryException;
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/AbstractRemoteRepositoryFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepository.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepository.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepository.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,47 @@
+/*
+ * 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 javax.naming.Context;
+
+import org.apache.jackrabbit.commons.repository.ProxyRepository;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+
+/**
+ * Proxy for a remote repository bound in JNDI. The configured repository is
+ * looked up from JNDI lazily during each method call. Thus the JNDI entry
+ * does not need to exist when this class is instantiated. The JNDI entry
+ * can also be replaced with another repository during the lifetime of an
+ * instance of this class.
+ *
+ * @since 1.4
+ */
+public class JNDIRemoteRepository extends ProxyRepository {
+
+ /**
+ * Creates a proxy for a remote repository in JNDI.
+ *
+ * @param factory local adapter factory
+ * @param context JNDI context
+ * @param location JNDI location
+ */
+ public JNDIRemoteRepository(
+ LocalAdapterFactory factory, Context context, String location) {
+ super(new JNDIRemoteRepositoryFactory(factory, context, location));
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepository.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepositoryFactory.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepositoryFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepositoryFactory.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,87 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+
+/**
+ * Factory that looks up a remote repository from JNDI.
+ *
+ * @since 1.4
+ */
+public class JNDIRemoteRepositoryFactory
+ extends AbstractRemoteRepositoryFactory {
+
+ /**
+ * JNDI context of the remote repository.
+ */
+ private final Context context;
+
+ /**
+ * JNDI location of the remote repository.
+ */
+ private final String location;
+
+ /**
+ * Creates a factory for looking up a remote repository from JNDI.
+ *
+ * @param factory local adapter factory
+ * @param context JNDI context
+ * @param location JNDI location
+ */
+ public JNDIRemoteRepositoryFactory(
+ LocalAdapterFactory factory, Context context, String location) {
+ super(factory);
+ this.context = context;
+ this.location = location;
+ }
+
+ /**
+ * Looks up a remote repository from JNDI.
+ *
+ * @return remote repository reference
+ * @throws RepositoryException if the remote repository is not available
+ */
+ protected RemoteRepository getRemoteRepository()
+ throws RepositoryException {
+ try {
+ Object remote = context.lookup(location);
+ if (remote instanceof RemoteRepository) {
+ return (RemoteRepository) remote;
+ } else if (remote == null) {
+ throw new RepositoryException(
+ "Remote repository not found: The JNDI entry "
+ + location + " is null");
+ } else {
+ throw new RepositoryException(
+ "Invalid remote repository: The JNDI entry "
+ + location + " is an instance of "
+ + remote.getClass().getName());
+ }
+ } catch (NamingException e) {
+ throw new RepositoryException(
+ "Remote repository not found: The JNDI entry " + location
+ + " could not be looked up", e);
+ }
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/JNDIRemoteRepositoryFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,43 @@
+/*
+ * 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 org.apache.jackrabbit.commons.repository.ProxyRepository;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+
+/**
+ * Proxy for a remote repository bound in RMI. The configured repository is
+ * looked up from RMI lazily during each method call. Thus the RMI entry
+ * does not need to exist when this class is instantiated. The RMI entry
+ * can also be replaced with another repository during the lifetime of an
+ * instance of this class.
+ *
+ * @since 1.4
+ */
+public class RMIRemoteRepository extends ProxyRepository {
+
+ /**
+ * Creates a proxy for the remote repository in the given RMI URL.
+ *
+ * @param factory local adapter factory
+ * @param url RMI URL of the remote repository
+ */
+ public RMIRemoteRepository(LocalAdapterFactory factory, String url) {
+ super(new RMIRemoteRepositoryFactory(factory, url));
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepository.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepositoryFactory.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepositoryFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepositoryFactory.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+
+/**
+ * Factory that looks up a remote repository from an RMI registry.
+ *
+ * @since 1.4
+ */
+public class RMIRemoteRepositoryFactory
+ extends AbstractRemoteRepositoryFactory {
+
+ /**
+ * RMI URL of the remote repository.
+ */
+ private final String url;
+
+ /**
+ * Creates a factory for looking up a remote repository from
+ * an RMI registry.
+ *
+ * @param factory local adapter factory
+ * @param url RMI URL of the repository
+ */
+ public RMIRemoteRepositoryFactory(LocalAdapterFactory factory, String url) {
+ super(factory);
+ this.url = url;
+ }
+
+ /**
+ * Looks up a remote repository from the RMI registry.
+ *
+ * @return remote repository reference
+ * @throws RepositoryException if the remote repository is not available
+ */
+ protected RemoteRepository getRemoteRepository()
+ throws RepositoryException {
+ try {
+ return (RemoteRepository) Naming.lookup(url);
+ } catch (MalformedURLException e) {
+ throw new RepositoryException("Invalid repository URL: " + url, e);
+ } catch (NotBoundException e) {
+ throw new RepositoryException("Repository not found: " + url, e);
+ } catch (ClassCastException e) {
+ throw new RepositoryException("Invalid repository: " + url, e);
+ } catch (RemoteException e) {
+ throw new RepositoryException("Repository access error: " + url, e);
+ }
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RMIRemoteRepositoryFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepository.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepository.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepository.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.URL;
+
+import org.apache.jackrabbit.commons.repository.ProxyRepository;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+
+/**
+ * Proxy for a remote repository accessed via a URL. The configured URL is
+ * dereferenced lazily during each method call. Thus the resource pointed to
+ * by the URL does not need to exist when this class is instantiated. The
+ * resource can also be replaced with another remote repository instance
+ * during the lifetime of an instance of this class.
+ *
+ * @since 1.4
+ */
+public class URLRemoteRepository extends ProxyRepository {
+
+ /**
+ * Creates a proxy for the remote repository at the given URL.
+ *
+ * @param factory local adapter factory
+ * @param url URL of the remote repository
+ */
+ public URLRemoteRepository(LocalAdapterFactory factory, URL url) {
+ super(new URLRemoteRepositoryFactory(factory, url));
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepository.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepositoryFactory.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepositoryFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepositoryFactory.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,90 @@
+/*
+ * 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.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.URL;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+
+/**
+ * Factory that looks up a remote repository from a given URL.
+ *
+ * @since 1.4
+ */
+public class URLRemoteRepositoryFactory
+ extends AbstractRemoteRepositoryFactory {
+
+ /**
+ * URL of the remote repository.
+ */
+ private final URL url;
+
+ /**
+ * Creates a factory for looking up a remote repository from a URL.
+ *
+ * @param factory local adapter factory
+ * @param url URL or the remote repository
+ */
+ public URLRemoteRepositoryFactory(LocalAdapterFactory factory, URL url) {
+ super(factory);
+ this.url = url;
+ }
+
+ /**
+ * Looks up and returns a remote repository from the configured URL.
+ *
+ * @return remote repository reference
+ * @throws RepositoryException if the remote repository is not available
+ */
+ protected RemoteRepository getRemoteRepository()
+ throws RepositoryException {
+ try {
+ ObjectInputStream input = new ObjectInputStream(url.openStream());
+ try {
+ Object remote = input.readObject();
+ if (remote instanceof RemoteRepository) {
+ return (RemoteRepository) remote;
+ } else if (remote == null) {
+ throw new RepositoryException(
+ "Remote repository not found: The resource at "
+ + url + " is null");
+ } else {
+ throw new RepositoryException(
+ "Invalid remote repository: The resource at "
+ + url + " is an instance of "
+ + remote.getClass().getName());
+ }
+ } finally {
+ input.close();
+ }
+ } catch (ClassNotFoundException e) {
+ throw new RepositoryException(
+ "Invalid remote repository: The resource at " + url
+ + " is an instance of an unknown class", e);
+ } catch (IOException e) {
+ throw new RepositoryException(
+ "Remote repository not found: The resource at " + url
+ + " could not be retrieved", e);
+ }
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/URLRemoteRepositoryFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteBindingServlet.java (from r543865, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIBindingServlet.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteBindingServlet.java?view=diff&rev=543987&p1=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIBindingServlet.java&r1=543865&p2=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteBindingServlet.java&r2=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIBindingServlet.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteBindingServlet.java Sun Jun 3 13:55:08 2007
@@ -62,12 +62,12 @@
*
* @since 1.4
*/
-public class JNDIRMIBindingServlet extends RemoteBindingServlet {
+public class JNDIRemoteBindingServlet extends RemoteBindingServlet {
/**
* Serial version UID.
*/
- private static final long serialVersionUID = 3387067305901189614L;
+ private static final long serialVersionUID = -7984144838866544543L;
/**
* JNDI context to which to bind the repository.
Copied: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteRepositoryServlet.java (from r543865, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIRepositoryServlet.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteRepositoryServlet.java?view=diff&rev=543987&p1=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIRepositoryServlet.java&r1=543865&p2=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteRepositoryServlet.java&r2=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRMIRepositoryServlet.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/JNDIRemoteRepositoryServlet.java Sun Jun 3 13:55:08 2007
@@ -25,10 +25,10 @@
import javax.servlet.ServletException;
import org.apache.jackrabbit.commons.servlet.AbstractRepositoryServlet;
-import org.apache.jackrabbit.rmi.client.JNDIRMIRepository;
import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitClientAdapterFactory;
import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+import org.apache.jackrabbit.rmi.repository.JNDIRemoteRepository;
/**
* Servlet that makes a remote repository from JNDI available as an attribute
@@ -66,12 +66,12 @@
*
* @since 1.4
*/
-public class JNDIRMIRepositoryServlet extends RemoteRepositoryServlet {
+public class JNDIRemoteRepositoryServlet extends RemoteRepositoryServlet {
/**
* Serial version UID.
*/
- private static final long serialVersionUID = 3640243088693016475L;
+ private static final long serialVersionUID = 9029928193416404478L;
/**
* Creates and returns a proxy for the remote repository in the configured
@@ -94,7 +94,7 @@
environment.put(name, getInitParameter(name));
}
}
- return new JNDIRMIRepository(
+ return new JNDIRemoteRepository(
getLocalAdapterFactory(),
new InitialContext(environment), location);
} catch (NamingException e) {
Copied: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteBindingServlet.java (from r543865, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteBindingServlet.java?view=diff&rev=543987&p1=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java&r1=543865&p2=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteBindingServlet.java&r2=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteBindingServlet.java Sun Jun 3 13:55:08 2007
@@ -52,12 +52,12 @@
*
* @since 1.4
*/
-public class RMIBindingServlet extends RemoteBindingServlet {
+public class RMIRemoteBindingServlet extends RemoteBindingServlet {
/**
- * Serial version UID.
+ * Serial version UID.
*/
- private static final long serialVersionUID = 7239156891304655304L;
+ private static final long serialVersionUID = 1627580747678104906L;
/**
* Location of the repository within the JNDI context.
Copied: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteRepositoryServlet.java (from r543871, jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteRepositoryServlet.java?view=diff&rev=543987&p1=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java&r1=543871&p2=jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteRepositoryServlet.java&r2=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRemoteRepositoryServlet.java Sun Jun 3 13:55:08 2007
@@ -20,8 +20,8 @@
import javax.servlet.ServletException;
import org.apache.jackrabbit.commons.servlet.AbstractRepositoryServlet;
-import org.apache.jackrabbit.rmi.client.RMIRepository;
import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitClientAdapterFactory;
+import org.apache.jackrabbit.rmi.repository.RMIRemoteRepository;
/**
* Servlet that makes a repository from RMI available as an attribute
@@ -53,12 +53,12 @@
*
* @since 1.4
*/
-public class RMIRepositoryServlet extends RemoteRepositoryServlet {
+public class RMIRemoteRepositoryServlet extends RemoteRepositoryServlet {
/**
- * Serial version UID.
+ * Serial version UID.
*/
- private static final long serialVersionUID = 3361176460018801671L;
+ private static final long serialVersionUID = 2410543206806054854L;
/**
* Creates and returns an RMI repository proxy for the configured RMI URL.
@@ -66,7 +66,7 @@
* @return RMI repository proxy
*/
protected Repository getRepository() throws ServletException {
- return new RMIRepository(
+ return new RMIRemoteRepository(
getLocalAdapterFactory(),
getInitParameter("url", "//localhost/javax/jcr/Repository"));
}
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteBindingServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteBindingServlet.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteBindingServlet.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteBindingServlet.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,87 @@
+/*
+ * 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.servlet;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.servlet.ServletException;
+
+import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitServerAdapterFactory;
+
+/**
+ * Servlet that writes the remote reference of a repository in the servlet
+ * context to the configured URL.
+ * <p>
+ * The initialization parameters of this servlet are:
+ * <dl>
+ * <dt>javax.jcr.Repository</dt>
+ * <dd>
+ * Name of the servlet context attribute that contains the repository.
+ * The default value is "<code>javax.jcr.Repository</code>".
+ * </dd>
+ * <dt>org.apache.jackrabbit.rmi.server.RemoteAdapterFactory</dt>
+ * <dd>
+ * Name of the remote adapter factory class used to create the remote
+ * repository reference. The configured class should have public
+ * constructor that takes no arguments. The default class is
+ * {@link JackrabbitServerAdapterFactory}.
+ * </dd>
+ * <dt>url</dt>
+ * <dd>
+ * URL where to store the remote repository reference.
+ * </dd>
+ * </dl>
+ *
+ * @since 1.4
+ */
+public class URLRemoteBindingServlet extends RemoteBindingServlet {
+
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 3187755583290121129L;
+
+ /**
+ * Writes the remote reference of a repository in the servlet context
+ * to the configured URL.
+ *
+ * @throws ServletException if the URL could not be written to
+ */
+ public void init() throws ServletException {
+ String url = getInitParameter("url");
+ if (url == null) {
+ throw new ServletException("Missing init parameter: url");
+ }
+ try {
+ ObjectOutputStream output = new ObjectOutputStream(
+ new URL(url).openConnection().getOutputStream());
+ try {
+ output.writeObject(getRemoteRepository());
+ } finally {
+ output.close();
+ }
+ } catch (MalformedURLException e) {
+ throw new ServletException("Malformed URL: " + url, e);
+ } catch (IOException e) {
+ throw new ServletException("Failed to write to URL: " + url, e);
+ }
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteBindingServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteRepositoryServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteRepositoryServlet.java?view=auto&rev=543987
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteRepositoryServlet.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteRepositoryServlet.java Sun Jun 3 13:55:08 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.servlet;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+
+import org.apache.jackrabbit.commons.servlet.AbstractRepositoryServlet;
+import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitClientAdapterFactory;
+import org.apache.jackrabbit.rmi.repository.URLRemoteRepository;
+
+/**
+ * Servlet that makes a remote repository from a ULR available as an attribute
+ * in the servlet context.
+ * <p>
+ * The supported initialization parameters of this servlet are:
+ * <dl>
+ * <dt>javax.jcr.Repository</dt>
+ * <dd>
+ * Name of the servlet context attribute to put the repository in.
+ * The default value is "<code>javax.jcr.Repository</code>".
+ * </dd>
+ * <dt>org.apache.jackrabbit.rmi.client.LocalAdapterFactory</dt>
+ * <dd>
+ * Name of the local adapter factory class used to create the local
+ * adapter for the remote repository. The configured class should have
+ * public constructor that takes no arguments. The default class is
+ * {@link JackrabbitClientAdapterFactory}.
+ * </dd>
+ * <dt>url</dt>
+ * <dd>
+ * URL of the remote repository.
+ * </dd>
+ * </dl>
+ * <p>
+ * This servlet can also be mapped to the URL space. See
+ * {@link AbstractRepositoryServlet} for the details.
+ *
+ * @since 1.4
+ */
+public class URLRemoteRepositoryServlet extends RemoteRepositoryServlet {
+
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 6144781813459102448L;
+
+ /**
+ * Creates and returns a proxy for the remote repository at the given URL.
+ *
+ * @return repository proxy
+ */
+ protected Repository getRepository() throws ServletException {
+ String url = getInitParameter("url");
+ if (url == null) {
+ throw new ServletException("Missing init parameter: url");
+ }
+
+ try {
+ return new URLRemoteRepository(
+ getLocalAdapterFactory(), new URL(url));
+ } catch (MalformedURLException e) {
+ throw new ServletException("Invalid repository URL: " + url, e);
+ }
+ }
+
+}
Propchange: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/URLRemoteRepositoryServlet.java
------------------------------------------------------------------------------
svn:eol-style = native