1 package org.jboss.test.bpel.ws.consumption.partner; 2 3 import java.rmi.Remote ; 4 import java.rmi.RemoteException ; 5 import java.util.HashSet ; 6 import java.util.Locale ; 7 import java.util.Set ; 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 22 public class TextTranslator_Impl implements TextTranslator, Remote { 23 24 private static Set clientNames = new HashSet (); 25 26 private static final Log log = LogFactory.getLog(TextTranslator_Impl.class); 27 28 public String translate(String text, String sourceLanguage, String targetLanguage) 29 throws TDictionaryNotAvailable, TTextNotTranslatable, RemoteException { 30 Locale sourceLocale = new Locale (sourceLanguage); 31 Locale targetLocale = new Locale (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 clientName, String text, 38 String sourceLanguage, String targetLanguage) throws RemoteException { 39 log.debug("received quotation request: clientName=" + clientName); 40 clientNames.add(clientName); 41 } 42 43 public TQuoteStatus getQuotationStatus(String clientName) throws RemoteException { 44 return clientNames.contains(clientName) ? TQuoteStatus.received : TQuoteStatus.none; 45 } 46 } 47 | Popular Tags |