1 28 package org.objectweb.wssample.beans.wsclient; 29 30 import java.rmi.RemoteException ; 31 32 import javax.ejb.CreateException ; 33 import javax.ejb.SessionBean ; 34 import javax.ejb.SessionContext ; 35 import javax.naming.Context ; 36 import javax.naming.InitialContext ; 37 import javax.naming.NamingException ; 38 39 import org.objectweb.jonas.common.Log; 40 import org.objectweb.util.monolog.api.Logger; 41 import org.objectweb.util.monolog.api.BasicLevel; 42 43 import org.objectweb.wssample.genbean.google.GoogleSearchResult; 44 import org.objectweb.wssample.genbean.google.GoogleSearchService; 45 import org.objectweb.wssample.genbean.google.GoogleSearchPort; 46 47 import javax.xml.rpc.ServiceException ; 48 49 55 public class GoogleClientBeanSLR implements SessionBean { 56 57 60 private static Logger logger = null; 61 62 65 private SessionContext ejbContext; 66 67 71 75 public void setSessionContext(SessionContext ctx) { 76 if (logger == null) { 77 logger = Log.getLogger("org.objectweb.jonas_tests"); 78 } 79 logger.log(BasicLevel.DEBUG, ""); 80 ejbContext = ctx; 81 } 82 83 86 public void ejbRemove() { 87 logger.log(BasicLevel.DEBUG, ""); 88 } 89 90 94 public void ejbCreate() throws CreateException { 95 logger.log(BasicLevel.DEBUG, ""); 96 } 97 98 101 public void ejbPassivate() { 102 logger.log(BasicLevel.DEBUG, ""); 103 } 104 105 108 public void ejbActivate() { 109 logger.log(BasicLevel.DEBUG, ""); 110 } 111 112 116 122 public GoogleSearchResult executeQuery(java.lang.String query) { 123 124 logger.log(BasicLevel.INFO, "Executing Google Query '" + query + "'"); 125 126 try { 127 128 Context ctx = new InitialContext (); 130 131 GoogleSearchService google = 133 (GoogleSearchService) ctx.lookup("java:comp/env/service/google"); 134 135 GoogleSearchPort search = google.getGoogleSearchPort(); 137 138 String key = (String ) ctx.lookup("java:comp/env/googleKey"); 140 141 return search.doGoogleSearch(key, 143 query, 144 0, 10, false, null, false, null, null, null ); 153 } catch (NamingException ne) { 154 return null; 155 } catch (RemoteException re) { 156 return null; 157 } catch (ServiceException se) { 158 return null; 159 } 160 } 161 } 162 163 | Popular Tags |