SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Posh: an OSGi Shell
         RFC132 in action!
                    Derek Baum
                  Paremus Limited
Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
The (Draft) Specification




Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
RFC132: Problem Description
No standard way for user to interact with an
 OSGi-based system.
• Different commands for common tasks
     – install, start, stop, status
• Different API to add commands
     – Commands are not reusable
• No script support



Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Equinox & Felix Shells
$ java -jar org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar
$ java -jar org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar -console
osgi> ss
Framework is launched.
id State       Bundle
0 ACTIVE       org.eclipse.osgi_3.4.3.R34x_v20081215-1030
osgi> ^D$

$ java -jar bin/felix.jar
-> ss
Command not found.
-> ps
START LEVEL 1
    ID   State         Level Name
[    0] [Active    ] [     0] System Bundle (1.8.0)
[    1] [Active    ] [     1] Apache Felix Shell Service (1.2.0)
[    2] [Active    ] [     1] Apache Felix Shell TUI (1.2.0)
[    3] [Active    ] [     1] Apache Felix Bundle Repository (1.4.0)
-> ^DShellTUI: No standard input...exiting.
^C$
 Posh OSGi Shell    Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Hello, Equinox
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;

public class Commands implements CommandProvider {

    public void _hello(CommandInterpreter ci) {
      ci.print("Hello, " + ci.nextArgument());
    }

    public String getHelp() {
      return "thello - say hellon";
    }
}




    Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Hello, Felix
import org.apache.felix.shell.Command;

public class HelloCommand implements Command {

    public void execute(String s, PrintStream out, PrintStream err) {
      String[] args = s.split(“s+”);

        if (args.length < 2) {
          err.println(“Usage: ” + getUsage());
        }
        else {
          out.println(“Hello, “ + args[1]);
        }
    }

    public String getName() { return "hello";}
    public String getUsage() { return "hello name";}
    public String getShortDescription() { return "say hello";}
}


    Posh OSGi Shell     Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Hello, RFC132
public class Commands {

    public boolean hello(String name) {
      System.out.println(“Hello, “ + name);
      return name != null;
    }

}




    Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
RFC132 Command Interface
• Simple & lightweight to add commands
          – Promotes adding commands in any bundle

• Access to input and output streams
• Shared session state between commands
• Small (core runtime < 50Kb)




Posh OSGi Shell    Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Architecture
                      Console                 Telnet                 ...
                      Session                Session               Session



                                        CommandProvider


                     CommandSessionImpl                                 ThreadIO

                                         CommandSession
                                                        command providers
              Converter                                 scope=xxx, function=yyy


                      Basic                  Basic                    ...
                   Conversions             Commands                Commands



Posh OSGi Shell           Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
CommandProcessor
package org.osgi.service.command;

public interface CommandProcessor {
    CommandSession createSession(InputStream in, PrintStream out,
     PrintStream err);
}




    Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
CommandSession
package org.osgi.service.command;

public interface CommandSession {
  Object execute(CharSequence program) throws Exception;
  void close();

    InputStream getKeyboard();
    PrintStream getConsole();

    Object get(String name);
    void put(String name, Object value);

    CharSequence format(Object target, int level);
    Object convert(Class<?> type, Object instance);
}




    Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Command Provider
• There is no CommandProvider interface
• Parameters are coerced using reflection
• Any service can provide commands

    public void start(BundleContext ctx) {
        Commands cmd = new Commands();
        String functions[] = {“hello”, “goodbye”};
        Dictionary dict = new Dictionary();
        dict.put(“osgi.command.scope”, “myscope”);
        dict.put(“osgi.command.function”, functions);
        ctx.registerService(cmd.getClass().getName,() cmd, dict);
    }

Posh OSGi Shell       Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Any Command Interface
public boolean grep(String[] args) throws IOException;


public URI cd(CommandSession session, String dir);
public URI pwd(CommandSession session);


public void addCommand(String scope, Object target);
public void addCommand(String scope, Object target, Class<?> fc);
public void addCommand(String scope, Object target, String func);


public Bundle getBundle(long id);
public Bundle[] getBundles();
public ServiceRegistration registerService(
        String clazz, Object svcObj, Dictionary dict);




 Posh OSGi Shell    Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Grep command
public boolean grep(CommandSession session, List<String> args)
                                            throws IOException {
  Pattern pattern = Pattern.compile(args.remove(0));

    for (String arg : args) {
      InputStream in =
               Directory.resolve(session,arg).toURL().openStream();
      Reader rdr = new BufferedReader(new InputStreamReader(in));
      String s;

        while ((s = rdr.readLine()) != null) {
          if (pattern.matcher(s).find()) {
            match = true;
            System.out.println(s);
          }
        }
    }

    return match;
}

    Posh OSGi Shell     Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Interactive Shell Language
