cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emanuele Maiarelli <maiarelli.emanu...@gmail.com>
Subject Migrating web application from 3.0 to 3.1
Date Wed, 06 Nov 2013 22:47:24 GMT
We have a web multi tenant application developed with cayenne 3.0.

Tenants are implemented in a single database, so there's a 'tenantId' on
most of database tables.

With cayenne we implemented the tenancy, 'injecting' the property, either
on SelectQuery and new entities, using a custom automated way.

Everything is working fine, but we'd like to migrate it to cayenne 3.1
reimplementing teantcy management using LifeCycle events listeners (to
populate tenat field)  and datachannelflters (for intercepting
selectqueries to add tenant field).

Actually we provide ObjectContexts using a WebApplicationContextFilter
implemented this way:
....
 public void doFilter(ServletRequest request,
                       ServletResponse response, FilterChain chain) throws
IOException,

ServletException {

    boolean reset = false;

    if (request instanceof HttpServletRequest) {
      reset = true;

      HttpSession session = ((HttpServletRequest)request)
        .getSession(true);
      DataContext context = ServletUtil.getSessionContext(session);


      BaseContext.bindThreadObjectContext(context);
    }

    try {
      chain.doFilter(request, response);
    }


....

so for each session we have a context and we bind it to threads.

Now with cayenne 3.1, we should use ServerRuntime getting its DataDomain,
setting the callback listener and filter, and then obtaining contexts from
the  ServerRuntime.

What's the right way to manage the ServerRuntime inside the application
server?

Should we implement it as singleton, and obtain an ObjectContex for each
session and binding to threads using BaseContext as we did before?

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