[jboss-cvs] JBossAS SVN: r99344 - in projects/jboss-jca/trunk/deployers/src: test/java/org/jboss/jca/test/deployers/spec and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 13 11:20:24 EST 2010
Author: jesper.pedersen
Date: 2010-01-13 11:20:23 -0500 (Wed, 13 Jan 2010)
New Revision: 99344
Modified:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Annotations.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java
Log:
[JBJCA-258] Bind connection factories into JNDI (Part 1)
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Annotations.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Annotations.java 2010-01-13 14:51:43 UTC (rev 99343)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Annotations.java 2010-01-13 16:20:23 UTC (rev 99344)
@@ -1008,6 +1008,7 @@
* @return The fully qualified classname
* @exception ClassNotFoundException Thrown if a class cannot be found
*/
+ @SuppressWarnings("unchecked")
private String getConfigPropertyType(Annotation annotation)
throws ClassNotFoundException
{
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2010-01-13 14:51:43 UTC (rev 99343)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2010-01-13 16:20:23 UTC (rev 99344)
@@ -44,6 +44,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
+import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
@@ -54,6 +55,11 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.Referenceable;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ResourceAdapter;
@@ -75,6 +81,7 @@
import org.jboss.papaki.AnnotationRepository;
import org.jboss.papaki.AnnotationScanner;
import org.jboss.papaki.AnnotationScannerFactory;
+import org.jboss.util.naming.Util;
/**
* The RA deployer for JCA/SJC
@@ -356,6 +363,16 @@
// ConnectionFactory
Object cf = mcf.createConnectionFactory(new NoTxConnectionManager());
archiveValidationObjects.add(new ValidateObject(Key.CONNECTION_FACTORY, cf));
+
+ if (cdMetas.size() == 1)
+ {
+ String jndiName = f.getName().substring(0, f.getName().indexOf(".rar"));
+ bindConnectionFactory(jndiName, (Serializable)cf);
+ }
+ else
+ {
+ log.warn("NYI: There are multiple connection factories for: " + f.getName());
+ }
}
}
}
@@ -545,6 +562,7 @@
* @param resourceAdapter The resource adapter
* @throws DeployException Thrown if the resource adapter cant be started
*/
+ @SuppressWarnings("unchecked")
private void startContext(ResourceAdapter resourceAdapter) throws DeployException
{
try
@@ -573,6 +591,7 @@
* @param associationObjects The list of possible objects
* @throws DeployException Thrown if the resource adapter cant be started
*/
+ @SuppressWarnings("unchecked")
private void associateResourceAdapter(ResourceAdapter resourceAdapter,
List<Object> associationObjects)
throws DeployException
@@ -664,6 +683,24 @@
}
/**
+ * Bind connection factory into JNDI
+ * @param name The JNDI name
+ * @param cf The connection factory
+ * @exception Thrown if an error occurs
+ */
+ private void bindConnectionFactory(String name, Serializable cf) throws Exception
+ {
+ Context context = new InitialContext();
+
+ Util.bind(context, "java:/eis/" + name, cf);
+
+ Referenceable referenceable = (Referenceable)cf;
+ Reference ref = null;
+
+ referenceable.setReference(ref);
+ }
+
+ /**
* Clone
* @return The copy of the object
* @exception CloneNotSupportedException Thrown if a copy can't be created
Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java 2010-01-13 14:51:43 UTC (rev 99343)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java 2010-01-13 16:20:23 UTC (rev 99344)
@@ -27,6 +27,10 @@
import java.io.File;
import java.net.URL;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import org.jboss.logging.Logger;
import org.junit.AfterClass;
@@ -49,6 +53,8 @@
private static Logger log = Logger.getLogger(RarTestCase.class);
+ private static final String JNDI_PREFIX = "java:/eis/";
+
/*
* Embedded
*/
@@ -66,10 +72,19 @@
public void testRa10dtdout() throws Throwable
{
URL archive = getURL("ra10dtdout.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ /*
+ TODO
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra10dtdout");
+ assertNotNull(o);
+ */
}
catch (Throwable t)
{
@@ -78,6 +93,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -90,10 +117,15 @@
public void testRa15dtdinout() throws Throwable
{
URL archive = getURL("ra15dtdinout.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra15dtdinout");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -102,6 +134,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -114,10 +158,15 @@
public void testRa15inoutjbossra() throws Throwable
{
URL archive = getURL("ra15inoutjbossra.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra15inoutjbossra");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -126,6 +175,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -138,10 +199,15 @@
public void testRa15inout() throws Throwable
{
URL archive = getURL("ra15inout.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra15inout");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -150,6 +216,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -162,10 +240,15 @@
public void testRa15outjbossradefaultns() throws Throwable
{
URL archive = getURL("ra15outjbossradefaultns.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra15outjbossradefaultns");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -174,6 +257,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -186,10 +281,15 @@
public void testRa15outjbossra() throws Throwable
{
URL archive = getURL("ra15outjbossra.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra15outjbossra");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -198,6 +298,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -210,10 +322,15 @@
public void testRa15out() throws Throwable
{
URL archive = getURL("ra15out.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra15out");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -222,6 +339,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -234,10 +363,15 @@
public void testRa16dtdinout() throws Throwable
{
URL archive = getURL("ra16dtdinout.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16dtdinout");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -246,6 +380,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -258,10 +404,19 @@
public void testRa16inoutanno() throws Throwable
{
URL archive = getURL("ra16inoutanno.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ /*
+ TODO - as there are multiple connection factories
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16inoutanno");
+ assertNotNull(o);
+ */
}
catch (Throwable t)
{
@@ -270,6 +425,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -282,10 +449,15 @@
public void testRa16inoutmultianno() throws Throwable
{
URL archive = getURL("ra16inoutmultianno.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16inoutmultianno");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -294,6 +466,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -306,10 +490,15 @@
public void testRa16inoutjar() throws Throwable
{
URL archive = getURL("ra16inoutjar.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16inoutjar");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -318,6 +507,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -330,10 +531,15 @@
public void testRa16inoutjbossra() throws Throwable
{
URL archive = getURL("ra16inoutjbossra.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16inoutjbossra");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -342,6 +548,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -354,10 +572,15 @@
public void testRa16inoutnora() throws Throwable
{
URL archive = getURL("ra16inoutnora.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16inoutnora");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -366,6 +589,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -378,10 +613,15 @@
public void testRa16inoutoverwrite() throws Throwable
{
URL archive = getURL("ra16inoutoverwrite.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16inoutoverwrite");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -390,6 +630,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -402,10 +654,15 @@
public void testRa16inout() throws Throwable
{
URL archive = getURL("ra16inout.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16inout");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -414,6 +671,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -426,10 +695,15 @@
public void testRa16outjbossradefaultns() throws Throwable
{
URL archive = getURL("ra16outjbossradefaultns.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16outjbossradefaultns");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -438,6 +712,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -450,10 +736,15 @@
public void testRa16outjbossra() throws Throwable
{
URL archive = getURL("ra16outjbossra.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16outjbossra");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -462,6 +753,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -474,10 +777,15 @@
public void testRa16outnora() throws Throwable
{
URL archive = getURL("ra16outnora.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16outnora");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -486,6 +794,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -498,10 +818,15 @@
public void testRa16out() throws Throwable
{
URL archive = getURL("ra16out.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16out");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -510,6 +835,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -522,10 +859,15 @@
public void testRa16standard303jbossra() throws Throwable
{
URL archive = getURL("ra16standard303jbossra.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16standard303jbossra");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -534,6 +876,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -546,10 +900,15 @@
public void testRa16standard303() throws Throwable
{
URL archive = getURL("ra16standard303.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16standard303");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -558,6 +917,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -594,10 +965,15 @@
public void testRa16user303() throws Throwable
{
URL archive = getURL("ra16user303.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16user303");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -606,6 +982,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -618,10 +1006,15 @@
public void testRa16annoconfprop() throws Throwable
{
URL archive = getURL("ra16annoconfprop.rar");
-
+ Context context = null;
+
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16annoconfprop");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -630,6 +1023,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
@@ -642,10 +1047,15 @@
public void testRa16asso() throws Throwable
{
URL archive = getURL("ra16asso.rar");
+ Context context = null;
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra16asso");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -654,6 +1064,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(archive);
}
}
More information about the jboss-cvs-commits
mailing list