com.ocpsoft.rewrite.servlet.impl.HttpRewriteRequestCycleWrapper Maven / Gradle / Ivy
/*
* Copyright 2011 Lincoln Baxter, III
*
* Licensed 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 com.ocpsoft.rewrite.servlet.impl;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ocpsoft.common.services.NonEnriching;
import com.ocpsoft.common.services.ServiceLoader;
import com.ocpsoft.rewrite.servlet.http.HttpRequestCycleWrapper;
import com.ocpsoft.rewrite.servlet.spi.RequestParameterProvider;
/**
* @author Lincoln Baxter, III
*
*/
public class HttpRewriteRequestCycleWrapper extends HttpRequestCycleWrapper implements NonEnriching
{
@Override
@SuppressWarnings("unchecked")
public HttpServletRequest wrapRequest(final HttpServletRequest request, final HttpServletResponse response)
{
Map additionalParams = new HashMap();
ServiceLoader providers = ServiceLoader.load(RequestParameterProvider.class);
for (RequestParameterProvider provider : providers) {
Map m = provider.getParameters(request, response);
if (m != null)
{
additionalParams.putAll(m);
}
}
return new HttpRewriteWrappedRequest(request, additionalParams);
}
@Override
public HttpServletResponse wrapResponse(final HttpServletRequest request, final HttpServletResponse response)
{
return new HttpRewriteWrappedResponse(request, response);
}
@Override
public int priority()
{
return 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy