[jboss-cvs] JBossAS SVN: r111540 - in projects/jboss-jca/trunk: common/src/main/java/org/jboss/jca/common and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 7 13:03:05 EDT 2011
Author: jesper.pedersen
Date: 2011-06-07 13:03:04 -0400 (Tue, 07 Jun 2011)
New Revision: 111540
Added:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/Util.java
Removed:
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerImpl.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/KeyConnectionAssociation.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/ExplicitJndiStrategy.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/SimpleJndiStrategy.java
projects/jboss-jca/trunk/ivy.xml
Log:
Remove dependency on common-core
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -1,218 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.lang.reflect.UndeclaredThrowableException;
-
-import javax.resource.ResourceException;
-
-import org.jboss.util.NestedThrowable;
-
-/**
- * Thrown to indicate a problem with a resource related operation.
- *
- * <p>
- * Properly displays linked exception (ie. nested exception)
- * when printing the stack trace.
- *
- * @version <tt>$Revision: 76129 $</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- */
-public class JBossResourceException extends ResourceException implements NestedThrowable
-{
- /** The servial version uid*/
- private static final long serialVersionUID = 6614203184612359692L;
-
- /**
- * Rethrow as a resource exception if it is not already
- *
- * @param message the message
- * @param t the original exception
- * @throws ResourceException the resource exception
- */
- public static void rethrowAsResourceException(String message, Throwable t) throws ResourceException
- {
- if (t instanceof ResourceException)
- throw (ResourceException) t;
- else
- throw new JBossResourceException(message, t);
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message.
- *
- * @param msg Detail message.
- */
- public JBossResourceException(final String msg)
- {
- super(msg);
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message and error code.
- *
- * @param msg Detail message.
- * @param code Error code.
- */
- public JBossResourceException(final String msg, final String code)
- {
- super(msg, code);
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message, error code and linked <tt>Exception</tt>.
- *
- * @param msg Detail message.
- * @param code Error code.
- * @param linked Linked <tt>Exception</tt>.
- */
- @SuppressWarnings("deprecation")
- public JBossResourceException(final String msg, final String code, final Throwable linked)
- {
- super(msg, code);
- setLinkedException(process(linked));
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message and linked <tt>Exception</tt>.
- *
- * @param msg Detail message.
- * @param linked Linked <tt>Exception</tt>.
- */
- @SuppressWarnings("deprecation")
- public JBossResourceException(final String msg, final Throwable linked)
- {
- super(msg);
- setLinkedException(process(linked));
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified
- * linked <tt>Exception</tt>.
- *
- * @param linked Linked <tt>Exception</tt>.
- */
- public JBossResourceException(final Throwable linked)
- {
- this(linked.getMessage(), linked);
- }
-
- /**
- * Return the nested <tt>Throwable</tt>.
- *
- * @return Nested <tt>Throwable</tt>.
- */
- @Override
- @SuppressWarnings("deprecation")
- public Throwable getNested()
- {
- return getLinkedException();
- }
-
- /**
- * Return the nested <tt>Throwable</tt>.
- *
- * <p>For JDK 1.4 compatibility.
- *
- * @return Nested <tt>Throwable</tt>.
- */
- @Override
- @SuppressWarnings("deprecation")
- public Throwable getCause()
- {
- return getLinkedException();
- }
-
- /**
- * Returns the composite throwable message.
- *
- * @return The composite throwable message.
- */
- @Override
- @SuppressWarnings("deprecation")
- public String getMessage()
- {
- return NestedThrowable.Util.getMessage(super.getMessage(), getLinkedException());
- }
-
- /**
- * Prints the composite message and the embedded stack trace to the
- * specified print stream.
- *
- * @param stream Stream to print to.
- */
- @Override
- @SuppressWarnings("deprecation")
- public void printStackTrace(final PrintStream stream)
- {
- Exception linked = getLinkedException();
- if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED)
- {
- super.printStackTrace(stream);
- }
- NestedThrowable.Util.print(linked, stream);
- }
-
- /**
- * Prints the composite message and the embedded stack trace to the
- * specified print writer.
- *
- * @param writer Writer to print to.
- */
- @Override
- @SuppressWarnings("deprecation")
- public void printStackTrace(final PrintWriter writer)
- {
- Exception linked = getLinkedException();
- if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED)
- {
- super.printStackTrace(writer);
- }
- NestedThrowable.Util.print(linked, writer);
- }
-
- /**
- * Prints the composite message and the embedded stack trace to
- * <tt>System.err</tt>.
- */
- @Override
- public void printStackTrace()
- {
- printStackTrace(System.err);
- }
-
- private Exception process(Throwable t)
- {
- if (t instanceof Exception)
- {
- return (Exception)t;
- }
- return new UndeclaredThrowableException(t);
- }
-}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -22,7 +22,6 @@
package org.jboss.jca.core.connectionmanager;
-import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.common.api.metadata.common.FlushStrategy;
import org.jboss.jca.core.CoreBundle;
import org.jboss.jca.core.CoreLogger;
@@ -385,8 +384,7 @@
}
catch (InterruptedException ie)
{
- JBossResourceException.rethrowAsResourceException("getManagedConnection retry wait was interrupted " +
- jndiName, ie);
+ throw new ResourceException("getManagedConnection retry wait was interrupted " + jndiName, ie);
}
}
}
@@ -489,8 +487,7 @@
log.trace("Get exception from managedConnectionDisconnected, maybe delist() have problem" + re);
returnManagedConnection(cl, true);
}
- JBossResourceException.rethrowAsResourceException(
- "Unchecked throwable in ManagedConnection.getConnection() cl=" + cl, t);
+ throw new ResourceException("Unchecked throwable in ManagedConnection.getConnection() cl=" + cl, t);
}
// Associate managed connection with the connection
@@ -607,8 +604,7 @@
catch (Throwable t)
{
disconnectManagedConnection(cl);
- JBossResourceException.rethrowAsResourceException("Unchecked throwable in managedConnectionReconnected() cl="
- + cl, t);
+ throw new ResourceException("Unchecked throwable in managedConnectionReconnected() cl=" + cl, t);
}
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerImpl.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerImpl.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -52,7 +52,6 @@
import org.jboss.logging.Logger;
import org.jboss.logging.Messages;
-import org.jboss.util.Strings;
/**
* CacheConnectionManager.
@@ -197,7 +196,7 @@
KeyConnectionAssociation oldKey = (KeyConnectionAssociation) stack.removeLast();
if (trace)
- log.tracef("popped object: %s", Strings.defaultToString(oldKey));
+ log.tracef("popped object: %s", oldKey);
if (!stack.contains(oldKey))
{
@@ -319,7 +318,7 @@
if (stack == null)
{
if (trace)
- log.tracef("new stack for key: %s", Strings.defaultToString(rawKey));
+ log.tracef("new stack for key: %s", rawKey);
stack = new LinkedList<Object>();
currentObjects.set(stack);
@@ -327,7 +326,7 @@
else
{
if (trace)
- log.tracef("old stack for key: %s", Strings.defaultToString(rawKey));
+ log.tracef("old stack for key: %s", rawKey);
}
KeyConnectionAssociation key = new KeyConnectionAssociation(rawKey);
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/KeyConnectionAssociation.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/KeyConnectionAssociation.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/KeyConnectionAssociation.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -28,9 +28,6 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
-import org.jboss.util.Strings;
-
-
/**
* The class <code>KeyConnectionAssociation</code> wraps objects so they may be used in hashmaps
* based on their object identity rather than equals implementation. Used for keys.
@@ -76,7 +73,7 @@
*/
public String toString()
{
- return Strings.defaultToString(metaAwareObject);
+ return metaAwareObject.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(metaAwareObject));
}
/**
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -21,7 +21,6 @@
*/
package org.jboss.jca.core.connectionmanager.listener;
-import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.common.api.metadata.common.FlushStrategy;
import org.jboss.jca.core.CoreBundle;
import org.jboss.jca.core.CoreLogger;
@@ -311,7 +310,7 @@
}
catch (Throwable t)
{
- JBossResourceException.rethrowAsResourceException("Error in delist!", t);
+ throw new ResourceException("Error in delist!", t);
}
}
@@ -416,7 +415,7 @@
}
catch (Throwable t)
{
- JBossResourceException.rethrowAsResourceException("Unfinished local transaction - " +
+ throw new ResourceException("Unfinished local transaction - " +
"error getting local transaction from " + this, t);
}
if (local == null)
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -22,7 +22,6 @@
package org.jboss.jca.core.connectionmanager.pool.mcp;
-import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.CoreBundle;
import org.jboss.jca.core.CoreLogger;
import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
@@ -265,8 +264,7 @@
{
log.throwableWhileAttemptingGetNewGonnection(cl, t);
- JBossResourceException.rethrowAsResourceException("Unexpected throwable while trying " +
- "to create a connection: " + cl, t);
+ throw new ResourceException("Unexpected throwable while trying to create a connection: " + cl, t);
}
}
}
@@ -312,8 +310,7 @@
{
log.throwableWhileAttemptingGetNewGonnection(cl, t);
- JBossResourceException.rethrowAsResourceException("Unexpected throwable while trying to " +
- "create a connection: " + cl, t);
+ throw new ResourceException("Unexpected throwable while trying to create a connection: " + cl, t);
}
}
}
@@ -375,12 +372,11 @@
doDestroy(cl);
cl = null;
- JBossResourceException.rethrowAsResourceException("Unexpected throwable while trying " +
- "to create a connection: " + cl, t);
+ throw new ResourceException("Unexpected throwable while trying to create a connection: " + cl, t);
}
}
- throw new JBossResourceException(bundle.shouldNeverHappen(), new Throwable("STACKTRACE"));
+ throw new ResourceException(bundle.shouldNeverHappen(), new Throwable("STACKTRACE"));
}
/**
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -22,7 +22,6 @@
package org.jboss.jca.core.connectionmanager.pool.mcp;
-import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.CoreBundle;
import org.jboss.jca.core.CoreLogger;
import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
@@ -53,8 +52,6 @@
import org.jboss.logging.Messages;
-import org.jboss.util.UnreachableStatementException;
-
/**
* The internal pool implementation
*
@@ -346,9 +343,7 @@
permits.release();
- JBossResourceException.rethrowAsResourceException("Unexpected throwable while trying to " +
- "create a connection: " + cl, t);
- throw new UnreachableStatementException();
+ throw new ResourceException("Unexpected throwable while trying to create a connection: " + cl, t);
}
}
else
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -21,7 +21,6 @@
*/
package org.jboss.jca.core.connectionmanager.tx;
-import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.CoreBundle;
import org.jboss.jca.core.CoreLogger;
import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
@@ -57,8 +56,6 @@
import org.jboss.logging.Logger;
import org.jboss.logging.Messages;
-import org.jboss.util.NestedRuntimeException;
-import org.jboss.util.NotImplementedException;
/**
* The TxConnectionManager is a JBoss ConnectionManager
@@ -361,7 +358,7 @@
}
catch (Throwable t)
{
- JBossResourceException.rethrowAsResourceException("Error checking for a transaction.", t);
+ throw new ResourceException("Error checking for a transaction.", t);
}
if (trace)
@@ -430,7 +427,7 @@
if (trace)
log.trace("Could not enlist in transaction on entering meta-aware object! " + cl, t);
- throw new JBossResourceException(bundle.notEnlistInTransactionOnEnteringMetaAwareObject(), t);
+ throw new ResourceException(bundle.notEnlistInTransactionOnEnteringMetaAwareObject(), t);
}
}
@@ -466,8 +463,7 @@
// Rethrow the error
if (throwable != null)
{
- JBossResourceException.rethrowAsResourceException(
- "Could not delist resource, probably a transaction rollback? ", throwable);
+ throw new ResourceException("Could not delist resource, probably a transaction rollback?", throwable);
}
}
@@ -539,7 +535,7 @@
}
catch (XAException e)
{
- throw new JBossResourceException(bundle.unableSetXAResourceTransactionTimeout(getJndiName()), e);
+ throw new ResourceException(bundle.unableSetXAResourceTransactionTimeout(getJndiName()), e);
}
}
}
@@ -569,7 +565,7 @@
*/
public int getTransactionTimeout() throws SystemException
{
- throw new NotImplementedException("NYI: getTransactionTimeout()");
+ throw new RuntimeException("NYI: getTransactionTimeout()");
}
/**
@@ -594,7 +590,7 @@
if (t instanceof RollbackException)
throw new IllegalStateException(context + " tx=" + tx + " marked for rollback.");
- throw new NestedRuntimeException(context + " tx=" + tx + " got unexpected error ", t);
+ throw new RuntimeException(context + " tx=" + tx + " got unexpected error ", t);
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/ExplicitJndiStrategy.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/ExplicitJndiStrategy.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/ExplicitJndiStrategy.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -40,7 +40,6 @@
import org.jboss.logging.Logger;
import org.jboss.logging.Messages;
-import org.jboss.util.naming.Util;
/**
* An explicit JNDI strategy that requires a JNDI for each connection factory
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/SimpleJndiStrategy.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/SimpleJndiStrategy.java 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/SimpleJndiStrategy.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -40,7 +40,6 @@
import org.jboss.logging.Logger;
import org.jboss.logging.Messages;
-import org.jboss.util.naming.Util;
/**
* A simple JNDI strategy that bind a single connection factory under the
Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/Util.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/Util.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/naming/Util.java 2011-06-07 17:03:04 UTC (rev 111540)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.naming;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A static utility class for common JNDI operations.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.com
+ */
+ at SuppressWarnings("unchecked")
+class Util
+{
+ private static final Logger log = Logger.getLogger(Util.class);
+
+ /**
+ * Create a subcontext including any intermediate contexts.
+ * @param ctx the parent JNDI Context under which value will be bound
+ * @param name the name relative to ctx of the subcontext.
+ * @return The new or existing JNDI subcontext
+ * @throws javax.naming.NamingException on any JNDI failure
+ */
+ private static Context createSubcontext(Context ctx, String name) throws NamingException
+ {
+ Name n = ctx.getNameParser("").parse(name);
+ return createSubcontext(ctx, n);
+ }
+
+ /**
+ * Create a subcontext including any intermediate contexts.
+ * @param ctx the parent JNDI Context under which value will be bound
+ * @param name the name relative to ctx of the subcontext.
+ * @return The new or existing JNDI subcontext
+ * @throws NamingException on any JNDI failure
+ */
+ private static Context createSubcontext(Context ctx, Name name) throws NamingException
+ {
+ Context subctx = ctx;
+ for (int pos = 0; pos < name.size(); pos++)
+ {
+ String ctxName = name.get(pos);
+ try
+ {
+ subctx = (Context) ctx.lookup(ctxName);
+ }
+ catch (NameNotFoundException e)
+ {
+ subctx = ctx.createSubcontext(ctxName);
+ }
+ // The current subctx will be the ctx for the next name component
+ ctx = subctx;
+ }
+ return subctx;
+ }
+
+ /**
+ * Bind val to name in ctx, and make sure that all intermediate contexts exist
+ * @param ctx the parent JNDI Context under which value will be bound
+ * @param name the name relative to ctx where value will be bound
+ * @param value the value to bind.
+ * @throws NamingException for any error
+ */
+ public static void bind(Context ctx, String name, Object value) throws NamingException
+ {
+ Name n = ctx.getNameParser("").parse(name);
+ bind(ctx, n, value);
+ }
+
+ /**
+ * Bind val to name in ctx, and make sure that all intermediate contexts exist
+ * @param ctx the parent JNDI Context under which value will be bound
+ * @param name the name relative to ctx where value will be bound
+ * @param value the value to bind.
+ * @throws NamingException for any error
+ */
+ private static void bind(Context ctx, Name name, Object value) throws NamingException
+ {
+ int size = name.size();
+ String atom = name.get(size - 1);
+ Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1));
+ parentCtx.bind(atom, value);
+ }
+
+ /**
+ * Unbinds a name from ctx, and removes parents if they are empty
+ * @param ctx the parent JNDI Context under which the name will be unbound
+ * @param name The name to unbind
+ * @throws NamingException for any error
+ */
+ public static void unbind(Context ctx, String name) throws NamingException
+ {
+ unbind(ctx, ctx.getNameParser("").parse(name));
+ }
+
+ /**
+ * Unbinds a name from ctx, and removes parents if they are empty
+ * @param ctx the parent JNDI Context under which the name will be unbound
+ * @param name The name to unbind
+ * @throws NamingException for any error
+ */
+ private static void unbind(Context ctx, Name name) throws NamingException
+ {
+ ctx.unbind(name); //unbind the end node in the name
+ int sz = name.size();
+ // walk the tree backwards, stopping at the domain
+ while (--sz > 0)
+ {
+ Name pname = name.getPrefix(sz);
+ try
+ {
+ ctx.destroySubcontext(pname);
+ }
+ catch (NamingException e)
+ {
+ log.trace("Unable to remove context " + pname, e);
+ break;
+ }
+ }
+ }
+}
Modified: projects/jboss-jca/trunk/ivy.xml
===================================================================
--- projects/jboss-jca/trunk/ivy.xml 2011-06-07 16:59:47 UTC (rev 111539)
+++ projects/jboss-jca/trunk/ivy.xml 2011-06-07 17:03:04 UTC (rev 111540)
@@ -140,7 +140,7 @@
<artifact name="hornetq-ra" type="rar" conf="hornetq"/>
</dependency>
<dependency org="org.javassist" name="javassist" rev="${version.javassist}" conf="common,ironjacamar-depchain"/>
- <dependency org="org.jboss" name="jboss-common-core" rev="${version.jboss.common}" conf="common,ironjacamar-common-impl,ironjacamar-core-impl,ironjacamar-depchain"/>
+ <dependency org="org.jboss" name="jboss-common-core" rev="${version.jboss.common}" conf="common,ironjacamar-depchain"/>
<dependency org="org.jboss" name="jboss-transaction-spi" rev="${version.jboss.ts.spi}" conf="common,ironjacamar-core-api,ironjacamar-core-impl,ironjacamar-depchain"/>
<dependency org="org.jboss.apiviz" name="apiviz" rev="${version.apiviz}" conf="tools"/>
<dependency org="org.jboss.arquillian.config" name="arquillian-config-api" rev="${version.arquillian}" conf="arquillian,ironjacamar-depchain,ironjacamar-embedded-arquillian"/>
More information about the jboss-cvs-commits
mailing list