• Interactive shell requirements differ from
  those for scripting languages
            – Easy for users to type
            – Minimum parenthesis, semi-colons etc
            – Compatibility with Unix shells like bash

• Existing JVM languages not good for shell
            – Jacl: needs own TCL-derived library
            – BeanShell: syntax too verbose



Posh OSGi Shell       Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Tiny Shell Language - TSL
• Easy to use – no unnecessary syntax
• Provides lists, pipes and closures
• Leverages Java capabilities
            – Method calls using reflection
            – Argument coercion

• Commands can provide control primitives
• Small size (<50Kb)


Posh OSGi Shell      Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Closures implement Function
package org.osgi.service.command;
public interface Function {
    Object execute(CommandSession session, List<Object> arguments)
     throws Exception;
}




    Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Add Control Primitives
public void each(CommandSession session, Collection<Object> list,
   Function closure) throws Exception {

    List<Object> args = new ArrayList<Object>();
    args.add(null);

    for (Object x : list) {
      args.set(0, x);
      closure.execute(session, args);
    }
}


% each [a, b, 1, 2] { echo $it }
a
b
1
2

    Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
RFC132: What's missing?
• Commands in osgi: scope are not defined
• Search order for unscoped commands
• List available commands and variables
• Script execution
• Command editing, history and completion




Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Posh: in action!



Posh OSGi Shell      Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Posh in action!
Builds on basic RFC132 runtime
•        Adds SCOPE path
•        Shell builtins: set, type
•        Script execution
•        Command editing, history & completion
•        Control-C interrupt handling
•        And more…

Posh OSGi Shell    Copyright © 2009 Paremus Limited. All rights reserved.   June 2009
Links

RFC132 Draft Specification
www.osgi.org/download/osgi-4.2-early-draft.pdf

Posh “devcon” binary download
www.paremus.com/devcon2009download/

derek.baum@paremus.com



Posh OSGi Shell   Copyright © 2009 Paremus Limited. All rights reserved.   June 2009

Mais conteúdo relacionado

Mais procurados

Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8Marco Massarelli
 
Brno meetr: Packaging Ruby Gems into RPM
Brno meetr: Packaging Ruby Gems into RPMBrno meetr: Packaging Ruby Gems into RPM
Brno meetr: Packaging Ruby Gems into RPMLubomir Rintel
 
Using puppet
Using puppetUsing puppet
Using puppetAlex Su
 
Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007Rupesh Kumar
 
Ios i pv4_access_lists
Ios i pv4_access_listsIos i pv4_access_lists
Ios i pv4_access_listsMohamed Gamel
 
解读server.xml文件
解读server.xml文件解读server.xml文件
解读server.xml文件wensheng wei
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseChristian Melchior
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn WorkshopBastian Feder
 
Python concurrency: libraries overview
Python concurrency: libraries overviewPython concurrency: libraries overview
Python concurrency: libraries overviewAndrii Mishkovskyi
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a NutshellCoreOS
 
When symfony met promises
When symfony met promises When symfony met promises
When symfony met promises Marc Morera
 

Mais procurados (19)

Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8
 
Caché acelerador de contenido
Caché acelerador de contenidoCaché acelerador de contenido
Caché acelerador de contenido
 
Comredis
ComredisComredis
Comredis
 
Ip Access Lists
Ip Access ListsIp Access Lists
Ip Access Lists
 
Brno meetr: Packaging Ruby Gems into RPM
Brno meetr: Packaging Ruby Gems into RPMBrno meetr: Packaging Ruby Gems into RPM
Brno meetr: Packaging Ruby Gems into RPM
 
Using puppet
Using puppetUsing puppet
Using puppet
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 
Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
 
Ios i pv4_access_lists
Ios i pv4_access_listsIos i pv4_access_lists
Ios i pv4_access_lists
 
解读server.xml文件
解读server.xml文件解读server.xml文件
解读server.xml文件
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn Workshop
 
Python concurrency: libraries overview
Python concurrency: libraries overviewPython concurrency: libraries overview
Python concurrency: libraries overview
 
JAVA NIO
JAVA NIOJAVA NIO
JAVA NIO
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
 
When symfony met promises
When symfony met promises When symfony met promises
When symfony met promises
 
Raj apache
Raj apacheRaj apache
Raj apache
 

Destaque

O triunfo dos nerds
O triunfo dos nerdsO triunfo dos nerds
O triunfo dos nerdsLuiz Borba
 
