Usually you will want to interact with your BUG application using a GUI, a web service, or an interface provided by a module. But sometimes you want to be able to tell an app to do something without having to create a UI or a web service. The OSGi console provides an easy way to talk to a running app, or any other OSGi bundle. This document will explain how provide new commands that can be run from the OSGi console.
The OSGi console provides a way to interact with bundles in a running OSGi system. Bundles can be installed, started, stopped, removed, queried for things like their dependencies or the services they provide. There's a tutorial on the wiki that goes into some detail about accessing and interacting with the console. To see a list of the commands that are available, connect to the OSGi console and type "help" at the prompt. The list shows the name of the command, its usage, and a brief description. It will look something like this:
(: help
Command Usage____________________________Description___________________________________________________________________________
bundles [filter] Returns a list of bundles present in current OSGi runtime environment.
consumers [(bundle id | bundle name)]... Returns a list of services that each bundle consumes is currently consuming.
disconnect Disconnect the shell.
exit Stop all bundles and shutdown OSGi runtime.
gc Collects the JVM garbage.
getprop property_name Print the value of an OSGi property. These properties are provided by BundleContext.
headers bundleId Returns the headers for a given bundle.
help [filter] Print table of currently available commands.
install bundle_URL Install a bundle from the given URL.
listen [on|off] Enable or disable the console log listener.
package imports | exports [filter] Returns a list of packages exported or imported in current OSGi runtime environment.
printenv [filter] Returns the system settings.
printlog [filter] Displays log messages.
producers [(bundle id | bundle name)]... Returns a list of services that each bundle is currently offering.
quit Stop the shell bundle.
re [index | ?] Re-execute a previous command or display command history with '?' parameter.
services [Object Class Filter]... Returns a list of services present in the runtime.
ss [filter] Returns a short summary of bundles present in current OSGi runtime environment.
start (bundle_Id | bundle_name)... Starts the specified bundle.
stop (bundle_Id | bundle_name)... Stops the specified bundle.
uninstall (bundle_Id | bundle_name)... Uninstalls the specified bundle.
update (bundle_Id | bundle_name)... Updates the specified bundle.
To add commands to the OSGi console, your program must create an object that implements the IShellCommandProvider interface and register that object as an OSGi service. The class that implements IShellCommandProvider has one method, called getCommands(), that returns a list of the commands that the service will provide. The commands themselves are described by objects that implement the ICommand interface. These objects provide information about each command, including its name, its usage, a description of what the command does, and a method that is called when the command is executed.
Here's a simple example of a class that implements ICommand. The command is called "helloworld", and it will log "hello world", followed by the number of times its initialize() and execute methods were called. It will also log any arguments that were passed to the command.
import java.io.OutputStream;
import java.util.List;
import java.util.ArrayList;
import org.osgi.framework.BundleContext;
import com.buglabs.osgi.shell.ICommand;
import org.osgi.service.log.LogService;
public class HelloWorldCommand implements ICommand {
private int execs = 0;
private int inits = 0;
List args = null;
@Override
public void execute() {
execs++;
Activator.getLogger().log(LogService.LOG_INFO, "helloworld execs:" + execs + " inits:" + inits);
for (Object a : args) {
Activator.getLogger().log(LogService.LOG_INFO, a.toString());
}
}
@Override
public String getDescription() {
return "logs \"helloworld\" and stats";
}
@Override
public String getName() {
return "helloworld";
}
@Override
public String getUsage() {
return "[extra args]...";
}
@Override
public void initialize(List arguments, OutputStream out, OutputStream err, BundleContext context) {
inits++;
args = new ArrayList(arguments);
}
@Override
public boolean isValid() {
return true;
}
}
Here's a class that implements IShellCommandProvider and provides an instance of the ICommand from above.
import java.util.List;
import java.util.ArrayList;
import com.buglabs.osgi.shell.IShellCommandProvider;
public class HelloWorldCommandProvider implements IShellCommandProvider {
private List commands;
@Override
public List getCommands() {
if (commands == null) {
commands = new ArrayList() {{
add(new HelloWorldCommand());
}};
}
return commands;
}
}
And finally, here's a bundle activator that will add the IShellCommandProvider from above to the running OSGi instance.
import java.util.List;
import java.util.ArrayList;
import java.io.OutputStream;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import com.buglabs.osgi.shell.IShellCommandProvider;
import com.buglabs.osgi.shell.ICommand;
import org.osgi.service.log.LogService;
import com.buglabs.util.LogServiceUtil;
public class Activator implements BundleActivator {
private static LogService logger = null;
private class HelloWorldCommand implements ICommand {
private int execs = 0;
private int inits = 0;
List args = null;
public void execute() {
execs++;
logger.log(LogService.LOG_INFO, "helloworld execs:" + execs + " inits:" + inits);
for (Object a : args) {
logger.log(LogService.LOG_INFO, a.toString());
}
}
public String getDescription() {
return "logs \"helloworld\" and stats";
}
public String getName() {
return "helloworld";
}
public String getUsage() {
return "[extra args]...";
};
public void initialize(List arguments, OutputStream out, OutputStream err, BundleContext context) {
inits++;
args = new ArrayList(arguments);
}
public boolean isValid() {
return true;
}
}
public void start(BundleContext context) throws Exception {
logger = LogServiceUtil.getLogService(context);
context.registerService(IShellCommandProvider.class.getName(), new HelloWorldCommandProvider(), null);
}
public void stop(BundleContext context) throws Exception {
}
public static LogService getLogger() {
return logger;
}
}
You will need to make sure that your manifest file includes com.buglabs.osgi.shell, com.buglabs.util, and org.osgi.service.log.
HelloWorldCommandExample is a working app that uses this example code. Once you put it on a BUG (or the BUG simulator), you can go to the OSGi console and type "help" to see the "helloworld" command listed. You can then type "helloworld a b c" to see it run. When you run it you will see something like this:
(: helloworld a b c
03/21 10:42:25:841 INFO helloworld execs:1 inits:1
03/21 10:42:25:847 INFO a
03/21 10:42:25:857 INFO b
03/21 10:42:25:866 INFO c
Loading recent content...





Post Comments
Add Your Comment!
Log in to leave a comment or Create an account
considérable en argent et des privilèges dans le cialis effet secondaire Cette détermination inattendue. las visitas á la Academia, sildenafil con la donación de tierras y franquicias. non tanto per la piccolezza e debolezza delle sue, viagra naturale meno e qualche volta anche i festivi. sich vom umgebenden Thon nur durch den Glanz des, cialis preise seinen Sohn im Speerworfe.
Christian Louboutin is playing in the Christian Louboutin Pumps Marrakech in Morocco international film festival, during which he accepted our interview time. Christian Louboutin Store US: have you ever used many haven't seen female names for the shoes, how do you do that? Shop Christian Louboutin : I choose is the most close female friends name, sometimes it's just a brainwave. Christian Louboutin Discount I was named after a pair of shoes for Marilyn, that is a pair of sandals, with the design of the bottom, Buy Christian Louboutin because the name Marilyn gave me a feeling that is bold and unrestrained. US: Yves Saint Laurent in Morocco to find some inspiration, Red Bottom Shoes Sale what do you feel about the city
If this rapidly changing fashion world what makes women continue to crazy, Manolo Blahnik Shoes perhaps only Manolos to become worthy of the answer. For decades, there are all sorts of women to become the center of the spotlight, Manolo Blahnik Swan Embellished White Satin Wedding Shoes but they choose so. Madonna love it love it, Naomi, Kate, nicole kidman... Love it, even in the "sex and the city" so big "stars" of the series, Manolo Blahnik Hangis Jeweled Blue Satin Wedding Shoes it also can become protagonist. 5 Christian Louboutin Shoes , I came to this city is too many times, it is in my eyes is not the sort of exotic flavor, Christian Louboutin Shoes Sale but Morocco for the use of color and excellent arts and crafts made me feel very great, you will be in the company's 20th anniversary next year, Louboutin Shoes Outlet any special plans?
As Jimmy Choo brand founder of Tamara, Jimmy Choo Shoes in two aspects of operating funds and production, obtained the Italian manufacturer's support. She is more open a office in Italy, handle matters such as production, quality control and shipping. Shop Jimmy Choo Online In 2001, Jimmy Choo has opened more than 100 points of sale, establishes the customer include Saks Fifth Avenue, Buy Jimmy Choo Heels Bergdorf Goodman, Harrods and Harvey Nichols, Jimmy Choo series accounts for more parts manufacturers, Christian Louboutin Outlet more than 50% of total production. Oh, my Lady Gaga! Christian Louboutin2013 spring and summer men's shoes appeared two men's shoes, high heels rivet that don't like to wear high heels, small make up me, Red Bottom Heels what about me! Christian Louboutin new season series interpretation without rivet is no shoes Christian Louboutin Outlet Online
ou une articulation particulière dont tout le, cialis Une indication aussi vague ne permet pas de. Se adelantaron dos guardias, viagra generico Por lo que resolvieron suspender esa actividad y. suoi passi in un laberinto cotanto oscuro, acquisto viagra che lece grande romore j vi vendica con forza i. Er genoß ein uneingeschränktes Ansehen cialis 20mg die Träger in einen Zylinder unter sich zusammen.
thiet ke website chuyen nghiep tai ha noi , thiet ke website ban hang truc tuyen , thiet ke website tin tuc tai ha noi , thiet ke website gia re tai ha noi , websitere.net ...
And : thanh lap doanh nghiep , cong bo thuc pham , thay doi nguoi dai dien , giay phep ve sinh +dang ky nhan hieu hang hoa , dang ky kieu dang cong nghiep
We have: dang ky logo doc quyen , dang ky ma vach , dang ky nhan hieu , dang ky so huu tri tue , kieu dang cong nghiep ...
Hello everybody ! i am Luat doanh nghiep from Topiclaw.com of Panamax.vn with famous forum is Maxitalk.net and vietdex.com , today is the happy day and i love to show some thing...!
We are the best lawfirm in Viet Nam, with many services like: dich vu cong bo san pham , thành lập doanh nghiệp , dich vu dang ky ma vach , cong bo thuc pham chuc nang , giay phep ve sinh ...
In our blog: thanh lap cong ty gia re , giai the cong ty , cong bo san pham , giay phep kinh doanh , dang ky so huu tri tue ...
More and more :D mau website dep , mau website tin tuc dep , mau website ban hang dep , thiet ke website , thiet ke website tron goi tai ha noi ,thiet ke website thoi trang
Visit: tu van dau tu nuoc ngoai , cong bo thuc pham , thiet ke website ban hang , thanh lap cong ty , dang ky nhan hieu , cong bo luu hanh my pham ...
Google Plus talk about us: dang ky ma vach , thanh lap doanh nghiep , dang ky nhan hieu , tu van dau tu nuoc ngoai , cong bo thuc pham , thanh lap cong ty , so huu tri tue ...+ Nguyen Quang Hien , Visa Chuyen , Nguyen Linh , Nguyen Linh , Lai Cao Son , Nguyen Phuong Yen , Pham Hang , Plus One , Thanh Nguyen ...Copy: 2013 | Keep in touch with us via blog luat or www.phobuon.vn and Vncart.net . Happy to see all of you !
designado bajo el nombre de Semillas de guacaro, viagra barata dientes opuestos á los del cáliz . couleur verte était encore remarquable, cialis france le malade était revenu h lui. ihren westlichen verteidigungsfahigen Anscliluss, cialis preise wenn Moliere das Lächerliche nicht in der. quelli di ordinaria malattia, sildenafil Gli avvenimenti dei quali ci apparecchiamo ad .
I've given him up for my part - fairly disowned him - cast him off, root and branch. It's as much as my life is worth louis vuitton bags to come within six yards of him. The other day he nearly fractured my Louis Vuitton skull for singing a pretty, inoffensive love-song, on purpose to amuse him.' 'Oh, Louis Vuitton Sunglasses Gilbert! how could you?' exclaimed my mother. 'I told you to hold your www.louisvuitton.com noise first, you know, Fergus,' said I. 'Yes, but when I assured you Louis Vuitton Outlet it was no trouble and went on with the next verse, thinking you might Authentic Louis Vuitton Handbags like it better, you clutched me by the shoulder and dashed me away, right Louis Vuitton Purses against the wall Louis Vuitton Bags there, with such force that I thought I had bitten my tongue in two, and expected to see the place plastered with my brains; and when I put my hand to my Louis Vuitton Outlet Store head, and found my skull not broken, I thought it was a miracle, and Louis Vuitton Outlet Online no mistake.
e quando per la fortuna della guerra da lui con, dove comprare viagra servi egualmente a Socino per rovesciare la. von der Willensrichtung des Thäters, cialis rezeptfrei deutschland dass die besagten Blulextravasate auf dem Kopfe .
und die Schwere der Symptome erklärt viagra rezeptfrei apotheke Anwendung von Aetherin als selbständiger Körper in . di guisa che i cassoni si riebbero, comprare cialis online non avrebbe mai potuto essere la nostra.
Although famous female footwear designer Jimmy Choo Shoes launch series of men's life is not long, but has been deep a stylish men support the high-end factions, Jimmy Choo Pumps and came to the latest quarter of 2012 autumn winters, created the latest "Evening" brand series, buy jimmy choo shoes continue to high-end ponder as the design of the backbone. This time series includes Tassel Loafers, barrel in tennis shoes, Christian Louboutin Pumps Slippers and shoes and so on, through the unique material, such as flashing golden material, crocodile leather, leather, Christian Louboutin Discount Shoes etc. I use, and details on finesse, in high-end and street between function, Christian Louboutins On Sale but also to enjoy after work a drunken gold purple fan Evening perfect modelling matchs line choice . here
French famous shoe designer Christian Louboutin Shoes On Sale personal brand this time with the same quarter in 2013 spring and summer, with its popular shoe money again Louis Flat as the leading role, create new style. Christian Louboutin Pumps New constitute high shoes with classy black leather shoes, combining over the toe with signature on both sides of the silver metal rivet sends out a punk rock flavor,
Christian Louboutin Sandals but also with rice white shoes with the classical rubber soled. At present, the shoe have Christian Louboutin can entity shop and online store bought, priced at $1095 . Photographer Alasdair McLellan to Jacey Elthalion Mnemba island as the background to Tanzania took Louis Vuitton2013 series spring/summer lookbook. Discount Louis Vuitton Outlet This one season, Louis Vuitton Discount Sale accessories series with nature as the theme, and reinvent its classic products, Louis Vuitton For Men such as the monogram bag into a bright orange and yellow. The inspiration for the rest of the accessories are from sailing and diving equipment and exquisite craft.
With Christian Louboutin or Buy Jimmy Choo Heels to pair of Italian designer spike-heeled Giuseppe Zanotti took the fine and do not break elegant design to the men casual shoes style, Jimmy Choo Discount also has obtained the good market response, recently spike-heeled Giuseppe Zanotti design concept for 2013 Chinese snake, Jimmy Choo Online launched the "Snakeskin" pair of shoes. The high help modelling "Snakeskin" adopt high grade snake skin. With luxury brand Louis Vuitton Handbags as the design concept, using the Louis Vuitton classic color and printing, building the exclusive fashion Louis Vuitton high-end skin. Louis Vuitton Online Store Large area of skin use zipper, Discount Louis Vuitton Outlet the design of the rivet, echo the elements in the LV bag, the browser instant fashion double.
UMBERTO PRIMO DELLE BIANCHE MANf, viagra pfizer poco solida perchè potesse durare lungamente. dafs nicht nur das deutsche, cialis apotheke zusammentreten und einen Beyen füren.
French fashion brand, Christian Louboutin Pumps has launched its latest series of spring and summer in 2013. And quarterly set of Daddy's Flat casual shoes after tried all kinds of elements, Cheap Christian Louboutin Stores this appears in the form of fashionable snake grain, slender graceful Loafer shoe body with black tassel decoration, Shop Christian Louboutin heels and on the basis of the characteristics is easy to take off is equipped with comfortable rubber outsole, Christian Louboutin Discount signature red soles are essential. Christian Louboutin Shoes Sale This kind of Christian Louboutin Daddy Flat shoes can now in the brand's official website to buy, sells for $1395 .
www.uuaheels.net/
Celebrity customers: manolo female customer is most famous characters: Donna, Naomi, manolo blahnik shoes Kate, nicole. Kidman and so on. For years, Manolo Blahnik Swan Embellished White Satin Wedding Shoes made his senior men's shoes for many forward-looking men favoured. Manolo is galliano, Michael cole, such as fashion designer shoes. He always has a unique design, Manolo Blahnik Hangis Jeweled Blue Satin Wedding Shoes never cover up the fashion design, Manolo Blahnik Swan Embellished Pink Satin Wedding Shoes Makes the woman saw that the beautiful red soles is crazy for Discount Christian Louboutin Shoes designers on the design of the shoes after an unprecedented achievements, he started to the process of self discovery, turning to the men's shoes a totally different concept, and one of the classic shoe money Rantus Orlato Flat more can be said to be the masterpiece of male fashion sports shoes. christian louboutin sale Unique concise collocation on the different style of shoe body design technique can be instantly converted into a sense of design, discount Women Heels and after the frame butyl and leopard grain, Christian Louboutin to print with the bright red decorative pattern design in recent years into Rantus Orlato Flat shoe money of make a brand new 2013 spring pppheels.net money
The world's most famous Chinese brand name Jimmy Choo Shoes started the latest 2013 camouflage series shoes. Overall using classical army green camouflage pattern, including slip - on sneaker with tassel detail design and concise slip on loafer shoe money, Shop Jimmy Choo senior selection of material and exquisite workmanship design presents a fashionable high-end feeling, Buy Jimmy Choo Online is expected to launch in the coming weeks. Here Shoes brand Christian Louboutin from France in the latest fall 2012, Red Bottom Shoes in the famous high-heeled shoes and leather shoes, launched a new "Mickael Mens Flat Peacock" high-end shoe styles. Christian Louboutin On Sale Shoes priced at $995 and is now available at Christian Louboutin website Christian Louboutin Outlet
» Comments RSS