public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) { System.out.println("[Detected a service being added to the context]"); BeanContextServices context = bcsae.getSourceAsBeanContextServices(); System.out.println("Is the context offering a WordCount service? " + context.hasService(WordCount.class)); if (context.hasService(WordCount.class)) { System.out.println("Attempting to use the service..."); try { WordCount service = (WordCount)context.getService(this, this, WordCount.class, document, this); System.out.println("Got the service!"); service.countWords(); } catch(Exception e) { } } }
Code: [Select]public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) { System.out.println("[Detected a service being added to the context]"); BeanContextServices context = bcsae.getSourceAsBeanContextServices(); System.out.println("Is the context offering a WordCount service? " + context.hasService(WordCount.class)); if (context.hasService(WordCount.class)) { System.out.println("Attempting to use the service..."); try { WordCount service = (WordCount)context.getService(this, this, WordCount.class, document, this); System.out.println("Got the service!"); service.countWords(); } catch(Exception e) { } } }
Quote from: "Bubba"Code: [Select]public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) { System.out.println("[Detected a service being added to the context]"); BeanContextServices context = bcsae.getSourceAsBeanContextServices(); System.out.println("Is the context offering a WordCount service? " + context.hasService(WordCount.class)); if (context.hasService(WordCount.class)) { System.out.println("Attempting to use the service..."); try { WordCount service = (WordCount)context.getService(this, this, WordCount.class, document, this); System.out.println("Got the service!"); service.countWords(); } catch(Exception e) { } } }Oh my god, it's beautiful.