1 /* 2 * Copyright 2004-2008 the Seasar Foundation and the Others. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 13 * either express or implied. See the License for the specific language 14 * governing permissions and limitations under the License. 15 */ 16 package org.seasar.cubby.routing; 17 18 import java.util.List; 19 import java.util.Map; 20 21 import org.seasar.cubby.action.Action; 22 import org.seasar.cubby.action.RequestMethod; 23 24 /** 25 * {@link Router} がフォワードするための情報を抽出するクラス。 26 * 27 * @author baba 28 * @since 1.0.0 29 */ 30 public interface PathResolver { 31 32 /** 33 * 指定されたパスとメソッドからフォワードするための情報を抽出します。 34 * <p> 35 * パスにマッチするパターンがない場合は <code>null</code> を返します。 36 * </p> 37 * 38 * @param path 39 * パス 40 * @param requestMethod 41 * HTTPメソッド 42 * @param characterEncoding 43 * URI のエンコーディング 44 * @return フォワード情報 45 */ 46 InternalForwardInfo getInternalForwardInfo(String path, 47 String requestMethod, String characterEncoding); 48 49 /** 50 * ルーティング情報の一覧を取得します。 ルーティング情報は優先度順にソートされています。 51 * 52 * @return ルーティング情報の一覧 53 */ 54 List<Routing> getRoutings(); 55 56 /** 57 * ルーティング情報を手動登録します。 58 * <p> 59 * 手動登録の場合、優先度は0から連番で設定されます。 60 * </p> 61 * 62 * @param actionPath 63 * アクションのパス 64 * @param actionClass 65 * アクションクラス 66 * @param methodName 67 * アクションメソッド名 68 * @param requestMethods 69 * リクエストメソッド。<code>null</code> の場合、{@link RequestMethod#GET}, 70 * {@link RequestMethod#POST} がデフォルト値として設定されます。 71 * @see org.seasar.cubby.action.Path#priority() 自動設定の際のプライオリティ 72 */ 73 void add(final String actionPath, 74 final Class<? extends Action> actionClass, final String methodName, 75 final RequestMethod... requestMethods); 76 77 /** 78 * 指定されたアクションクラス、メソッド名、パラメータからパスを逆引きします。 79 * 80 * @param actionClass 81 * アクションクラス 82 * @param methodName 83 * メソッド名 84 * @param parameters 85 * パラメータ 86 * @param characterEncoding 87 * URI のエンコーディング 88 * @return リダイレクト用のパス 89 * @since 1.1.0 90 */ 91 String reverseLookup(final Class<? extends Action> actionClass, 92 String methodName, Map<String, String[]> parameters, 93 String characterEncoding); 94 95 /** 96 * 内部フォワードパスを構築します。 97 * 98 * @param parameters 99 * パラメータ 100 * @param characterEncoding 101 * URI のエンコーディング 102 * @return 内部フォワードパス 103 * @since 1.1.0 104 */ 105 String buildInternalForwardPath(Map<String, String[]> parameters, 106 String characterEncoding); 107 108 }