Package org.restlet.ext.osgi.servlet

Source Code of org.restlet.ext.osgi.servlet.ApplicationServlet

/*******************************************************************************
* Copyright (c) 2010 Bryan Hunt & Wolfgang Werner.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*    Bryan Hunt & Wolfgang Werner - initial API and implementation
*******************************************************************************/

package org.restlet.ext.osgi.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;

import org.restlet.Application;
import org.restlet.Context;
import org.restlet.ext.osgi.IApplicationProvider;
import org.restlet.ext.servlet.ServerServlet;

/**
* @author bhunt
*
*/
public class ApplicationServlet extends ServerServlet
{
  public ApplicationServlet(IApplicationProvider applicationProvider)
  {
    this.applicationProvider = applicationProvider;
  }

  @Override
  protected Application createApplication(Context context)
  {
    Context childContext = context.createChildContext();
    childContext.getAttributes().put(IApplicationProvider.SERVLET_CONFIG_ATTRIBUTE, servletConfig);
    childContext.getAttributes().put(IApplicationProvider.SERVLET_CONTEXT_ATTRIBUTE, getServletContext());
    return applicationProvider.createApplication(childContext);
  }

  @Override
  public void init(ServletConfig config) throws ServletException
  {
    servletConfig = config;
    super.init(config);
  }

  private static final long serialVersionUID = 5252087180467260130L;
  private transient IApplicationProvider applicationProvider;
  private ServletConfig servletConfig;
}
TOP

Related Classes of org.restlet.ext.osgi.servlet.ApplicationServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.