01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.ajax;
18:
19: import java.util.Collections;
20: import java.util.Map;
21:
22: import org.apache.avalon.framework.parameters.Parameters;
23: import org.apache.avalon.framework.thread.ThreadSafe;
24: import org.apache.cocoon.environment.ObjectModelHelper;
25: import org.apache.cocoon.environment.Request;
26: import org.apache.cocoon.matching.Matcher;
27: import org.apache.cocoon.sitemap.PatternException;
28:
29: /**
30: * A matcher that tests if the current request is an Ajax request. This matcher
31: * provides no sitemap variables.
32: * <p>
33: * Example:
34: * <pre>
35: * <map:match type="ajax-request">
36: * ... ajax request ...
37: * </map:match>
38: * </pre>
39: *
40: * @since 2.1.8
41: * @version $Id: AjaxRequestMatcher.java 448479 2006-09-21 07:33:36Z crossley $
42: */
43: public class AjaxRequestMatcher implements Matcher, ThreadSafe {
44:
45: public Map match(String pattern, Map objectModel,
46: Parameters parameters) throws PatternException {
47: Request req = ObjectModelHelper.getRequest(objectModel);
48:
49: return AjaxHelper.isAjaxRequest(req) ? Collections.EMPTY_MAP
50: : null;
51: }
52: }
|