Wicket1.5に挑戦中
ダウンロードしたファイルにはwicket-core-1.5-rc2.jarが入っていなかったのでmavenで入れた。
何も考えずにmavenプロジェクトに変換したら、GWTやs2jdbc-genを使っているのでハマるハマる…。
m2eclipseなどを入れたらpom.xmlが開けなくなるし、設定解決で数時間使ってしまった。
なかなか解決しなかったので新しいプロジェクトを作ってmavenを使わずにやってみた。
s2wicket変更点。
- WebApplication.newSessionStore()がなくなったのでS2WebApplicationを削除
- ReloadingWicketFilter.init(FilterConfig)がfinalになっているので引数が二つの方を使う
- Application.DEVELOPMENTなどがenumのRuntimeConfigurationTypeになった
- Application.addComponentInstantiationListener → Application.getComponentInstantiationListeners().add()
- LoopItem.getIteration() → LoopItem.getIndex()
diff
diff --git a/src/org/seasar/wicket/S2WebApplication.java b/src/org/seasar/wicket/S2WebApplication.java deleted file mode 100644 index cba7093..0000000 --- a/src/org/seasar/wicket/S2WebApplication.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.seasar.wicket; - -import org.apache.wicket.protocol.http.HttpSessionStore; -import org.apache.wicket.protocol.http.WebApplication; -import org.apache.wicket.session.ISessionStore; - -public abstract class S2WebApplication extends WebApplication { - @Override - protected ISessionStore newSessionStore() { - if (DEPLOYMENT.equalsIgnoreCase(getConfigurationType())) { - return super.newSessionStore(); - } else { - return new HttpSessionStore(this); - } - } -} diff --git a/src/org/seasar/wicket/S2WicketFilter.java b/src/org/seasar/wicket/S2WicketFilter.java index 1687a3a..33891b3 100644 --- a/src/org/seasar/wicket/S2WicketFilter.java +++ b/src/org/seasar/wicket/S2WicketFilter.java @@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.wicket.Application; +import org.apache.wicket.RuntimeConfigurationType; import org.apache.wicket.application.ReloadingClassLoader; import org.apache.wicket.protocol.http.ReloadingWicketFilter; import org.apache.wicket.protocol.http.WebApplication; @@ -130,12 +131,12 @@ public class S2WicketFilter extends ReloadingWicketFilter { private String reloadingClassPattern; /** アプリケーションのコンフィグ(DEPLOYMENT, DEVELOPMENT) */ - private String applicationConfigType; + private RuntimeConfigurationType applicationConfigType; /** アプリケーションのデフォルトエンコーディング */ private String applicationEncoding; @Override - public void init(FilterConfig filterConfig) throws ServletException { + public void init(boolean isServlet, FilterConfig filterConfig) throws ServletException { if (SingletonS2ContainerFactory.hasContainer()) { SingletonS2ContainerFactory.destroy(); } @@ -156,7 +157,10 @@ public class S2WicketFilter extends ReloadingWicketFilter { reloadingClassPattern); } - if (Application.DEVELOPMENT.equalsIgnoreCase(configuration) + RuntimeConfigurationType confType = + "development".equalsIgnoreCase(configuration) ? + RuntimeConfigurationType.DEVELOPMENT : RuntimeConfigurationType.DEPLOYMENT; + if (confType == RuntimeConfigurationType.DEVELOPMENT && reloadingClassPattern != null) { ReloadingClassLoader.getPatterns().clear(); // すべてのクラスが読み込まれる前に先に監視クラスを設定 @@ -191,21 +195,19 @@ public class S2WicketFilter extends ReloadingWicketFilter { "S2Wicket does not support HOT deploy mode."); } - super.init(filterConfig); + super.init(isServlet, filterConfig); // 関連づけられたWebApplicationを取り出す(現状これしか方法がない?) - String contextKey = "wicket:" + filterConfig.getFilterName(); - WebApplication webApplication = - (WebApplication) filterConfig.getServletContext().getAttribute( - contextKey); - webApplication.addComponentInstantiationListener(new ComponentInjectionListener()); + String contextKey = filterConfig.getFilterName(); + WebApplication webApplication = (WebApplication) Application.get(contextKey); + webApplication.getComponentInstantiationListeners().add(new ComponentInjectionListener()); applicationConfigType = webApplication.getConfigurationType(); applicationEncoding = webApplication.getRequestCycleSettings().getResponseRequestEncoding(); - if (Application.DEVELOPMENT.equalsIgnoreCase(configuration) + if (confType == RuntimeConfigurationType.DEVELOPMENT && debug != null) { - webApplication.mountBookmarkablePage(debug, S2DebugPage.class); + webApplication.mountPage(debug, S2DebugPage.class); } } @@ -222,7 +224,7 @@ public class S2WicketFilter extends ReloadingWicketFilter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - if (Application.DEVELOPMENT.equalsIgnoreCase(applicationConfigType)) { + if (RuntimeConfigurationType.DEVELOPMENT == applicationConfigType) { if (request instanceof HttpServletRequest) { // 旧セッションクラスローダーで読み込まれていたセッションオブジェクトの削除 HttpSession session = diff --git a/src/org/seasar/wicket/debug/S2DebugPage.java b/src/org/seasar/wicket/debug/S2DebugPage.java index 54b6b1e..0a30f42 100644 --- a/src/org/seasar/wicket/debug/S2DebugPage.java +++ b/src/org/seasar/wicket/debug/S2DebugPage.java @@ -1,5 +1,6 @@ package org.seasar.wicket.debug; +import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.markup.ComponentTag; @@ -7,6 +8,7 @@ import org.apache.wicket.markup.MarkupStream; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.list.Loop; +import org.apache.wicket.markup.html.list.LoopItem; import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.markup.resolver.IComponentResolver; import org.apache.wicket.model.CompoundPropertyModel; @@ -49,7 +51,7 @@ public class S2DebugPage extends WebPage { @Override protected void populateItem(LoopItem item) { item.setDefaultModel(new CompoundPropertyModel<ComponentDef>( - container.getComponentDef(item.getIteration()))); + container.getComponentDef(item.getIndex()))); } }.setVisible(container.getComponentDefSize() > 0)); add(new AutoResolveLoop("containers", container.getChildSize()) { @@ -60,17 +62,18 @@ public class S2DebugPage extends WebPage { item.add(new SimpleAttributeModifier("class", "level" + (level + 1))); item.add(new S2ContainerFragment("container", - container.getChild(item.getIteration()), level + 1)); + container.getChild(item.getIndex()), level + 1)); } }.setVisible(container.getChildSize() > 0)); } - public boolean resolve(MarkupContainer container, + // TODO: これでいい? + public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { if (tag.isAutoComponentTag()) { - return false; + return null; } - return container.autoAdd(new Label(tag.getId()), markupStream); + return new Label(tag.getId()); } } @@ -82,12 +85,12 @@ public class S2DebugPage extends WebPage { super(id, iterations); } - public boolean resolve(MarkupContainer container, + public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { if (tag.isAutoComponentTag()) { - return false; + return null; } - return container.autoAdd(new Label(tag.getId()), markupStream); + return new Label(tag.getId()); } }
とりあえずs2wicketが動くように新規プロジェクトを作ってやっているので、まだデプロイとか自動リロードとかは試していない。wicket-1.5-rc2 でトップが表示できるまで。