org.apache.felix.examples.spellcheckscr
Class SpellCheckServiceImpl

java.lang.Object
  extended by org.apache.felix.examples.spellcheckscr.SpellCheckServiceImpl
All Implemented Interfaces:
SpellCheckService

public class SpellCheckServiceImpl
extends Object
implements SpellCheckService

This class re-implements the spell check service of Example 5. This service implementation behaves exactly like the one in Example 5, specifically, it aggregates all available dictionary services, monitors their dynamic availability, and only offers the spell check service if there are dictionary services available. The service implementation is greatly simplified, though, by using the Service Component Runtime. Notice that there is no OSGi references in the application code; intead, the metadata.xml file describes the service dependencies to the Service Component Runtime, which automatically manages them and it also automatically registers the spell check services as appropriate.

Author:
Felix Project Team

Constructor Summary
SpellCheckServiceImpl()
           
 
Method Summary
 void addDictionary(DictionaryService dictionary)
          This method is used by the Service Component Runtime to add new dictionaries to the spell check service.
 String[] check(String passage)
          Checks a given passage for spelling errors.
 void removeDictionary(DictionaryService dictionary)
          This method is used by the Service Component Runtime to remove dictionaries from the spell check service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpellCheckServiceImpl

public SpellCheckServiceImpl()
Method Detail

addDictionary

public void addDictionary(DictionaryService dictionary)
This method is used by the Service Component Runtime to add new dictionaries to the spell check service.

Parameters:
dictionary - the dictionary to add to the spell check service.

removeDictionary

public void removeDictionary(DictionaryService dictionary)
This method is used by the Service Component Runtime to remove dictionaries from the spell check service.

Parameters:
dictionary - the dictionary to remove from the spell check service.

check

public String[] check(String passage)
Checks a given passage for spelling errors. A passage is any number of words separated by a space and any of the following punctuation marks: comma (,), period (.), exclamation mark (!), question mark (?), semi-colon (;), and colon(:).

Specified by:
check in interface SpellCheckService
Parameters:
passage - the passage to spell check.
Returns:
An array of misspelled words or null if no words are misspelled.


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.