RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?
Armin, Thanks for the description. I forgot to mention, I'm using EJBs that I modelled after the OJB sample EJBs. So, for my ODMG save methods, I'm using Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); Where odmg is created by a factory in the ejbCreate method as follows; public class PersistenceManagerBean implements SessionBean { private Implementation odmg; private Database db; ODMGFactory factory = (ODMGFactory)context.lookup(OjbConstants.ODMG_FACTORY_LOOKUP); odmg = factory.getInstance(); db = odmg.newDatabase(); Since the currentTransaction method doesn't appear to have any way to pass in a jdcAlias, I'm not sure how to pass it in in my persist methods. In fact, looking closer at the OJB example EJBs, the save methods don't even use the Database db member, they just use Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); How would I specify the jdcAlias in this case? Thx, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Sunday, August 31, 2003 12:47 AM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, do you mean changing the used DataSource within a transaction or only how to use multiple databases? Only how to use with multiple DataSources (each with a different database login and different privelages). i.e. I've defined multiple DataSources in JBoss. Define for each DataSource a jdbc-connection-descriptor. PB-api: Use the defined jcdAlias name and PBKey to lookup the different DataSources PBKey user_1 = new PBKey(jcdAlias,username, passwd); PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(user_1); ODMG-api: Use jcdAlias name to lookup different DataSources Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase(); db.open(jcdAlias#username#passwd, Database.OPEN_READ_WRITE); see http://db.apache.org/ojb/faq.html (or in shipped docs) sections 'How do I use multiple databases within OJB?' 'Many different database user - How do they login?' 'Needed to put user/password of database connection in repository file?' HTH regards, Armin Thanks, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Saturday, August 30, 2003 5:01 PM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, - Original Message - From: Bates, Alex [EMAIL PROTECTED] To: 'OJB Users List' [EMAIL PROTECTED] Sent: Friday, August 29, 2003 10:31 PM Subject: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hello, I'm using the ODMG/PB APIs in the following situations; in each I need to be able to tell OJB to use a named DataSource (defined in repository_database.xml) other than the default. Any help would be appreciated - do you mean changing the used DataSource within a transaction or only how to use multiple databases? regards, Armin -- Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); -- db = odmg.getDatabase(null); db.deletePersistent(obj); -- PersistenceBroker broker = ((HasBroker) odmg.currentTransaction()).getBroker(); Connection conn = null; try { conn = broker.serviceConnectionManager().getConnection(); } catch (LookupException e) { e.printStackTrace(); } -- // Must mark object as dirty to signal OJB to persist Transaction tx = odmg.currentTransaction(); ((NarrowTransaction)tx).markDirty(obj); --- Thanks! Alex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?
I looked into the relevent OJB source a little, and am curious if this would be a valid solution: Instead of using Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); use Database db = odmg.getDatabase(jcdAlias); db.makePersistent(obj); would this achieve the same thing? Alex -Original Message- From: Alex Bates [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2003 1:21 AM To: OJB Users List; Armin Waibel Subject: RE: How to specify non-default DataSource for ODMG/PB api in different scenarios? Armin, Thanks for the description. I forgot to mention, I'm using EJBs that I modelled after the OJB sample EJBs. So, for my ODMG save methods, I'm using Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); Where odmg is created by a factory in the ejbCreate method as follows; public class PersistenceManagerBean implements SessionBean { private Implementation odmg; private Database db; ODMGFactory factory = (ODMGFactory)context.lookup(OjbConstants.ODMG_FACTORY_LOOKUP); odmg = factory.getInstance(); db = odmg.newDatabase(); Since the currentTransaction method doesn't appear to have any way to pass in a jdcAlias, I'm not sure how to pass it in in my persist methods. In fact, looking closer at the OJB example EJBs, the save methods don't even use the Database db member, they just use Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); How would I specify the jdcAlias in this case? Thx, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Sunday, August 31, 2003 12:47 AM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, do you mean changing the used DataSource within a transaction or only how to use multiple databases? Only how to use with multiple DataSources (each with a different database login and different privelages). i.e. I've defined multiple DataSources in JBoss. Define for each DataSource a jdbc-connection-descriptor. PB-api: Use the defined jcdAlias name and PBKey to lookup the different DataSources PBKey user_1 = new PBKey(jcdAlias,username, passwd); PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(user_1); ODMG-api: Use jcdAlias name to lookup different DataSources Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase(); db.open(jcdAlias#username#passwd, Database.OPEN_READ_WRITE); see http://db.apache.org/ojb/faq.html (or in shipped docs) sections 'How do I use multiple databases within OJB?' 'Many different database user - How do they login?' 'Needed to put user/password of database connection in repository file?' HTH regards, Armin Thanks, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Saturday, August 30, 2003 5:01 PM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, - Original Message - From: Bates, Alex [EMAIL PROTECTED] To: 'OJB Users List' [EMAIL PROTECTED] Sent: Friday, August 29, 2003 10:31 PM Subject: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hello, I'm using the ODMG/PB APIs in the following situations; in each I need to be able to tell OJB to use a named DataSource (defined in repository_database.xml) other than the default. Any help would be appreciated - do you mean changing the used DataSource within a transaction or only how to use multiple databases? regards, Armin -- Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); -- db = odmg.getDatabase(null); db.deletePersistent(obj); -- PersistenceBroker broker = ((HasBroker) odmg.currentTransaction()).getBroker(); Connection conn = null; try { conn = broker.serviceConnectionManager().getConnection(); } catch (LookupException e) { e.printStackTrace(); } -- // Must mark object as dirty to signal OJB to persist Transaction tx = odmg.currentTransaction(); ((NarrowTransaction)tx).markDirty(obj); --- Thanks! Alex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?
do you mean changing the used DataSource within a transaction or only how to use multiple databases? Only how to use with multiple DataSources (each with a different database login and different privelages). i.e. I've defined multiple DataSources in JBoss. Thanks, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Saturday, August 30, 2003 5:01 PM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, - Original Message - From: Bates, Alex [EMAIL PROTECTED] To: 'OJB Users List' [EMAIL PROTECTED] Sent: Friday, August 29, 2003 10:31 PM Subject: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hello, I'm using the ODMG/PB APIs in the following situations; in each I need to be able to tell OJB to use a named DataSource (defined in repository_database.xml) other than the default. Any help would be appreciated - do you mean changing the used DataSource within a transaction or only how to use multiple databases? regards, Armin -- Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); -- db = odmg.getDatabase(null); db.deletePersistent(obj); -- PersistenceBroker broker = ((HasBroker) odmg.currentTransaction()).getBroker(); Connection conn = null; try { conn = broker.serviceConnectionManager().getConnection(); } catch (LookupException e) { e.printStackTrace(); } -- // Must mark object as dirty to signal OJB to persist Transaction tx = odmg.currentTransaction(); ((NarrowTransaction)tx).markDirty(obj); --- Thanks! Alex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to deploy OJB on Jboss 3.2
Armin, I'm not sure about xdoclet - since this requirement just came out in 3.2 would guess not. Unless they have some sort of 'custom' tag that lets you insert your own element. Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2003 12:45 AM To: OJB Users List Subject: Re: How to deploy OJB on Jboss 3.2 Hi Alex, great news! Many thanks. Does xdoclet support the depends element? regards, Armin - Original Message - From: Bates, Alex [EMAIL PROTECTED] To: OJB Users List [EMAIL PROTECTED] Sent: Friday, June 20, 2003 2:49 AM Subject: How to deploy OJB on Jboss 3.2 Armin, Found the fix to get OJB to deploy (without having to redeploy) on JBoss 3.2 with its new classloader scheme. The jboss.xml from db-ojb-1.0.rc2-beans.jar must be modified to this: (the change is a new depends element added in) jboss.xml ?xml version=1.0 encoding=UTF-8? !DOCTYPE jboss PUBLIC -//JBoss//DTD JBOSS//EN http://www.jboss.org/j2ee/dtd/jboss.dtd; jboss enterprise-beans session ejb-nameODMGSessionBean/ejb-name jndi-nameorg.apache.ojb.ejb.ODMGSessionBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ODMGSessionBeanLocal/local-jndi-nam e depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePBSessionBean/ejb-name jndi-nameorg.apache.ojb.ejb.PBSessionBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PBSessionBeanLocal/local-jndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-nameArticleManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.ArticleManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ArticleManagerODMGBeanLocal/local-j ndi- name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-nameArticleManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.ArticleManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.ArticleManagerPBBeanLocal/local-jnd i-na me depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonArticleManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonArticleManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonArticleManagerODMGBeanLocal/l ocal -jndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonArticleManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonArticleManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonArticleManagerPBBeanLocal/loc al-j ndi-name depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonManagerODMGBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonManagerODMGBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonManagerODMGBeanLocal/local-jn di-n ame depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session session ejb-namePersonManagerPBBean/ejb-name jndi-nameorg.apache.ojb.ejb.PersonManagerPBBean/jndi-name local-jndi-nameorg.apache.ojb.ejb.PersonManagerPBBeanLocal/local-jndi -nam e depends optional-attribute-name=Invokerjboss:service=invoker,type=jrmp/depen ds /session /enterprise-beans resource-managers /resource-managers /jboss -Original Message- From: Bates, Alex Sent: Wednesday, June 18, 2003 9:37 PM To: OJB Users List Subject: RE: OJB/JBoss depends on me startup problem - but redeployment works fine! I heard back from the Jboss newsgroup on this one. But not sure exactly how to implement the workaround (Adrian's #3 seems like the best bet). Below is the response from Adrian Bock, JBoss Director of Support - -Original Message- From: Adrian Brock [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 18, 2003 6:42 PM To: [EMAIL PROTECTED] Subject: RE: [JBoss-user] depends on me startup problem - but redeployment works fine! Hi, The changes to the way the transaction manager is deployed have highlighted this problem. The root problem is that an ejb shouldn't be deployed until its declared invokers have started. There are a number of possible workarounds: 1) Make the EJB Deployer depend upon the invoker (no ejbs will be deployed until the invoker starts) 2) Move the transaction manager deployment back into jboss-service.xml (allowing the invoker to start before the scanner starts looking at /deploy) 3) Declare a dependency for each ejb on the invoker(s) in jboss.xml The real fix will be to make (3) automatic. Regards, Adrian Adrian Brock Director of Support Back Office
RE: OJB + commercial JDO ?
Thomas, Thanks for the reply. My question actually stemmed from some others working on the project, who wanted to make sure our solution could integrate if a given client had already purchased a commercial JDO implementation. If we had to do this, I wanted to shield applications sitting on top of OJB from the underlying implementation. Personally, I like OJB's APIs and mapping files better than those put out by the JDO spec. ESPECIALLY your query APIs, I don't want to write any *QL. Well, I'm happy to write SQL, but not OQL, JDOQL, or EJBQL. However, the real need was to be able to integrate with a distributed cache like Tangosol. So I was happy to see Jason McKerr's recent email/blog about integrating OJB + Tangosol! Alex -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, June 01, 2003 11:10 AM To: OJB Users List Subject: Re: OJB + commercial JDO ? Hi Alex, I have no idea what kind of integration you are looking for. If you are using a commercial JDO O/R tool why should you use OJB? Or are you looking for that kind of integration that we did with the OJB JDORI plugin for SUN's JDO RI? If so it depends on the layering of the commercial tool. Maybe it's as easy as for the OJB JDORI plugin. But if there is no clear layering than it will be a lot of work. cheers, Thomas Bates, Alex wrote: Has anyone used OJB with a commercial JDO implementation? (esp. Solar Metric?) If so, could you give an idea of the work required to integrate the two? thanks, Alex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OJB read/write cache - beware the synchronized bottleneck
Has anyone implemented a read/write cache for use with OJB? This article goes over how to implement, and links to some code for ReadWriteLock (and ConcurrentHashMap): http://www.theserverside.com/resources/article.jsp?l=Readers-Writers However, my real question is: would it be possible to implement such a cache for use with the J2EE version of OJB? Since you can't use threads or the threading API, it appears it would not. If that's the case, I supposed the read/write cache would only be able to run in the servlet layer? Alex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]