From: <ri...@us...> - 2007-02-12 05:00:12
|
Revision: 44 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=44&view=rev Author: rickles Date: 2007-02-11 21:00:13 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Fixed NPE problem when framework command is typed in before setting the framework. Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java Modified: sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java =================================================================== --- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-12 00:31:10 UTC (rev 43) +++ sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-12 05:00:13 UTC (rev 44) @@ -172,7 +172,7 @@ context = (BundleContext) getContext.invoke(systemBundle, null); System.out.println("BundleContext: " + context); - Class clazz = Class.forName("org.apache.felix.shell.ShellService"); + //Class clazz = Class.forName("org.apache.felix.shell.ShellService"); Object[] args = {line, in, out}; ServiceReference ref = context.getServiceReference(ShellService.class.getName()); @@ -186,6 +186,9 @@ //Thread.currentThread().setContextClassLoader(clazz.getClassLoader()); //shell = ShellService.class.cast(o); } + } catch (NullPointerException npe) { + logger.warn("Could not invoke execute method: ", npe); + System.out.println("Cannot execute framework command. Please select a framework."); } catch (Exception e) { e.printStackTrace(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-02-26 07:57:49
|
Revision: 83 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=83&view=rev Author: rickles Date: 2007-02-25 23:57:48 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Clean up code and initialize container factory. Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java Modified: sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java =================================================================== --- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-26 07:56:05 UTC (rev 82) +++ sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-26 07:57:48 UTC (rev 83) @@ -5,6 +5,7 @@ import java.io.*; import java.text.*; +import java.util.List; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -12,12 +13,15 @@ import org.apache.commons.logging.LogFactory; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkEvent; +import org.osgi.framework.FrameworkListener; import org.osgi.framework.ServiceReference; //import org.ungoverned.osgi.service.shell.ShellService; import org.apache.felix.shell.ShellService; import org.apache.felix.shell.impl.*; import org.apache.felix.framework.*; +import org.digivitality.techne.core.ContainerFactory; import org.digivitality.techne.launch.felix.*; /** @@ -27,21 +31,30 @@ * @author Rick Liton * */ -public class Shell { +public class Shell implements FrameworkListener { - static boolean FRAMEWORK_SET; + private static boolean FRAMEWORK_SET; private String profile = "Peter"; + private static String DEFAULT_CONTAINER_TYPE = "web"; protected static final Log logger = LogFactory.getLog(Shell.class); private boolean stopping = false; - Thread techneThread; - Thread frameworkThread; - FelixLauncher launcher; - FelixFrameworkThread felix; + private ContainerFactory containerFactory; + private Thread techneThread; + private Thread frameworkThread; + protected FelixLauncher launcher; + protected FelixFrameworkThread felix; //static ShellService shellService; - static Method executeCommand; - BundleContext context; + private static Method executeCommand; + private BundleContext context; + protected Shell container; + private List containerInstances; + public Shell() { + + } + public void init() { + container = this; System.out.println("\n===============================================================================\n"); System.out.println(" TTTTTTTTTTT EEEEEEEEE CCCCCCCCCC HHHHH HHHHH NNNNN NNNNN EEEEEEEEE"); System.out.println(" TTTTTTTTTTT EEEEEEEEE CCCCCCCCCC HHHHH HHHHH NNNNNN NNNNN EEEEEEEEE"); @@ -110,16 +123,16 @@ if (FRAMEWORK_SET) { out.print("Framework has already been set to Felix\n"); } else { + felix = new FelixFrameworkThread(); + frameworkThread = new Thread(felix); + frameworkThread.setPriority(1); + frameworkThread.start(); + try { - File file = new File("mytempfile"); - System.out.println("Where am i: " + file.getCanonicalPath()); + } catch (Exception e) { e.printStackTrace(); } - felix = new FelixFrameworkThread(); - frameworkThread = new Thread(felix); - frameworkThread.setPriority(1); - frameworkThread.start(); } } else if (line.equals("exit") || line.equals("quit") ) { stopping = true; @@ -163,18 +176,8 @@ } */ try { - Method m = Felix.class.getDeclaredMethod("getBundle", new Class[] { long.class }); - m.setAccessible(true); - Bundle systemBundle = (Bundle) m.invoke(launcher.getFelix(), new Object[] { new Long(0) }); - System.out.println("systemBundle superclass: " + systemBundle.getClass().getSuperclass().getName()); - Method getContext = systemBundle.getClass().getSuperclass().getDeclaredMethod("getContext", null); - getContext.setAccessible(true); - context = (BundleContext) getContext.invoke(systemBundle, null); - System.out.println("BundleContext: " + context); - //Class clazz = Class.forName("org.apache.felix.shell.ShellService"); - Object[] args = {line, in, out}; - + Object[] args = {line, in, out}; ServiceReference ref = context.getServiceReference(ShellService.class.getName()); if (ref!=null) { Object o = context.getService(ref); @@ -220,6 +223,7 @@ try { launcher = new FelixLauncher(); launcher.launch(); + setContainer(); System.out.print("techne> "); } catch (Exception e) { e.printStackTrace(); @@ -236,4 +240,36 @@ } */ } + + protected void setContainer() { + try { + Method m = Felix.class.getDeclaredMethod("getBundle", new Class[] { long.class }); + m.setAccessible(true); + Bundle systemBundle = (Bundle) m.invoke(launcher.getFelix(), new Object[] { new Long(0) }); + System.out.println("systemBundle superclass: " + systemBundle.getClass().getSuperclass().getName()); + Method getContext = systemBundle.getClass().getSuperclass().getDeclaredMethod("getContext", null); + getContext.setAccessible(true); + context = (BundleContext) getContext.invoke(systemBundle, null); + System.out.println("BundleContext: " + context); + containerFactory = ContainerFactory.getInstance(); + containerFactory.init(); + containerInstances = containerFactory.getContainerInstances(); + System.out.println("Available container instances: " + containerInstances.size()); + System.out.println("Container type: " + DEFAULT_CONTAINER_TYPE); + } catch (Exception e) { + e.printStackTrace(); + } + } + + protected Shell getContainer() { + System.out.println("Container: " + container); + return container; + } + + /* + * need to create a Techne event dispatcher later + */ + public void frameworkEvent(FrameworkEvent event) { + // will implement later + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ri...@us...> - 2007-03-01 07:44:54
|
Revision: 87 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=87&view=rev Author: rickles Date: 2007-02-28 23:44:55 -0800 (Wed, 28 Feb 2007) Log Message: ----------- Set default container type to basic Modified Paths: -------------- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java Modified: sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java =================================================================== --- sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-02-28 19:25:17 UTC (rev 86) +++ sandbox/rickles/org.digivitality.techne.shell/src/org/digivitality/techne/shell/Shell.java 2007-03-01 07:44:55 UTC (rev 87) @@ -35,7 +35,7 @@ private static boolean FRAMEWORK_SET; private String profile = "Peter"; - private static String DEFAULT_CONTAINER_TYPE = "web"; + private static String DEFAULT_CONTAINER_TYPE = "basic"; protected static final Log logger = LogFactory.getLog(Shell.class); private boolean stopping = false; private ContainerFactory containerFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |