[jboss-cvs] JBossAS SVN: r108056 - in projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core: spi/mdr and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 8 17:02:24 EDT 2010
Author: jesper.pedersen
Date: 2010-09-08 17:02:24 -0400 (Wed, 08 Sep 2010)
New Revision: 108056
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java
Log:
[JBJCA-404] Root and JNDI information
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java 2010-09-08 20:50:20 UTC (rev 108055)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java 2010-09-08 21:02:24 UTC (rev 108056)
@@ -27,8 +27,13 @@
import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.mdr.NotFoundException;
+import java.io.File;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -43,18 +48,26 @@
/** Resource adapter templates */
private ConcurrentMap<URL, Connector> raTemplates;
+ /** Resource adapter roots */
+ private ConcurrentMap<URL, File> raRoots;
+
+ /** JNDI mappings */
+ private ConcurrentMap<URL, Map<String, List<String>>> jndiMappings;
+
/**
* Constructor
*/
public SimpleMetadataRepository()
{
this.raTemplates = new ConcurrentHashMap<URL, Connector>();
+ this.raRoots = new ConcurrentHashMap<URL, File>();
+ this.jndiMappings = new ConcurrentHashMap<URL, Map<String, List<String>>>();
}
/**
* {@inheritDoc}
*/
- public void registerResourceAdapter(URL deployment, Connector md) throws AlreadyExistsException
+ public void registerResourceAdapter(URL deployment, File root, Connector md) throws AlreadyExistsException
{
if (deployment == null)
throw new IllegalArgumentException("Deployment is null");
@@ -66,6 +79,7 @@
throw new AlreadyExistsException(deployment + " already registered");
raTemplates.put(deployment, md);
+ raRoots.put(deployment, root);
}
/**
@@ -106,4 +120,101 @@
{
return Collections.unmodifiableSet(raTemplates.keySet());
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getRoot(URL deployment) throws NotFoundException
+ {
+ if (deployment == null)
+ throw new IllegalArgumentException("Deployment is null");
+
+ if (!raRoots.containsKey(deployment))
+ throw new NotFoundException(deployment + " isn't registered");
+
+ return raRoots.get(deployment);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void registerJndiMapping(URL deployment, String clz, String jndi)
+ {
+ if (deployment == null)
+ throw new IllegalArgumentException("Deployment is null");
+
+ if (clz == null)
+ throw new IllegalArgumentException("Clz is null");
+
+ if (jndi == null)
+ throw new IllegalArgumentException("Jndi is null");
+
+ Map<String, List<String>> mappings = jndiMappings.get(deployment);
+ if (mappings == null)
+ {
+ Map<String, List<String>> newMappings = new HashMap<String, List<String>>(1);
+ mappings = jndiMappings.putIfAbsent(deployment, newMappings);
+
+ if (mappings == null)
+ {
+ mappings = newMappings;
+ }
+ }
+
+ List<String> l = mappings.get(clz);
+
+ if (l == null)
+ l = new ArrayList<String>(1);
+
+ l.add(jndi);
+ mappings.put(clz, l);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void unregisterJndiMapping(URL deployment, String clz, String jndi)
+ {
+ if (deployment == null)
+ throw new IllegalArgumentException("Deployment is null");
+
+ if (clz == null)
+ throw new IllegalArgumentException("Clz is null");
+
+ if (jndi == null)
+ throw new IllegalArgumentException("Jndi is null");
+
+ Map<String, List<String>> mappings = jndiMappings.get(deployment);
+
+ if (mappings != null)
+ {
+ List<String> l = mappings.get(clz);
+
+ if (l != null)
+ {
+ l.remove(jndi);
+
+ if (l.size() == 0)
+ {
+ mappings.remove(clz);
+ }
+ }
+
+ if (mappings.size() == 0)
+ {
+ jndiMappings.remove(deployment);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<String, List<String>> getJndiMappings(URL deployment)
+ {
+ if (deployment == null)
+ throw new IllegalArgumentException("Deployment is null");
+
+ return jndiMappings.get(deployment);
+ }
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java 2010-09-08 20:50:20 UTC (rev 108055)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java 2010-09-08 21:02:24 UTC (rev 108056)
@@ -24,7 +24,10 @@
import org.jboss.jca.common.api.metadata.ra.Connector;
+import java.io.File;
import java.net.URL;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -37,10 +40,11 @@
/**
* Register a resource adapter template
* @param deployment The deployment
+ * @param root The deployment root
* @param md The metadata
* @exception AlreadyExistsException Thrown if the deployment is already registered
*/
- public void registerResourceAdapter(URL deployment, Connector md) throws AlreadyExistsException;
+ public void registerResourceAdapter(URL deployment, File root, Connector md) throws AlreadyExistsException;
/**
* Unregister a resource adapter template
@@ -62,4 +66,35 @@
* @return The names of the deployments
*/
public Set<URL> getResourceAdapters();
+
+ /**
+ * Get the root for a resource adapter deployment
+ * @param deployment The deployment
+ * @return The root
+ * @exception NotFoundException Thrown if the deployment isn't registered
+ */
+ public File getRoot(URL deployment) throws NotFoundException;
+
+ /**
+ * Register a JNDI mapping for a deployment
+ * @param deployment The deployment
+ * @param clz The fully qualified class name
+ * @param jndi The JNDI name
+ */
+ public void registerJndiMapping(URL deployment, String clz, String jndi);
+
+ /**
+ * Unregister a JNDI mapping for a deployment
+ * @param deployment The deployment
+ * @param clz The fully qualified class name
+ * @param jndi The JNDI name
+ */
+ public void unregisterJndiMapping(URL deployment, String clz, String jndi);
+
+ /**
+ * Get the JNDI mappings for a deployment
+ * @param deployment The deployment
+ * @return The mappings
+ */
+ public Map<String, List<String>> getJndiMappings(URL deployment);
}
More information about the jboss-cvs-commits
mailing list