001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.pageStore; 018 019import org.apache.wicket.page.IManageablePage; 020 021/** 022 * A store of pages 023 */ 024public interface IPageStore 025{ 026 /** 027 * Is versioning of pages supported, i.e. when an altered page instance has been stored in this store, can the previous state of that page 028 * still be retrieved under its former page id. Most implementations achieve this by keeping a copy of the page instance, e.g. by means of serialization. 029 */ 030 boolean supportsVersioning(); 031 032 /** 033 * This method is called by {@link AsynchronousPageStore} before any attempt to call 034 * {@link #addPage(IPageContext, IManageablePage)} asynchronously. 035 * <p> 036 * A page store returning <code>true</code> must immediately access all required values from the context, 037 * since no additional values can be accessed when {@link #addPage(IPageContext, IManageablePage)} is called 038 * asynchronously afterwards. 039 * 040 * @return whether {@link #addPage(IPageContext, IManageablePage)} may be called asynchronously, 041 * default is <code>false</code> 042 */ 043 default boolean canBeAsynchronous(IPageContext context) 044 { 045 return false; 046 } 047 048 /** 049 * Stores the page- 050 * 051 * @param context 052 * the context of the page 053 * @param page 054 * the page. 055 */ 056 void addPage(IPageContext context, IManageablePage page); 057 058 /** 059 * Removes a page from storage. 060 * 061 * @param context 062 * the context of the page 063 * @param page 064 * the page. 065 */ 066 void removePage(IPageContext context, IManageablePage page); 067 068 /** 069 * All pages should be removed from storage for the given context. 070 * 071 * @param context 072 * the context of the pages 073 */ 074 void removeAllPages(IPageContext context); 075 076 /** 077 * Revert adding a page - optional operation. 078 * 079 * @param page 080 * the page that should be reverted 081 */ 082 default void revertPage(IPageContext context, IManageablePage page) { 083 } 084 085 /** 086 * Restores a page from storage. 087 * 088 * @param context 089 * the context of the page 090 * @param id 091 * the id of the page. 092 * @return the page 093 */ 094 IManageablePage getPage(IPageContext context, int id); 095 096 /** 097 * End the current context. 098 * 099 * @param context 100 */ 101 default void end(IPageContext context) 102 { 103 } 104 105 /** 106 * Detach from the current context. 107 * 108 * @param context 109 * the context of the pages 110 */ 111 default void detach(IPageContext context) 112 { 113 } 114 115 /** 116 * Destroy the store. 117 */ 118 default void destroy() 119 { 120 } 121}