|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Prevayler FacadeHi all!
For a project i'm developing i wrote a simple proxy that implements the transactions using annotations. Rigth now, this proxy needs that you implement an interface with the annotations. But the idea is that you define your prevalent object (without any interface) with those annotations. These annotations are the prevayler transactions: @Query @Transaction @TransactionWithQuery An example, following the prevayler demo examples: public interface IBank implements Serializable { @TransactionWithQuery public Account createAccount (String holder) throws Account.InvalidHolder; @Transaction public void deleteAccount(long number) throws AccountNotFound; } The implementation of IBank: public class Bank implements IBank { ... public Account createAccount(String holder) throws Account.InvalidHolder { Account account = new Account(nextAccountNumber, holder); accountsByNumber.put(new Long(nextAccountNumber++), account); if (bankListener != null) bankListener.accountCreated(account); return account; } public void deleteAccount(long number) throws AccountNotFound { Account account = findAccount(number); accountsByNumber.remove(new Long(number)); if (bankListener != null) bankListener.accountDeleted(account); } ... The code remains the same. Generating the proxy is straighforward: Bank bank = PrevaylerProxy.createInstance ( IBank.class, new Bank(), "Bank" ); If you found this is useful (and if possible, of course) i would be glad to contrib with the code. :) Regards Diego -- Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun cuando se tenga en cuenta la Ley de Hofstadter. ------------------------------------------------------------------------------ _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org |
|
|
Re: Prevayler FacadeInteresting.
Void methods without the annotation can default to Transaction. Methods with a return value and without an annotation can default to TransactionWithQuery. So I think you might only need the @Query annotation. It that right? See you, Klaus. On Wed, Jul 22, 2009 at 12:03 PM, Diego Miranda<diego.miranda@...> wrote: > Hi all! > > For a project i'm developing i wrote a simple proxy that implements the > transactions using annotations. > Rigth now, this proxy needs that you implement an interface with the > annotations. But the idea is that you > define your prevalent object (without any interface) with those annotations. > These annotations are the prevayler > transactions: > > @Query > @Transaction > @TransactionWithQuery > > An example, following the prevayler demo examples: > > public interface IBank implements Serializable { > > @TransactionWithQuery public Account createAccount (String holder) > throws Account.InvalidHolder; > @Transaction public void deleteAccount(long number) throws > AccountNotFound; > > } > > The implementation of IBank: > > public class Bank implements IBank { > > ... > public Account createAccount(String holder) throws Account.InvalidHolder > { > Account account = new Account(nextAccountNumber, holder); > accountsByNumber.put(new Long(nextAccountNumber++), account); > > if (bankListener != null) bankListener.accountCreated(account); > return account; > } > > public void deleteAccount(long number) throws AccountNotFound { > Account account = findAccount(number); > accountsByNumber.remove(new Long(number)); > if (bankListener != null) bankListener.accountDeleted(account); > } > ... > > The code remains the same. > > Generating the proxy is straighforward: > > Bank bank = PrevaylerProxy.createInstance ( IBank.class, new Bank(), "Bank" > ); > > If you found this is useful (and if possible, of course) i would be glad to > contrib with the code. :) > > Regards > > Diego > > > > > -- > Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun cuando se > tenga en cuenta la Ley de Hofstadter. > > ------------------------------------------------------------------------------ > > _______________________________________________ > To unsubscribe go to the end of this page: > http://lists.sourceforge.net/lists/listinfo/prevayler-discussion > _______________________________________________ > "Databases in Memoriam" -- http://www.prevayler.org > > ------------------------------------------------------------------------------ _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org |
|
|
Re: Prevayler FacadeThat's right! A @Transaction annotation is enough, then the Proxy can infer the type of transaction. Actually i'm not using a default transaction when the method is not marked. I've been thinking in adding some attributes to the annotations, like encrypt="true" but i havent time to implement this yet.
D. On Wed, Jul 22, 2009 at 1:17 PM, Klaus Wuestefeld <klauswuestefeld@...> wrote: Interesting. -- Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun cuando se tenga en cuenta la Ley de Hofstadter. ------------------------------------------------------------------------------ _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org |
|
|
Re: Prevayler Facade@Transaction or @Query?
On Wed, Jul 22, 2009 at 2:32 PM, Diego Miranda<diego.miranda@...> wrote: > That's right! A @Transaction annotation is enough, then the Proxy can infer > the type of transaction. Actually i'm not using a default transaction when > the method is not marked. I've been thinking in adding some attributes to > the annotations, like encrypt="true" but i havent time to implement this > yet. > > D. > > On Wed, Jul 22, 2009 at 1:17 PM, Klaus Wuestefeld > <klauswuestefeld@...> wrote: >> >> Interesting. >> >> Void methods without the annotation can default to Transaction. >> Methods with a return value and without an annotation can default to >> TransactionWithQuery. >> >> So I think you might only need the @Query annotation. It that right? >> >> See you, Klaus. >> >> >> >> On Wed, Jul 22, 2009 at 12:03 PM, Diego Miranda<diego.miranda@...> >> wrote: >> > Hi all! >> > >> > For a project i'm developing i wrote a simple proxy that implements the >> > transactions using annotations. >> > Rigth now, this proxy needs that you implement an interface with the >> > annotations. But the idea is that you >> > define your prevalent object (without any interface) with those >> > annotations. >> > These annotations are the prevayler >> > transactions: >> > >> > @Query >> > @Transaction >> > @TransactionWithQuery >> > >> > An example, following the prevayler demo examples: >> > >> > public interface IBank implements Serializable { >> > >> > @TransactionWithQuery public Account createAccount (String >> > holder) >> > throws Account.InvalidHolder; >> > @Transaction public void deleteAccount(long number) throws >> > AccountNotFound; >> > >> > } >> > >> > The implementation of IBank: >> > >> > public class Bank implements IBank { >> > >> > ... >> > public Account createAccount(String holder) throws >> > Account.InvalidHolder >> > { >> > Account account = new Account(nextAccountNumber, holder); >> > accountsByNumber.put(new Long(nextAccountNumber++), account); >> > >> > if (bankListener != null) bankListener.accountCreated(account); >> > return account; >> > } >> > >> > public void deleteAccount(long number) throws AccountNotFound { >> > Account account = findAccount(number); >> > accountsByNumber.remove(new Long(number)); >> > if (bankListener != null) bankListener.accountDeleted(account); >> > } >> > ... >> > >> > The code remains the same. >> > >> > Generating the proxy is straighforward: >> > >> > Bank bank = PrevaylerProxy.createInstance ( IBank.class, new Bank(), >> > "Bank" >> > ); >> > >> > If you found this is useful (and if possible, of course) i would be glad >> > to >> > contrib with the code. :) >> > >> > Regards >> > >> > Diego >> > >> > >> > >> > >> > -- >> > Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun >> > cuando se >> > tenga en cuenta la Ley de Hofstadter. >> > >> > >> > ------------------------------------------------------------------------------ >> > >> > _______________________________________________ >> > To unsubscribe go to the end of this page: >> > http://lists.sourceforge.net/lists/listinfo/prevayler-discussion >> > _______________________________________________ >> > "Databases in Memoriam" -- http://www.prevayler.org >> > >> > >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> To unsubscribe go to the end of this page: >> http://lists.sourceforge.net/lists/listinfo/prevayler-discussion >> _______________________________________________ >> "Databases in Memoriam" -- http://www.prevayler.org > > > > -- > Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun cuando se > tenga en cuenta la Ley de Hofstadter. > > ------------------------------------------------------------------------------ > > _______________________________________________ > To unsubscribe go to the end of this page: > http://lists.sourceforge.net/lists/listinfo/prevayler-discussion > _______________________________________________ > "Databases in Memoriam" -- http://www.prevayler.org > > ------------------------------------------------------------------------------ _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org |
|
|
Re: Prevayler FacadeUps ... sorry :P a @Query!
I write it again: The @Query annotation is enough. Actually i'm not using a default transaction when the method is not marked, thus i'm annotating with @Transaction. But this functionality could be changed by a parameter. A @Transaction annotation only is needed if you On Wed, Jul 22, 2009 at 2:36 PM, Klaus Wuestefeld <klauswuestefeld@...> wrote: @Transaction or @Query? -- Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun cuando se tenga en cuenta la Ley de Hofstadter. ------------------------------------------------------------------------------ _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org |
|
|
Re: Prevayler FacadeSorry, im very idiot today. Dont pay attention to the last sentence.
Diego. On Wed, Jul 22, 2009 at 2:54 PM, Diego Miranda <diego.miranda@...> wrote: Ups ... sorry :P a @Query! -- Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun cuando se tenga en cuenta la Ley de Hofstadter. ------------------------------------------------------------------------------ _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org |
| Free embeddable forum powered by Nabble | Forum Help |