jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r414435 - in /jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command: cli/command-line.xml cli/command.xml ext/ConnectToJNDIServer.java resources.properties
Date Thu, 15 Jun 2006 01:58:29 GMT
Author: edgarpoce
Date: Wed Jun 14 18:58:28 2006
New Revision: 414435

URL: http://svn.apache.org/viewvc?rev=414435&view=rev
Log:
add command to connect to a remote jcr-rmi server through jndi

Added:
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
Modified:
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml?rev=414435&r1=414434&r2=414435&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
Wed Jun 14 18:58:28 2006
@@ -173,6 +173,13 @@
       required="true"/>
   </command>
 
+  <command name="jndi" impl="connectToJndiServer">
+    <argument
+      name="url"
+      position="0"
+      required="true"/>
+  </command>
+    
   <command name="currentnode" impl="currentNode">
     <alias name="cd"/>
     <alias name="cn"/>

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml?rev=414435&r1=414434&r2=414435&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
Wed Jun 14 18:58:28 2006
@@ -41,6 +41,9 @@
 		<command name="connectToRmiServer"
 			className="org.apache.jackrabbit.command.ext.ConnectToRmiServer"/>
 
+		<command name="connectToJndiServer"
+			className="org.apache.jackrabbit.command.ext.ConnectToJNDIServer"/>
+			
 		<command name="copy"
 			className="org.apache.jackrabbit.command.core.Copy"/>
 

Added: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java?rev=414435&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
(added)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
Wed Jun 14 18:58:28 2006
@@ -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.command.ext;
+
+import javax.jcr.Repository;
+import javax.naming.InitialContext;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.rmi.client.ClientAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+
+/**
+ * Connect to a JCR-RMI server
+ */
+public class ConnectToJNDIServer implements Command {
+	/** logger */
+	private static Log log = LogFactory.getLog(ConnectToJNDIServer.class);
+
+	// ---------------------------- < keys >
+	/** url key */
+	private String urlKey = "url";
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean execute(Context ctx) throws Exception {
+		String url = (String) ctx.get(this.urlKey);
+		if (log.isDebugEnabled()) {
+			log.debug("connecting to jndi server at " + url);
+		}
+		InitialContext iCtx = new InitialContext();
+		ClientAdapterFactory adapter = new ClientAdapterFactory();
+		RemoteRepository remote = (RemoteRepository) iCtx.lookup(url);
+		Repository repo = adapter.getRepository(remote);
+		CommandHelper.setRepository(ctx, repo);
+		return false;
+	}
+
+	/**
+	 * @return the url key
+	 */
+	public String getUrlKey() {
+		return urlKey;
+	}
+
+	/**
+	 * @param urlKey
+	 *            the url key to set
+	 */
+	public void setUrlKey(String urlKey) {
+		this.urlKey = urlKey;
+	}
+}

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties?rev=414435&r1=414434&r2=414435&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties
Wed Jun 14 18:58:28 2006
@@ -50,6 +50,7 @@
 cmd.help.command.desc              = name of the command to describe
 cmd.importfilesystem               = Import data from the file system. If the given path
refers to a file it's imported to a Node of type nt:file under the current working Node. If
the given path refers to a folder, the given folder and all the subtree is imported.
 cmd.importxml                      = Imports the xml view from the given file to the current
working Node
+cmd.jndi                           = Connect to a repository through jndi
 cmd.lock                           = Lock the given Node
 cmd.lock.deep.desc                 = A deep lock applies to its holding node and all its
descendants.
 cmd.lock.session.desc              = session scoped locks expire with the session



Mime
View raw message