Author: ehillenius Date: Thu Jun 7 18:00:12 2007 New Revision: 545357 URL: http://svn.apache.org/viewvc?view=rev&rev=545357 Log: sorted members
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java?view=diff&rev=545357&r1=545356&r2=545357 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java Thu Jun 7 18:00:12 2007 @@ -139,36 +139,76 @@ public abstract class Page extends MarkupContainer implements IRedirectListener, IPageMapEntry { /** + * You can set implementation of the interface in the + * [EMAIL PROTECTED] Page#serializer} then that implementation will handle the + * serialization of this page. The serializePage method is called from the + * writeObject method then the implementation override the default + * serialization. + * + * @author jcompagner + */ + public static interface IPageSerializer + { + /** + * Called when page is being deserialized + * + * @param id + * TODO + * @param name + * TODO + * @param page + * @param stream + * @return New instance to replace page instance being deserialized + * @throws IOException + * @throws ClassNotFoundException + * + */ + public Page deserializePage(int id, String name, Page page, ObjectInputStream stream) + throws IOException, ClassNotFoundException; + + /** + * Called from the [EMAIL PROTECTED] Page#writeObject()} method. + * + * @param page + * The page that must be serialized. + * @param stream + * ObjectOutputStream + * @throws IOException + */ + public void serializePage(Page page, ObjectOutputStream stream) throws IOException; + } + + /** * When passed to [EMAIL PROTECTED] Page#getVersion(int)} the latest page version is * returned. */ public static final int LATEST_VERSION = -1; - private static final long serialVersionUID = 1L; - /** - * [EMAIL PROTECTED] #isBookmarkable()} is expensive, we cache the result here + * This is a thread local that is used for serializing page references in + * this page.It stores a [EMAIL PROTECTED] IPageSerializer} which can be set by the + * outside world to do the serialization of this page. */ - private static final ConcurrentHashMap pageClassToBookmarkableCache = new ConcurrentHashMap(); + public static final ThreadLocal serializer = new ThreadLocal(); /** True if a new version was created for this request. */ private static final short FLAG_NEW_VERSION = FLAG_RESERVED3; - /** True if component changes are being tracked. */ - private static final short FLAG_TRACK_CHANGES = FLAG_RESERVED4; - /** True if the page should try to be stateless */ private static final int FLAG_STATELESS_HINT = FLAG_RESERVED5; + /** True if component changes are being tracked. */ + private static final short FLAG_TRACK_CHANGES = FLAG_RESERVED4; + /** Log. */ private static final Logger log = LoggerFactory.getLogger(Page.class); /** - * This is a thread local that is used for serializing page references in - * this page.It stores a [EMAIL PROTECTED] IPageSerializer} which can be set by the - * outside world to do the serialization of this page. + * [EMAIL PROTECTED] #isBookmarkable()} is expensive, we cache the result here */ - public static final ThreadLocal serializer = new ThreadLocal(); + private static final ConcurrentHashMap pageClassToBookmarkableCache = new ConcurrentHashMap(); + + private static final long serialVersionUID = 1L; /** Used to create page-unique numbers */ private short autoIndex; @@ -182,6 +222,9 @@ /** Name of PageMap that this page is stored in */ private String pageMapName; + // temporary variable to pass page instance from readObject to readResolve + private transient Page pageToResolve = null; + /** Set of components that rendered if component use checking is enabled */ private transient Set renderedComponents; @@ -263,58 +306,6 @@ super(null); } - // temporary variable to pass page instance from readObject to readResolve - private transient Page pageToResolve = null; - - // called after readObject - private Object readResolve() throws ObjectStreamException - { - if (pageToResolve == null) - { - return this; - } - else - { - Page page = pageToResolve; - pageToResolve = null; - return page; - } - } - - private void writeObject(java.io.ObjectOutputStream s) throws IOException - { - s.writeShort(numericId); - s.writeObject(pageMapName); - - - IPageSerializer ps = (IPageSerializer)serializer.get(); - - if (ps != null) - { - ps.serializePage(this, s); - } - else - { - s.defaultWriteObject(); - } - } - - private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException - { - int id = s.readShort(); - String name = (String)s.readObject(); - - IPageSerializer ps = (IPageSerializer)serializer.get(); - if (ps != null) - { - pageToResolve = ps.deserializePage(id, name, this, s); - } - else - { - s.defaultReadObject(); - } - } - /** * Called right after a component's listener method (the provided method * argument) was called. This method may be used to clean up dependencies, @@ -358,7 +349,6 @@ { } - /** * Adds a component to the set of rendered components. * @@ -415,6 +405,7 @@ super.detachModels(); } + /** * Mark this page as dirty in the session */ @@ -525,14 +516,6 @@ } /** - * @return - */ - public final String getPageMapName() - { - return pageMapName; - } - - /** * @return Get a page map entry for this page. By default, this is the page * itself. But if you know of some way to compress the state for the * page, you can return a custom implementation that produces the @@ -544,6 +527,14 @@ } /** + * @return + */ + public final String getPageMapName() + { + return pageMapName; + } + + /** * @return Size of this page in bytes */ public final long getSizeInBytes() @@ -892,16 +883,16 @@ try { beforeRender(); - } - catch(RuntimeException e) + } + catch (RuntimeException e) { // if an exception is thrown then we have to call after render // else the components could be in a wrong state (rendering) try { afterRender(); - } - catch(RuntimeException e2) + } + catch (RuntimeException e2) { // ignore this one could be a result off. } @@ -1244,6 +1235,55 @@ } } + private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException + { + int id = s.readShort(); + String name = (String)s.readObject(); + + IPageSerializer ps = (IPageSerializer)serializer.get(); + if (ps != null) + { + pageToResolve = ps.deserializePage(id, name, this, s); + } + else + { + s.defaultReadObject(); + } + } + + // called after readObject + private Object readResolve() throws ObjectStreamException + { + if (pageToResolve == null) + { + return this; + } + else + { + Page page = pageToResolve; + pageToResolve = null; + return page; + } + } + + private void writeObject(java.io.ObjectOutputStream s) throws IOException + { + s.writeShort(numericId); + s.writeObject(pageMapName); + + + IPageSerializer ps = (IPageSerializer)serializer.get(); + + if (ps != null) + { + ps.serializePage(this, s); + } + else + { + s.defaultWriteObject(); + } + } + /** * Set-up response with appropriate content type, locale and encoding. The * locale is set equal to the session's locale. The content type header @@ -1349,6 +1389,7 @@ super.onDetach(); } + /** * Renders this container to the given response object. * @@ -1367,7 +1408,6 @@ renderAll(associatedMarkupStream); } - /** * A component was added. * @@ -1462,45 +1502,5 @@ void setPageStateless(Boolean stateless) { this.stateless = stateless; - } - - /** - * You can set implementation of the interface in the - * [EMAIL PROTECTED] Page#serializer} then that implementation will handle the - * serialization of this page. The serializePage method is called from the - * writeObject method then the implementation override the default - * serialization. - * - * @author jcompagner - */ - public static interface IPageSerializer - { - /** - * Called from the [EMAIL PROTECTED] Page#writeObject()} method. - * - * @param page - * The page that must be serialized. - * @param stream - * ObjectOutputStream - * @throws IOException - */ - public void serializePage(Page page, ObjectOutputStream stream) throws IOException; - - /** - * Called when page is being deserialized - * - * @param id - * TODO - * @param name - * TODO - * @param page - * @param stream - * @return New instance to replace page instance being deserialized - * @throws IOException - * @throws ClassNotFoundException - * - */ - public Page deserializePage(int id, String name, Page page, ObjectInputStream stream) - throws IOException, ClassNotFoundException; } }