Hi,

The JNDI lookup just done for you in normal JavaEE setup as well.
So I think your code is OK.

On Mon, Oct 8, 2012 at 6:24 PM, Dieter Tremel <tre...@tremel-computer.de> wrote:
> I found a different solution I would like to post for discussion:
> I encapsulated the Facade in a LoadableDetachableModel like this:
>> /**
>>  * Model for JPA facade beans.
>>  * @author Dieter Tremel <tre...@tremel-computer.de>
>>  */
>> public class EntityFacadeModel<E extends JPAEntity> extends 
>> LoadableDetachableModel<AbstractFacade<E>> {
>>
>>     private Class<? extends JPAEntity> entityClass;
>>
>>     public EntityFacadeModel(Class<? extends JPAEntity> entityClass) {
>>         this.entityClass = entityClass;
>>     }
>>
>>     @Override
>>     protected AbstractFacade<E> load() {
>>         AbstractFacade<E> result = null;
>>         try {
>>             InitialContext ctx = new InitialContext();
>>             result = (AbstractFacade<E>) ctx.lookup("java:module/" + 
>> entityClass.getSimpleName() + "Facade");
>>         } catch (NamingException ex) {
>>             
>> Logger.getLogger(EntityFacadeModel.class.getName()).log(Level.SEVERE, null, 
>> ex);
>>         }
>>         return result;
>>     }
>> }
>
> I hope the JNDI lookup is a not too expensive operation, is it?
>
> In the page I build this like:
>>         EntityDataProvider<Buch> buchProvider = new EntityDataProvider<>(new 
>> EntityFacadeModel<Buch>(Buch.class));
>>         DefaultDataTable<Buch, String> dTable = new 
>> DefaultDataTable<>("datatable", columns, buchProvider, 10);
>
> And in the EntityDataProvider I have overwritten:
>>     @Override
>>     public void detach() {
>>         facadeModel.detach();
>>         super.detach();
>>     }
>
> As a result there are no serialization errors in my trial. The lookup
> will be called once per request.
>
> What do you think?
> Dieter
>
>
> ---------------------------------------------------------------------
> 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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to