Posh Pows With Logan
Posh Pows With LoganPosh Pows With Logan
Posh Pows With Logansatonner
 
Posh Consulting Inc. Overview
Posh Consulting Inc. OverviewPosh Consulting Inc. Overview
Posh Consulting Inc. Overviewash321ash
 
Prevention of Sexual Harassment at Workplace Act
Prevention of Sexual Harassment at Workplace ActPrevention of Sexual Harassment at Workplace Act
Prevention of Sexual Harassment at Workplace ActAID FOR CHANGE
 

Destaque (7)

O triunfo dos nerds
O triunfo dos nerdsO triunfo dos nerds
O triunfo dos nerds
 
Apresentacao nerd
Apresentacao nerdApresentacao nerd
Apresentacao nerd
 
Dia do Orgulho Nerd
Dia do Orgulho NerdDia do Orgulho Nerd
Dia do Orgulho Nerd
 
Posh Pows With Logan
Posh Pows With LoganPosh Pows With Logan
Posh Pows With Logan
 
Posh Consulting Inc. Overview
Posh Consulting Inc. OverviewPosh Consulting Inc. Overview
Posh Consulting Inc. Overview
 
Cultura nerd
Cultura nerdCultura nerd
Cultura nerd
 
Prevention of Sexual Harassment at Workplace Act
Prevention of Sexual Harassment at Workplace ActPrevention of Sexual Harassment at Workplace Act
Prevention of Sexual Harassment at Workplace Act
 

Semelhante a Posh Devcon2009

Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAThuy_Dang
 
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureHabeeb Rahman
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleCarsten Ziegeler
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegelermfrancis
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleAdobe
 
20100730 phpstudy
20100730 phpstudy20100730 phpstudy
20100730 phpstudyYusuke Ando
 
Service oriented web development with OSGi
Service oriented web development with OSGiService oriented web development with OSGi
Service oriented web development with OSGiCarsten Ziegeler
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Eugene Yokota
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Jimmy Schementi
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introductionBirol Efe
 
Intro to Rust 2019
Intro to Rust 2019Intro to Rust 2019
Intro to Rust 2019Timothy Bess
 
Exchange 2010 PowerShell and the Exchange 2003 Administrator
Exchange 2010 PowerShell and the Exchange 2003 AdministratorExchange 2010 PowerShell and the Exchange 2003 Administrator
Exchange 2010 PowerShell and the Exchange 2003 AdministratorMichel de Rooij
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RaceBaruch Sadogursky
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modulesPython Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modulesP3 InfoTech Solutions Pvt. Ltd.
 
Automated infrastructure is on the menu
Automated infrastructure is on the menuAutomated infrastructure is on the menu
Automated infrastructure is on the menujtimberman
 

Semelhante a Posh Devcon2009 (20)

Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEA
 
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
20100730 phpstudy
20100730 phpstudy20100730 phpstudy
20100730 phpstudy
 
Service oriented web development with OSGi
Service oriented web development with OSGiService oriented web development with OSGi
Service oriented web development with OSGi
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introduction
 
Intro to Rust 2019
Intro to Rust 2019Intro to Rust 2019
Intro to Rust 2019
 
Exchange 2010 PowerShell and the Exchange 2003 Administrator
Exchange 2010 PowerShell and the Exchange 2003 AdministratorExchange 2010 PowerShell and the Exchange 2003 Administrator
Exchange 2010 PowerShell and the Exchange 2003 Administrator
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools Race
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modulesPython Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modules
 
Automated infrastructure is on the menu
Automated infrastructure is on the menuAutomated infrastructure is on the menu
Automated infrastructure is on the menu
 

