openejb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Cai <greensi...@gmail.com>
Subject Re: Propagating extra context information in remote EJB calls
Date Tue, 10 Nov 2009 15:36:56 GMT
Since I'm using the OpenEJB that comes with Geronimo, which port shall I
connect to if http protocol is used? Still 4201 where the EJB daemon is
listening? I did try setting the url to something like "http://hostname:4201"
but didn't work out. Are you suggesting that I shall write a servlet to
receive the client call and then forward to the openejb server?

-Jack


On Sat, Nov 7, 2009 at 4:17 AM, David Blevins <david.blevins@visi.com>wrote:

> On Oct 29, 2009, at 1:16 AM, Jack Cai wrote:
>
>  I want to propagate some context information in remote EJB calls, and
>> hopefully this can be done transparently, i.e., does not require code
>> change
>> to existing applications. Is this possible?
>>
>> I understand transaction and security context are already being propagated
>> as part of an EJB container impl. Can I just inject the extra data into
>> the
>> security context for example to do the trick?
>>
>> Appreciate some insight in this area!
>>
>
> The idea that comes to mind is modifying the HttpConnectionFactory to in
> some way set headers into the HttpURLConnection.  In the 3.1.x codebase it's
> actually possible to replace the HttpConnectionFactory on an existing
> client:
>
>
> http://mail-archives.apache.org/mod_mbox/openejb-users/200911.mbox/%3CB003CC7A-74F0-4E88-AB61-F8C7A80F7F3B@visi.com%3E
>
> On the server side if there was a Servlet like this:
>
>  import org.apache.openejb.loader.SystemInstance;
>  import org.apache.openejb.server.ServiceException;
>  import org.apache.openejb.server.ejbd.EjbServer;
>
>  import javax.servlet.ServletConfig;
>  import javax.servlet.ServletException;
>  import javax.servlet.ServletInputStream;
>  import javax.servlet.ServletOutputStream;
>  import javax.servlet.http.HttpServlet;
>  import javax.servlet.http.HttpServletRequest;
>  import javax.servlet.http.HttpServletResponse;
>  import java.io.IOException;
>
>  public class ServerServlet extends HttpServlet {
>      private EjbServer ejbServer;
>
>      public void init(ServletConfig config) {
>          ejbServer = SystemInstance.get().getComponent(EjbServer.class);
>      }
>
>      protected void service(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
>          ServletInputStream in = request.getInputStream();
>          ServletOutputStream out = response.getOutputStream();
>          try {
>              ejbServer.service(in, out);
>          } catch (ServiceException e) {
>              throw new ServletException("ServerService error: " +
> ejbServer.getClass().getName() + " -- " + e.getMessage(), e);
>          }
>      }
>  }
>
>
> You could get the headers and put them on a ThreadLocal or something.
>
> If the state is going to be the same on a per connection basis, then we can
> maybe make some standard way to put the headers in the connection URI and
> pull them out of that "params" map we create.
>
> We'd need some more creativity to make it really nice and easy for people.
>  But this is a rough approach to get the ideas started.
>
> -David
>
>
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message