Re: SV: LDAP and EJBs

2001-07-15 Thread Magnus Rydin

Another try..

OK.. fourth try to get this posted on the OI list..

The LdapDelegate session bean proposed by Patrik would probably have to
implement SessionSynchronization and take care of the rollback in the
afterCompletion(boolean successfull) method. Just make sure that you keep
track of if an entry has been written or not.

That would leave us with something like:
snip
LdapDelegateEJB implements SessionBean, SessionSynchronization {
...
public void writeLdapEntry(){
...
entryWritten=true;
}
public void afterCompletion(boolean successfull){
if(!successfull){
if(entryWritten){
//clean-up the made
}
}
}
...
}
 /snip

For an example, check out the good old ATM sample's
UserManagementSessionEJB.
WR

- Original Message -
From: Joni Suominen [EMAIL PROTECTED]
To: Orion-Interest [EMAIL PROTECTED]
Sent: Tuesday, July 10, 2001 9:29 AM
Subject: Re: SV: LDAP and EJBs


Thanks Patrik!
There's one issue which still puzzles me. Do I have to write my own
rollback code for LDAP operations when a transaction rolls back? I
browsed the JNDI API and SPI and I couldn't figure out if JNDI somehow
supports transactions (like JDBC does with begin(), rollback() and
commit()).

If my code is following for instance:

UpdatingFacadeEJB implements SessionBean {
public void doTheUpdate() {
   ldapDelegate.writeLdapEntry();
   rdbmsDelegate.writeRdbmsRow();
}
}

Let's say that ldapDelegate.writeLdapEntry() succeeds but
rdbmsDelegate.writeRdbmsRow() fails by throwing an EJBException. In this
case can the container's transaction manager somehow rollback the LDAP
operations done earlier in ldapDelegate.writeLdapEntry() method?

--
Joni
[EMAIL PROTECTED]


 Patrik Andersson wrote:

 You would have one sessionbean being business delegate in front of the
 EntityBean manipulating the RDBMS and another managing the LDAP
 directory service. Then you would have a Facade in front of both these
 sessionbeans with one method that does the whole trick with
 transactional attributes set up to require a transaction before
 entering the method.

 interface UpdatingFacade : SessionBean {
   void doTheUpdate() throws RemoteException;
 }

 interface LdapDelegate : SessionBean {
   void writeLdapEntry() throws RemoteException;
 }

 interface RdbmsDelegate : SessionBean or EntityBean {
   void writeRdbmsRow() throws RemoteException;
 }

 Then you want an error in the writeLdapEntry() aswell as the
 writeRdbmsRow() to throw an EJBException breaking the transaction
 begun by doTheUpdate() method. Both writeXxx methods must require that
 a transaction already exists before being called. The doTheUpdate()
 method  can really have it either way, as long as there is an active
 transaction associated to the thread calling it.

 regards,
 Patrik Andersson

 -Ursprungligt meddelande-
 Från: Joni Suominen [mailto:[EMAIL PROTECTED]]
 Skickat: den 6 juli 2001 08:32
 Till: Orion-Interest
 Ämne: LDAP and EJBs

 Hi everyone!
 I have a use case where I need to interface an LDAP directory and a
 relational database within a same transaction. That is, to create a
 new
 row to RDBMS from session bean using entity bean and to create an LDAP

 entry from the same session bean using Sun's LDAP provider through
 JNDI.

 1. Is this possible?

 2. Can I use container managed transactions?

 Thanks a lot!

 --
 Joni
 [EMAIL PROTECTED]






Re: SV: LDAP and EJBs

2001-07-10 Thread Joni Suominen

Thanks Patrik!
There's one issue which still puzzles me. Do I have to write my own
rollback code for LDAP operations when a transaction rolls back? I
browsed the JNDI API and SPI and I couldn't figure out if JNDI somehow
supports transactions (like JDBC does with begin(), rollback() and
commit()).

If my code is following for instance:

UpdatingFacadeEJB implements SessionBean {
public void doTheUpdate() {
   ldapDelegate.writeLdapEntry();
   rdbmsDelegate.writeRdbmsRow();
}
}

