[jboss-cvs] JBossAS SVN: r112320 - in projects/jboss-jca/branches/Branch_1_0: doc/samples/helloworld and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 12 14:17:32 EDT 2011
Author: jesper.pedersen
Date: 2011-10-12 14:17:32 -0400 (Wed, 12 Oct 2011)
New Revision: 112320
Modified:
projects/jboss-jca/branches/Branch_1_0/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/build.xml
projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java
projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/resources/logging.properties
Log:
[JBJCA-681] Resource adapters with native libraries fails
Modified: projects/jboss-jca/branches/Branch_1_0/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/branches/Branch_1_0/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2011-10-12 18:11:27 UTC (rev 112319)
+++ projects/jboss-jca/branches/Branch_1_0/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2011-10-12 18:17:32 UTC (rev 112320)
@@ -85,11 +85,15 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import javax.resource.Referenceable;
import javax.resource.ResourceException;
@@ -908,6 +912,89 @@
}
/**
+ * Load native libraries
+ * @param root The deployment root
+ */
+ private void loadNativeLibraries(File root)
+ {
+ if (root != null && root.exists())
+ {
+ List<String> libs = null;
+
+ if (root.isDirectory())
+ {
+ for (File f : root.listFiles())
+ {
+ String fileName = f.getName().toLowerCase(Locale.US);
+ if (fileName.endsWith(".a") || fileName.endsWith(".so") || fileName.endsWith(".dll"))
+ {
+ if (libs == null)
+ libs = new ArrayList<String>();
+
+ libs.add(f.getAbsolutePath());
+ }
+ }
+ }
+ else
+ {
+ JarFile jarFile = null;
+ try
+ {
+ jarFile = new JarFile(root);
+ Enumeration<JarEntry> entries = jarFile.entries();
+
+ while (entries.hasMoreElements())
+ {
+ JarEntry jarEntry = entries.nextElement();
+ String entryName = jarEntry.getName().toLowerCase(Locale.US);
+ if (entryName.endsWith(".a") || entryName.endsWith(".so") || entryName.endsWith(".dll"))
+ {
+ if (libs == null)
+ libs = new ArrayList<String>();
+
+ libs.add(jarEntry.getName());
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ log.debugf("Unable to load native libraries from: %s", root.getAbsolutePath());
+ }
+ finally
+ {
+ if (jarFile != null)
+ {
+ try
+ {
+ jarFile.close();
+ }
+ catch (IOException ioe)
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+
+ if (libs != null)
+ {
+ for (String lib : libs)
+ {
+ try
+ {
+ System.load(lib);
+ log.debugf("Loaded library: %s", lib);
+ }
+ catch (Throwable t)
+ {
+ log.debugf("Unable to load library: %s", lib);
+ }
+ }
+ }
+ }
+ }
+
+ /**
*
* create objects and inject value for this depployment. it is a general method returning a {@link CommonDeployment}
* to be used to exchange objects needed to real injection in the container
@@ -995,6 +1082,10 @@
log.tracef("ActivateDeployment=%s", activateDeployment);
}
+ // Load native libraries
+ if (activateDeployment)
+ loadNativeLibraries(root);
+
// Create objects and inject values
if (cmd != null)
{
Modified: projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/build.xml
===================================================================
--- projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/build.xml 2011-10-12 18:11:27 UTC (rev 112319)
+++ projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/build.xml 2011-10-12 18:17:32 UTC (rev 112320)
@@ -135,6 +135,7 @@
<jvmarg line="${junit.jvm.options}"/>
<sysproperty key="archives.dir" value="${target.dir}"/>
+ <sysproperty key="reports.dir" value="${basedir}/reports"/>
<sysproperty key="java.util.logging.manager" value="org.jboss.logmanager.LogManager"/>
<sysproperty key="log4j.defaultInitOverride" value="true"/>
<sysproperty key="org.jboss.logging.Logger.pluginClass"
Modified: projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java
===================================================================
--- projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java 2011-10-12 18:11:27 UTC (rev 112319)
+++ projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java 2011-10-12 18:17:32 UTC (rev 112320)
@@ -26,7 +26,7 @@
import javax.annotation.Resource;
-import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -71,12 +71,13 @@
HelloWorldConnection.class,
HelloWorldConnectionImpl.class);
raa.addAsLibrary(ja);
+ raa.addAsManifestResource("META-INF/ironjacamar.xml", "ironjacamar.xml");
return raa;
}
/** resource */
- @Resource(mappedName = "java:/eis/ConnectorTestCase")
+ @Resource(mappedName = "java:/eis/HelloWorld")
private HelloWorldConnectionFactory connectionFactory;
/**
Modified: projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/resources/logging.properties
===================================================================
--- projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/resources/logging.properties 2011-10-12 18:11:27 UTC (rev 112319)
+++ projects/jboss-jca/branches/Branch_1_0/doc/samples/helloworld/src/test/resources/logging.properties 2011-10-12 18:17:32 UTC (rev 112320)
@@ -30,7 +30,7 @@
handler.FILE.level=${iron.jacamar.log.file.level:DEBUG}
handler.FILE.properties=autoFlush,fileName
handler.FILE.autoFlush=true
-handler.FILE.fileName=${test.dir}/deployers/test.log
+handler.FILE.fileName=${reports.dir}/test.log
handler.FILE.formatter=PATTERN
# Formatter pattern configuration
More information about the jboss-cvs-commits
mailing list