KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > bpel > ws > consumption > partner > TextTranslator_Impl


1 package org.jboss.test.bpel.ws.consumption.partner;
2
3 import java.rmi.Remote JavaDoc;
4 import java.rmi.RemoteException JavaDoc;
5 import java.util.HashSet JavaDoc;
6 import java.util.Locale JavaDoc;
7 import java.util.Set JavaDoc;
8
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11
12 import org.jboss.test.bpel.ws.consumption.partner.spi.Dictionary;
13 import org.jboss.test.bpel.ws.consumption.partner.spi.DictionaryFactory;
14 import org.jboss.test.bpel.ws.consumption.partner.types.TDictionaryNotAvailable;
15 import org.jboss.test.bpel.ws.consumption.partner.types.TQuoteStatus;
16 import org.jboss.test.bpel.ws.consumption.partner.types.TTextNotTranslatable;
17
18 /**
19  * @author Alejandro Guizar
20  * @version $Revision: 43322 $ $Date: 2006-04-03 12:19:24 -0400 (Mon, 03 Apr 2006) $
21  */

22 public class TextTranslator_Impl implements TextTranslator, Remote JavaDoc {
23   
24   private static Set JavaDoc clientNames = new HashSet JavaDoc();
25   
26   private static final Log log = LogFactory.getLog(TextTranslator_Impl.class);
27
28   public String JavaDoc translate(String JavaDoc text, String JavaDoc sourceLanguage, String JavaDoc targetLanguage)
29       throws TDictionaryNotAvailable, TTextNotTranslatable, RemoteException JavaDoc {
30     Locale JavaDoc sourceLocale = new Locale JavaDoc(sourceLanguage);
31     Locale JavaDoc targetLocale = new Locale JavaDoc(targetLanguage);
32     DictionaryFactory dictionaryFactory = DictionaryFactory.getInstance(sourceLocale, targetLocale);
33     Dictionary dictionary = dictionaryFactory.createDictionary(sourceLocale, targetLocale);
34     return dictionary.translate(text);
35   }
36
37   public void quoteTranslation(String JavaDoc clientName, String JavaDoc text,
38       String JavaDoc sourceLanguage, String JavaDoc targetLanguage) throws RemoteException JavaDoc {
39     log.debug("received quotation request: clientName=" + clientName);
40     clientNames.add(clientName);
41   }
42   
43   public TQuoteStatus getQuotationStatus(String JavaDoc clientName) throws RemoteException JavaDoc {
44     return clientNames.contains(clientName) ? TQuoteStatus.received : TQuoteStatus.none;
45   }
46 }
47
Popular Tags