1 7 8 10 package org.jboss.test.jbossnet.external.server; 11 12 import java.rmi.RemoteException ; 13 14 import javax.ejb.SessionBean ; 15 16 import org.jboss.test.util.ejb.SessionSupport; 17 import org.jboss.test.jbossnet.external.google.GoogleSearchPort; 18 import org.jboss.test.jbossnet.external.google.GoogleSearchService; 19 import org.jboss.test.jbossnet.external.google.GoogleSearchResult; 20 21 import org.jboss.test.jbossnet.external.babelfish.BabelFishPortType; 22 import org.jboss.test.jbossnet.external.babelfish.BabelFishService; 23 import org.jboss.logging.Logger; 24 25 import javax.naming.InitialContext ; 26 27 43 44 public class FederatedServiceBean extends SessionSupport implements SessionBean 45 { 46 private static Logger log = Logger.getLogger(FederatedServiceBean.class); 47 48 56 57 public String findAndTranslate(String searchTerm) throws Exception 58 { 59 InitialContext initContext = new InitialContext (); 61 62 GoogleSearchService googleService = 64 (GoogleSearchService) initContext.lookup("Google"); 65 GoogleSearchPort google = googleService.getGoogleSearchPort(); 66 67 String licenseKey = 68 System.getProperty( 69 "google.license", 70 "Wr5iTf5QFHJKmmnJn+61lt9jaMuWMKCj"); 71 72 GoogleSearchResult searchResult = 73 google.doGoogleSearch( 74 licenseKey, 75 searchTerm, 76 0, 77 10, 78 true, 79 "", 80 false, 81 "", 82 "latin1", 83 "latin1"); 84 85 log.debug("Query for: '" + searchTerm + "' returned: " + searchResult); 86 87 BabelFishService babelFishService = 88 (BabelFishService) initContext.lookup("BabelFish"); 89 90 BabelFishPortType babelFish = babelFishService.getBabelFishPort(); 91 92 try 94 { 95 String translationResult = babelFish.babelFish("en_de", searchTerm); 96 log.debug( 97 "Translation of: '" 98 + searchTerm 99 + "' returned: " 100 + translationResult); 101 return translationResult; 102 } catch (RemoteException e) 103 { 104 return "This service is currently disabled."; 106 } 107 108 } 109 110 } 111 | Popular Tags |