blob: 49da73df6ae4bf7bf6ced0910337f776b421f3b9 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.mortbay.jetty.servlet;
import java.io.IOException;
import java.net.URL;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.http.PathMap;
import org.mortbay.util.Code;
public class OsgiServletHandler extends ServletHandler
{
// allow external adding of osgi servlet holder
public void addOsgiServletHolder( String pathSpec, ServletHolder holder )
{
super.addServletHolder( pathSpec, holder );
}
public OsgiServletHolder removeOsgiServletHolder( String pathSpec )
{
OsgiServletHolder holder = ( OsgiServletHolder ) super.getServletHolder( pathSpec );
PathMap map = super.getServletMap();
map.remove( pathSpec );
// Remove holder from handler name map to allow re-registration.
super._nameMap.remove( holder.getName() );
return holder;
}
// override standard handler behaviour to return resource from OSGi
// HttpContext
public URL getResource( String uriInContext )
{
Code.debug( "OSGI ServletHandler getResource:" + uriInContext );
return null;
}
// override standard behaviour to check context first
protected void dispatch( String pathInContext, HttpServletRequest request, HttpServletResponse response,
ServletHolder servletHolder ) throws ServletException, UnavailableException, IOException
{
Code.debug( "dispatch path = " + pathInContext );
super.dispatch( pathInContext, request, response, servletHolder );
}
}