Example usage for org.apache.wicket Page getPath

List of usage examples for org.apache.wicket Page getPath

Introduction

In this page you can find the example usage for org.apache.wicket Page getPath.

Prototype

public final String getPath() 

Source Link

Document

Gets this component's path.

Usage

From source file:com.servoy.j2db.server.headlessclient.WebClientSession.java

License:Open Source License

/**
 * @param touchedPages/*w w w.j  av a2 s . c  om*/
 * @param mainPage
 */
public void wantsToLock(List<Page> touchedPages, MainPage mainPage) {
    List<Page> ownLockedPages = toRelease.get();
    if (ownLockedPages.contains(mainPage))
        return;
    synchronized (lockedPages) {
        boolean found = touchedPages.size() > 0;
        boolean released = false;
        while (found) {
            for (Page touched : touchedPages) {
                // if the current touched pages are in the locked pages map and its not on our own locked pages list. 
                // something is waiting for that page to be released.
                found = !ownLockedPages.contains(touched) && lockedPages.containsKey(touched);
                if (found) {
                    // release first all current pages so that the other thread can go on.
                    releaseLocks();
                    released = true;
                    try {
                        // wait for the other to release the locked pages.
                        lockedPages.wait();
                    } catch (InterruptedException e) {
                        Debug.error(e);
                    }
                    break;
                }
            }
        }
        // if we did release our own pages, we have to lock them now again.
        if (released) {
            for (Page touched : touchedPages) {
                getPage(touched.getPageMapName(), touched.getPath(), Page.LATEST_VERSION);
            }
        }
        // add them to the threadlocal so that we know what to release for this thread in ondetach.
        ownLockedPages.add(mainPage);
        // mark the page as locked by the current touched pages.
        lockedPages.put(mainPage, touchedPages);
    }
}