You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by le...@apache.org on 2007/09/10 01:45:47 UTC

svn commit: r574104 - in /felix/sandbox/lenzi: shell.tui/ shell.tui/src/main/java/org/apache/felix/shell/tui/ shell.tui/src/main/java/org/apache/felix/shell/tui/completor/ shell/ shell/src/main/java/org/apache/felix/shell/

Author: lenzi
Date: Sun Sep  9 16:45:46 2007
New Revision: 574104

URL: http://svn.apache.org/viewvc?rev=574104&view=rev
Log:
enhancing Shell TUI with jline library

Added:
    felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/
    felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/BundleCentricCommandCompletor.java
    felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/DynamicMultiCompletor.java
    felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/ShellCommandCompletor.java
    felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/VersionCommandCompletor.java
    felix/sandbox/lenzi/shell/src/main/java/org/apache/felix/shell/CommandCompletor.java
Modified:
    felix/sandbox/lenzi/shell.tui/pom.xml
    felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
    felix/sandbox/lenzi/shell/pom.xml

Modified: felix/sandbox/lenzi/shell.tui/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell.tui/pom.xml?rev=574104&r1=574103&r2=574104&view=diff
==============================================================================
--- felix/sandbox/lenzi/shell.tui/pom.xml (original)
+++ felix/sandbox/lenzi/shell.tui/pom.xml Sun Sep  9 16:45:46 2007
@@ -38,8 +38,13 @@
     <dependency>
       <groupId>${pom.groupId}</groupId>
       <artifactId>org.apache.felix.shell</artifactId>
-      <version>1.1.0-SNAPSHOT</version>
+      <version>1.2.0+lenzi-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>jline</groupId>
+      <artifactId>jline</artifactId>
+      <version>0.9.91</version>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
@@ -51,11 +56,13 @@
         <configuration>
           <instructions>
             <Private-Package>org.apache.felix.shell.tui.*</Private-Package>
-            <Bundle-Activator>org.apache.felix.shell.tui.Activator</Bundle-Activator>
+            <Bundle-Activator>org.apache.felix.shell.tui.Activator</Bundle-Activator>
+            <Bundle-Version>1.2.0</Bundle-Version>            
             <Bundle-DocURL>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</Bundle-DocURL>
             <Bundle-Url>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</Bundle-Url>
             <Bundle-Source>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</Bundle-Source>
-            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Private-Package>org.apache.felix.shell.tui.*</Private-Package>
             <Import-Service>org.apache.felix.shell.ShellService</Import-Service>
           </instructions>
         </configuration>

Modified: felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java?rev=574104&r1=574103&r2=574104&view=diff
==============================================================================
--- felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java (original)
+++ felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java Sun Sep  9 16:45:46 2007
@@ -19,13 +19,20 @@
 package org.apache.felix.shell.tui;
 
 import java.io.*;
+import java.util.Iterator;
 
+import jline.Completor;
+import jline.ConsoleReader;
+
+import org.apache.felix.shell.CommandCompletor;
 import org.apache.felix.shell.ShellService;
+import org.apache.felix.shell.tui.completor.DynamicMultiCompletor;
+import org.apache.felix.shell.tui.completor.ShellCommandCompletor;
 import org.osgi.framework.*;
 
 public class Activator implements BundleActivator
 {
-    private BundleContext m_context = null;
+    static public BundleContext m_context;
     private ShellTuiRunnable m_runnable = null;
     private Thread m_thread = null;
     private ServiceReference m_shellRef = null;
@@ -113,10 +120,35 @@
             m_thread.interrupt();
         }
     }
+    
+    private class UnifiedReader
+    {
+    	private ConsoleReader cr = null;
+    	private BufferedReader br = null;
+    	
+    	public UnifiedReader(BufferedReader br) {
+			this.br = br;
+		}
+
+    	public UnifiedReader(ConsoleReader cr) {
+			this.cr = cr;
+		}
+    	
+		public String readLine() throws IOException{
+			if(br != null)
+				return br.readLine();
+			if(cr != null)
+				return cr.readLine();
+			return null;
+		}
+    }
 
