Re: Do not cache pages, nor in application, nor in browser

2013-01-16 Thread Martin Grigorov
These impls are quite simple ...
No one so far ever needed something like this


On Wed, Jan 16, 2013 at 1:14 PM, Oscar Besga Arcauz wrote:

> I've made a class, extending the DefaultPageManagerProvider to avoid
> Wicket page store (in order recreate every page at every request from users)
>
>
> I'm testing it, and found no problems - for now.
>
> Take a look; I'm thinking about sending it to JIRA as an improvement
>
>
> /**
>  * User: obesga
>  * Date: 16-jan-2013
>  * Page manager that does not store any page, nor any bit
>  */
> public class VoidPageManagerProvider extends DefaultPageManagerProvider {
>
> // Common properties
> private IPageManagerContext iPageManagerContext;
> private IPageManager iPageManager;
> private IDataStore iDataStore;
> private IPageStore iPageStore;
>
> /**
>  * Basic construftor
>  * @param application Actual application
>  */
> public VoidPageManagerProvider(Application application) {
> super(application);
> iPageManagerContext =  new DefaultPageManagerContext();
> iDataStore = new VoidIDataStore();
> iPageStore = new VoidIPageStore();
> iPageManager = new
> VoidPageStoreManager(application.getName(),iPageStore,iPageManagerContext);
> }
>
> @Override
> public IPageManager get(IPageManagerContext pageManagerContext) {
> return iPageManager;
> }
>
> @Override
> protected IPageStore newPageStore(IDataStore dataStore) {
> return iPageStore;
> }
>
> @Override
> protected IDataStore newDataStore() {
> return iDataStore;
> }
>
> /**
>  * A data store that doesn't store a byte
>  */
> private class VoidIDataStore implements IDataStore {
>
> public byte[] getData(String s, int i) {
> return null;
> }
>
> public void removeData(String s, int i) {
> }
>
> public void removeData(String s) {
> }
>
> public void storeData(String s, int i, byte[] bytes) {
> }
>
> public void destroy() {
> }
>
> public boolean isReplicated() {
> return true;
> }
>
> public boolean canBeAsynchronous() {
> return true;
> }
> }
>
> /**
>  * A page store that doesn't store a page
>  */
> private class VoidIPageStore implements IPageStore {
>
> public void destroy() {
>
> }
>
> public IManageablePage getPage(String s, int i) {
> return null;
> }
>
> public void removePage(String s, int i) {
>
> }
>
> public void storePage(String s, IManageablePage iManageablePage) {
>
> }
>
> public void unbind(String s) {
>
> }
>
> public Serializable prepareForSerialization(String s, Object o) {
> return null;
> }
>
> public Object restoreAfterSerialization(Serializable serializable)
> {
> return null;
> }
>
> public IManageablePage convertToPage(Object o) {
> return null;
> }
> }
>
> /**
>  * The basic store manager, extended to not support versioning
>  */
> private class VoidPageStoreManager extends PageStoreManager implements
> IPageManager {
>
> public VoidPageStoreManager(String applicationName, IPageStore
> pageStore, IPageManagerContext context) {
>     super(applicationName, pageStore, context);
> }
>
> @Override
> public boolean supportsVersioning() {
> return false;
> }
> }
>
>
> }
>
>
>
>
>
> > > > Oscar Besga Arcauz  < < <
>
> -Martin Grigorov  escribió: -
> Para: users@wicket.apache.org
> De: Martin Grigorov 
> Fecha: 16/01/2013  09:00
> Asunto: Re: Do not cache pages, nor in application, nor in browser
>
> Hi,
>
>
> On Tue, Jan 15, 2013 at 7:59 PM, Oscar Besga Arcauz  >wrote:
>
> >
> >
> > I use these code in order to avoid web page cache, in browser and in
> > wicket application;
> > also I want to avoid disk caching and serialization
> >
> > I'm using Wicket6
> >
> >
> > ¿ Do you see this code correct ? ¿ Is there any easier way to accomplish
> > this ?
> >
> > /**
> >  * App
> >  */
> > public class MyApplication extends WebApplication {
> > @Override
> > public void init() {
> >

Re: Do not cache pages, nor in application, nor in browser

2013-01-16 Thread Oscar Besga Arcauz
I've made a class, extending the DefaultPageManagerProvider to avoid Wicket 
page store (in order recreate every page at every request from users)


I'm testing it, and found no problems - for now.

Take a look; I'm thinking about sending it to JIRA as an improvement


/**
 * User: obesga
 * Date: 16-jan-2013
 * Page manager that does not store any page, nor any bit
 */
public class VoidPageManagerProvider extends DefaultPageManagerProvider {

    // Common properties
    private IPageManagerContext iPageManagerContext;
    private IPageManager iPageManager;
    private IDataStore iDataStore;
    private IPageStore iPageStore;

    /**
 * Basic construftor
 * @param application Actual application
 */
    public VoidPageManagerProvider(Application application) {
    super(application);
    iPageManagerContext =  new DefaultPageManagerContext();
    iDataStore = new VoidIDataStore();
    iPageStore = new VoidIPageStore();
    iPageManager = new 
VoidPageStoreManager(application.getName(),iPageStore,iPageManagerContext);
    }

    @Override
    public IPageManager get(IPageManagerContext pageManagerContext) {
    return iPageManager;
    }

    @Override
    protected IPageStore newPageStore(IDataStore dataStore) {
    return iPageStore;
    }

    @Override
    protected IDataStore newDataStore() {
    return iDataStore;
    }

    /**
 * A data store that doesn't store a byte
 */
    private class VoidIDataStore implements IDataStore {

    public byte[] getData(String s, int i) {
    return null;
    }

    public void removeData(String s, int i) {
    }

    public void removeData(String s) {
    }

    public void storeData(String s, int i, byte[] bytes) {
    }

    public void destroy() {
    }

    public boolean isReplicated() {
    return true;
    }

    public boolean canBeAsynchronous() {
    return true;
    }
    }

    /**
 * A page store that doesn't store a page
 */
    private class VoidIPageStore implements IPageStore {

    public void destroy() {

    }

    public IManageablePage getPage(String s, int i) {
    return null;
    }

    public void removePage(String s, int i) {

    }

    public void storePage(String s, IManageablePage iManageablePage) {

    }

    public void unbind(String s) {

    }

    public Serializable prepareForSerialization(String s, Object o) {
    return null;
    }

    public Object restoreAfterSerialization(Serializable serializable) {
    return null;
    }

    public IManageablePage convertToPage(Object o) {
    return null;
    }
    }

    /**
 * The basic store manager, extended to not support versioning
 */
    private class VoidPageStoreManager extends PageStoreManager implements 
IPageManager {

    public VoidPageStoreManager(String applicationName, IPageStore 
pageStore, IPageManagerContext context) {
    super(applicationName, pageStore, context);
    }

    @Override
    public boolean supportsVersioning() {
    return false;
    }
    }


}





> > > Oscar Besga Arcauz  < < < 

-Martin Grigorov  escribió: -
Para: users@wicket.apache.org
De: Martin Grigorov 
Fecha: 16/01/2013  09:00
Asunto: Re: Do not cache pages, nor in application, nor in browser

Hi,


On Tue, Jan 15, 2013 at 7:59 PM, Oscar Besga Arcauz wrote:

>
>
> I use these code in order to avoid web page cache, in browser and in
> wicket application;
> also I want to avoid disk caching and serialization
>
> I'm using Wicket6
>
>
> ¿ Do you see this code correct ? ¿ Is there any easier way to accomplish
> this ?
>
> /**
>  * App
>  */
> public class MyApplication extends WebApplication {
>     @Override
>     public void init() {
>         super.init();
>         setPageManagerProvider(new MyPageManagerProvider(this));
>     }
>
>     /**
>      * shall not save
>      */
>     private class MyPageManagerProvider extends DefaultPageManagerProvider
> {
>
>         private MyPageManagerProvider(Application application) {
>             super(application);
>         }
>
>
>         @Override
>         protected IDataStore newDataStore() {
>             // guardamos tod o en memoria
>             return new HttpSessionDataStore(new
> DefaultPageManagerContext(), new PageNumberEvictionStrategy(0));
>

You can use getStoreSettings#setMaxSizePerSession(Bytes.bytes(1))  with the
default DiskDataStore too.
But your approach is better because this way you don't do IO operations.


>         }
>
>     }
>
> }
>
>
>
> /

Re: Do not cache pages, nor in application, nor in browser

2013-01-16 Thread Martin Grigorov
Hi,


On Tue, Jan 15, 2013 at 7:59 PM, Oscar Besga Arcauz wrote:

>
>
> I use these code in order to avoid web page cache, in browser and in
> wicket application;
> also I want to avoid disk caching and serialization
>
> I'm using Wicket6
>
>
> ¿ Do you see this code correct ? ¿ Is there any easier way to accomplish
> this ?
>
> /**
>  * App
>  */
> public class MyApplication extends WebApplication {
> @Override
> public void init() {
> super.init();
> setPageManagerProvider(new MyPageManagerProvider(this));
> }
>
> /**
>  * shall not save
>  */
> private class MyPageManagerProvider extends DefaultPageManagerProvider
> {
>
> private MyPageManagerProvider(Application application) {
> super(application);
> }
>
>
> @Override
> protected IDataStore newDataStore() {
> // guardamos tod o en memoria
> return new HttpSessionDataStore(new
> DefaultPageManagerContext(), new PageNumberEvictionStrategy(0));
>

You can use getStoreSettings#setMaxSizePerSession(Bytes.bytes(1))  with the
default DiskDataStore too.
But your approach is better because this way you don't do IO operations.


> }
>
> }
>
> }
>
>
>
> /**/
>
> /**
>  * Web Page
>  */
> public class MyPage extends WebPage {
>
> @Override
> protected void setHeaders(WebResponse response) {
> super.setHeaders(response);
> response.setHeader("X-Frame-Options","deny"); // Avoid  IFRFAMES
> response.setHeader("Cache-Control",
> "no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0");
> response.setHeader("Expires","0");
> response.setHeader("Pragma", "no-cache");
> response.disableCaching();
>

You probably want to call #disableCaching() *before* your setHeader()
calls. Currently #disableCaching() overrides some of them.


> }
>
> }
>
>
>
>
> > > > Oscar Besga Arcauz  < < <
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com 


Do not cache pages, nor in application, nor in browser

2013-01-15 Thread Oscar Besga Arcauz
 

I use these code in order to avoid web page cache, in browser and in wicket 
application;
also I want to avoid disk caching and serialization

I'm using Wicket6


¿ Do you see this code correct ? ¿ Is there any easier way to accomplish this ?

/**
 * App
 */
public class MyApplication extends WebApplication {
    @Override
    public void init() {
    super.init();
    setPageManagerProvider(new MyPageManagerProvider(this));
}

/**
 * shall not save
 */
private class MyPageManagerProvider extends DefaultPageManagerProvider {

private MyPageManagerProvider(Application application) {
super(application);
}


@Override
protected IDataStore newDataStore() {
// guardamos tod o en memoria
return new HttpSessionDataStore(new DefaultPageManagerContext(), 
new PageNumberEvictionStrategy(0));
}

}

}


/**/

/**
 * Web Page
 */
public class MyPage extends WebPage {

    @Override
    protected void setHeaders(WebResponse response) {
    super.setHeaders(response);
    response.setHeader("X-Frame-Options","deny"); // Avoid  IFRFAMES
    response.setHeader("Cache-Control", 
"no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0");
    response.setHeader("Expires","0");
    response.setHeader("Pragma", "no-cache");
    response.disableCaching();
    }

}




> > > Oscar Besga Arcauz  < < < 
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org