-
1. Re: What data source is my CMP bound to?
sviluppatorefico Feb 27, 2005 10:48 AM (in response to feigling)hi feigling.....I guess you need to know a manner to get the datasource jndiname of an entity. Then if you are in your junit test application you can do this:
String jndiName = " ...... jndi name of your entity.......";
ObjectName name = new ObjectName("jndiName="+jndiName+",service=EJB");
InitialContext ic = new InitialContext();
RMIAdaptor server = (RMIAdaptor)lookup("jmx/rmi/RMIAdaptor");
String[] sig = {};
Object[] opArgs = {};
JDBCEntityMetaData jamd = new JDBCEntityMetadata(
server.invoke(name,"getBeanMetaData().getApplicationMetaData())",opArgs,sig),
server.invoke(name,"getClassLoader()",opArgs,sig)
); -
2. Re: What data source is my CMP bound to?
sviluppatorefico Feb 27, 2005 10:50 AM (in response to feigling)sorry ...i continue.....
String dataSource = jamd.getDataSource();
if your application test is an mbean you can put off the part of lookup jmx and you can to write so:
MBeanServer server = this.getServer();
instead of:
RMIAdaptor server = (RMIAdaptor)lookup("jmx/rmi/RMIAdaptor"); -
3. Re: What data source is my CMP bound to?
feigling Feb 28, 2005 2:56 PM (in response to feigling)Hello sviluppatorefico!
Thanks for the help, but I'm still having problems. In the code you gave me, the returned type for the 'name' ObjectName var is org.jboss.ejb.EntityContainer, which does not contain a getBeanMetaData() method, so it throws a ReflectionException. There is a getEJBMetaData() method, but that's just an EJB interface. I didn't see anything in the interface that could get me to a BeanMetaData interface. Perhaps you left something out? -
4. Re: What data source is my CMP bound to?
feigling Feb 28, 2005 3:52 PM (in response to feigling)Hello again,
Well, I figured out the BeanMetaData issue. BeanMetaData is just an attribute of the EntityContainer instance.
I couldn't get a ClassLoader from the EntityContainer though - no getClass(), no getClassLoader(). I created a JDBCEntityMetaData object using the ClassLoader from the EntityMetaData attribute and managed to create an instance of JDBCEntityMetaData, but the getDataSource() method returns null.
Any ideas? -
5. Re: What data source is my CMP bound to?
feigling Mar 2, 2005 6:29 PM (in response to feigling)So no one out there knows how to do this? Anyone?