JBoss Community

Custom resource adapter and MDB

created by Takayoshi Kimura in JBoss AS7 Development - View the full discussion

Hi,

 

I'm using AS7 head (7.1.0.Alpha1-SNAPSHOT) and I've created a basic resource adapter for twitter and an MDB. The files are twitter-ra.rar and twittermdb.jar. My code is hosted at GitHub https://github.com/nekop/twitter-resource-adapter .

 

There are 2 issues in EJBUtilities.

 

1. When I put those files in the standalone/deployment directory the MDB deployment failed with the following exception:

 

java.lang.IllegalStateException: Not found RA registered as twitter-ra

 

EJBUtilities tries to find a corresponding rar in the following way:

 

for (String id : getMdr().getResourceAdapters()) {
    if (getMdr().getRoot(id).getName().indexOf(resourceAdapterName) != -1) {

 

but this doesn't work because the File#getName() method of the deployment root File returns just "content". It's not a rar name.

 

2. @ResourceAdapter("twitter-ra.rar") doesn't work but @ResourceAdapter("twitter-ra") works

 

Because the resource adapter id is "twitter-ra". I thought we support both with and without ".rar".

 

What's the design behind the current logic? Could it be a problem if we replaced the code with the following?

 

String resourceAdapterId =
    resourceAdapterName.endsWith(".rar") ?
    resourceAdapterName.substring(0, resourceAdapterName.length() - ".rar".length()) :
    resourceAdapterName;
if (!raFound && getMdr().getResourceAdapter(resourceAdapterId) != null) {
    ResourceAdapter ra = getMdr().getResourceAdapter(resourceAdapterId).getResourceadapter();
    if (ra instanceof ResourceAdapter1516
        && ((ResourceAdapter1516) ra).getInboundResourceadapter() != null) {
        String className = ((ResourceAdapter1516) ra).getResourceadapterClass();
        if (className.lastIndexOf(".") != -1)
            packageName = className.substring(0, className.lastIndexOf("."));
        else
            packageName = "";
        raFound = true;
    }
} 

 

Thanks,

Takayoshi

Reply to this message by going to Community

Start a new discussion in JBoss AS7 Development at Community