Package org.openhab.ui.webapp.internal.servlet

Source Code of org.openhab.ui.webapp.internal.servlet.BaseServlet

/**
* Copyright (c) 2010-2014, openHAB.org and others.
*
* 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
*/
package org.openhab.ui.webapp.internal.servlet;

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

import org.openhab.core.items.ItemRegistry;
import org.openhab.io.net.http.SecureHttpContext;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;


/**
* This is the base servlet class for other servlet in the WebApp UI.
*
* @author Thomas.Eichstaedt-Engelen
*/
public abstract class BaseServlet implements Servlet {
 
  /** the root path of this web application */
  public static final String WEBAPP_ALIAS = "/";
   
  protected HttpService httpService;
  protected ItemRegistry itemRegistry;

 
  public void setItemRegistry(ItemRegistry itemRegistry) {
    this.itemRegistry = itemRegistry;
  }

  public void unsetItemRegistry(ItemRegistry itemRegistry) {
    this.itemRegistry = null;
  }

  public void setHttpService(HttpService httpService) {
    this.httpService = httpService;
  }

  public void unsetHttpService(HttpService httpService) {
    this.httpService = null;
  }

  /**
   * Creates a {@link SecureHttpContext} which handles the security for this
   * Servlet 
   * @return a {@link SecureHttpContext}
   */
  protected HttpContext createHttpContext() {
    HttpContext defaultHttpContext = httpService.createDefaultHttpContext();
    return new SecureHttpContext(defaultHttpContext, "openHAB.org");
  }
 
  /**
   * {@inheritDoc}
   */
  public void init(ServletConfig config) throws ServletException {
  }

  /**
   * {@inheritDoc}
   */
  public ServletConfig getServletConfig() {
    return null;
  }
 
  /**
   * {@inheritDoc}
   */
  public String getServletInfo() {
    return null;
  }

  /**
   * {@inheritDoc}
   */
  public void destroy() {
  }

}
TOP

Related Classes of org.openhab.ui.webapp.internal.servlet.BaseServlet

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.