java - OSGI+CDI: strange behaviour with system printers detecting -


i have cdi+osgi javase application. cdi-weld,osgi-felix , pax-cdi. , have following code in "cdi-main"

@applicationscoped public class foo{      public void postcreate(@observes containerinitialized event, bundlecontext ctx) throws exception {         printservice[] printservices = printservicelookup.lookupprintservices(null, null);         system.out.println("$number of print services: " + printservices.length);         (printservice printer : printservices)             system.out.println("$printer: " + printer.getname());      }   } 

when run application following output(although have printers right drivers!)

$number of print services:0

notice, first sign $; if add following code bundle activator , start it

public class activator implements bundleactivator {      public void start(bundlecontext context) throws exception {         printservice[] printservices = printservicelookup.lookupprintservices(null, null);         system.out.println("#number of print services: " + printservices.length);         (printservice printer : printservices)             system.out.println("#printer: " + printer.getname());     }      public void stop(bundlecontext context) throws exception {   } } 

notice, first sign #.then printers detected:

#number of print services: 1 #printer: mf3110 jun 14, 2015 1:47:34 pm org.jboss.weld.bootstrap.weldstartup startcontainer... .... $number of print services: 1 $printer: mf3110 

how explain it?

is printservicelookup defined in separate bundle or use code separate osgi service? might related osgi services cardinality?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -