001package org.apache.turbine.services.urlmapper;
002
003
004/*
005 * Licensed to the Apache Software Foundation (ASF) under one
006 * or more contributor license agreements.  See the NOTICE file
007 * distributed with this work for additional information
008 * regarding copyright ownership.  The ASF licenses this file
009 * to you under the Apache License, Version 2.0 (the
010 * "License"); you may not use this file except in compliance
011 * with the License.  You may obtain a copy of the License at
012 *
013 *   http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing,
016 * software distributed under the License is distributed on an
017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018 * KIND, either express or implied.  See the License for the
019 * specific language governing permissions and limitations
020 * under the License.
021 */
022
023
024import java.io.IOException;
025
026import org.apache.turbine.annotation.TurbineService;
027import org.apache.turbine.pipeline.PipelineData;
028import org.apache.turbine.pipeline.Valve;
029import org.apache.turbine.pipeline.ValveContext;
030import org.apache.turbine.util.RunData;
031import org.apache.turbine.util.TurbineException;
032
033/**
034 * This valve is responsible for parsing parameters out of
035 * simplified URLs.
036 *
037 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
038 */
039public class URLMapperValve
040    implements Valve
041{
042    /** Injected service instance */
043    @TurbineService
044    private URLMapperService urlMapperService;
045
046    /**
047     * @see org.apache.turbine.pipeline.Valve#invoke(PipelineData, ValveContext)
048     */
049    @Override
050    public void invoke(PipelineData pipelineData, ValveContext context)
051        throws IOException, TurbineException
052    {
053        RunData data = pipelineData.getRunData();
054        String uri = data.getRequest().getRequestURI();
055
056        urlMapperService.mapFromURL(uri, data.getParameters());
057
058        // Pass control to the next Valve in the Pipeline
059        context.invokeNext(pipelineData);
060    }
061}