1 /* 2 * Copyright 2004-2010 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 17 package org.seasar.cubby.routing; 18 19 import java.util.Collection; 20 import java.util.Map; 21 22 import org.seasar.cubby.action.RequestMethod; 23 24 /** 25 * パスに対応するアクションメソッドを解決するためのクラスです。 26 * 27 * @author baba 28 */ 29 public interface PathResolver { 30 31 /** 32 * 指定されたパスとメソッドからフォワードするための情報を抽出します。 33 * <p> 34 * パスにマッチするパターンがない場合は <code>null</code> を返します。 35 * </p> 36 * 37 * @param path 38 * パス 39 * @param requestMethod 40 * HTTPメソッド 41 * @param characterEncoding 42 * URI のエンコーディング 43 * @return フォワード情報 44 */ 45 PathInfo getPathInfo(String path, String requestMethod, 46 String characterEncoding); 47 48 /** 49 * ルーティング情報の一覧を取得します。 ルーティング情報は優先度順にソートされています。 50 * 51 * @return ルーティング情報の一覧 52 */ 53 Collection<Routing> getRoutings(); 54 55 /** 56 * 指定されたアクションクラスのルーティング情報を登録します。 57 * 58 * @param actionClass 59 * アクションクラス 60 * @throws RoutingException 61 * ルーティング情報の登録に失敗した場合 62 */ 63 void add(Class<?> actionClass); 64 65 /** 66 * 指定されたアクションクラスのコレクションからすべてのルーティング情報を登録します。 67 * 68 * @param actionClasses 69 * アクションクラスのコレクション 70 * @throws RoutingException 71 * ルーティング情報の登録に失敗した場合 72 */ 73 void addAll(Collection<Class<?>> actionClasses); 74 75 /** 76 * ルーティング情報を手動登録します。 77 * 78 * @param actionPath 79 * アクションのパス 80 * @param actionClass 81 * アクションクラス 82 * @param actionMethodName 83 * アクションメソッド名 84 * @param requestMethod 85 * 要求メソッド 86 * @param onSubmit 87 * アクションメソッドへ振り分けるための要求パラメータ名 88 * @param priority 89 * プライオリティ 90 * @throws RoutingException 91 * ルーティング情報の登録に失敗した場合 92 */ 93 void add(String actionPath, Class<?> actionClass, String actionMethodName, 94 RequestMethod requestMethod, String onSubmit, int priority); 95 96 /** 97 * 登録されたルーティング情報をクリアします。 98 */ 99 void clear(); 100 101 /** 102 * 指定されたアクションクラス、メソッド名、パラメータからパスを逆引きします。 103 * 104 * @param actionClass 105 * アクションクラス 106 * @param methodName 107 * メソッド名 108 * @param parameters 109 * パラメータ 110 * @param characterEncoding 111 * URI のエンコーディング 112 * @return リダイレクト用のパス 113 * @throws RoutingException 114 * ルーティング情報の逆引きに失敗した場合 115 */ 116 String reverseLookup(Class<?> actionClass, String methodName, 117 Map<String, String[]> parameters, String characterEncoding); 118 119 }