-    private class ShellTuiRunnable implements Runnable
+    private class ShellTuiRunnable implements Runnable, ServiceListener
     {
         private boolean stop = false;
+        private ConsoleReader console = null;
+		private ShellCommandCompletor completorProvider = null;
+		private DynamicMultiCompletor completor;
 
         public void stop()
         {
@@ -125,9 +157,17 @@
 
         public void run()
         {
+        	UnifiedReader in = initializeConsoleReader();
             String line = null;
-            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-
+            if(in == null)
+            {
+            	in = new UnifiedReader(new BufferedReader(new InputStreamReader(System.in)));
+            }
+            else
+            {
+    	        completorProvider  = new ShellCommandCompletor();
+    	        completorProvider.start();            	
+            }
             while (!stop)
             {
                 System.out.print("-> ");
@@ -173,6 +213,122 @@
                     }
                 }
             }
+            if(console!=null)
+            {
+            	completorProvider.stop();
+            	
+            	/*
+            	 * The following clean steps must be perfoemed:
+            	 * A - remove the service listener 
+            	 * B - remove reference to service which we'll release
+            	 * C - release all the service  
+            	 */
+            	synchronized (console) {
+            		//Phase A: Removing service listener
+            		m_context.removeServiceListener(this);
+            		
+            		//Phase B: Removing reference to service
+            		for (Iterator i = console.getCompletors().iterator(); i.hasNext();) {
+						Completor c = (Completor) i.next();
+						completor.removeCompletor(c);
+					}
+            		
+            		//Phase C: Releasing all service
+    	        	ServiceReference[] completorsReference = null;
+    				try {
+    					completorsReference = m_context.getAllServiceReferences(
+    							org.apache.felix.shell.CommandCompletor.class.getName(), null
+    					);					
+    				} catch (InvalidSyntaxException ignore) {    					
+    				}
+    				
+    				for (int i = 0; i < completorsReference.length; i++) {
+    					m_context.ungetService(completorsReference[i]);
+    				}
+					
+				}
+            	
+            }
         }
+
+		private UnifiedReader initializeConsoleReader() {
+            console = null;
+            completor = new DynamicMultiCompletor();
+			try {
+				console = new ConsoleReader();
+				console.addCompletor(completor);
+			} catch (IOException e) {
+				e.printStackTrace();
+				return null;
+			}
+			
+			try
+	        {
+	            m_context.addServiceListener(this,
+	                "(objectClass="
+	                + org.apache.felix.shell.CommandCompletor.class.getName()
+	                + ")");	            
+	        }
+	        catch (InvalidSyntaxException ex)
+	        {
+	            System.err.println("ShellTui: Cannot add service listener.");
+	            System.err.println("ShellTui: " + ex);
+	        }
+
+	        synchronized (console) {
+	        	ServiceReference[] completors = null;
+				try {
+					completors = m_context.getAllServiceReferences(
+							org.apache.felix.shell.CommandCompletor.class.getName(), null
+					);					
+				} catch (InvalidSyntaxException ignore) {
+					
+				}
+
+				if(completors == null)
+					return new UnifiedReader(console);
+				
+				for (int i = 0; i < completors.length; i++) {
+					CommandCompletor cc = (CommandCompletor) m_context.getService(completors[i]);
+					completor.addCompletor(cc);
+				}
+			}
+	        	        
+			return new UnifiedReader(console);
+		}
+
+		public void serviceChanged(ServiceEvent event) {
+			StringBuffer msg = new StringBuffer();
+			switch (event.getType()) {
+				case ServiceEvent.REGISTERED:
+				{
+					msg.append("Service REGISTERED");
+					ServiceReference incoming = event.getServiceReference();
+					CommandCompletor cc = (CommandCompletor) m_context.getService(incoming);
+					synchronized (console) {
+						completor.addCompletor(cc);
+					}
+				}
+				break;
+	
+				case ServiceEvent.MODIFIED:
+					msg.append("Service MODIFIED");
+				break;
+				
+				case ServiceEvent.UNREGISTERING:
+				{
+					msg.append("Service UNREGISTERED");
+					ServiceReference leaving = event.getServiceReference();
+					synchronized (console) {
+						completor.removeCompletor((Completor) m_context.getService(leaving));
+					}
+					m_context.ungetService(event.getServiceReference());
+				}
+				break;
+			}
+			msg.append(" from ").append(event.getServiceReference().getBundle().getHeaders().get(Constants.BUNDLE_NAME));
+			msg.append(" with ID ").append(event.getServiceReference().getProperty(Constants.SERVICE_ID));			
+			System.err.println(msg.toString());
+		}
     }
 }

