private CharSequence getShortNames(String[] list) { StringBuilder sb = new StringBuilder(); String del = ""; for (String s : list) { sb.append(del + getShortName(s)); del = " | "; } return sb; }
public CharSequence format(Object target, int level, Converter converter) throws IOException { if (level == INSPECT && target instanceof InputStream) { return read(((InputStream) target)); } if (level == LINE && target instanceof Bundle) { return print((Bundle) target); } if (level == LINE && target instanceof ServiceReference) { return print((ServiceReference) target); } if (level == PART && target instanceof Bundle) { return ((Bundle) target).getSymbolicName(); } if (level == PART && target instanceof ServiceReference) { return getShortNames((String[]) ((ServiceReference) target).getProperty("objectclass")); } return null; }
return convertBundle(in); return convertServiceReference(in); return read(((InputStream) in));
private void startShell(BundleContext context, CommandProcessor processor) { Dictionary<String, Object> dict = new Hashtable<String, Object>(); dict.put(CommandProcessor.COMMAND_SCOPE, "gogo"); // register converters regs.add(context.registerService(Converter.class.getName(), new Converters(context), null)); // register commands dict.put(CommandProcessor.COMMAND_FUNCTION, Builtin.functions); regs.add(context.registerService(Builtin.class.getName(), new Builtin(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Procedural.functions); regs.add(context.registerService(Procedural.class.getName(), new Procedural(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Posix.functions); regs.add(context.registerService(Posix.class.getName(), new Posix(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Telnet.functions); regs.add(context.registerService(Telnet.class.getName(), new Telnet(processor), dict)); shell = new Shell(context, processor); dict.put(CommandProcessor.COMMAND_FUNCTION, Shell.functions); regs.add(context.registerService(Shell.class.getName(), shell, dict)); // start shell session = processor.createSession(System.in, System.out, System.err); thread = new Thread(this, "Gogo shell"); thread.start(); }
private CharSequence print(Bundle bundle) { // [ ID ] [STATE ] [ SL ] symname int level = bundle.adapt(BundleStartLevel.class).getStartLevel(); return String.format("%5d|%-11s|%5d|%s (%s)", bundle.getBundleId(), getState(bundle), level, bundle.getSymbolicName(), bundle.getVersion()); }
private CharSequence print(ServiceReference<?> ref) { String spid = ""; Object pid = ref.getProperty("service.pid"); if (pid != null) { spid = pid.toString(); } return String.format("%06d %3s %-40s %s", ref.getProperty("service.id"), ref.getBundle().getBundleId(), getShortNames((String[]) ref.getProperty("objectclass")), spid); }
return convertBundle(in); return convertServiceReference(in); return read(((InputStream) in));
private void startShell(BundleContext context, CommandProcessor processor) { Dictionary<String, Object> dict = new Hashtable<>(); dict.put(CommandProcessor.COMMAND_SCOPE, "gogo"); Set<ServiceRegistration<?>> currentRegs = new HashSet<>(); // register converters currentRegs.add(context.registerService(Converter.class.getName(), new Converters(context.getBundle(0).getBundleContext()), null)); // register commands dict.put(CommandProcessor.COMMAND_FUNCTION, Builtin.functions); currentRegs.add(context.registerService(Builtin.class.getName(), new Builtin(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Procedural.functions); currentRegs.add(context.registerService(Procedural.class.getName(), new Procedural(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Posix.functions); currentRegs.add(context.registerService(Posix.class.getName(), new Posix(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Telnet.functions); currentRegs.add(context.registerService(Telnet.class.getName(), new Telnet(processor), dict)); Shell shell = new Shell(context, processor); dict.put(CommandProcessor.COMMAND_FUNCTION, Shell.functions); currentRegs.add(context.registerService(Shell.class.getName(), shell, dict)); synchronized (regs) { regs.addAll(currentRegs); currentRegs.clear(); } // start shell on a separate thread... executor = Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, "Gogo shell")); shellJob = new StartShellJob(context, processor); executor.submit(shellJob); }
private CharSequence print(Bundle bundle) { // [ ID ] [STATE ] [ SL ] symname StartLevel sl = null; ServiceReference ref = context.getServiceReference(StartLevel.class.getName()); if (ref != null) { sl = (StartLevel) context.getService(ref); } if (sl == null) { return String.format("%5d|%-11s|%s (%s)", bundle.getBundleId(), getState(bundle), bundle.getSymbolicName(), bundle.getVersion()); } int level = sl.getBundleStartLevel(bundle); context.ungetService(ref); return String.format("%5d|%-11s|%5d|%s (%s)", bundle.getBundleId(), getState(bundle), level, bundle.getSymbolicName(), bundle.getVersion()); }
private CharSequence print(ServiceReference<?> ref) { String spid = ""; Object pid = ref.getProperty("service.pid"); if (pid != null) { spid = pid.toString(); } return String.format("%06d %3s %-40s %s", ref.getProperty("service.id"), ref.getBundle().getBundleId(), getShortNames((String[]) ref.getProperty("objectclass")), spid); }
public CharSequence format(Object target, int level, Converter converter) throws IOException { if (level == INSPECT && target instanceof InputStream) { return read(((InputStream) target)); } if (level == LINE && target instanceof Bundle) { return print((Bundle) target); } if (level == LINE && target instanceof ServiceReference) { return print((ServiceReference) target); } if (level == PART && target instanceof Bundle) { return ((Bundle) target).getSymbolicName(); } if (level == PART && target instanceof ServiceReference) { return getShortNames((String[]) ((ServiceReference) target).getProperty("objectclass")); } return null; }
return convertBundle(in); return convertServiceReference(in); return read(((InputStream) in));
private void startShell(BundleContext context, CommandProcessor processor) { Dictionary<String, Object> dict = new Hashtable<String, Object>(); dict.put(CommandProcessor.COMMAND_SCOPE, "gogo"); // register converters regs.add(context.registerService(Converter.class.getName(), new Converters(context), null)); // register commands dict.put(CommandProcessor.COMMAND_FUNCTION, Builtin.functions); regs.add(context.registerService(Builtin.class.getName(), new Builtin(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Procedural.functions); regs.add(context.registerService(Procedural.class.getName(), new Procedural(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Posix.functions); regs.add(context.registerService(Posix.class.getName(), new Posix(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Telnet.functions); regs.add(context.registerService(Telnet.class.getName(), new Telnet(processor), dict)); shell = new Shell(context, processor); dict.put(CommandProcessor.COMMAND_FUNCTION, Shell.functions); regs.add(context.registerService(Shell.class.getName(), shell, dict)); // start shell session = processor.createSession(System.in, System.out, System.err); thread = new Thread(this, "Gogo shell"); thread.start(); }
private CharSequence print(Bundle bundle) { // [ ID ] [STATE ] [ SL ] symname StartLevel sl = null; ServiceReference ref = context.getServiceReference(StartLevel.class.getName()); if (ref != null) { sl = (StartLevel) context.getService(ref); } if (sl == null) { return String.format("%5d|%-11s|%s (%s)", bundle.getBundleId(), getState(bundle), bundle.getSymbolicName(), bundle.getVersion()); } int level = sl.getBundleStartLevel(bundle); context.ungetService(ref); return String.format("%5d|%-11s|%5d|%s (%s)", bundle.getBundleId(), getState(bundle), level, bundle.getSymbolicName(), bundle.getVersion()); }
private CharSequence getShortNames(String[] list) { StringBuilder sb = new StringBuilder(); String del = ""; for (String s : list) { sb.append(del + getShortName(s)); del = " | "; } return sb; }
private CharSequence print(ServiceReference ref) { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); String spid = ""; Object pid = ref.getProperty("service.pid"); if (pid != null) { spid = pid.toString(); } f.format("%06d %3s %-40s %s", ref.getProperty("service.id"), ref.getBundle().getBundleId(), getShortNames((String[]) ref.getProperty("objectclass")), spid); return sb; }
public CharSequence format(Object target, int level, Converter converter) throws IOException { if (level == INSPECT && target instanceof InputStream) { return read(((InputStream) target)); } if (level == LINE && target instanceof Bundle) { return print((Bundle) target); } if (level == LINE && target instanceof ServiceReference) { return print((ServiceReference<?>) target); } if (level == PART && target instanceof Bundle) { return ((Bundle) target).getSymbolicName(); } if (level == PART && target instanceof ServiceReference) { return getShortNames((String[]) ((ServiceReference<?>) target).getProperty("objectclass")); } return null; }
return convertBundle(in); return convertServiceReference(in); return read(((InputStream) in));
private void startShell(BundleContext context, CommandProcessor processor) { Dictionary<String, Object> dict = new Hashtable<>(); dict.put(CommandProcessor.COMMAND_SCOPE, "gogo"); Set<ServiceRegistration<?>> currentRegs = new HashSet<>(); // register converters currentRegs.add(context.registerService(Converter.class.getName(), new Converters(context.getBundle(0).getBundleContext()), null)); // register commands dict.put(CommandProcessor.COMMAND_FUNCTION, Builtin.functions); currentRegs.add(context.registerService(Builtin.class.getName(), new Builtin(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Procedural.functions); currentRegs.add(context.registerService(Procedural.class.getName(), new Procedural(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Posix.functions); currentRegs.add(context.registerService(Posix.class.getName(), new Posix(), dict)); dict.put(CommandProcessor.COMMAND_FUNCTION, Telnet.functions); currentRegs.add(context.registerService(Telnet.class.getName(), new Telnet(processor), dict)); Shell shell = new Shell(context, processor); dict.put(CommandProcessor.COMMAND_FUNCTION, Shell.functions); currentRegs.add(context.registerService(Shell.class.getName(), shell, dict)); synchronized (regs) { regs.addAll(currentRegs); currentRegs.clear(); } // start shell on a separate thread... executor = Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, "Gogo shell")); shellJob = new StartShellJob(context, processor); executor.submit(shellJob); }
private CharSequence print(Bundle bundle) { // [ ID ] [STATE ] [ SL ] symname int level = bundle.adapt(BundleStartLevel.class).getStartLevel(); return String.format("%5d|%-11s|%5d|%s (%s)", bundle.getBundleId(), getState(bundle), level, bundle.getSymbolicName(), bundle.getVersion()); }