Último

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Último (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Posh Devcon2009

  • 1. Posh: an OSGi Shell RFC132 in action! Derek Baum Paremus Limited Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 2. The (Draft) Specification Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 3. RFC132: Problem Description No standard way for user to interact with an OSGi-based system. • Different commands for common tasks – install, start, stop, status • Different API to add commands – Commands are not reusable • No script support Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 4. Equinox & Felix Shells $ java -jar org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar $ java -jar org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar -console osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.4.3.R34x_v20081215-1030 osgi> ^D$ $ java -jar bin/felix.jar -> ss Command not found. -> ps START LEVEL 1 ID State Level Name [ 0] [Active ] [ 0] System Bundle (1.8.0) [ 1] [Active ] [ 1] Apache Felix Shell Service (1.2.0) [ 2] [Active ] [ 1] Apache Felix Shell TUI (1.2.0) [ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.4.0) -> ^DShellTUI: No standard input...exiting. ^C$ Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 5. Hello, Equinox import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; public class Commands implements CommandProvider { public void _hello(CommandInterpreter ci) { ci.print("Hello, " + ci.nextArgument()); } public String getHelp() { return "thello - say hellon"; } } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 6. Hello, Felix import org.apache.felix.shell.Command; public class HelloCommand implements Command { public void execute(String s, PrintStream out, PrintStream err) { String[] args = s.split(“s+”); if (args.length < 2) { err.println(“Usage: ” + getUsage()); } else { out.println(“Hello, “ + args[1]); } } public String getName() { return "hello";} public String getUsage() { return "hello name";} public String getShortDescription() { return "say hello";} } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 7. Hello, RFC132 public class Commands { public boolean hello(String name) { System.out.println(“Hello, “ + name); return name != null; } } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 8. RFC132 Command Interface • Simple & lightweight to add commands – Promotes adding commands in any bundle • Access to input and output streams • Shared session state between commands • Small (core runtime < 50Kb) Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 9. Architecture Console Telnet ... Session Session Session CommandProvider CommandSessionImpl ThreadIO CommandSession command providers Converter scope=xxx, function=yyy Basic Basic ... Conversions Commands Commands Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 10. CommandProcessor package org.osgi.service.command; public interface CommandProcessor { CommandSession createSession(InputStream in, PrintStream out, PrintStream err); } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 11. CommandSession package org.osgi.service.command; public interface CommandSession { Object execute(CharSequence program) throws Exception; void close(); InputStream getKeyboard(); PrintStream getConsole(); Object get(String name); void put(String name, Object value); CharSequence format(Object target, int level); Object convert(Class<?> type, Object instance); } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 12. Command Provider • There is no CommandProvider interface • Parameters are coerced using reflection • Any service can provide commands public void start(BundleContext ctx) { Commands cmd = new Commands(); String functions[] = {“hello”, “goodbye”}; Dictionary dict = new Dictionary(); dict.put(“osgi.command.scope”, “myscope”); dict.put(“osgi.command.function”, functions); ctx.registerService(cmd.getClass().getName,() cmd, dict); } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 13. Any Command Interface public boolean grep(String[] args) throws IOException; public URI cd(CommandSession session, String dir); public URI pwd(CommandSession session); public void addCommand(String scope, Object target); public void addCommand(String scope, Object target, Class<?> fc); public void addCommand(String scope, Object target, String func); public Bundle getBundle(long id); public Bundle[] getBundles(); public ServiceRegistration registerService( String clazz, Object svcObj, Dictionary dict); Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 14. Grep command public boolean grep(CommandSession session, List<String> args) throws IOException { Pattern pattern = Pattern.compile(args.remove(0)); for (String arg : args) { InputStream in = Directory.resolve(session,arg).toURL().openStream(); Reader rdr = new BufferedReader(new InputStreamReader(in)); String s; while ((s = rdr.readLine()) != null) { if (pattern.matcher(s).find()) { match = true; System.out.println(s); } } } return match; } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 15. Interactive Shell Language • Interactive shell requirements differ from those for scripting languages – Easy for users to type – Minimum parenthesis, semi-colons etc – Compatibility with Unix shells like bash • Existing JVM languages not good for shell – Jacl: needs own TCL-derived library – BeanShell: syntax too verbose Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 16. Tiny Shell Language - TSL • Easy to use – no unnecessary syntax • Provides lists, pipes and closures • Leverages Java capabilities – Method calls using reflection – Argument coercion • Commands can provide control primitives • Small size (<50Kb) Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 17. Closures implement Function package org.osgi.service.command; public interface Function { Object execute(CommandSession session, List<Object> arguments) throws Exception; } Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 18. Add Control Primitives public void each(CommandSession session, Collection<Object> list, Function closure) throws Exception { List<Object> args = new ArrayList<Object>(); args.add(null); for (Object x : list) { args.set(0, x); closure.execute(session, args); } } % each [a, b, 1, 2] { echo $it } a b 1 2 Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 19. RFC132: What's missing? • Commands in osgi: scope are not defined • Search order for unscoped commands • List available commands and variables • Script execution • Command editing, history and completion Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 20. Posh: in action! Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 21. Posh in action! Builds on basic RFC132 runtime • Adds SCOPE path • Shell builtins: set, type • Script execution • Command editing, history & completion • Control-C interrupt handling • And more… Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009
  • 22. Links RFC132 Draft Specification www.osgi.org/download/osgi-4.2-early-draft.pdf Posh “devcon” binary download www.paremus.com/devcon2009download/ derek.baum@paremus.com Posh OSGi Shell Copyright © 2009 Paremus Limited. All rights reserved. June 2009