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.page;
018
019import org.apache.wicket.Page;
020import org.apache.wicket.pageStore.IPageStore;
021
022/**
023 * A manager of pages - facade between {@link Page}s and {@link IPageStore}s they are stored in.
024 * 
025 * @see PageManager
026 */
027public interface IPageManager
028{
029        /**
030         * Is versionining of pages supported, see {@link IPageStore#supportsVersioning()}.
031         * 
032         * @return {@code true} if versioning is supported
033         */
034        boolean supportsVersioning();
035
036        /**
037         * Get a page
038         * 
039         * @param pageId
040         *            id of page
041         * @return page, may be <code>null</code>
042         */
043        IManageablePage getPage(int pageId);
044
045        /**
046         * Remove a page
047         * 
048         * @param page
049         *            page to remove
050         */
051        void removePage(IManageablePage page);
052
053        /**
054         * Add a page.
055         * 
056         * @param page
057         *            page to add
058         */
059        void touchPage(IManageablePage page);
060        
061        /**
062         * Marks page as non-changed.
063         * Could be used in Ajax requests to avoid storing the page if no changes have happened.
064         *
065         * @param page
066         *      the page that should <strong>not</strong> be stored in the page stores at the end of the request.
067         */
068        void untouchPage(IManageablePage page);
069
070        /**
071         * Clear all pages.
072         */
073        void clear();
074
075        /**
076         * End the request.
077         */
078        default void end() {
079        }
080        
081        /**
082         * Detach at end of request.
083         */
084        void detach();
085
086        /**
087         * Destroy when application is destroyed.
088         */
089        void destroy();
090
091        /**
092         * Get the storage of pages, optional.
093         *  
094         * @return store or <code>null</code>
095         */
096        IPageStore getPageStore();
097}