Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 268919941 for ; Wed, 22 Feb 2012 07:06:27 +0000 (UTC) Received: (qmail 69745 invoked by uid 500); 22 Feb 2012 07:06:27 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 69673 invoked by uid 500); 22 Feb 2012 07:06:26 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 69663 invoked by uid 99); 22 Feb 2012 07:06:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Feb 2012 07:06:25 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 22 Feb 2012 07:06:18 +0000 Received: (qmail 20824 invoked from network); 22 Feb 2012 07:05:56 -0000 Received: from unknown (HELO ?192.168.1.95?) (194.158.197.10) by vorsha.objectstyle.org with SMTP; 22 Feb 2012 07:05:56 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: Where to put the ServerRuntime in a servlet app? From: Andrus Adamchik In-Reply-To: Date: Wed, 22 Feb 2012 10:05:55 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <747F6736-DD8A-4020-B5AD-CCE6851B9B3C@objectstyle.org> References: To: user@cayenne.apache.org X-Mailer: Apple Mail (2.1084) X-Virus-Checked: Checked by ClamAV on apache.org Yes, normally a Cayenne stack should be shared between all servlets, = filters, etc. in a webapp. "Application" scope is provided by = javax.servlet.ServletContext per servlet specification.=20 Bootstrapping ServerRuntime and placing it in the app scope can be done = via a variety of ways - Filter.init, Servlet.init, = ServletContextListener.contextInitialized. CayenneFilter provided by = Cayenne is a good template for how ServerRuntime should be started and = stopped: = https://github.com/apache/cayenne/blob/trunk/framework/cayenne-jdk1.5-unpu= blished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.j= ava Andrus On Feb 22, 2012, at 1:12 AM, John Huss wrote: > I'm new to Servlets and containers and all that. If I have multiple > servlets, where is the best place to create and store a reference to = the > cayenne ServerRuntime (I'm using 3.1)? One of my servlets is an > ROPHessianServlet and it gets the ServerRuntime information from the > web.xml file. But the others are just regular servlets. I want to = avoid > creating a bunch of different runtimes and just have one. >=20 > Thanks, > John