001    // Copyright 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry.services.impl;
016    
017    import javax.servlet.http.HttpServlet;
018    
019    import org.apache.tapestry.services.ApplicationInitializer;
020    
021    /**
022     * Stores services and configurations into the
023     * {@link org.apache.tapestry.services.ApplicationGlobals tapestry.globals.ApplicationGlobals}
024     * service, which is used to see the
025     * {@link org.apache.tapestry.services.Infrastructure tapestry.infrastructure} service. The mode to
026     * use is normally "servlet", but this can be overriden by setting the
027     * org.apache.tapestry.application-mode initialization parameter. WML applications should use the
028     * mode "wml".
029     * 
030     * @author Howard M. Lewis Ship
031     * @since 4.0
032     */
033    public class SetupServletApplicationGlobals extends AbstractSetupApplicationGlobals implements
034            ApplicationInitializer
035    {
036        public void initialize(HttpServlet servlet)
037        {
038            String mode = servlet.getInitParameter("org.apache.tapestry.application-mode");
039    
040            initialize(mode == null ? "servlet" : mode);
041        }
042    }