Revision 672:163de098320c src/gr/ebs/gss/server/BaseServlet.java
b/src/gr/ebs/gss/server/BaseServlet.java | ||
---|---|---|
21 | 21 |
import static gr.ebs.gss.server.configuration.GSSConfigurationFactory.getConfiguration; |
22 | 22 |
import gr.ebs.gss.client.exceptions.RpcException; |
23 | 23 |
import gr.ebs.gss.server.ejb.ExternalAPI; |
24 |
import gr.ebs.gss.server.ejb.ExternalAPIBean; |
|
24 | 25 |
|
25 | 26 |
import java.io.UnsupportedEncodingException; |
26 | 27 |
import java.net.URLEncoder; |
27 | 28 |
import java.util.Formatter; |
28 | 29 |
|
29 |
import javax.naming.Context; |
|
30 |
import javax.naming.InitialContext; |
|
31 |
import javax.naming.NamingException; |
|
32 |
import javax.rmi.PortableRemoteObject; |
|
33 | 30 |
import javax.servlet.http.HttpServlet; |
34 | 31 |
|
35 |
import org.apache.commons.logging.Log; |
|
36 |
import org.apache.commons.logging.LogFactory; |
|
37 |
|
|
38 | 32 |
/** |
39 | 33 |
* The base servlet contains a collection of helper methods. |
40 | 34 |
* |
... | ... | |
53 | 47 |
private static final long serialVersionUID = 1L; |
54 | 48 |
|
55 | 49 |
/** |
56 |
* The logger. |
|
57 |
*/ |
|
58 |
private static Log logger = LogFactory.getLog(BaseServlet.class); |
|
59 |
|
|
60 |
/** |
|
61 | 50 |
* A helper method that retrieves a reference to the ExternalAPI bean and |
62 | 51 |
* stores it for future use. |
63 | 52 |
* |
... | ... | |
65 | 54 |
* @throws RpcException in case an error occurs |
66 | 55 |
*/ |
67 | 56 |
protected ExternalAPI getService() throws RpcException { |
68 |
try { |
|
69 |
final Context ctx = new InitialContext(); |
|
70 |
final Object ref = ctx.lookup(getConfiguration().getString("externalApiPath")); |
|
71 |
return (ExternalAPI) PortableRemoteObject.narrow(ref, ExternalAPI.class); |
|
72 |
} catch (final NamingException e) { |
|
73 |
logger.error("Unable to retrieve the ExternalAPI EJB", e); |
|
74 |
throw new RpcException("An error occurred while contacting the naming service"); |
|
75 |
} |
|
57 |
return new ExternalAPIBean(); |
|
76 | 58 |
} |
77 | 59 |
|
78 | 60 |
/** |
Also available in: Unified diff