This content has been marked as final.
Show 4 replies
-
1. Re: CachedConnectionManager API issue
vickyk Feb 5, 2010 11:08 AM (in response to gaohoward)1 of 1 people found this helpfulgaohoward wrote:
As the method setTransactionManagerServiceName(ObjectName), I don't know how to adapt the above code to the new JCA apis. Can you give some advice?We could inject the tm like this
TransactionManager tm = (TransactionManager) getServer().getAttribute(TRANSACTION_MANAGER_OBJECT_NAME
,"TransactionManager");ccm.setTransactionManager(tm);
But this will not help you as the following would not behave well
mbeanServer.invoke(on, "start", new Object[0], new String[0]);
We may land up in code change in the CCM.
Before we take a deep look into it, can you explain what exactly your test case is doing?
-
2. Re: CachedConnectionManager API issue
gaohoward Feb 5, 2010 11:51 AM (in response to vickyk)Hi Vicky,
Thanks for look after my question. JBM 1.x has a test framework to simulate a JBoss server runtime environment. The simulated server can be configured to selectively start a set of services such as
Transactions, Remoting, Datasources, JCA services etc for different tests. The above mentioned method is used to start a JCA service, like:
if (jca)
{
startCachedConnectionManager(CACHED_CONNECTION_MANAGER_OBJECT_NAME);
// DefaultDS specific
startManagedConnectionFactory(DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
startManagedConnectionPool(
DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME,
DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME,
"ByContainer");
startConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME,
true, true, TRANSACTION_MANAGER_OBJECT_NAME,
CachedConnectionManagerMBean.OBJECT_NAME,
DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
startWrapperDataSourceService();
}
where CACHED_CONNECTION_MANAGER_OBJECT_NAME = new ObjectName("jboss.jca:service=CachedConnectionManager");
DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME = new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionFactory");
DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME = new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionPool");
DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME = new ObjectName("jboss.jca:name=DefaultDS,service=LocalTxCM");
TRANSACTION_MANAGER_OBJECT_NAME = new ObjectName("jboss:service=TransactionManager");
My understanding is that it simulates a JCA start up in a JBoss server. This works with AS 4 lib set. Now I need this work with AS 5 too. It turned out AS 5 has changed the API. I don't know how to do it.
I attached the source file (ServiceContainer) that contains the above code piece for your info.
Thanks.-
ServiceContainer.java.zip 11.9 KB
-
-
3. Re: CachedConnectionManager API issue
vickyk Feb 5, 2010 1:28 PM (in response to gaohoward)gaohoward wrote:
My understanding is that it simulates a JCA start up in a JBoss server. This works with AS 4 lib set. Now I need this work with AS 5 too. It turned out AS 5 has changed the API. I don't know how to do it.The code basically plugs in the JCA infrastruture MBeans for the testcase.
You can knock off the following call
mbeanServer.invoke(on, "start", new Object[0], new String[0]);
This basically was calling the startService() operation in 4.x implementation which had been doing thisprotected void startService() throws Exception { tm = (TransactionManager) getServer().getAttribute(transactionManagerServiceName, "TransactionManager"); TransactionSynchronizer.setTransactionManager(tm); ServerVMClientUserTransaction.getSingleton().registerTxStartedListener(this); EnterpriseContext.setUserTransactionStartedListener(this); }
setTransactionManager() on the CachedConnectionManager implenetation, check code
https://svn.jboss.org/repos/jbossas/trunk/connector/src/main/java/org/jboss/resource/connectionmanager/CachedConnectionManager.java
The other parts are knocked off as needed for this
https://jira.jboss.org/jira/browse/JBAS-6159
So what I had pointed before should be helpful, you should knockoff the call on start() operation on the CCM in your testcase.
Also I am wondering if you really need to plugin the CCM, the CCM is used to track the connection taken by the meta-ware objects.
I am not sure if your test case need it, this is what you will have to check.
Go ahead and try the approach which I had suggested and let us know if you see red signal. -
4. Re: CachedConnectionManager API issue
gaohoward Feb 7, 2010 11:17 PM (in response to vickyk)Thanks Vicky, I'll try it.
Howard