Added: felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/BundleCentricCommandCompletor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/BundleCentricCommandCompletor.java?rev=574104&view=auto
==============================================================================
--- felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/BundleCentricCommandCompletor.java (added)
+++ felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/BundleCentricCommandCompletor.java Sun Sep  9 16:45:46 2007
@@ -0,0 +1,80 @@
+/* 
+ * 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.felix.shell.tui.completor;
+
+import java.util.List;
+
+import jline.ArgumentCompletor;
+import jline.ArgumentCompletor.ArgumentList;
+
+import org.apache.felix.shell.CommandCompletor;
+import org.apache.felix.shell.tui.Activator;
+import org.osgi.framework.Bundle;
+
+public class BundleCentricCommandCompletor implements CommandCompletor 
+{
+	//TODO Use a cache for bundle list and status
+	
+	final private String name;
+	final private int status;
+	
+	public BundleCentricCommandCompletor(final String name, final int status) {
+		this.name = name;
+		this.status = status;
+	}
+
+	public int complete(String buffer, int cursor, List candidates) {
+		try{
+			StringBuffer msg = new StringBuffer();
+			msg.append("BundleCentricCommandCompletor "+name+": ").append(buffer).append('@').append(cursor).append("\r\n");
+			
+			ArgumentCompletor.AbstractArgumentDelimiter delimiter = 
+				new ArgumentCompletor.WhitespaceArgumentDelimiter();
+			
+			ArgumentList argumentList = delimiter.delimit(buffer, cursor);
+			msg.append("ArgList: ArgumentPosition=").append(argumentList.getArgumentPosition());
+			msg.append(" CursorArgumentIndex=").append(argumentList.getCursorArgumentIndex());
+			msg.append(" BufferPosition=").append(argumentList.getBufferPosition());
+			msg.append(" CursorArgument=").append(argumentList.getCursorArgument());
+			System.err.println(msg);
+	
+			if(argumentList.getCursorArgumentIndex()==0){
+				final String arg = argumentList.getCursorArgument();
+				if(arg==null || name.startsWith(arg))
+					candidates.add(name);
+			}else if(argumentList.getCursorArgumentIndex()>0){
+				String arg = argumentList.getCursorArgument();
+				final Bundle[] bundles = Activator.m_context.getBundles();
+				for (int i = 0; i < bundles.length; i++) {
+					final String bundleId = Long.toString(bundles[i].getBundleId());
+					if ( (bundles[i].getState() & status) > 0 
+							&& (arg==null || bundleId.startsWith(arg)))
+					{
+						candidates.add(buffer+bundleId);
+					}						
+				}
+			}
+			return 0;
+		}catch (Throwable e) {
+			e.printStackTrace();
+			return -1;
+		}
+	}
+
+}
\ No newline at end of file

Added: felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/DynamicMultiCompletor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/DynamicMultiCompletor.java?rev=574104&view=auto
==============================================================================
--- felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/DynamicMultiCompletor.java (added)
+++ felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/DynamicMultiCompletor.java Sun Sep  9 16:45:46 2007
@@ -0,0 +1,55 @@
+package org.apache.felix.shell.tui.completor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import jline.Completor;
+import jline.MultiCompletor;
+
+public class DynamicMultiCompletor implements Completor{
+
+	final protected ArrayList completors; 
+	boolean dirty = false;
+	private MultiCompletor multi;
+	
+	public DynamicMultiCompletor() {
+		multi = new MultiCompletor();
+		completors = new ArrayList();
+	}
+
+	public DynamicMultiCompletor(Completor[] completors) {
+		multi = new MultiCompletor(completors);
+		this.completors = new ArrayList();
+		for (int i = 0; i < completors.length; i++) {
+			this.completors.add(completors[i]);
+		}
+	}
+
+	public DynamicMultiCompletor(List completors) {
+		multi = new MultiCompletor(completors);
+		this.completors = new ArrayList (completors);
+	}
+	
+	public boolean addCompletor(Completor c){
+		boolean flag;
+		flag = completors.add(c);
+		dirty = flag == true;
+		return flag;
+	}
+
+	public boolean removeCompletor(Completor c){
+		boolean flag;
+		flag = completors.remove(c);
+		dirty = flag == true;
+		return flag;
+	}
+
+	public int complete(String buffer, int pos, List cand) {
+		if(dirty){
+			multi = new MultiCompletor(completors);
+		}
+		return multi.complete(buffer, pos, cand);
+	}
+	
+	
+}

Added: felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/ShellCommandCompletor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/ShellCommandCompletor.java?rev=574104&view=auto
==============================================================================
--- felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/ShellCommandCompletor.java (added)
+++ felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/ShellCommandCompletor.java Sun Sep  9 16:45:46 2007
@@ -0,0 +1,183 @@
+/* 
+ * 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.felix.shell.tui.completor;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import org.apache.felix.shell.Command;
+import org.apache.felix.shell.CommandCompletor;
+import org.apache.felix.shell.tui.Activator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+
+public class ShellCommandCompletor implements ServiceListener
+{	
+	final private Hashtable completors;
+	
+	public ShellCommandCompletor()
+	{
+		completors = new Hashtable();
+	}
+	
+	public void start()
+	{
+		try {
+	        Activator.m_context.addServiceListener(this,
+	                "(|(objectClass="
+	                + org.apache.felix.shell.Command.class.getName()
+	                + ")(objectClass="
+	                + org.ungoverned.osgi.service.shell.Command.class.getName()
+	                + "))");
+        }
+        catch (InvalidSyntaxException ex)
+        {
+            System.err.println("Activator: Cannot register service listener.");
+            System.err.println("Activator: " + ex);
+		}
+        init();		
+	}
+	
+	public void stop()
+	{
+		Activator.m_context.removeServiceListener(this);
+		for (Iterator i = completors.entrySet().iterator(); i.hasNext();) {
+			Entry e = (Entry) i.next();
+			((ServiceRegistration) e.getValue()).unregister();
+		}
+	}
+	
+    private synchronized void init()
+    {
+    	ServiceReference commandReferences[] = null;
+    	try {
+			commandReferences = Activator.m_context.getAllServiceReferences(
+					org.apache.felix.shell.Command.class.getName(), null
+					);
+		} catch (InvalidSyntaxException ignore) {
+		}
+		if(commandReferences!=null) {
+			for (int i = 0; i < commandReferences.length; i++) {
+				Command c = (Command) Activator.m_context.getService(commandReferences[i]);
+				installCommandCompletor(
+						((Long)commandReferences[i].getProperty(Constants.SERVICE_ID)).toString(), 
+						c.getName()
+				);
+				Activator.m_context.ungetService(commandReferences[i]);
+			}
+		}
+
+    	try {
+			commandReferences = Activator.m_context.getAllServiceReferences(
+					org.ungoverned.osgi.service.shell.Command.class.getName(), null
+					);
+		} catch (InvalidSyntaxException ignore) {
+		}
+		if(commandReferences!=null) {
+			for (int i = 0; i < commandReferences.length; i++) {
+				org.ungoverned.osgi.service.shell.Command c = (org.ungoverned.osgi.service.shell.Command) 
+				Activator.m_context.getService(commandReferences[i]);
+				installCommandCompletor(
+						((Long)commandReferences[i].getProperty(Constants.SERVICE_ID)).toString(), 
+						c.getName()
+				);
+				Activator.m_context.ungetService(commandReferences[i]);
+			}
+		}
+    }
+    
+    private synchronized void installCommandCompletor(String id, String name)
+    {
+		System.err.println("Creating CommandCompletor SERVICE for "+name+"@"+id);
+    	
+    	CommandCompletor service = null;
+    	if("start".equals(name)){
+    		service = new BundleCentricCommandCompletor("start",(Bundle.RESOLVED + Bundle.INSTALLED));
+    	}else if("stop".equals(name)){
+    		service = new BundleCentricCommandCompletor("stop", Bundle.ACTIVE);
+    	}else if("update".equals(name)){
+    		service = new BundleCentricCommandCompletor("update",(Bundle.RESOLVED + Bundle.INSTALLED + Bundle.ACTIVE));
+    	//}else if("uninstall".equals(name)){
+        //	service = new BundleCentricCommandCompletor("uninstall",(Bundle.RESOLVED + Bundle.INSTALLED + Bundle.ACTIVE));
+    	}else if("version".equals(name)){
+    		service = new VersionCommandCompletor();
+    	}
+    	if(service!=null){
+    		System.err.println("CommandCompletor SERVICE for "+name+"@"+id+" CREATED");
+        	Properties prop = new Properties();
+        	prop.put(CommandCompletor.COMMAND_ID, id);
+        	prop.put(CommandCompletor.COMMAND_NAME, name);
+        	ServiceRegistration reg =  Activator.m_context.registerService(
+        			CommandCompletor.class.getName(), service, prop 
+        	);
+    		System.err.println("CommandCompletor SERVICE for "+name+"@"+id+" REGISTERED");
+        	completors.put(id, reg);        	
+    	}
+    }
+
+    private synchronized void removeCommandCompletor(String id){
+    	ServiceRegistration reg = (ServiceRegistration) completors.get(id);
+    	if(reg != null) reg.unregister();    	
+    }
+
+	public void serviceChanged(ServiceEvent event) {
+		StringBuffer msg = new StringBuffer();		
+		switch (event.getType()) {
+			case ServiceEvent.REGISTERED:
+			{
+				msg.append("Service REGISTERED");				
+				ServiceReference installing = event.getServiceReference();
+				Object command = Activator.m_context.getService(installing);
+				String name = null;
+				if (command instanceof Command) {
+					Command cmd = (Command) command;
+					name = cmd.getName();
+				}else if (command instanceof org.ungoverned.osgi.service.shell.Command) {
+					org.ungoverned.osgi.service.shell.Command cmd = 
+						(org.ungoverned.osgi.service.shell.Command) command;
+					name = cmd.getName();
+				}
+				installCommandCompletor(
+						((Long) installing.getProperty(Constants.SERVICE_ID)).toString(), 
+						name
+				);
+				Activator.m_context.ungetService(installing);
+			}break;
+			case ServiceEvent.UNREGISTERING:
+			{
+				msg.append("Service UNREGISTERED");				
+				ServiceReference removing = event.getServiceReference();
+				removeCommandCompletor(
+						((Long) removing.getProperty(Constants.SERVICE_ID)).toString()
+				);
+			}break;
+		}
+		msg.append(" from ").append(event.getServiceReference().getBundle().getHeaders().get(Constants.BUNDLE_NAME));
+		msg.append(" with ID ").append(event.getServiceReference().getProperty(Constants.SERVICE_ID));			
+		System.err.println(msg.toString());		
+	}
+}
\ No newline at end of file

Added: felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/VersionCommandCompletor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/VersionCommandCompletor.java?rev=574104&view=auto
==============================================================================
--- felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/VersionCommandCompletor.java (added)
+++ felix/sandbox/lenzi/shell.tui/src/main/java/org/apache/felix/shell/tui/completor/VersionCommandCompletor.java Sun Sep  9 16:45:46 2007
@@ -0,0 +1,35 @@
+/* 
+ * 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.felix.shell.tui.completor;
+
+import java.util.List;
+
+import jline.SimpleCompletor;
+
+import org.apache.felix.shell.CommandCompletor;
+
+public class VersionCommandCompletor implements CommandCompletor 
+{
+	private final SimpleCompletor completor = new SimpleCompletor("version"); 
+
+	public int complete(String buffer, int cursor, List candidates) {
+		return completor.complete(buffer, cursor, candidates);
+	}
+
+}
\ No newline at end of file

Modified: felix/sandbox/lenzi/shell/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell/pom.xml?rev=574104&r1=574103&r2=574104&view=diff
==============================================================================
--- felix/sandbox/lenzi/shell/pom.xml (original)
+++ felix/sandbox/lenzi/shell/pom.xml Sun Sep  9 16:45:46 2007
@@ -33,8 +33,14 @@
     <dependency>
       <groupId>${pom.groupId}</groupId>
       <artifactId>org.osgi.core</artifactId>
-      <version>1.1.0-SNAPSHOT</version>
+      <version>1.1.0-SNAPSHOT</version>
+      <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>jline</groupId>
+      <artifactId>jline</artifactId>
+      <version>0.9.91</version>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
@@ -45,8 +51,10 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
-            <Export-Package>org.apache.felix.shell; org.ungoverned.osgi.service.shell; version=1.0.0</Export-Package>
-            <Private-Package>org.apache.felix.*</Private-Package>
+            <Export-Package>org.apache.felix.shell; version=1.2.0, org.ungoverned.osgi.service.shell; version=1.0.0</Export-Package>
+            <Import-Package>jline.*</Import-Package>
+            <Private-Package>org.apache.felix.*</Private-Package>
+            <Bundle-Version>1.2.0</Bundle-Version>
             <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
             <Bundle-Activator>org.apache.felix.shell.impl.Activator</Bundle-Activator>
             <Export-Service>org.apache.felix.shell.ShellService, org.ungoverned.osgi.service.shell.ShellService</Export-Service>

Added: felix/sandbox/lenzi/shell/src/main/java/org/apache/felix/shell/CommandCompletor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/lenzi/shell/src/main/java/org/apache/felix/shell/CommandCompletor.java?rev=574104&view=auto
==============================================================================
--- felix/sandbox/lenzi/shell/src/main/java/org/apache/felix/shell/CommandCompletor.java (added)
+++ felix/sandbox/lenzi/shell/src/main/java/org/apache/felix/shell/CommandCompletor.java Sun Sep  9 16:45:46 2007
@@ -0,0 +1,8 @@
+package org.apache.felix.shell;
+
+import jline.Completor;
+
+public interface CommandCompletor extends Completor {
+	public final static String COMMAND_NAME = "command.completor.reference.name";
+	public final static String COMMAND_ID = "command.completor.reference.service.id";
+}