Let's say that ldapDelegate.writeLdapEntry() succeeds but
rdbmsDelegate.writeRdbmsRow() fails by throwing an EJBException. In this
case can the container's transaction manager somehow rollback the LDAP
operations done earlier in ldapDelegate.writeLdapEntry() method?

-- 
Joni
[EMAIL PROTECTED]


 Patrik Andersson wrote:
 
 You would have one sessionbean being business delegate in front of the
 EntityBean manipulating the RDBMS and another managing the LDAP
 directory service. Then you would have a Facade in front of both these
 sessionbeans with one method that does the whole trick with
 transactional attributes set up to require a transaction before
 entering the method.
 
 interface UpdatingFacade : SessionBean {
   void doTheUpdate() throws RemoteException;
 }
 
 interface LdapDelegate : SessionBean {
   void writeLdapEntry() throws RemoteException;
 }
 
 interface RdbmsDelegate : SessionBean or EntityBean {
   void writeRdbmsRow() throws RemoteException;
 }
 
 Then you want an error in the writeLdapEntry() aswell as the
 writeRdbmsRow() to throw an EJBException breaking the transaction
 begun by doTheUpdate() method. Both writeXxx methods must require that
 a transaction already exists before being called. The doTheUpdate()
 method  can really have it either way, as long as there is an active
 transaction associated to the thread calling it.
 
 regards,
 Patrik Andersson
 
 -Ursprungligt meddelande-
 Från: Joni Suominen [mailto:[EMAIL PROTECTED]]
 Skickat: den 6 juli 2001 08:32
 Till: Orion-Interest
 Ämne: LDAP and EJBs
 
 Hi everyone!
 I have a use case where I need to interface an LDAP directory and a
 relational database within a same transaction. That is, to create a
 new
 row to RDBMS from session bean using entity bean and to create an LDAP
 
 entry from the same session bean using Sun's LDAP provider through
 JNDI.
 
 1. Is this possible?
 
 2. Can I use container managed transactions?
 
 Thanks a lot!
 
 --
 Joni
 [EMAIL PROTECTED]




SV: LDAP and EJBs

2001-07-09 Thread Patrik Andersson
Title: SV: LDAP and EJBs





You would have one sessionbean being business delegate in front of the EntityBean manipulating the RDBMS and another managing the LDAP directory service. Then you would have a Facade in front of both these sessionbeans with one method that does the whole trick with transactional attributes set up to require a transaction before entering the method.

interface UpdatingFacade : SessionBean {
 void doTheUpdate() throws RemoteException;
}


interface LdapDelegate : SessionBean {
 void writeLdapEntry() throws RemoteException;
}


interface RdbmsDelegate : SessionBean or EntityBean {
 void writeRdbmsRow() throws RemoteException;
}


Then you want an error in the writeLdapEntry() aswell as the writeRdbmsRow() to throw an EJBException breaking the transaction begun by doTheUpdate() method. Both writeXxx methods must require that a transaction already exists before being called. The doTheUpdate() method can really have it either way, as long as there is an active transaction associated to the thread calling it.

regards,
Patrik Andersson


-Ursprungligt meddelande-
Från: Joni Suominen [mailto:[EMAIL PROTECTED]]
Skickat: den 6 juli 2001 08:32
Till: Orion-Interest
Ämne: LDAP and EJBs



Hi everyone!
I have a use case where I need to interface an LDAP directory and a
relational database within a same transaction. That is, to create a new
row to RDBMS from session bean using entity bean and to create an LDAP
entry from the same session bean using Sun's LDAP provider through JNDI.


1. Is this possible?


2. Can I use container managed transactions?


Thanks a lot! 


-- 
Joni
[EMAIL PROTECTED]





LDAP and EJBs

2001-07-06 Thread Joni Suominen

Hi everyone!
I have a use case where I need to interface an LDAP directory and a
relational database within a same transaction. That is, to create a new
row to RDBMS from session bean using entity bean and to create an LDAP
entry from the same session bean using Sun's LDAP provider through JNDI.

1. Is this possible?

2. Can I use container managed transactions?

Thanks a lot! 

-- 
Joni
[EMAIL PROTECTED]