Merge #48 more JNDI removal

This commit is contained in:
jbertram 2014-12-31 09:43:24 -06:00
commit 1b791ef9e6
62 changed files with 451 additions and 534 deletions

View File

@ -39,9 +39,9 @@ public interface ConnectionFactoryControl
String getName(); String getName();
/** /**
* Returns the JNDI bindings associated to this connection factory. * Returns the Registry bindings associated to this connection factory.
*/ */
String[] getJNDIBindings(); String[] getRegistryBindings();
/** /**
* does ths cf support HA * does ths cf support HA
@ -380,14 +380,14 @@ public interface ConnectionFactoryControl
DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(); DiscoveryGroupConfiguration getDiscoveryGroupConfiguration();
/** /**
* Add the JNDI binding to this destination * Add the Registry binding to this destination
*/ */
@Operation(desc = "Adds the factory to another JNDI binding") @Operation(desc = "Adds the factory to another Registry binding")
void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; void addBinding(@Parameter(name = "binding", desc = "the name of the binding for the Registry") String binding) throws Exception;
/** /**
* Remove a JNDI binding * Remove a Registry binding
*/ */
@Operation(desc = "Remove an existing JNDI binding") @Operation(desc = "Remove an existing Registry binding")
void removeJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; void removeBinding(@Parameter(name = "binding", desc = "the name of the binding for Registry") String binding) throws Exception;
} }

View File

@ -74,16 +74,16 @@ public interface JMSQueueControl extends DestinationControl
// Operations ---------------------------------------------------- // Operations ----------------------------------------------------
/** /**
* Returns the JNDI bindings associated to this connection factory. * Returns the Registry bindings associated to this connection factory.
*/ */
@Operation(desc = "Returns the list of JNDI bindings associated") @Operation(desc = "Returns the list of Registry bindings associated")
String[] getJNDIBindings(); String[] getRegistryBindings();
/** /**
* Add the JNDI binding to this destination * Add the JNDI binding to this destination
*/ */
@Operation(desc = "Adds the queue to another JNDI binding") @Operation(desc = "Adds the queue to another Registry binding")
void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; void addBinding(@Parameter(name = "binding", desc = "the name of the binding for the registry") String binding) throws Exception;
/** /**
* Lists all the JMS messages in this queue matching the specified filter. * Lists all the JMS messages in this queue matching the specified filter.

View File

@ -57,16 +57,16 @@ public interface TopicControl extends DestinationControl
int getNonDurableMessageCount(); int getNonDurableMessageCount();
/** /**
* Returns the JNDI bindings associated to this connection factory. * Returns the Registry bindings associated to this connection factory.
*/ */
@Operation(desc = "Returns the list of JNDI bindings associated") @Operation(desc = "Returns the list of Registry bindings associated")
String[] getJNDIBindings(); String[] getRegistryBindings();
/** /**
* Add the JNDI binding to this destination * Add the Registry binding to this destination
*/ */
@Operation(desc = "Adds the queue to another JNDI binding") @Operation(desc = "Adds the queue to another Registry binding")
void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; void addBinding(@Parameter(name = "binding", desc = "the name of the binding for Registry") String binding) throws Exception;

View File

@ -66,9 +66,9 @@ public class JMSConnectionFactoryControlImpl extends StandardMBean implements Co
// ManagedConnectionFactoryMBean implementation ------------------ // ManagedConnectionFactoryMBean implementation ------------------
public String[] getJNDIBindings() public String[] getRegistryBindings()
{ {
return jmsManager.getJNDIOnConnectionFactory(name); return jmsManager.getBindingsOnConnectionFactory(name);
} }
public boolean isCompressLargeMessages() public boolean isCompressLargeMessages()
@ -331,14 +331,14 @@ public class JMSConnectionFactoryControlImpl extends StandardMBean implements Co
return cf.getDiscoveryGroupConfiguration(); return cf.getDiscoveryGroupConfiguration();
} }
public void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception public void addBinding(@Parameter(name = "binding", desc = "the name of the binding for the Registry") String binding) throws Exception
{ {
jmsManager.addConnectionFactoryToJNDI(name, jndi); jmsManager.addConnectionFactoryToBindingRegistry(name, binding);
} }
public void removeJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception public void removeBinding(@Parameter(name = "binding", desc = "the name of the binding for the Registry") String binding) throws Exception
{ {
jmsManager.removeConnectionFactoryFromJNDI(name, jndi); jmsManager.removeConnectionFactoryFromBindingRegistry(name, binding);
} }
public long getCallTimeout() public long getCallTimeout()

View File

@ -159,19 +159,19 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro
} }
@Override @Override
public void addJNDI(String jndi) throws Exception public void addBinding(String binding) throws Exception
{ {
jmsServerManager.addQueueToJndi(managedQueue.getName(), jndi); jmsServerManager.addQueueToBindingRegistry(managedQueue.getName(), binding);
} }
public void removeJNDI(String jndi) throws Exception public void removeBinding(String binding) throws Exception
{ {
jmsServerManager.removeQueueFromJNDI(managedQueue.getName(), jndi); jmsServerManager.removeQueueFromBindingRegistry(managedQueue.getName(), binding);
} }
public String[] getJNDIBindings() public String[] getRegistryBindings()
{ {
return jmsServerManager.getJNDIOnQueue(managedQueue.getName()); return jmsServerManager.getBindingsOnQueue(managedQueue.getName());
} }
public boolean removeMessage(final String messageID) throws Exception public boolean removeMessage(final String messageID) throws Exception

View File

@ -76,14 +76,14 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
// Static -------------------------------------------------------- // Static --------------------------------------------------------
private static String[] convert(final Object[] jndiBindings) private static String[] convert(final Object[] bindings)
{ {
String[] bindings = new String[jndiBindings.length]; String[] theBindings = new String[bindings.length];
for (int i = 0, jndiBindingsLength = jndiBindings.length; i < jndiBindingsLength; i++) for (int i = 0, bindingsLength = bindings.length; i < bindingsLength; i++)
{ {
bindings[i] = jndiBindings[i].toString().trim(); theBindings[i] = bindings[i].toString().trim();
} }
return bindings; return theBindings;
} }
private static String[] toArray(final String commaSeparatedString) private static String[] toArray(final String commaSeparatedString)
@ -217,7 +217,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
boolean useDiscovery, boolean useDiscovery,
int cfType, int cfType,
String connectors, String connectors,
String jndiBindings, String bindings,
String clientID, String clientID,
long clientFailureCheckPeriod, long clientFailureCheckPeriod,
long connectionTTL, long connectionTTL,
@ -253,7 +253,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
useDiscovery, useDiscovery,
cfType, cfType,
toArray(connectors), toArray(connectors),
toArray(jndiBindings), toArray(bindings),
clientID, clientID,
clientFailureCheckPeriod, clientFailureCheckPeriod,
connectionTTL, connectionTTL,
@ -392,16 +392,16 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
/** /**
* Create a JMS ConnectionFactory with the specified name connected to a single live-backup pair of servers. * Create a JMS ConnectionFactory with the specified name connected to a single live-backup pair of servers.
* <br> * <br>
* The ConnectionFactory is bound to JNDI for all the specified bindings Strings. * The ConnectionFactory is bound to the Registry for all the specified bindings Strings.
*/ */
public void createConnectionFactory(String name, public void createConnectionFactory(String name,
boolean ha, boolean ha,
boolean useDiscovery, boolean useDiscovery,
int cfType, int cfType,
String connectors, String connectors,
String jndiBindings) throws Exception String bindings) throws Exception
{ {
createConnectionFactory(name, ha, useDiscovery, cfType, toArray(connectors), toArray(jndiBindings)); createConnectionFactory(name, ha, useDiscovery, cfType, toArray(connectors), toArray(bindings));
} }
public boolean createQueue(final String name) throws Exception public boolean createQueue(final String name) throws Exception
@ -409,19 +409,19 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
return createQueue(name, null, null, true); return createQueue(name, null, null, true);
} }
public boolean createQueue(final String name, final String jndiBindings) throws Exception public boolean createQueue(final String name, final String bindings) throws Exception
{ {
return createQueue(name, jndiBindings, null, true); return createQueue(name, bindings, null, true);
} }
@Override @Override
public boolean createQueue(String name, String jndiBindings, String selector) throws Exception public boolean createQueue(String name, String bindings, String selector) throws Exception
{ {
return createQueue(name, jndiBindings, selector, true); return createQueue(name, bindings, selector, true);
} }
public boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name, public boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
@Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use '&comma;' if u need to use commas in your jndi name)") String jndiBindings, @Parameter(name = "bindings", desc = "comma-separated list of Registry bindings (use '&comma;' if u need to use commas in your bindings name)") String bindings,
@Parameter(name = "selector", desc = "the jms selector") String selector, @Parameter(name = "selector", desc = "the jms selector") String selector,
@Parameter(name = "durable", desc = "is the queue persistent and resilient to restart") boolean durable) throws Exception @Parameter(name = "durable", desc = "is the queue persistent and resilient to restart") boolean durable) throws Exception
{ {
@ -432,7 +432,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
try try
{ {
return server.createQueue(true, name, selector, durable, return server.createQueue(true, name, selector, durable,
JMSServerControlImpl.toArray(jndiBindings)); JMSServerControlImpl.toArray(bindings));
} }
finally finally
{ {
@ -466,7 +466,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
return createTopic(name, null); return createTopic(name, null);
} }
public boolean createTopic(final String topicName, final String jndiBindings) throws Exception public boolean createTopic(final String topicName, final String bindings) throws Exception
{ {
checkStarted(); checkStarted();
@ -474,7 +474,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
try try
{ {
return server.createTopic(true, topicName, JMSServerControlImpl.toArray(jndiBindings)); return server.createTopic(true, topicName, JMSServerControlImpl.toArray(bindings));
} }
finally finally
{ {

View File

@ -80,14 +80,14 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl
// TopicControlMBean implementation ------------------------------ // TopicControlMBean implementation ------------------------------
@Override @Override
public void addJNDI(String jndi) throws Exception public void addBinding(String binding) throws Exception
{ {
jmsServerManager.addTopicToJndi(managedTopic.getName(), jndi); jmsServerManager.addTopicToBindingRegistry(managedTopic.getName(), binding);
} }
public String[] getJNDIBindings() public String[] getRegistryBindings()
{ {
return jmsServerManager.getJNDIOnTopic(managedTopic.getName()); return jmsServerManager.getBindingsOnTopic(managedTopic.getName());
} }
public String getName() public String getName()

View File

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.activemq.core.server.ActiveMQComponent; import org.apache.activemq.core.server.ActiveMQComponent;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
import org.apache.activemq.jms.persistence.config.PersistedDestination; import org.apache.activemq.jms.persistence.config.PersistedDestination;
import org.apache.activemq.jms.persistence.config.PersistedJNDI; import org.apache.activemq.jms.persistence.config.PersistedBindings;
import org.apache.activemq.jms.persistence.config.PersistedType; import org.apache.activemq.jms.persistence.config.PersistedType;
/** /**
@ -48,11 +48,11 @@ public interface JMSStorageManager extends ActiveMQComponent
List<PersistedConnectionFactory> recoverConnectionFactories(); List<PersistedConnectionFactory> recoverConnectionFactories();
void addJNDI(PersistedType type, String name, String ... address) throws Exception; void addBindings(PersistedType type, String name, String... address) throws Exception;
List<PersistedJNDI> recoverPersistedJNDI() throws Exception; List<PersistedBindings> recoverPersistedBindings() throws Exception;
void deleteJNDI(PersistedType type, String name, String address) throws Exception; void deleteBindings(PersistedType type, String name, String address) throws Exception;
void deleteJNDI(PersistedType type, String name) throws Exception; void deleteBindings(PersistedType type, String name) throws Exception;
} }

View File

@ -25,11 +25,11 @@ import org.apache.activemq.utils.BufferHelper;
import org.apache.activemq.utils.DataConstants; import org.apache.activemq.utils.DataConstants;
/** /**
* A PersistedJNDI * A PersistedBinding
* *
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a> * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
*/ */
public class PersistedJNDI implements EncodingSupport public class PersistedBindings implements EncodingSupport
{ {
// Constants ----------------------------------------------------- // Constants -----------------------------------------------------
@ -42,13 +42,13 @@ public class PersistedJNDI implements EncodingSupport
private String name; private String name;
private ArrayList<String> jndi = new ArrayList<String>(); private ArrayList<String> bindings = new ArrayList<String>();
// Static -------------------------------------------------------- // Static --------------------------------------------------------
// Constructors -------------------------------------------------- // Constructors --------------------------------------------------
public PersistedJNDI() public PersistedBindings()
{ {
} }
@ -56,7 +56,7 @@ public class PersistedJNDI implements EncodingSupport
* @param type * @param type
* @param name * @param name
*/ */
public PersistedJNDI(PersistedType type, String name) public PersistedBindings(PersistedType type, String name)
{ {
super(); super();
this.type = type; this.type = type;
@ -69,12 +69,12 @@ public class PersistedJNDI implements EncodingSupport
{ {
type = PersistedType.getType(buffer.readByte()); type = PersistedType.getType(buffer.readByte());
name = buffer.readSimpleString().toString(); name = buffer.readSimpleString().toString();
int jndiArraySize = buffer.readInt(); int bindingArraySize = buffer.readInt();
jndi = new ArrayList<String>(jndiArraySize); bindings = new ArrayList<String>(bindingArraySize);
for (int i = 0; i < jndiArraySize; i++) for (int i = 0; i < bindingArraySize; i++)
{ {
jndi.add(buffer.readSimpleString().toString()); bindings.add(buffer.readSimpleString().toString());
} }
} }
@ -83,10 +83,10 @@ public class PersistedJNDI implements EncodingSupport
{ {
buffer.writeByte(type.getType()); buffer.writeByte(type.getType());
BufferHelper.writeAsSimpleString(buffer, name); BufferHelper.writeAsSimpleString(buffer, name);
buffer.writeInt(jndi.size()); buffer.writeInt(bindings.size());
for (String jndiEl : jndi) for (String bindingsEl : bindings)
{ {
BufferHelper.writeAsSimpleString(buffer, jndiEl); BufferHelper.writeAsSimpleString(buffer, bindingsEl);
} }
} }
@ -95,14 +95,14 @@ public class PersistedJNDI implements EncodingSupport
{ {
return DataConstants.SIZE_BYTE + return DataConstants.SIZE_BYTE +
BufferHelper.sizeOfSimpleString(name) + BufferHelper.sizeOfSimpleString(name) +
sizeOfJNDI(); sizeOfBindings();
} }
private int sizeOfJNDI() private int sizeOfBindings()
{ {
int size = DataConstants.SIZE_INT; // for the number of elements written int size = DataConstants.SIZE_INT; // for the number of elements written
for (String str : jndi) for (String str : bindings)
{ {
size += BufferHelper.sizeOfSimpleString(str); size += BufferHelper.sizeOfSimpleString(str);
} }
@ -143,21 +143,21 @@ public class PersistedJNDI implements EncodingSupport
} }
/** /**
* @return the jndi * @return the bindings
*/ */
public List<String> getJndi() public List<String> getBindings()
{ {
return jndi; return bindings;
} }
public void addJNDI(String address) public void addBinding(String address)
{ {
jndi.add(address); bindings.add(address);
} }
public void deleteJNDI(String address) public void deleteBinding(String address)
{ {
jndi.remove(address); bindings.remove(address);
} }
// Package protected --------------------------------------------- // Package protected ---------------------------------------------

View File

@ -38,7 +38,7 @@ import org.apache.activemq.core.server.JournalType;
import org.apache.activemq.jms.persistence.JMSStorageManager; import org.apache.activemq.jms.persistence.JMSStorageManager;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
import org.apache.activemq.jms.persistence.config.PersistedDestination; import org.apache.activemq.jms.persistence.config.PersistedDestination;
import org.apache.activemq.jms.persistence.config.PersistedJNDI; import org.apache.activemq.jms.persistence.config.PersistedBindings;
import org.apache.activemq.jms.persistence.config.PersistedType; import org.apache.activemq.jms.persistence.config.PersistedType;
import org.apache.activemq.utils.IDGenerator; import org.apache.activemq.utils.IDGenerator;
@ -56,7 +56,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
public static final byte DESTINATION_RECORD = 2; public static final byte DESTINATION_RECORD = 2;
public static final byte JNDI_RECORD = 3; public static final byte BINDING_RECORD = 3;
// Attributes ---------------------------------------------------- // Attributes ----------------------------------------------------
@ -74,7 +74,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
private final Map<Pair<PersistedType, String>, PersistedDestination> destinations = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedDestination>(); private final Map<Pair<PersistedType, String>, PersistedDestination> destinations = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedDestination>();
private final Map<Pair<PersistedType, String>, PersistedJNDI> mapJNDI = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedJNDI>(); private final Map<Pair<PersistedType, String>, PersistedBindings> mapBindings = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedBindings>();
// Static -------------------------------------------------------- // Static --------------------------------------------------------
@ -166,87 +166,87 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination); destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
} }
public List<PersistedJNDI> recoverPersistedJNDI() throws Exception public List<PersistedBindings> recoverPersistedBindings() throws Exception
{ {
ArrayList<PersistedJNDI> list = new ArrayList<PersistedJNDI>(mapJNDI.values()); ArrayList<PersistedBindings> list = new ArrayList<PersistedBindings>(mapBindings.values());
return list; return list;
} }
public void addJNDI(PersistedType type, String name, String... address) throws Exception public void addBindings(PersistedType type, String name, String... address) throws Exception
{ {
Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name); Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
long tx = idGenerator.generateID(); long tx = idGenerator.generateID();
PersistedJNDI currentJNDI = mapJNDI.get(key); PersistedBindings currentBindings = mapBindings.get(key);
if (currentJNDI != null) if (currentBindings != null)
{ {
jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId()); jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId());
} }
else else
{ {
currentJNDI = new PersistedJNDI(type, name); currentBindings = new PersistedBindings(type, name);
} }
mapJNDI.put(key, currentJNDI); mapBindings.put(key, currentBindings);
for (String adItem : address) for (String adItem : address)
{ {
currentJNDI.addJNDI(adItem); currentBindings.addBinding(adItem);
} }
long newId = idGenerator.generateID(); long newId = idGenerator.generateID();
currentJNDI.setId(newId); currentBindings.setId(newId);
jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI); jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings);
jmsJournal.appendCommitRecord(tx, true); jmsJournal.appendCommitRecord(tx, true);
} }
public void deleteJNDI(PersistedType type, String name, String address) throws Exception public void deleteBindings(PersistedType type, String name, String address) throws Exception
{ {
Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name); Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
long tx = idGenerator.generateID(); long tx = idGenerator.generateID();
PersistedJNDI currentJNDI = mapJNDI.get(key); PersistedBindings currentBindings = mapBindings.get(key);
if (currentJNDI == null) if (currentBindings == null)
{ {
return; return;
} }
else else
{ {
jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId()); jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId());
} }
currentJNDI.deleteJNDI(address); currentBindings.deleteBinding(address);
if (currentJNDI.getJndi().size() == 0) if (currentBindings.getBindings().size() == 0)
{ {
mapJNDI.remove(key); mapBindings.remove(key);
} }
else else
{ {
long newId = idGenerator.generateID(); long newId = idGenerator.generateID();
currentJNDI.setId(newId); currentBindings.setId(newId);
jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI); jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings);
} }
jmsJournal.appendCommitRecord(tx, true); jmsJournal.appendCommitRecord(tx, true);
} }
public void deleteJNDI(PersistedType type, String name) throws Exception public void deleteBindings(PersistedType type, String name) throws Exception
{ {
Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name); Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
PersistedJNDI currentJNDI = mapJNDI.remove(key); PersistedBindings currentBindings = mapBindings.remove(key);
if (currentJNDI != null) if (currentBindings != null)
{ {
jmsJournal.appendDeleteRecord(currentJNDI.getId(), true); jmsJournal.appendDeleteRecord(currentBindings.getId(), true);
} }
} }
@ -316,13 +316,13 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
destination.setId(id); destination.setId(id);
destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination); destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
} }
else if (rec == JNDI_RECORD) else if (rec == BINDING_RECORD)
{ {
PersistedJNDI jndi = new PersistedJNDI(); PersistedBindings bindings = new PersistedBindings();
jndi.decode(buffer); bindings.decode(buffer);
jndi.setId(id); bindings.setId(id);
Pair<PersistedType, String> key = new Pair<PersistedType, String>(jndi.getType(), jndi.getName()); Pair<PersistedType, String> key = new Pair<PersistedType, String>(bindings.getType(), bindings.getName());
mapJNDI.put(key, jndi); mapBindings.put(key, bindings);
} }
else else
{ {

View File

@ -22,7 +22,7 @@ import java.util.List;
import org.apache.activemq.jms.persistence.JMSStorageManager; import org.apache.activemq.jms.persistence.JMSStorageManager;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
import org.apache.activemq.jms.persistence.config.PersistedDestination; import org.apache.activemq.jms.persistence.config.PersistedDestination;
import org.apache.activemq.jms.persistence.config.PersistedJNDI; import org.apache.activemq.jms.persistence.config.PersistedBindings;
import org.apache.activemq.jms.persistence.config.PersistedType; import org.apache.activemq.jms.persistence.config.PersistedType;
/** /**
@ -80,12 +80,12 @@ public class NullJMSStorageManagerImpl implements JMSStorageManager
} }
@Override @Override
public void addJNDI(PersistedType type, String name, String ... address) throws Exception public void addBindings(PersistedType type, String name, String... address) throws Exception
{ {
} }
@Override @Override
public void deleteJNDI(PersistedType type, String name, String address) throws Exception public void deleteBindings(PersistedType type, String name, String address) throws Exception
{ {
} }
@ -95,12 +95,12 @@ public class NullJMSStorageManagerImpl implements JMSStorageManager
} }
@Override @Override
public void deleteJNDI(PersistedType type, String name) throws Exception public void deleteBindings(PersistedType type, String name) throws Exception
{ {
} }
@Override @Override
public List<PersistedJNDI> recoverPersistedJNDI() throws Exception public List<PersistedBindings> recoverPersistedBindings() throws Exception
{ {
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -58,8 +58,8 @@ public interface ActiveMQJMSServerBundle
@Message(id = 129005, value = "Connector ''{0}'' not found on the main configuration file" , format = Message.Format.MESSAGE_FORMAT) @Message(id = 129005, value = "Connector ''{0}'' not found on the main configuration file" , format = Message.Format.MESSAGE_FORMAT)
ActiveMQIllegalStateException noConnectorNameConfiguredOnCF(String name); ActiveMQIllegalStateException noConnectorNameConfiguredOnCF(String name);
@Message(id = 129006, value = "JNDI {0} is already being used by another connection factory", format = Message.Format.MESSAGE_FORMAT) @Message(id = 129006, value = "Binding {0} is already being used by another connection factory", format = Message.Format.MESSAGE_FORMAT)
ActiveMQAddressExistsException cfJndiExists(String name); ActiveMQAddressExistsException cfBindingsExists(String name);
@Message(id = 129007, value = "Error decoding password using codec instance", format = Message.Format.MESSAGE_FORMAT) @Message(id = 129007, value = "Error decoding password using codec instance", format = Message.Format.MESSAGE_FORMAT)
ActiveMQIllegalStateException errorDecodingPassword(@Cause Exception e); ActiveMQIllegalStateException errorDecodingPassword(@Cause Exception e);

View File

@ -73,8 +73,8 @@ public interface ActiveMQJMSServerLogger extends BasicLogger
void recoveryConnectFailed(String s); void recoveryConnectFailed(String s);
@LogMessage(level = Logger.Level.WARN) @LogMessage(level = Logger.Level.WARN)
@Message(id = 122011, value = "error unbinding {0} from JNDI" , format = Message.Format.MESSAGE_FORMAT) @Message(id = 122011, value = "error unbinding {0} from Registry" , format = Message.Format.MESSAGE_FORMAT)
void jndiUnbindError(@Cause Exception e, String key); void bindingsUnbindError(@Cause Exception e, String key);
@LogMessage(level = Logger.Level.WARN) @LogMessage(level = Logger.Level.WARN)
@Message(id = 122012, value = "JMS Server Manager error" , format = Message.Format.MESSAGE_FORMAT) @Message(id = 122012, value = "JMS Server Manager error" , format = Message.Format.MESSAGE_FORMAT)

View File

@ -19,8 +19,6 @@ package org.apache.activemq.jms.server;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.naming.Context;
import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.security.Role; import org.apache.activemq.core.security.Role;
import org.apache.activemq.core.server.ActiveMQComponent; import org.apache.activemq.core.server.ActiveMQComponent;
@ -56,17 +54,17 @@ public interface JMSServerManager extends ActiveMQComponent
* @param selectorString * @param selectorString
* @param durable * @param durable
* @return true if the queue is created or if it existed and was added to * @return true if the queue is created or if it existed and was added to
* JNDI * the Binding Registry
* @throws Exception * @throws Exception
* if problems were encountered creating the queue. * if problems were encountered creating the queue.
*/ */
boolean createQueue(boolean storeConfig, String queueName, String selectorString, boolean durable, String ...bindings) throws Exception; boolean createQueue(boolean storeConfig, String queueName, String selectorString, boolean durable, String ...bindings) throws Exception;
boolean addTopicToJndi(final String topicName, final String binding) throws Exception; boolean addTopicToBindingRegistry(final String topicName, final String binding) throws Exception;
boolean addQueueToJndi(final String queueName, final String binding) throws Exception; boolean addQueueToBindingRegistry(final String queueName, final String binding) throws Exception;
boolean addConnectionFactoryToJNDI(final String name, final String binding) throws Exception; boolean addConnectionFactoryToBindingRegistry(final String name, final String binding) throws Exception;
/** /**
* Creates a JMS Topic * Creates a JMS Topic
@ -74,68 +72,68 @@ public interface JMSServerManager extends ActiveMQComponent
* @param topicName * @param topicName
* the name of the topic * the name of the topic
* @param bindings * @param bindings
* the names of the binding for JNDI or BindingRegistry * the names of the binding for the Binding Registry or BindingRegistry
* @return true if the topic was created or if it existed and was added to * @return true if the topic was created or if it existed and was added to
* JNDI * the Binding Registry
* @throws Exception * @throws Exception
* if a problem occurred creating the topic * if a problem occurred creating the topic
*/ */
boolean createTopic(boolean storeConfig, String topicName, String ... bindings) throws Exception; boolean createTopic(boolean storeConfig, String topicName, String ... bindings) throws Exception;
/** /**
* Remove the topic from JNDI or BindingRegistry. * Remove the topic from the Binding Registry or BindingRegistry.
* Calling this method does <em>not</em> destroy the destination. * Calling this method does <em>not</em> destroy the destination.
* *
* @param name * @param name
* the name of the destination to remove from JNDI or BindingRegistry * the name of the destination to remove from the BindingRegistry
* @return true if removed * @return true if removed
* @throws Exception * @throws Exception
* if a problem occurred removing the destination * if a problem occurred removing the destination
*/ */
boolean removeTopicFromJNDI(String name, String binding) throws Exception; boolean removeTopicFromBindingRegistry(String name, String binding) throws Exception;
/** /**
* Remove the topic from JNDI or BindingRegistry. * Remove the topic from the BindingRegistry.
* Calling this method does <em>not</em> destroy the destination. * Calling this method does <em>not</em> destroy the destination.
* *
* @param name * @param name
* the name of the destination to remove from JNDI or BindingRegistry * the name of the destination to remove from the BindingRegistry
* @return true if removed * @return true if removed
* @throws Exception * @throws Exception
* if a problem occurred removing the destination * if a problem occurred removing the destination
*/ */
boolean removeTopicFromJNDI(String name) throws Exception; boolean removeTopicFromBindingRegistry(String name) throws Exception;
/** /**
* Remove the queue from JNDI or BindingRegistry. * Remove the queue from the BindingRegistry.
* Calling this method does <em>not</em> destroy the destination. * Calling this method does <em>not</em> destroy the destination.
* *
* @param name * @param name
* the name of the destination to remove from JNDI or BindingRegistry * the name of the destination to remove from the BindingRegistry
* @return true if removed * @return true if removed
* @throws Exception * @throws Exception
* if a problem occurred removing the destination * if a problem occurred removing the destination
*/ */
boolean removeQueueFromJNDI(String name, String binding) throws Exception; boolean removeQueueFromBindingRegistry(String name, String binding) throws Exception;
/** /**
* Remove the queue from JNDI or BindingRegistry. * Remove the queue from the BindingRegistry.
* Calling this method does <em>not</em> destroy the destination. * Calling this method does <em>not</em> destroy the destination.
* *
* @param name * @param name
* the name of the destination to remove from JNDI or BindingRegistry * the name of the destination to remove from the BindingRegistry
* @return true if removed * @return true if removed
* @throws Exception * @throws Exception
* if a problem occurred removing the destination * if a problem occurred removing the destination
*/ */
boolean removeQueueFromJNDI(String name) throws Exception; boolean removeQueueFromBindingRegistry(String name) throws Exception;
boolean removeConnectionFactoryFromJNDI(String name, String binding) throws Exception; boolean removeConnectionFactoryFromBindingRegistry(String name, String binding) throws Exception;
boolean removeConnectionFactoryFromJNDI(String name) throws Exception; boolean removeConnectionFactoryFromBindingRegistry(String name) throws Exception;
/** /**
* destroys a queue and removes it from JNDI or BindingRegistry * destroys a queue and removes it from the BindingRegistry
* *
* @param name * @param name
* the name of the queue to destroy * the name of the queue to destroy
@ -146,7 +144,7 @@ public interface JMSServerManager extends ActiveMQComponent
boolean destroyQueue(String name) throws Exception; boolean destroyQueue(String name) throws Exception;
/** /**
* destroys a queue and removes it from JNDI or BindingRegistry. * destroys a queue and removes it from the BindingRegistry.
* disconnects any consumers connected to the queue. * disconnects any consumers connected to the queue.
* *
* @param name * @param name
@ -157,14 +155,14 @@ public interface JMSServerManager extends ActiveMQComponent
*/ */
boolean destroyQueue(String name, boolean removeConsumers) throws Exception; boolean destroyQueue(String name, boolean removeConsumers) throws Exception;
String[] getJNDIOnQueue(String queue); String[] getBindingsOnQueue(String queue);
String[] getJNDIOnTopic(String topic); String[] getBindingsOnTopic(String topic);
String[] getJNDIOnConnectionFactory(String factoryName); String[] getBindingsOnConnectionFactory(String factoryName);
/** /**
* destroys a topic and removes it from JNDI or BindingRegistry * destroys a topic and removes it from the BindingRegistry
* *
* @param name * @param name
* the name of the topic to destroy * the name of the topic to destroy
@ -175,7 +173,7 @@ public interface JMSServerManager extends ActiveMQComponent
boolean destroyTopic(String name, boolean removeConsumers) throws Exception; boolean destroyTopic(String name, boolean removeConsumers) throws Exception;
/** /**
* destroys a topic and removes it from JNDI or BindingRegistry * destroys a topic and removes it from theBindingRegistry
* *
* @param name * @param name
* the name of the topic to destroy * the name of the topic to destroy
@ -185,11 +183,11 @@ public interface JMSServerManager extends ActiveMQComponent
*/ */
boolean destroyTopic(String name) throws Exception; boolean destroyTopic(String name) throws Exception;
/** Call this method to have a CF rebound to JNDI and stored on the Journal /** Call this method to have a CF rebound to the Binding Registry and stored on the Journal
* @throws Exception */ * @throws Exception */
ActiveMQConnectionFactory recreateCF(String name, ConnectionFactoryConfiguration cf) throws Exception; ActiveMQConnectionFactory recreateCF(String name, ConnectionFactoryConfiguration cf) throws Exception;
void createConnectionFactory(String name, boolean ha, JMSFactoryType cfType, String discoveryGroupName, String ... jndiBindings) throws Exception; void createConnectionFactory(String name, boolean ha, JMSFactoryType cfType, String discoveryGroupName, String ... bindings) throws Exception;
void createConnectionFactory(String name, void createConnectionFactory(String name,
boolean ha, boolean ha,
@ -300,8 +298,6 @@ public interface JMSServerManager extends ActiveMQComponent
String listPreparedTransactionDetailsAsHTML() throws Exception; String listPreparedTransactionDetailsAsHTML() throws Exception;
void setContext(final Context context);
ActiveMQServer getActiveMQServer(); ActiveMQServer getActiveMQServer();
void addAddressSettings(String address, AddressSettings addressSettings); void addAddressSettings(String address, AddressSettings addressSettings);
@ -315,7 +311,7 @@ public interface JMSServerManager extends ActiveMQComponent
BindingRegistry getRegistry(); BindingRegistry getRegistry();
/** /**
* Set this property if you want something other than JNDI for your registry * Set this property if you want JMS resources bound to a registry
* *
* @param registry * @param registry
*/ */

View File

@ -18,8 +18,6 @@ package org.apache.activemq.jms.server.config;
import java.util.List; import java.util.List;
import javax.naming.Context;
/** /**
* A JMSConfiguration * A JMSConfiguration
* *
@ -29,10 +27,6 @@ import javax.naming.Context;
*/ */
public interface JMSConfiguration public interface JMSConfiguration
{ {
JMSConfiguration setContext(Context context);
Context getContext();
List<JMSQueueConfiguration> getQueueConfigurations(); List<JMSQueueConfiguration> getQueueConfigurations();
JMSConfiguration setQueueConfigurations(List<JMSQueueConfiguration> queueConfigurations); JMSConfiguration setQueueConfigurations(List<JMSQueueConfiguration> queueConfigurations);

View File

@ -19,8 +19,6 @@ package org.apache.activemq.jms.server.config.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.naming.Context;
import org.apache.activemq.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration; import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration;
import org.apache.activemq.jms.server.config.JMSConfiguration; import org.apache.activemq.jms.server.config.JMSConfiguration;
@ -42,8 +40,6 @@ public class JMSConfigurationImpl implements JMSConfiguration
private String domain = ActiveMQDefaultConfiguration.getDefaultJmxDomain(); private String domain = ActiveMQDefaultConfiguration.getDefaultJmxDomain();
private Context context = null;
// JMSConfiguration implementation ------------------------------- // JMSConfiguration implementation -------------------------------
public JMSConfigurationImpl() public JMSConfigurationImpl()
@ -83,17 +79,6 @@ public class JMSConfigurationImpl implements JMSConfiguration
return this; return this;
} }
public Context getContext()
{
return context;
}
public JMSConfigurationImpl setContext(final Context context)
{
this.context = context;
return this;
}
public String getDomain() public String getDomain()
{ {
return domain; return domain;

View File

@ -115,12 +115,12 @@ public class JMSServerDeployer extends XmlDeployer
if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME)) if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
{ {
String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue(); String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
jmsServerManager.removeQueueFromJNDI(queueName); jmsServerManager.removeQueueFromBindingRegistry(queueName);
} }
else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME)) else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
{ {
String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue(); String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
jmsServerManager.removeTopicFromJNDI(topicName); jmsServerManager.removeTopicFromBindingRegistry(topicName);
} }
} }

View File

@ -16,8 +16,6 @@
*/ */
package org.apache.activemq.jms.server.impl; package org.apache.activemq.jms.server.impl;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException; import javax.naming.NamingException;
import javax.transaction.xa.Xid; import javax.transaction.xa.Xid;
@ -49,7 +47,6 @@ import org.apache.activemq.core.deployers.impl.FileDeploymentManager;
import org.apache.activemq.core.deployers.impl.XmlDeployer; import org.apache.activemq.core.deployers.impl.XmlDeployer;
import org.apache.activemq.core.postoffice.Binding; import org.apache.activemq.core.postoffice.Binding;
import org.apache.activemq.core.postoffice.BindingType; import org.apache.activemq.core.postoffice.BindingType;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.core.security.Role; import org.apache.activemq.core.security.Role;
@ -70,7 +67,7 @@ import org.apache.activemq.jms.client.SelectorTranslator;
import org.apache.activemq.jms.persistence.JMSStorageManager; import org.apache.activemq.jms.persistence.JMSStorageManager;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
import org.apache.activemq.jms.persistence.config.PersistedDestination; import org.apache.activemq.jms.persistence.config.PersistedDestination;
import org.apache.activemq.jms.persistence.config.PersistedJNDI; import org.apache.activemq.jms.persistence.config.PersistedBindings;
import org.apache.activemq.jms.persistence.config.PersistedType; import org.apache.activemq.jms.persistence.config.PersistedType;
import org.apache.activemq.jms.persistence.impl.journal.JMSJournalStorageManagerImpl; import org.apache.activemq.jms.persistence.impl.journal.JMSJournalStorageManagerImpl;
import org.apache.activemq.jms.persistence.impl.nullpm.NullJMSStorageManagerImpl; import org.apache.activemq.jms.persistence.impl.nullpm.NullJMSStorageManagerImpl;
@ -93,7 +90,7 @@ import org.apache.activemq.utils.json.JSONArray;
import org.apache.activemq.utils.json.JSONObject; import org.apache.activemq.utils.json.JSONObject;
/** /**
* A Deployer used to create and add to JNDI queues, topics and connection * A Deployer used to create and add to Bindings queues, topics and connection
* factories. Typically this would only be used in an app server env. * factories. Typically this would only be used in an app server env.
* <p> * <p>
* JMS Connection Factories and Destinations can be configured either * JMS Connection Factories and Destinations can be configured either
@ -120,11 +117,11 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
private final Map<String, ActiveMQConnectionFactory> connectionFactories = new HashMap<String, ActiveMQConnectionFactory>(); private final Map<String, ActiveMQConnectionFactory> connectionFactories = new HashMap<String, ActiveMQConnectionFactory>();
private final Map<String, List<String>> queueJNDI = new HashMap<String, List<String>>(); private final Map<String, List<String>> queueBindings = new HashMap<String, List<String>>();
private final Map<String, List<String>> topicJNDI = new HashMap<String, List<String>>(); private final Map<String, List<String>> topicBindings = new HashMap<String, List<String>>();
private final Map<String, List<String>> connectionFactoryJNDI = new HashMap<String, List<String>>(); private final Map<String, List<String>> connectionFactoryBindings = new HashMap<String, List<String>>();
// We keep things cached if objects are created while the JMS is not active // We keep things cached if objects are created while the JMS is not active
private final List<Runnable> cachedCommands = new ArrayList<Runnable>(); private final List<Runnable> cachedCommands = new ArrayList<Runnable>();
@ -143,15 +140,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
private final String configFileName; private final String configFileName;
private boolean contextSet;
private JMSConfiguration config; private JMSConfiguration config;
private Configuration coreConfig; private Configuration coreConfig;
private JMSStorageManager storage; private JMSStorageManager storage;
private final Map<String, List<String>> unRecoveredJndi = new HashMap<String, List<String>>(); private final Map<String, List<String>> unRecoveredBindings = new HashMap<String, List<String>>();
public JMSServerManagerImpl(final ActiveMQServer server) throws Exception public JMSServerManagerImpl(final ActiveMQServer server) throws Exception
{ {
@ -269,7 +264,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
// do not clear the cachedCommands - HORNETQ-1047 // do not clear the cachedCommands - HORNETQ-1047
recoverJndiBindings(); recoverBindings();
} }
catch (Exception e) catch (Exception e)
{ {
@ -306,11 +301,11 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
storage.stop(); storage.stop();
} }
unbindJNDI(queueJNDI); unbindBindings(queueBindings);
unbindJNDI(topicJNDI); unbindBindings(topicBindings);
unbindJNDI(connectionFactoryJNDI); unbindBindings(connectionFactoryBindings);
for (String connectionFactory : new HashSet<String>(connectionFactories.keySet())) for (String connectionFactory : new HashSet<String>(connectionFactories.keySet()))
{ {
@ -318,12 +313,12 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
connectionFactories.clear(); connectionFactories.clear();
connectionFactoryJNDI.clear(); connectionFactoryBindings.clear();
queueJNDI.clear(); queueBindings.clear();
queues.clear(); queues.clear();
topicJNDI.clear(); topicBindings.clear();
topics.clear(); topics.clear();
// it could be null if a backup // it could be null if a backup
@ -352,102 +347,102 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
public void recoverJndiBindings(String name, PersistedType type) throws NamingException public void recoverregistryBindings(String name, PersistedType type) throws NamingException
{ {
List<String> bindings = unRecoveredJndi.get(name); List<String> bindings = unRecoveredBindings.get(name);
if ((bindings != null) && (bindings.size() > 0)) if ((bindings != null) && (bindings.size() > 0))
{ {
Map<String, List<String>> mapJNDI; Map<String, List<String>> mapBindings;
Map<String, ?> objects; Map<String, ?> objects;
switch (type) switch (type)
{ {
case Queue: case Queue:
mapJNDI = queueJNDI; mapBindings = queueBindings;
objects = queues; objects = queues;
break; break;
case Topic: case Topic:
mapJNDI = topicJNDI; mapBindings = topicBindings;
objects = topics; objects = topics;
break; break;
default: default:
case ConnectionFactory: case ConnectionFactory:
mapJNDI = connectionFactoryJNDI; mapBindings = connectionFactoryBindings;
objects = connectionFactories; objects = connectionFactories;
break; break;
} }
Object objectToBind = objects.get(name); Object objectToBind = objects.get(name);
List<String> jndiList = mapJNDI.get(name); List<String> bindingsList = mapBindings.get(name);
if (objectToBind == null) if (objectToBind == null)
{ {
return; return;
} }
if (jndiList == null) if (bindingsList == null)
{ {
jndiList = new ArrayList<String>(); bindingsList = new ArrayList<String>();
mapJNDI.put(name, jndiList); mapBindings.put(name, bindingsList);
} }
for (String jndi : bindings) for (String binding : bindings)
{ {
jndiList.add(jndi); bindingsList.add(binding);
bindToJndi(jndi, objectToBind); bindToBindings(binding, objectToBind);
} }
unRecoveredJndi.remove(name); unRecoveredBindings.remove(name);
} }
} }
private void recoverJndiBindings() throws Exception private void recoverBindings() throws Exception
{ {
//now its time to add journal recovered stuff //now its time to add journal recovered stuff
List<PersistedJNDI> jndiSpace = storage.recoverPersistedJNDI(); List<PersistedBindings> bindingsSpace = storage.recoverPersistedBindings();
for (PersistedJNDI record : jndiSpace) for (PersistedBindings record : bindingsSpace)
{ {
Map<String, List<String>> mapJNDI; Map<String, List<String>> mapBindings;
Map<String, ?> objects; Map<String, ?> objects;
switch (record.getType()) switch (record.getType())
{ {
case Queue: case Queue:
mapJNDI = queueJNDI; mapBindings = queueBindings;
objects = queues; objects = queues;
break; break;
case Topic: case Topic:
mapJNDI = topicJNDI; mapBindings = topicBindings;
objects = topics; objects = topics;
break; break;
default: default:
case ConnectionFactory: case ConnectionFactory:
mapJNDI = connectionFactoryJNDI; mapBindings = connectionFactoryBindings;
objects = connectionFactories; objects = connectionFactories;
break; break;
} }
Object objectToBind = objects.get(record.getName()); Object objectToBind = objects.get(record.getName());
List<String> jndiList = mapJNDI.get(record.getName()); List<String> bindingsList = mapBindings.get(record.getName());
if (objectToBind == null) if (objectToBind == null)
{ {
unRecoveredJndi.put(record.getName(), record.getJndi()); unRecoveredBindings.put(record.getName(), record.getBindings());
continue; continue;
} }
if (jndiList == null) if (bindingsList == null)
{ {
jndiList = new ArrayList<String>(); bindingsList = new ArrayList<String>();
mapJNDI.put(record.getName(), jndiList); mapBindings.put(record.getName(), bindingsList);
} }
for (String jndi : record.getJndi()) for (String bindings : record.getBindings())
{ {
jndiList.add(jndi); bindingsList.add(bindings);
bindToJndi(jndi, objectToBind); bindToBindings(bindings, objectToBind);
} }
} }
@ -477,17 +472,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
return; return;
} }
if (registry == null)
{
if (!contextSet)
{
if (System.getProperty(Context.INITIAL_CONTEXT_FACTORY) != null)
{
registry = new JndiBindingRegistry(new InitialContext());
}
}
}
deploymentManager = new FileDeploymentManager(server.getConfiguration().getFileDeployerScanPeriod()); deploymentManager = new FileDeploymentManager(server.getConfiguration().getFileDeployerScanPeriod());
server.registerActivateCallback(this); server.registerActivateCallback(this);
/** /**
@ -567,17 +551,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
return server.getSecurityRepository().getMatch(addressMatch); return server.getSecurityRepository().getMatch(addressMatch);
} }
public synchronized void setContext(final Context context)
{
if (registry == null || registry instanceof JndiBindingRegistry)
{
registry = new JndiBindingRegistry(context);
registry.setContext(context);
}
contextSet = true;
}
public synchronized String getVersion() public synchronized String getVersion()
{ {
checkInitialised(); checkInitialised();
@ -589,7 +562,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final String queueName, final String queueName,
final String selectorString, final String selectorString,
final boolean durable, final boolean durable,
final String... jndi) throws Exception final String... bindings) throws Exception
{ {
if (active && queues.get(queueName) != null) if (active && queues.get(queueName) != null)
@ -608,7 +581,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override @Override
public void runException() throws Exception public void runException() throws Exception
{ {
checkJNDI(jndi); checkBindings(bindings);
if (internalCreateQueue(queueName, selectorString, durable)) if (internalCreateQueue(queueName, selectorString, durable))
{ {
@ -620,22 +593,22 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
throw new IllegalArgumentException("Queue does not exist"); throw new IllegalArgumentException("Queue does not exist");
} }
String[] usedJNDI = null; String[] usedBindings = null;
if (jndi != null) if (bindings != null)
{ {
ArrayList<String> bindings = new ArrayList<String>(); ArrayList<String> bindingsToAdd = new ArrayList<String>();
for (String jndiItem : jndi) for (String bindingsItem : bindings)
{ {
if (bindToJndi(jndiItem, destination)) if (bindToBindings(bindingsItem, destination))
{ {
bindings.add(jndiItem); bindingsToAdd.add(bindingsItem);
} }
} }
usedJNDI = bindings.toArray(new String[bindings.size()]); usedBindings = bindingsToAdd.toArray(new String[bindingsToAdd.size()]);
addToBindings(queueJNDI, queueName, usedJNDI); addToBindings(queueBindings, queueName, usedBindings);
} }
if (storeConfig && durable) if (storeConfig && durable)
@ -644,9 +617,9 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
queueName, queueName,
selectorString, selectorString,
durable)); durable));
if (usedJNDI != null) if (usedBindings != null)
{ {
storage.addJNDI(PersistedType.Queue, queueName, usedJNDI); storage.addBindings(PersistedType.Queue, queueName, usedBindings);
} }
} }
} }
@ -657,7 +630,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
return true; return true;
} }
public synchronized boolean createTopic(final boolean storeConfig, final String topicName, final String... jndi) throws Exception public synchronized boolean createTopic(final boolean storeConfig, final String topicName, final String... bindings) throws Exception
{ {
if (active && topics.get(topicName) != null) if (active && topics.get(topicName) != null)
{ {
@ -675,7 +648,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override @Override
public void runException() throws Exception public void runException() throws Exception
{ {
checkJNDI(jndi); checkBindings(bindings);
if (internalCreateTopic(topicName)) if (internalCreateTopic(topicName))
{ {
@ -687,23 +660,23 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
throw new IllegalArgumentException("Queue does not exist"); throw new IllegalArgumentException("Queue does not exist");
} }
ArrayList<String> bindings = new ArrayList<String>(); ArrayList<String> bindingsToAdd = new ArrayList<String>();
for (String jndiItem : jndi) for (String bindingsItem : bindings)
{ {
if (bindToJndi(jndiItem, destination)) if (bindToBindings(bindingsItem, destination))
{ {
bindings.add(jndiItem); bindingsToAdd.add(bindingsItem);
} }
} }
String[] usedJNDI = bindings.toArray(new String[bindings.size()]); String[] usedBindings = bindingsToAdd.toArray(new String[bindingsToAdd.size()]);
addToBindings(topicJNDI, topicName, usedJNDI); addToBindings(topicBindings, topicName, usedBindings);
if (storeConfig) if (storeConfig)
{ {
storage.storeDestination(new PersistedDestination(PersistedType.Topic, topicName)); storage.storeDestination(new PersistedDestination(PersistedType.Topic, topicName));
storage.addJNDI(PersistedType.Topic, topicName, usedJNDI); storage.addBindings(PersistedType.Topic, topicName, usedBindings);
} }
} }
} }
@ -714,11 +687,11 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
public boolean addTopicToJndi(final String topicName, final String jndiBinding) throws Exception public boolean addTopicToBindingRegistry(final String topicName, final String registryBinding) throws Exception
{ {
checkInitialised(); checkInitialised();
checkJNDI(jndiBinding); checkBindings(registryBinding);
ActiveMQTopic destination = topics.get(topicName); ActiveMQTopic destination = topics.get(topicName);
if (destination == null) if (destination == null)
@ -729,36 +702,36 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{ {
throw new IllegalArgumentException(topicName + " is not a topic"); throw new IllegalArgumentException(topicName + " is not a topic");
} }
boolean added = bindToJndi(jndiBinding, destination); boolean added = bindToBindings(registryBinding, destination);
if (added) if (added)
{ {
addToBindings(topicJNDI, topicName, jndiBinding); addToBindings(topicBindings, topicName, registryBinding);
storage.addJNDI(PersistedType.Topic, topicName, jndiBinding); storage.addBindings(PersistedType.Topic, topicName, registryBinding);
} }
return added; return added;
} }
public String[] getJNDIOnQueue(String queue) public String[] getBindingsOnQueue(String queue)
{ {
return getJNDIList(queueJNDI, queue); return getBindingsList(queueBindings, queue);
} }
public String[] getJNDIOnTopic(String topic) public String[] getBindingsOnTopic(String topic)
{ {
return getJNDIList(topicJNDI, topic); return getBindingsList(topicBindings, topic);
} }
public String[] getJNDIOnConnectionFactory(String factoryName) public String[] getBindingsOnConnectionFactory(String factoryName)
{ {
return getJNDIList(connectionFactoryJNDI, factoryName); return getBindingsList(connectionFactoryBindings, factoryName);
} }
public boolean addQueueToJndi(final String queueName, final String jndiBinding) throws Exception public boolean addQueueToBindingRegistry(final String queueName, final String registryBinding) throws Exception
{ {
checkInitialised(); checkInitialised();
checkJNDI(jndiBinding); checkBindings(registryBinding);
ActiveMQQueue destination = queues.get(queueName); ActiveMQQueue destination = queues.get(queueName);
if (destination == null) if (destination == null)
@ -769,56 +742,56 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{ {
throw new IllegalArgumentException(queueName + " is not a queue"); throw new IllegalArgumentException(queueName + " is not a queue");
} }
boolean added = bindToJndi(jndiBinding, destination); boolean added = bindToBindings(registryBinding, destination);
if (added) if (added)
{ {
addToBindings(queueJNDI, queueName, jndiBinding); addToBindings(queueBindings, queueName, registryBinding);
storage.addJNDI(PersistedType.Queue, queueName, jndiBinding); storage.addBindings(PersistedType.Queue, queueName, registryBinding);
} }
return added; return added;
} }
public boolean addConnectionFactoryToJNDI(final String name, final String jndiBinding) throws Exception public boolean addConnectionFactoryToBindingRegistry(final String name, final String registryBinding) throws Exception
{ {
checkInitialised(); checkInitialised();
checkJNDI(jndiBinding); checkBindings(registryBinding);
ActiveMQConnectionFactory factory = connectionFactories.get(name); ActiveMQConnectionFactory factory = connectionFactories.get(name);
if (factory == null) if (factory == null)
{ {
throw new IllegalArgumentException("Factory does not exist"); throw new IllegalArgumentException("Factory does not exist");
} }
if (registry.lookup(jndiBinding) != null) if (registry.lookup(registryBinding) != null)
{ {
throw ActiveMQJMSServerBundle.BUNDLE.cfJndiExists(name); throw ActiveMQJMSServerBundle.BUNDLE.cfBindingsExists(name);
} }
boolean added = bindToJndi(jndiBinding, factory); boolean added = bindToBindings(registryBinding, factory);
if (added) if (added)
{ {
addToBindings(connectionFactoryJNDI, name, jndiBinding); addToBindings(connectionFactoryBindings, name, registryBinding);
storage.addJNDI(PersistedType.ConnectionFactory, name, jndiBinding); storage.addBindings(PersistedType.ConnectionFactory, name, registryBinding);
} }
return added; return added;
} }
@Override @Override
public boolean removeQueueFromJNDI(String name, String jndi) throws Exception public boolean removeQueueFromBindingRegistry(String name, String bindings) throws Exception
{ {
checkInitialised(); checkInitialised();
boolean removed = removeFromJNDI(queueJNDI, name, jndi); boolean removed = removeFromBindings(queueBindings, name, bindings);
if (removed) if (removed)
{ {
storage.deleteJNDI(PersistedType.Queue, name, jndi); storage.deleteBindings(PersistedType.Queue, name, bindings);
} }
return removed; return removed;
} }
@Override @Override
public boolean removeQueueFromJNDI(final String name) throws Exception public boolean removeQueueFromBindingRegistry(final String name) throws Exception
{ {
final AtomicBoolean valueReturn = new AtomicBoolean(false); final AtomicBoolean valueReturn = new AtomicBoolean(false);
@ -828,7 +801,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override @Override
public String toString() public String toString()
{ {
return "removeQueueFromJNDI for " + name; return "removeQueueFromBindings for " + name;
} }
@Override @Override
@ -836,7 +809,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{ {
checkInitialised(); checkInitialised();
if (removeFromJNDI(queues, queueJNDI, name)) if (removeFromBindings(queues, queueBindings, name))
{ {
storage.deleteDestination(PersistedType.Queue, name); storage.deleteDestination(PersistedType.Queue, name);
valueReturn.set(true); valueReturn.set(true);
@ -848,13 +821,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
@Override @Override
public boolean removeTopicFromJNDI(String name, String jndi) throws Exception public boolean removeTopicFromBindingRegistry(String name, String bindings) throws Exception
{ {
checkInitialised(); checkInitialised();
if (removeFromJNDI(topicJNDI, name, jndi)) if (removeFromBindings(topicBindings, name, bindings))
{ {
storage.deleteJNDI(PersistedType.Topic, name, jndi); storage.deleteBindings(PersistedType.Topic, name, bindings);
return true; return true;
} }
else else
@ -864,9 +837,9 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.activemq.jms.server.JMSServerManager#removeTopicFromJNDI(java.lang.String, java.lang.String) * @see org.apache.activemq.jms.server.JMSServerManager#removeTopicFromBindings(java.lang.String, java.lang.String)
*/ */
public boolean removeTopicFromJNDI(final String name) throws Exception public boolean removeTopicFromBindingRegistry(final String name) throws Exception
{ {
final AtomicBoolean valueReturn = new AtomicBoolean(false); final AtomicBoolean valueReturn = new AtomicBoolean(false);
@ -876,7 +849,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override @Override
public String toString() public String toString()
{ {
return "removeTopicFromJNDI for " + name; return "removeTopicFromBindings for " + name;
} }
@Override @Override
@ -884,7 +857,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{ {
checkInitialised(); checkInitialised();
if (removeFromJNDI(topics, topicJNDI, name)) if (removeFromBindings(topics, topicBindings, name))
{ {
storage.deleteDestination(PersistedType.Topic, name); storage.deleteDestination(PersistedType.Topic, name);
valueReturn.set(true); valueReturn.set(true);
@ -896,23 +869,23 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
@Override @Override
public boolean removeConnectionFactoryFromJNDI(String name, String jndi) throws Exception public boolean removeConnectionFactoryFromBindingRegistry(String name, String bindings) throws Exception
{ {
checkInitialised(); checkInitialised();
removeFromJNDI(connectionFactoryJNDI, name, jndi); removeFromBindings(connectionFactoryBindings, name, bindings);
storage.deleteJNDI(PersistedType.ConnectionFactory, name, jndi); storage.deleteBindings(PersistedType.ConnectionFactory, name, bindings);
return true; return true;
} }
@Override @Override
public boolean removeConnectionFactoryFromJNDI(String name) throws Exception public boolean removeConnectionFactoryFromBindingRegistry(String name) throws Exception
{ {
checkInitialised(); checkInitialised();
removeFromJNDI(connectionFactories, connectionFactoryJNDI, name); removeFromBindings(connectionFactories, connectionFactoryBindings, name);
storage.deleteConnectionFactory(name); storage.deleteConnectionFactory(name);
@ -931,13 +904,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
server.destroyQueue(ActiveMQDestination.createQueueAddressFromName(name), null, !removeConsumers, removeConsumers); server.destroyQueue(ActiveMQDestination.createQueueAddressFromName(name), null, !removeConsumers, removeConsumers);
// if the queue has consumers and 'removeConsumers' is false then the queue won't actually be removed // if the queue has consumers and 'removeConsumers' is false then the queue won't actually be removed
// therefore only remove the queue from JNDI, etc. if the queue is actually removed // therefore only remove the queue from Bindings, etc. if the queue is actually removed
if (this.server.getPostOffice().getBinding(ActiveMQDestination.createQueueAddressFromName(name)) == null) if (this.server.getPostOffice().getBinding(ActiveMQDestination.createQueueAddressFromName(name)) == null)
{ {
removeFromJNDI(queues, queueJNDI, name); removeFromBindings(queues, queueBindings, name);
queues.remove(name); queues.remove(name);
queueJNDI.remove(name); queueBindings.remove(name);
jmsManagementService.unregisterQueue(name); jmsManagementService.unregisterQueue(name);
@ -982,10 +955,10 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
if (addressControl.getQueueNames().length == 0) if (addressControl.getQueueNames().length == 0)
{ {
removeFromJNDI(topics, topicJNDI, name); removeFromBindings(topics, topicBindings, name);
topics.remove(name); topics.remove(name);
topicJNDI.remove(name); topicBindings.remove(name);
jmsManagementService.unregisterTopic(name); jmsManagementService.unregisterTopic(name);
@ -1009,7 +982,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final boolean ha, final boolean ha,
final JMSFactoryType cfType, final JMSFactoryType cfType,
final List<String> connectorNames, final List<String> connectorNames,
String... jndiBindings) throws Exception String... registryBindings) throws Exception
{ {
checkInitialised(); checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name); ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1021,7 +994,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
.setConnectorNames(connectorNames) .setConnectorNames(connectorNames)
.setFactoryType(cfType); .setFactoryType(cfType);
createConnectionFactory(true, configuration, jndiBindings); createConnectionFactory(true, configuration, registryBindings);
} }
} }
@ -1059,7 +1032,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final int reconnectAttempts, final int reconnectAttempts,
final boolean failoverOnInitialConnection, final boolean failoverOnInitialConnection,
final String groupId, final String groupId,
String... jndiBindings) throws Exception String... registryBindings) throws Exception
{ {
checkInitialised(); checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name); ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1100,7 +1073,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
.setFailoverOnInitialConnection(failoverOnInitialConnection) .setFailoverOnInitialConnection(failoverOnInitialConnection)
.setGroupID(groupId); .setGroupID(groupId);
createConnectionFactory(true, configuration, jndiBindings); createConnectionFactory(true, configuration, registryBindings);
} }
} }
@ -1138,7 +1111,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final int reconnectAttempts, final int reconnectAttempts,
final boolean failoverOnInitialConnection, final boolean failoverOnInitialConnection,
final String groupId, final String groupId,
final String... jndiBindings) throws Exception final String... registryBindings) throws Exception
{ {
checkInitialised(); checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name); ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1147,7 +1120,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl() ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl()
.setName(name) .setName(name)
.setHA(ha) .setHA(ha)
.setBindings(jndiBindings) .setBindings(registryBindings)
.setDiscoveryGroupName(discoveryGroupName) .setDiscoveryGroupName(discoveryGroupName)
.setFactoryType(cfType) .setFactoryType(cfType)
.setClientID(clientID) .setClientID(clientID)
@ -1179,7 +1152,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
.setMaxRetryInterval(maxRetryInterval) .setMaxRetryInterval(maxRetryInterval)
.setReconnectAttempts(reconnectAttempts) .setReconnectAttempts(reconnectAttempts)
.setFailoverOnInitialConnection(failoverOnInitialConnection); .setFailoverOnInitialConnection(failoverOnInitialConnection);
createConnectionFactory(true, configuration, jndiBindings); createConnectionFactory(true, configuration, registryBindings);
} }
} }
@ -1187,7 +1160,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final boolean ha, final boolean ha,
final JMSFactoryType cfType, final JMSFactoryType cfType,
final String discoveryGroupName, final String discoveryGroupName,
final String... jndiBindings) throws Exception final String... registryBindings) throws Exception
{ {
checkInitialised(); checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name); ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1196,34 +1169,34 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl() ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl()
.setName(name) .setName(name)
.setHA(ha) .setHA(ha)
.setBindings(jndiBindings) .setBindings(registryBindings)
.setDiscoveryGroupName(discoveryGroupName); .setDiscoveryGroupName(discoveryGroupName);
createConnectionFactory(true, configuration, jndiBindings); createConnectionFactory(true, configuration, registryBindings);
} }
} }
public synchronized ActiveMQConnectionFactory recreateCF(String name, ConnectionFactoryConfiguration cf) throws Exception public synchronized ActiveMQConnectionFactory recreateCF(String name, ConnectionFactoryConfiguration cf) throws Exception
{ {
List<String> jndi = connectionFactoryJNDI.get(name); List<String> bindings = connectionFactoryBindings.get(name);
if (jndi == null) if (bindings == null)
{ {
throw ActiveMQJMSServerBundle.BUNDLE.cfDoesntExist(name); throw ActiveMQJMSServerBundle.BUNDLE.cfDoesntExist(name);
} }
String[] usedJNDI = jndi.toArray(new String[jndi.size()]); String[] usedBindings = bindings.toArray(new String[bindings.size()]);
ActiveMQConnectionFactory realCF = internalCreateCFPOJO(cf); ActiveMQConnectionFactory realCF = internalCreateCFPOJO(cf);
if (cf.isPersisted()) if (cf.isPersisted())
{ {
storage.storeConnectionFactory(new PersistedConnectionFactory(cf)); storage.storeConnectionFactory(new PersistedConnectionFactory(cf));
storage.addJNDI(PersistedType.ConnectionFactory, cf.getName(), usedJNDI); storage.addBindings(PersistedType.ConnectionFactory, cf.getName(), usedBindings);
} }
for (String jndiElement : usedJNDI) for (String bindingsElement : usedBindings)
{ {
this.bindToJndi(jndiElement, realCF); this.bindToBindings(bindingsElement, realCF);
} }
return realCF; return realCF;
@ -1231,7 +1204,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
public synchronized void createConnectionFactory(final boolean storeConfig, public synchronized void createConnectionFactory(final boolean storeConfig,
final ConnectionFactoryConfiguration cfConfig, final ConnectionFactoryConfiguration cfConfig,
final String... jndi) throws Exception final String... bindings) throws Exception
{ {
runAfterActive(new WrappedRunnable() runAfterActive(new WrappedRunnable()
{ {
@ -1245,30 +1218,30 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override @Override
public void runException() throws Exception public void runException() throws Exception
{ {
checkJNDI(jndi); checkBindings(bindings);
ActiveMQConnectionFactory cf = internalCreateCF(storeConfig, cfConfig); ActiveMQConnectionFactory cf = internalCreateCF(storeConfig, cfConfig);
ArrayList<String> bindings = new ArrayList<String>(); ArrayList<String> bindingsToAdd = new ArrayList<String>();
for (String jndiItem : jndi) for (String bindingsItem : bindings)
{ {
if (bindToJndi(jndiItem, cf)) if (bindToBindings(bindingsItem, cf))
{ {
bindings.add(jndiItem); bindingsToAdd.add(bindingsItem);
} }
} }
String[] usedJNDI = bindings.toArray(new String[bindings.size()]); String[] usedBindings = bindingsToAdd.toArray(new String[bindingsToAdd.size()]);
addToBindings(connectionFactoryJNDI, cfConfig.getName(), usedJNDI); addToBindings(connectionFactoryBindings, cfConfig.getName(), usedBindings);
if (storeConfig) if (storeConfig)
{ {
storage.storeConnectionFactory(new PersistedConnectionFactory(cfConfig)); storage.storeConnectionFactory(new PersistedConnectionFactory(cfConfig));
storage.addJNDI(PersistedType.ConnectionFactory, cfConfig.getName(), usedJNDI); storage.addBindings(PersistedType.ConnectionFactory, cfConfig.getName(), usedBindings);
} }
JMSServerManagerImpl.this.recoverJndiBindings(cfConfig.getName(), PersistedType.ConnectionFactory); JMSServerManagerImpl.this.recoverregistryBindings(cfConfig.getName(), PersistedType.ConnectionFactory);
sendNotification(JMSNotificationType.CONNECTION_FACTORY_CREATED, cfConfig.getName()); sendNotification(JMSNotificationType.CONNECTION_FACTORY_CREATED, cfConfig.getName());
} }
}); });
@ -1300,7 +1273,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
this.storage = newStorage; this.storage = newStorage;
} }
private String[] getJNDIList(final Map<String, List<String>> map, final String name) private String[] getBindingsList(final Map<String, List<String>> map, final String name)
{ {
List<String> result = map.get(name); List<String> result = map.get(name);
if (result == null) if (result == null)
@ -1341,7 +1314,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
queues.put(queueName, activeMQQueue); queues.put(queueName, activeMQQueue);
this.recoverJndiBindings(queueName, PersistedType.Queue); this.recoverregistryBindings(queueName, PersistedType.Queue);
jmsManagementService.registerQueue(activeMQQueue, queue); jmsManagementService.registerQueue(activeMQQueue, queue);
@ -1379,7 +1352,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
topics.put(topicName, activeMQTopic); topics.put(topicName, activeMQTopic);
this.recoverJndiBindings(topicName, PersistedType.Topic); this.recoverregistryBindings(topicName, PersistedType.Topic);
jmsManagementService.registerTopic(activeMQTopic); jmsManagementService.registerTopic(activeMQTopic);
@ -1541,17 +1514,17 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
protected boolean shutdownConnectionFactory(final String name) throws Exception protected boolean shutdownConnectionFactory(final String name) throws Exception
{ {
checkInitialised(); checkInitialised();
List<String> jndiBindings = connectionFactoryJNDI.get(name); List<String> registryBindings = connectionFactoryBindings.get(name);
if (registry != null) if (registry != null)
{ {
for (String jndiBinding : jndiBindings) for (String registryBinding : registryBindings)
{ {
registry.unbind(jndiBinding); registry.unbind(registryBinding);
} }
} }
connectionFactoryJNDI.remove(name); connectionFactoryBindings.remove(name);
connectionFactories.remove(name); connectionFactories.remove(name);
jmsManagementService.unregisterConnectionFactory(name); jmsManagementService.unregisterConnectionFactory(name);
@ -1726,7 +1699,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
} }
private void addToBindings(Map<String, List<String>> map, String name, String... jndi) private void addToBindings(Map<String, List<String>> map, String name, String... bindings)
{ {
List<String> list = map.get(name); List<String> list = map.get(name);
if (list == null) if (list == null)
@ -1734,32 +1707,32 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
list = new ArrayList<String>(); list = new ArrayList<String>();
map.put(name, list); map.put(name, list);
} }
for (String jndiItem : jndi) for (String bindingsItem : bindings)
{ {
list.add(jndiItem); list.add(bindingsItem);
} }
} }
private void checkJNDI(final String... jndiNames) throws NamingException private void checkBindings(final String... bindingsNames) throws NamingException
{ {
if (jndiNames != null) if (bindingsNames != null)
{ {
for (String jndiName : jndiNames) for (String bindingsName : bindingsNames)
{ {
if (registry != null && registry.lookup(jndiName) != null) if (registry != null && registry.lookup(bindingsName) != null)
{ {
throw new NamingException(jndiName + " already has an object bound"); throw new NamingException(bindingsName + " already has an object bound");
} }
} }
} }
} }
private boolean bindToJndi(final String jndiName, final Object objectToBind) throws NamingException private boolean bindToBindings(final String bindingsName, final Object objectToBind) throws NamingException
{ {
if (registry != null) if (registry != null)
{ {
registry.unbind(jndiName); registry.unbind(bindingsName);
registry.bind(jndiName, objectToBind); registry.bind(bindingsName, objectToBind);
} }
return true; return true;
} }
@ -1771,11 +1744,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
return; return;
} }
if (config.getContext() != null)
{
setContext(config.getContext());
}
List<ConnectionFactoryConfiguration> connectionFactoryConfigurations = config.getConnectionFactoryConfigurations(); List<ConnectionFactoryConfiguration> connectionFactoryConfigurations = config.getConnectionFactoryConfigurations();
for (ConnectionFactoryConfiguration cfConfig : connectionFactoryConfigurations) for (ConnectionFactoryConfiguration cfConfig : connectionFactoryConfigurations)
{ {
@ -1798,7 +1766,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
/** /**
* @param param * @param param
*/ */
private void unbindJNDI(Map<String, List<String>> param) private void unbindBindings(Map<String, List<String>> param)
{ {
if (registry != null) if (registry != null)
{ {
@ -1812,7 +1780,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
catch (Exception e) catch (Exception e)
{ {
ActiveMQJMSServerLogger.LOGGER.jndiUnbindError(e, key); ActiveMQJMSServerLogger.LOGGER.bindingsUnbindError(e, key);
} }
} }
} }
@ -1881,13 +1849,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
storage.start(); storage.start();
} }
private synchronized boolean removeFromJNDI(final Map<String, ?> keys, private synchronized boolean removeFromBindings(final Map<String, ?> keys,
final Map<String, List<String>> jndiMap, final Map<String, List<String>> bindingsMap,
final String name) throws Exception final String name) throws Exception
{ {
checkInitialised(); checkInitialised();
List<String> jndiBindings = jndiMap.remove(name); List<String> registryBindings = bindingsMap.remove(name);
if (jndiBindings == null || jndiBindings.size() == 0) if (registryBindings == null || registryBindings.size() == 0)
{ {
return false; return false;
} }
@ -1897,31 +1865,31 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
} }
if (registry != null) if (registry != null)
{ {
Iterator<String> iter = jndiBindings.iterator(); Iterator<String> iter = registryBindings.iterator();
while (iter.hasNext()) while (iter.hasNext())
{ {
String jndiBinding = iter.next(); String registryBinding = iter.next();
registry.unbind(jndiBinding); registry.unbind(registryBinding);
iter.remove(); iter.remove();
} }
} }
return true; return true;
} }
private synchronized boolean removeFromJNDI(final Map<String, List<String>> jndiMap, private synchronized boolean removeFromBindings(final Map<String, List<String>> bindingsMap,
final String name, final String name,
final String jndi) throws Exception final String bindings) throws Exception
{ {
checkInitialised(); checkInitialised();
List<String> jndiBindings = jndiMap.get(name); List<String> registryBindings = bindingsMap.get(name);
if (jndiBindings == null || jndiBindings.size() == 0) if (registryBindings == null || registryBindings.size() == 0)
{ {
return false; return false;
} }
if (jndiBindings.remove(jndi)) if (registryBindings.remove(bindings))
{ {
registry.unbind(jndi); registry.unbind(bindings);
return true; return true;
} }
else else

View File

@ -52,14 +52,4 @@ public class ServletContextBindingRegistry implements BindingRegistry
public void close() public void close()
{ {
} }
public Object getContext()
{
return servletContext;
}
public void setContext(Object o)
{
servletContext = (ServletContext)o;
}
} }

View File

@ -30,22 +30,6 @@ public class JndiBindingRegistry implements BindingRegistry
{ {
private Context context; private Context context;
/**
* @return the context
*/
public Object getContext()
{
return context;
}
/**
* @param context the context to set
*/
public void setContext(Object context)
{
this.context = (Context)context;
}
public JndiBindingRegistry(Context context) public JndiBindingRegistry(Context context)
{ {
this.context = context; this.context = context;

View File

@ -47,15 +47,4 @@ public class MapBindingRegistry implements BindingRegistry
public void close() public void close()
{ {
} }
public Object getContext()
{
return registry;
}
@Override
public void setContext(Object ctx)
{
registry = (ConcurrentMap)ctx;
}
} }

View File

@ -24,17 +24,6 @@ package org.apache.activemq.spi.core.naming;
*/ */
public interface BindingRegistry public interface BindingRegistry
{ {
/** The context used by the registry.
* This may be used to setup the JNDI Context on the JNDI Registry.
* We keep it as an object here as the interface needs to be generic
* as this could be reused by others Registries (e.g set/get the Map on MapRegistry)
* @return
*/
// XXX Unused?
Object getContext();
void setContext(Object ctx);
Object lookup(String name); Object lookup(String name);
boolean bind(String name, Object obj); boolean bind(String name, Object obj);

View File

@ -81,7 +81,7 @@ import org.apache.activemq.core.settings.impl.AddressSettings;
import org.apache.activemq.core.settings.impl.HierarchicalObjectRepository; import org.apache.activemq.core.settings.impl.HierarchicalObjectRepository;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
import org.apache.activemq.jms.persistence.config.PersistedDestination; import org.apache.activemq.jms.persistence.config.PersistedDestination;
import org.apache.activemq.jms.persistence.config.PersistedJNDI; import org.apache.activemq.jms.persistence.config.PersistedBindings;
import org.apache.activemq.jms.persistence.config.PersistedType; import org.apache.activemq.jms.persistence.config.PersistedType;
import org.apache.activemq.jms.persistence.impl.journal.JMSJournalStorageManagerImpl; import org.apache.activemq.jms.persistence.impl.journal.JMSJournalStorageManagerImpl;
import org.apache.activemq.utils.Base64; import org.apache.activemq.utils.Base64;
@ -124,7 +124,7 @@ public final class XmlDataExporter
private final Map<Pair<PersistedType, String>, PersistedDestination> jmsDestinations = new ConcurrentHashMap<>(); private final Map<Pair<PersistedType, String>, PersistedDestination> jmsDestinations = new ConcurrentHashMap<>();
private final Map<Pair<PersistedType, String>, PersistedJNDI> jmsJNDI = new ConcurrentHashMap<>(); private final Map<Pair<PersistedType, String>, PersistedBindings> jmsJNDI = new ConcurrentHashMap<>();
long messagesPrinted = 0L; long messagesPrinted = 0L;
@ -392,14 +392,14 @@ public final class XmlDataExporter
ActiveMQServerLogger.LOGGER.info("Found JMS destination: " + destination.getName()); ActiveMQServerLogger.LOGGER.info("Found JMS destination: " + destination.getName());
jmsDestinations.put(new Pair<>(destination.getType(), destination.getName()), destination); jmsDestinations.put(new Pair<>(destination.getType(), destination.getName()), destination);
} }
else if (rec == JMSJournalStorageManagerImpl.JNDI_RECORD) else if (rec == JMSJournalStorageManagerImpl.BINDING_RECORD)
{ {
PersistedJNDI jndi = new PersistedJNDI(); PersistedBindings jndi = new PersistedBindings();
jndi.decode(buffer); jndi.decode(buffer);
jndi.setId(id); jndi.setId(id);
Pair<PersistedType, String> key = new Pair<>(jndi.getType(), jndi.getName()); Pair<PersistedType, String> key = new Pair<>(jndi.getType(), jndi.getName());
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (String binding : jndi.getJndi()) for (String binding : jndi.getBindings())
{ {
builder.append(binding).append(" "); builder.append(binding).append(" ");
} }
@ -680,8 +680,8 @@ public final class XmlDataExporter
xmlWriter.writeEndElement(); xmlWriter.writeEndElement();
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRIES); xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRIES);
PersistedJNDI jndi = jmsJNDI.get(new Pair<>(PersistedType.ConnectionFactory, jmsConnectionFactory.getName())); PersistedBindings jndi = jmsJNDI.get(new Pair<>(PersistedType.ConnectionFactory, jmsConnectionFactory.getName()));
for (String jndiEntry : jndi.getJndi()) for (String jndiEntry : jndi.getBindings())
{ {
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRY); xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRY);
xmlWriter.writeCharacters(jndiEntry); xmlWriter.writeCharacters(jndiEntry);
@ -719,8 +719,8 @@ public final class XmlDataExporter
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRIES); xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRIES);
PersistedJNDI jndi = jmsJNDI.get(new Pair<>(jmsDestination.getType(), jmsDestination.getName())); PersistedBindings jndi = jmsJNDI.get(new Pair<>(jmsDestination.getType(), jmsDestination.getName()));
for (String jndiEntry : jndi.getJndi()) for (String jndiEntry : jndi.getBindings())
{ {
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRY); xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRY);
xmlWriter.writeCharacters(jndiEntry); xmlWriter.writeCharacters(jndiEntry);

View File

@ -60,16 +60,4 @@ public class SpringBindingRegistry implements BindingRegistry
public void close() public void close()
{ {
} }
@Override
public Object getContext()
{
return this.factory;
}
@Override
public void setContext(Object ctx)
{
this.factory = (ConfigurableBeanFactory) ctx;
}
} }

View File

@ -23,6 +23,7 @@ import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration;
import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration; import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -101,7 +102,7 @@ public class StartStopDeadlockTest extends ServiceTestBase
final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server); final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
final InVMNamingContext context = new InVMNamingContext(); final InVMNamingContext context = new InVMNamingContext();
jmsServer.setContext(context); jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start(); jmsServer.start();

View File

@ -16,6 +16,7 @@
*/ */
package org.apache.activemq.tests.integration.client; package org.apache.activemq.tests.integration.client;
import org.apache.activemq.api.core.ActiveMQNotConnectedException; import org.apache.activemq.api.core.ActiveMQNotConnectedException;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
@ -71,7 +72,7 @@ public class FailureDeadlockTest extends ServiceTestBase
.addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)); .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
server = createServer(false, conf); server = createServer(false, conf);
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(new NullInitialContext()); jmsServer.setRegistry(new JndiBindingRegistry(new NullInitialContext()));
jmsServer.start(); jmsServer.start();
cf1 = cf1 =

View File

@ -43,6 +43,7 @@ import org.apache.activemq.core.paging.PagingStore;
import org.apache.activemq.core.postoffice.Binding; import org.apache.activemq.core.postoffice.Binding;
import org.apache.activemq.core.postoffice.Bindings; import org.apache.activemq.core.postoffice.Bindings;
import org.apache.activemq.core.postoffice.impl.LocalQueueBinding; import org.apache.activemq.core.postoffice.impl.LocalQueueBinding;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.Queue; import org.apache.activemq.core.server.Queue;
import org.apache.activemq.core.server.impl.QueueImpl; import org.apache.activemq.core.server.impl.QueueImpl;
@ -726,7 +727,7 @@ public class PagingOrderTest extends ServiceTestBase
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server); JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext(); InVMNamingContext context = new InVMNamingContext();
jmsServer.setContext(context); jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start(); jmsServer.start();
jmsServer.createTopic(true, "tt", "/topic/TT"); jmsServer.createTopic(true, "tt", "/topic/TT");
@ -775,7 +776,7 @@ public class PagingOrderTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext(); context = new InVMNamingContext();
jmsServer.setContext(context); jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start(); jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.topic.TT"); AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.topic.TT");
@ -803,7 +804,7 @@ public class PagingOrderTest extends ServiceTestBase
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server); JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext(); InVMNamingContext context = new InVMNamingContext();
jmsServer.setContext(context); jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start(); jmsServer.start();
server.getActiveMQServerControl().addAddressSettings("jms.queue.Q1", server.getActiveMQServerControl().addAddressSettings("jms.queue.Q1",
@ -858,7 +859,7 @@ public class PagingOrderTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext(); context = new InVMNamingContext();
jmsServer.setContext(context); jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start(); jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.queue.Q1"); AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.queue.Q1");

View File

@ -15,6 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.tests.integration.jms; package org.apache.activemq.tests.integration.jms;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
@ -95,7 +96,7 @@ public class FloodServerTest extends UnitTestCase
serverManager = new JMSServerManagerImpl(server); serverManager = new JMSServerManagerImpl(server);
initialContext = new InVMNamingContext(); initialContext = new InVMNamingContext();
serverManager.setContext(initialContext); serverManager.setRegistry(new JndiBindingRegistry(initialContext));
serverManager.start(); serverManager.start();
serverManager.activated(); serverManager.activated();

View File

@ -15,6 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.tests.integration.jms; package org.apache.activemq.tests.integration.jms;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
@ -160,7 +161,9 @@ public class ManualReconnectionToSingleServerTest extends ServiceTestBase
server = createServer(false, conf); server = createServer(false, conf);
JMSConfiguration configuration = new JMSConfigurationImpl(); JMSConfiguration configuration = new JMSConfigurationImpl();
configuration.setContext(context); serverManager = new JMSServerManagerImpl(server, configuration);
serverManager.setRegistry(new JndiBindingRegistry(context));
configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(QUEUE_NAME).setBindings(QUEUE_NAME)); configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(QUEUE_NAME).setBindings(QUEUE_NAME));
ArrayList<TransportConfiguration> configs = new ArrayList<TransportConfiguration>(); ArrayList<TransportConfiguration> configs = new ArrayList<TransportConfiguration>();
@ -172,7 +175,6 @@ public class ManualReconnectionToSingleServerTest extends ServiceTestBase
.setRetryInterval(1000) .setRetryInterval(1000)
.setReconnectAttempts(-1); .setReconnectAttempts(-1);
configuration.getConnectionFactoryConfigurations().add(cfConfig); configuration.getConnectionFactoryConfigurations().add(cfConfig);
serverManager = new JMSServerManagerImpl(server, configuration);
serverManager.start(); serverManager.start();
listener = new Listener(); listener = new Listener();

View File

@ -44,6 +44,7 @@ import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.api.jms.management.JMSQueueControl; import org.apache.activemq.api.jms.management.JMSQueueControl;
import org.apache.activemq.api.jms.management.TopicControl; import org.apache.activemq.api.jms.management.TopicControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
@ -122,7 +123,7 @@ public abstract class BridgeTestBase extends UnitTestCase
context0 = new InVMNamingContext(); context0 = new InVMNamingContext();
jmsServer0 = new JMSServerManagerImpl(server0); jmsServer0 = new JMSServerManagerImpl(server0);
jmsServer0.setContext(context0); jmsServer0.setRegistry(new JndiBindingRegistry(context0));
jmsServer0.start(); jmsServer0.start();
params1 = new HashMap<String, Object>(); params1 = new HashMap<String, Object>();
@ -138,7 +139,7 @@ public abstract class BridgeTestBase extends UnitTestCase
context1 = new InVMNamingContext(); context1 = new InVMNamingContext();
jmsServer1 = new JMSServerManagerImpl(server1); jmsServer1 = new JMSServerManagerImpl(server1);
jmsServer1.setContext(context1); jmsServer1.setRegistry(new JndiBindingRegistry(context1));
jmsServer1.start(); jmsServer1.start();
createQueue("sourceQueue", 0); createQueue("sourceQueue", 0);

View File

@ -43,6 +43,7 @@ import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.config.ha.ReplicaPolicyConfiguration; import org.apache.activemq.core.config.ha.ReplicaPolicyConfiguration;
import org.apache.activemq.core.config.ha.ReplicatedPolicyConfiguration; import org.apache.activemq.core.config.ha.ReplicatedPolicyConfiguration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
@ -168,7 +169,7 @@ public abstract class ClusteredBridgeTestBase extends ServiceTestBase
liveContext = new InVMContext(); liveContext = new InVMContext();
liveNode = new JMSServerManagerImpl(server0); liveNode = new JMSServerManagerImpl(server0);
liveNode.setContext(liveContext); liveNode.setRegistry(new JndiBindingRegistry(liveContext));
//backup //backup
Configuration conf = createBasicConfig() Configuration conf = createBasicConfig()
@ -185,7 +186,7 @@ public abstract class ClusteredBridgeTestBase extends ServiceTestBase
Context context = new InVMContext(); Context context = new InVMContext();
backupNode = new JMSServerManagerImpl(backup); backupNode = new JMSServerManagerImpl(backup);
backupNode.setContext(context); backupNode.setRegistry(new JndiBindingRegistry(context));
} }
public void start() throws Exception public void start() throws Exception

View File

@ -28,6 +28,7 @@ import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.api.jms.ActiveMQJMSClient; import org.apache.activemq.api.jms.ActiveMQJMSClient;
import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
import org.apache.activemq.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
@ -64,7 +65,7 @@ public class RemoteConnectionStressTest extends ServiceTestBase
InVMNamingContext namingContext = new InVMNamingContext(); InVMNamingContext namingContext = new InVMNamingContext();
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(namingContext); jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start(); jmsServer.start();

View File

@ -75,7 +75,7 @@ public class StoreConfigTest extends JMSTestBase
try try
{ {
jmsServer.addConnectionFactoryToJNDI("np", "/someCF"); jmsServer.addConnectionFactoryToBindingRegistry("np", "/someCF");
fail("Failure expected and the API let duplicates"); fail("Failure expected and the API let duplicates");
} }
catch (NamingException expected) catch (NamingException expected)
@ -100,10 +100,10 @@ public class StoreConfigTest extends JMSTestBase
jmsServer.start(); jmsServer.start();
jmsServer.addConnectionFactoryToJNDI("tst", "/newJNDI"); jmsServer.addConnectionFactoryToBindingRegistry("tst", "/newJNDI");
try try
{ {
jmsServer.addConnectionFactoryToJNDI("tst", "/newJNDI"); jmsServer.addConnectionFactoryToBindingRegistry("tst", "/newJNDI");
fail("Failure expected and the API let duplicates"); fail("Failure expected and the API let duplicates");
} }
catch (NamingException expected) catch (NamingException expected)
@ -176,7 +176,7 @@ public class StoreConfigTest extends JMSTestBase
assertNullJNDI("/t2"); assertNullJNDI("/t2");
assertNullJNDI("/t.2"); assertNullJNDI("/t.2");
jmsServer.addTopicToJndi("topicOne", "/tI"); jmsServer.addTopicToBindingRegistry("topicOne", "/tI");
jmsServer.stop(); jmsServer.stop();
jmsServer.start(); jmsServer.start();
@ -189,11 +189,11 @@ public class StoreConfigTest extends JMSTestBase
assertNullJNDI("/t.2"); assertNullJNDI("/t.2");
assertTrue(jmsServer.removeTopicFromJNDI("topicOne", "/tI")); assertTrue(jmsServer.removeTopicFromBindingRegistry("topicOne", "/tI"));
assertFalse(jmsServer.removeTopicFromJNDI("topicOne","nothing")); assertFalse(jmsServer.removeTopicFromBindingRegistry("topicOne", "nothing"));
assertFalse(jmsServer.removeTopicFromJNDI("nothing","nothing")); assertFalse(jmsServer.removeTopicFromBindingRegistry("nothing", "nothing"));
assertFalse(jmsServer.removeTopicFromJNDI("nothing")); assertFalse(jmsServer.removeTopicFromBindingRegistry("nothing"));
assertNullJNDI("/tI"); assertNullJNDI("/tI");
checkDestination("/t1"); checkDestination("/t1");
@ -208,7 +208,7 @@ public class StoreConfigTest extends JMSTestBase
checkDestination("/t.1"); checkDestination("/t.1");
jmsServer.removeTopicFromJNDI("topicOne"); jmsServer.removeTopicFromBindingRegistry("topicOne");
assertTrue(jmsServer.createTopic(true, "topicOne", "/topicx.1", "/topicx.2")); assertTrue(jmsServer.createTopic(true, "topicOne", "/topicx.1", "/topicx.2"));
@ -292,7 +292,7 @@ public class StoreConfigTest extends JMSTestBase
assertNullJNDI("/q2"); assertNullJNDI("/q2");
assertNullJNDI("/q.2"); assertNullJNDI("/q.2");
jmsServer.addQueueToJndi("queue1", "/qI"); jmsServer.addQueueToBindingRegistry("queue1", "/qI");
jmsServer.stop(); jmsServer.stop();
jmsServer.start(); jmsServer.start();
@ -305,9 +305,9 @@ public class StoreConfigTest extends JMSTestBase
assertNullJNDI("/q.2"); assertNullJNDI("/q.2");
assertTrue(jmsServer.removeQueueFromJNDI("queue1", "/q1")); assertTrue(jmsServer.removeQueueFromBindingRegistry("queue1", "/q1"));
assertFalse(jmsServer.removeQueueFromJNDI("queue1","nothing")); assertFalse(jmsServer.removeQueueFromBindingRegistry("queue1", "nothing"));
assertNullJNDI("/q1"); assertNullJNDI("/q1");
checkDestination("/q.1"); checkDestination("/q.1");
@ -321,7 +321,7 @@ public class StoreConfigTest extends JMSTestBase
checkDestination("/q.1"); checkDestination("/q.1");
checkDestination("/qI"); checkDestination("/qI");
jmsServer.removeQueueFromJNDI("queue1"); jmsServer.removeQueueFromBindingRegistry("queue1");
assertTrue(jmsServer.createQueue(true, "queue1", null, true, "/newq1", "/newq.1")); assertTrue(jmsServer.createQueue(true, "queue1", null, true, "/newq1", "/newq.1"));

View File

@ -40,6 +40,7 @@ import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration;
import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration; import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMRegistry; import org.apache.activemq.core.remoting.impl.invm.InVMRegistry;
import org.apache.activemq.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
@ -315,7 +316,7 @@ public class JMSFailoverListenerTest extends ServiceTestBase
backupJMSService = new JMSServerManagerImpl(backupService); backupJMSService = new JMSServerManagerImpl(backupService);
backupJMSService.setContext(ctx2); backupJMSService.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSService.getActiveMQServer().setIdentity("JMSBackup"); backupJMSService.getActiveMQServer().setIdentity("JMSBackup");
log.info("Starting backup"); log.info("Starting backup");
@ -340,7 +341,7 @@ public class JMSFailoverListenerTest extends ServiceTestBase
liveJMSService = new JMSServerManagerImpl(liveService); liveJMSService = new JMSServerManagerImpl(liveService);
liveJMSService.setContext(ctx1); liveJMSService.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSService.getActiveMQServer().setIdentity("JMSLive"); liveJMSService.getActiveMQServer().setIdentity("JMSLive");
log.info("Starting life"); log.info("Starting life");

View File

@ -47,6 +47,7 @@ import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration;
import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration; import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration;
import org.apache.activemq.core.protocol.core.Packet; import org.apache.activemq.core.protocol.core.Packet;
import org.apache.activemq.core.protocol.core.impl.wireformat.SessionReceiveContinuationMessage; import org.apache.activemq.core.protocol.core.impl.wireformat.SessionReceiveContinuationMessage;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMRegistry; import org.apache.activemq.core.remoting.impl.invm.InVMRegistry;
import org.apache.activemq.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
@ -543,7 +544,7 @@ public class JMSFailoverTest extends ServiceTestBase
backupJMSService = new JMSServerManagerImpl(backupService); backupJMSService = new JMSServerManagerImpl(backupService);
backupJMSService.setContext(ctx2); backupJMSService.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSService.getActiveMQServer().setIdentity("JMSBackup"); backupJMSService.getActiveMQServer().setIdentity("JMSBackup");
log.info("Starting backup"); log.info("Starting backup");
@ -569,7 +570,7 @@ public class JMSFailoverTest extends ServiceTestBase
liveJMSService = new JMSServerManagerImpl(liveService); liveJMSService = new JMSServerManagerImpl(liveService);
liveJMSService.setContext(ctx1); liveJMSService.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSService.getActiveMQServer().setIdentity("JMSLive"); liveJMSService.getActiveMQServer().setIdentity("JMSLive");
log.info("Starting life"); log.info("Starting life");

View File

@ -19,6 +19,7 @@ package org.apache.activemq.tests.integration.jms.cluster;
import org.apache.activemq.api.core.TransportConfiguration; import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.core.config.ha.ReplicaPolicyConfiguration; import org.apache.activemq.core.config.ha.ReplicaPolicyConfiguration;
import org.apache.activemq.core.config.ha.ReplicatedPolicyConfiguration; import org.apache.activemq.core.config.ha.ReplicatedPolicyConfiguration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -55,7 +56,7 @@ public class ReplicatedJMSFailoverTest extends JMSFailoverTest
backupJMSService = new JMSServerManagerImpl(backupService); backupJMSService = new JMSServerManagerImpl(backupService);
backupJMSService.setContext(ctx2); backupJMSService.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSService.start(); backupJMSService.start();
@ -74,7 +75,7 @@ public class ReplicatedJMSFailoverTest extends JMSFailoverTest
liveJMSService = new JMSServerManagerImpl(liveService); liveJMSService = new JMSServerManagerImpl(liveService);
liveJMSService.setContext(ctx1); liveJMSService.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSService.start(); liveJMSService.start();
} }

View File

@ -16,6 +16,7 @@
*/ */
package org.apache.activemq.tests.integration.jms.connection; package org.apache.activemq.tests.integration.jms.connection;
import org.apache.activemq.api.core.ActiveMQInternalErrorException; import org.apache.activemq.api.core.ActiveMQInternalErrorException;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
@ -73,7 +74,7 @@ public class ExceptionListenerTest extends UnitTestCase
.addAcceptorConfiguration(new TransportConfiguration("org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory")); .addAcceptorConfiguration(new TransportConfiguration("org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory"));
server = addServer(ActiveMQServers.newActiveMQServer(conf, false)); server = addServer(ActiveMQServers.newActiveMQServer(conf, false));
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(new NullInitialContext()); jmsServer.setRegistry(new JndiBindingRegistry(new NullInitialContext()));
jmsServer.start(); jmsServer.start();
jmsServer.createQueue(false, ExceptionListenerTest.Q_NAME, null, true, ExceptionListenerTest.Q_NAME); jmsServer.createQueue(false, ExceptionListenerTest.Q_NAME, null, true, ExceptionListenerTest.Q_NAME);
cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration("org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory")); cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration("org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory"));

View File

@ -26,6 +26,7 @@ import org.apache.activemq.api.core.UDPBroadcastGroupConfiguration;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.deployers.DeploymentManager; import org.apache.activemq.core.deployers.DeploymentManager;
import org.apache.activemq.core.deployers.impl.FileDeploymentManager; import org.apache.activemq.core.deployers.impl.FileDeploymentManager;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.jms.server.JMSServerManager; import org.apache.activemq.jms.server.JMSServerManager;
@ -157,7 +158,7 @@ public class JMSServerDeployerTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext(); context = new InVMNamingContext();
jmsServer.setContext(context); jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start(); jmsServer.start();
} }

View File

@ -210,7 +210,7 @@ public class JMSServerStartStopTest extends UnitTestCase
liveJMSServer = new JMSServerManagerImpl(liveServer, "server-start-stop-jms-config1.xml"); liveJMSServer = new JMSServerManagerImpl(liveServer, "server-start-stop-jms-config1.xml");
addActiveMQComponent(liveJMSServer); addActiveMQComponent(liveJMSServer);
liveJMSServer.setContext(null); liveJMSServer.setRegistry(null);
liveJMSServer.start(); liveJMSServer.start();
} }

View File

@ -16,6 +16,7 @@
*/ */
package org.apache.activemq.tests.integration.jms.server.config; package org.apache.activemq.tests.integration.jms.server.config;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
@ -66,7 +67,6 @@ public class JMSConfigurationTest extends ServiceTestBase
ActiveMQServer coreServer = new ActiveMQServerImpl(coreConfiguration); ActiveMQServer coreServer = new ActiveMQServerImpl(coreConfiguration);
JMSConfiguration jmsConfiguration = new JMSConfigurationImpl(); JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
jmsConfiguration.setContext(context);
TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName()); TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName());
List<TransportConfiguration> transportConfigs = new ArrayList<TransportConfiguration>(); List<TransportConfiguration> transportConfigs = new ArrayList<TransportConfiguration>();
transportConfigs.add(connectorConfig); transportConfigs.add(connectorConfig);
@ -92,6 +92,8 @@ public class JMSConfigurationTest extends ServiceTestBase
jmsConfiguration.getTopicConfigurations().add(topicConfig); jmsConfiguration.getTopicConfigurations().add(topicConfig);
JMSServerManager server = new JMSServerManagerImpl(coreServer, jmsConfiguration); JMSServerManager server = new JMSServerManagerImpl(coreServer, jmsConfiguration);
server.setRegistry(new JndiBindingRegistry(context));
server.start(); server.start();
for (String binding : cfConfig.getBindings()) for (String binding : cfConfig.getBindings())

View File

@ -20,6 +20,7 @@ import java.util.List;
import javax.management.Notification; import javax.management.Notification;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
@ -171,7 +172,7 @@ public class ConnectionFactoryControlTest extends ManagementTestBase
ctx = new InVMNamingContext(); ctx = new InVMNamingContext();
serverManager.setContext(ctx); serverManager.setRegistry(new JndiBindingRegistry(ctx));
serverManager.activated(); serverManager.activated();
} }

View File

@ -45,6 +45,7 @@ import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.api.jms.management.JMSQueueControl; import org.apache.activemq.api.jms.management.JMSQueueControl;
import org.apache.activemq.api.jms.management.JMSServerControl; import org.apache.activemq.api.jms.management.JMSServerControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.core.settings.impl.AddressFullMessagePolicy;
@ -1229,7 +1230,7 @@ public class JMSQueueControlTest extends ManagementTestBase
ActiveMQQueue testQueue = (ActiveMQQueue) ActiveMQJMSClient.createQueue(testQueueName); ActiveMQQueue testQueue = (ActiveMQQueue) ActiveMQJMSClient.createQueue(testQueueName);
JMSQueueControl queueControl = createManagementControl(testQueue); JMSQueueControl queueControl = createManagementControl(testQueue);
String[] bindings = queueControl.getJNDIBindings(); String[] bindings = queueControl.getRegistryBindings();
String newJndi = "newTestQueueAddJndi"; String newJndi = "newTestQueueAddJndi";
@ -1237,9 +1238,9 @@ public class JMSQueueControlTest extends ManagementTestBase
{ {
assertFalse(b.equals(newJndi)); assertFalse(b.equals(newJndi));
} }
queueControl.addJNDI(newJndi); queueControl.addBinding(newJndi);
bindings = queueControl.getJNDIBindings(); bindings = queueControl.getRegistryBindings();
boolean newBindingAdded = false; boolean newBindingAdded = false;
for (String b : bindings) for (String b : bindings)
{ {
@ -1258,7 +1259,7 @@ public class JMSQueueControlTest extends ManagementTestBase
queueControl = createManagementControl(testQueue); queueControl = createManagementControl(testQueue);
bindings = queueControl.getJNDIBindings(); bindings = queueControl.getRegistryBindings();
newBindingAdded = false; newBindingAdded = false;
for (String b : bindings) for (String b : bindings)
{ {
@ -1327,7 +1328,7 @@ public class JMSQueueControlTest extends ManagementTestBase
serverManager = new JMSServerManagerImpl(server); serverManager = new JMSServerManagerImpl(server);
context = new InVMNamingContext(); context = new InVMNamingContext();
serverManager.setContext(context); serverManager.setRegistry(new JndiBindingRegistry(context));
serverManager.start(); serverManager.start();
serverManager.activated(); serverManager.activated();

View File

@ -293,13 +293,13 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest
return (String)proxy.retrieveAttributeValue("selector"); return (String)proxy.retrieveAttributeValue("selector");
} }
public void addJNDI(String jndi) throws Exception public void addBinding(String jndi) throws Exception
{ {
// TODO: Add a test for this // TODO: Add a test for this
proxy.invokeOperation("addJNDI", jndi); proxy.invokeOperation("addBindings", jndi);
} }
public String[] getJNDIBindings() public String[] getRegistryBindings()
{ {
// TODO: Add a test for this // TODO: Add a test for this
return null; return null;

View File

@ -40,6 +40,7 @@ import org.apache.activemq.api.jms.management.JMSConsumerInfo;
import org.apache.activemq.api.jms.management.JMSServerControl; import org.apache.activemq.api.jms.management.JMSServerControl;
import org.apache.activemq.api.jms.management.JMSSessionInfo; import org.apache.activemq.api.jms.management.JMSSessionInfo;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
@ -89,7 +90,7 @@ public class JMSServerControl2Test extends ManagementTestBase
context = new InVMNamingContext(); context = new InVMNamingContext();
serverManager = new JMSServerManagerImpl(server); serverManager = new JMSServerManagerImpl(server);
addActiveMQComponent(serverManager); addActiveMQComponent(serverManager);
serverManager.setContext(context); serverManager.setRegistry(new JndiBindingRegistry(context));
serverManager.start(); serverManager.start();
serverManager.activated(); serverManager.activated();
} }

View File

@ -30,6 +30,7 @@ import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.api.jms.management.JMSManagementHelper; import org.apache.activemq.api.jms.management.JMSManagementHelper;
import org.apache.activemq.api.jms.management.JMSServerControl; import org.apache.activemq.api.jms.management.JMSServerControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
@ -161,7 +162,7 @@ public class JMSServerControlRestartTest extends ManagementTestBase
context = new InVMNamingContext(); context = new InVMNamingContext();
serverManager = new JMSServerManagerImpl(server); serverManager = new JMSServerManagerImpl(server);
serverManager.setContext(context); serverManager.setRegistry(new JndiBindingRegistry(context));
return serverManager; return serverManager;
} }

View File

@ -50,6 +50,7 @@ import org.apache.activemq.api.jms.ActiveMQJMSClient;
import org.apache.activemq.api.jms.management.JMSServerControl; import org.apache.activemq.api.jms.management.JMSServerControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.postoffice.QueueBinding; import org.apache.activemq.core.postoffice.QueueBinding;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
@ -61,7 +62,7 @@ import org.apache.activemq.jms.client.ActiveMQQueueConnectionFactory;
import org.apache.activemq.jms.persistence.JMSStorageManager; import org.apache.activemq.jms.persistence.JMSStorageManager;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
import org.apache.activemq.jms.persistence.config.PersistedDestination; import org.apache.activemq.jms.persistence.config.PersistedDestination;
import org.apache.activemq.jms.persistence.config.PersistedJNDI; import org.apache.activemq.jms.persistence.config.PersistedBindings;
import org.apache.activemq.jms.persistence.config.PersistedType; import org.apache.activemq.jms.persistence.config.PersistedType;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
import org.apache.activemq.tests.integration.management.ManagementControlHelper; import org.apache.activemq.tests.integration.management.ManagementControlHelper;
@ -1073,7 +1074,7 @@ public class JMSServerControlTest extends ManagementTestBase
serverManager = new JMSServerManagerImpl(server); serverManager = new JMSServerManagerImpl(server);
context = new InVMNamingContext(); context = new InVMNamingContext();
serverManager.setContext(context); serverManager.setRegistry(new JndiBindingRegistry(context));
serverManager.start(); serverManager.start();
serverManager.activated(); serverManager.activated();
@ -1207,31 +1208,31 @@ public class JMSServerControlTest extends ManagementTestBase
return delegate.recoverConnectionFactories(); return delegate.recoverConnectionFactories();
} }
public void addJNDI(PersistedType type, String name, String... address) throws Exception public void addBindings(PersistedType type, String name, String... address) throws Exception
{ {
persistedJNDIMap.putIfAbsent(name, new ArrayList<String>()); persistedJNDIMap.putIfAbsent(name, new ArrayList<String>());
for (String ad : address) for (String ad : address)
{ {
persistedJNDIMap.get(name).add(ad); persistedJNDIMap.get(name).add(ad);
} }
delegate.addJNDI(type, name, address); delegate.addBindings(type, name, address);
} }
public List<PersistedJNDI> recoverPersistedJNDI() throws Exception public List<PersistedBindings> recoverPersistedBindings() throws Exception
{ {
return delegate.recoverPersistedJNDI(); return delegate.recoverPersistedBindings();
} }
public void deleteJNDI(PersistedType type, String name, String address) throws Exception public void deleteBindings(PersistedType type, String name, String address) throws Exception
{ {
persistedJNDIMap.get(name).remove(address); persistedJNDIMap.get(name).remove(address);
delegate.deleteJNDI(type, name, address); delegate.deleteBindings(type, name, address);
} }
public void deleteJNDI(PersistedType type, String name) throws Exception public void deleteBindings(PersistedType type, String name) throws Exception
{ {
persistedJNDIMap.get(name).clear(); persistedJNDIMap.get(name).clear();
delegate.deleteJNDI(type, name); delegate.deleteBindings(type, name);
} }
public void start() throws Exception public void start() throws Exception

View File

@ -38,6 +38,7 @@ import org.apache.activemq.api.jms.management.TopicControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.postoffice.Binding; import org.apache.activemq.core.postoffice.Binding;
import org.apache.activemq.core.postoffice.impl.LocalQueueBinding; import org.apache.activemq.core.postoffice.impl.LocalQueueBinding;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
@ -95,7 +96,7 @@ public class TopicControlTest extends ManagementTestBase
Assert.assertEquals(topic.getTopicName(), topicControl.getName()); Assert.assertEquals(topic.getTopicName(), topicControl.getName());
Assert.assertEquals(topic.getAddress(), topicControl.getAddress()); Assert.assertEquals(topic.getAddress(), topicControl.getAddress());
Assert.assertEquals(topic.isTemporary(), topicControl.isTemporary()); Assert.assertEquals(topic.isTemporary(), topicControl.isTemporary());
Object[] bindings = topicControl.getJNDIBindings(); Object[] bindings = topicControl.getRegistryBindings();
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
Assert.assertEquals(topicBinding, bindings[0]); Assert.assertEquals(topicBinding, bindings[0]);
} }
@ -607,7 +608,7 @@ public class TopicControlTest extends ManagementTestBase
serverManager = new JMSServerManagerImpl(server); serverManager = new JMSServerManagerImpl(server);
serverManager.start(); serverManager.start();
serverManager.setContext(new InVMNamingContext()); serverManager.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
serverManager.activated(); serverManager.activated();
clientID = RandomUtil.randomString(); clientID = RandomUtil.randomString();

View File

@ -15,6 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.tests.integration.jms.server.management; package org.apache.activemq.tests.integration.jms.server.management;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
@ -86,7 +87,8 @@ public class TopicControlUsingJMSTest extends ManagementTestBase
Assert.assertEquals(topic.getTopicName(), proxy.retrieveAttributeValue("name")); Assert.assertEquals(topic.getTopicName(), proxy.retrieveAttributeValue("name"));
Assert.assertEquals(topic.getAddress(), proxy.retrieveAttributeValue("address")); Assert.assertEquals(topic.getAddress(), proxy.retrieveAttributeValue("address"));
Assert.assertEquals(topic.isTemporary(), proxy.retrieveAttributeValue("temporary")); Assert.assertEquals(topic.isTemporary(), proxy.retrieveAttributeValue("temporary"));
Object[] bindings = (Object[])proxy.retrieveAttributeValue("JNDIBindings"); Object[] bindings = (Object[])proxy.retrieveAttributeValue("" +
"RegistryBindings");
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
Assert.assertEquals(topicBinding, bindings[0]); Assert.assertEquals(topicBinding, bindings[0]);
} }
@ -448,7 +450,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase
serverManager = new JMSServerManagerImpl(server); serverManager = new JMSServerManagerImpl(server);
serverManager.start(); serverManager.start();
serverManager.setContext(new InVMNamingContext()); serverManager.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
serverManager.activated(); serverManager.activated();
clientID = RandomUtil.randomString(); clientID = RandomUtil.randomString();

View File

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.activemq.api.core.TransportConfiguration; import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration; import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration;
import org.apache.activemq.jms.server.config.impl.ConnectionFactoryConfigurationImpl; import org.apache.activemq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -69,7 +70,7 @@ public class ManagementActivationTest extends FailoverTestBase
super.setUp(); super.setUp();
backupJmsServer = new JMSServerManagerImpl(backupServer.getServer()); backupJmsServer = new JMSServerManagerImpl(backupServer.getServer());
context = new InVMNamingContext(); context = new InVMNamingContext();
backupJmsServer.setContext(context); backupJmsServer.setRegistry(new JndiBindingRegistry(context));
backupJmsServer.start(); backupJmsServer.start();
} }
@ -265,7 +266,7 @@ public class ManagementActivationTest extends FailoverTestBase
boolean exception = false; boolean exception = false;
try try
{ {
backupJmsServer.removeQueueFromJNDI("fakeQueue"); backupJmsServer.removeQueueFromBindingRegistry("fakeQueue");
} }
catch (Exception e) catch (Exception e)
{ {
@ -287,7 +288,7 @@ public class ManagementActivationTest extends FailoverTestBase
boolean exception = false; boolean exception = false;
try try
{ {
backupJmsServer.removeTopicFromJNDI("fakeTopic"); backupJmsServer.removeTopicFromBindingRegistry("fakeTopic");
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -31,6 +31,7 @@ import org.apache.activemq.api.core.SimpleString;
import org.apache.activemq.api.core.TransportConfiguration; import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.api.jms.management.JMSServerControl; import org.apache.activemq.api.jms.management.JMSServerControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.core.security.Role; import org.apache.activemq.core.security.Role;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
@ -128,7 +129,7 @@ public class OpenWireTestBase extends ServiceTestBase
} }
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
namingContext = new InVMNamingContext(); namingContext = new InVMNamingContext();
jmsServer.setContext(namingContext); jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start(); jmsServer.start();
registerConnectionFactory(); registerConnectionFactory();

View File

@ -67,7 +67,7 @@ public class JMSDynamicConfigTest extends JMSTestBase
jmsServer.createConnectionFactory(true, cfg, "tst"); jmsServer.createConnectionFactory(true, cfg, "tst");
assertNotNull(namingContext.lookup("tst")); assertNotNull(namingContext.lookup("tst"));
jmsServer.removeConnectionFactoryFromJNDI("tst"); jmsServer.removeConnectionFactoryFromBindingRegistry("tst");
try try
{ {

View File

@ -21,7 +21,7 @@ import org.junit.Test;
import java.util.List; import java.util.List;
import org.apache.activemq.jms.persistence.config.PersistedDestination; import org.apache.activemq.jms.persistence.config.PersistedDestination;
import org.apache.activemq.jms.persistence.config.PersistedJNDI; import org.apache.activemq.jms.persistence.config.PersistedBindings;
import org.apache.activemq.jms.persistence.config.PersistedType; import org.apache.activemq.jms.persistence.config.PersistedType;
/** /**
@ -42,11 +42,11 @@ public class JMSStorageManagerTest extends StorageManagerTestBase
jmsJournal.storeDestination(new PersistedDestination(PersistedType.Queue, jmsJournal.storeDestination(new PersistedDestination(PersistedType.Queue,
"jndiPersistQueue", null, true)); "jndiPersistQueue", null, true));
jmsJournal.addJNDI(PersistedType.Queue, "jndiPersistQueue", "jndi-1"); jmsJournal.addBindings(PersistedType.Queue, "jndiPersistQueue", "jndi-1");
List<PersistedDestination> destinations = jmsJournal.recoverDestinations(); List<PersistedDestination> destinations = jmsJournal.recoverDestinations();
List<PersistedJNDI> jndiList = jmsJournal.recoverPersistedJNDI(); List<PersistedBindings> jndiList = jmsJournal.recoverPersistedBindings();
assertEquals(1, destinations.size()); assertEquals(1, destinations.size());
@ -66,13 +66,13 @@ public class JMSStorageManagerTest extends StorageManagerTestBase
assertEquals(0, destinations.size()); assertEquals(0, destinations.size());
jndiList = jmsJournal.recoverPersistedJNDI(); jndiList = jmsJournal.recoverPersistedBindings();
assertEquals(1, jndiList.size()); assertEquals(1, jndiList.size());
PersistedJNDI jndi = jndiList.get(0); PersistedBindings jndi = jndiList.get(0);
List<String> jndis = jndi.getJndi(); List<String> jndis = jndi.getBindings();
assertEquals(1, jndis.size()); assertEquals(1, jndis.size());

View File

@ -18,6 +18,7 @@ package org.apache.activemq.tests.integration.persistence;
import org.apache.activemq.api.core.TransportConfiguration; import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.jms.server.JMSServerManager; import org.apache.activemq.jms.server.JMSServerManager;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -172,7 +173,7 @@ public class XmlImportExportTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
addActiveMQComponent(jmsServer); addActiveMQComponent(jmsServer);
namingContext = new InVMContext(); namingContext = new InVMContext();
jmsServer.setContext(namingContext); jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start(); jmsServer.start();
locator = createInVMNonHALocator(); locator = createInVMNonHALocator();
factory = createSessionFactory(locator); factory = createSessionFactory(locator);

View File

@ -29,6 +29,7 @@ import org.apache.activemq.api.core.client.ActiveMQClient;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.protocol.stomp.Stomp; import org.apache.activemq.core.protocol.stomp.Stomp;
import org.apache.activemq.core.protocol.stomp.StompProtocolManagerFactory; import org.apache.activemq.core.protocol.stomp.StompProtocolManagerFactory;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
import org.apache.activemq.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
@ -703,7 +704,7 @@ public class ExtraStompTest extends StompTestBase
.setName(getTopicName()) .setName(getTopicName())
.setBindings(getTopicName())); .setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig); server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext()); server.setRegistry(new JndiBindingRegistry((new InVMNamingContext())));
return server; return server;
} }
@ -810,7 +811,7 @@ public class ExtraStompTest extends StompTestBase
.setName(getTopicName()) .setName(getTopicName())
.setBindings(getTopicName())); .setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig); server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext()); server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
return server; return server;
} }

View File

@ -52,6 +52,7 @@ import io.netty.handler.codec.string.StringEncoder;
import org.apache.activemq.api.core.TransportConfiguration; import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.protocol.stomp.StompProtocolManagerFactory; import org.apache.activemq.core.protocol.stomp.StompProtocolManagerFactory;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
@ -215,7 +216,7 @@ public abstract class StompTestBase extends UnitTestCase
.setName(getTopicName()) .setName(getTopicName())
.setBindings(getTopicName())); .setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig); server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext()); server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
return server; return server;
} }

View File

@ -85,7 +85,7 @@ public class StompWebSocketTest extends UnitTestCase
JMSConfiguration jmsConfig = new JMSConfigurationImpl(); JMSConfiguration jmsConfig = new JMSConfigurationImpl();
server = new JMSServerManagerImpl(activeMQServer, jmsConfig); server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(null); server.setRegistry(null);
return server; return server;
} }

View File

@ -15,6 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.tests.integration.stomp.v11; package org.apache.activemq.tests.integration.stomp.v11;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
@ -121,7 +122,7 @@ public abstract class StompV11TestBase extends UnitTestCase
.setName(getTopicName()) .setName(getTopicName())
.setBindings(getTopicName())); .setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig); server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext()); server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
return server; return server;
} }

View File

@ -31,6 +31,7 @@ import org.apache.activemq.api.jms.ActiveMQJMSClient;
import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.config.ClusterConnectionConfiguration; import org.apache.activemq.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
@ -155,7 +156,7 @@ public class JMSClusteredTestBase extends ServiceTestBase
server2 = ActiveMQServers.newActiveMQServer(conf2, mBeanServer2, enablePersistence()); server2 = ActiveMQServers.newActiveMQServer(conf2, mBeanServer2, enablePersistence());
jmsServer2 = new JMSServerManagerImpl(server2, jmsconfig); jmsServer2 = new JMSServerManagerImpl(server2, jmsconfig);
context2 = new InVMNamingContext(); context2 = new InVMNamingContext();
jmsServer2.setContext(context2); jmsServer2.setRegistry(new JndiBindingRegistry(context2));
} }
/** /**
@ -202,7 +203,7 @@ public class JMSClusteredTestBase extends ServiceTestBase
server1 = ActiveMQServers.newActiveMQServer(conf1, mBeanServer1, enablePersistence()); server1 = ActiveMQServers.newActiveMQServer(conf1, mBeanServer1, enablePersistence());
jmsServer1 = new JMSServerManagerImpl(server1, jmsconfig); jmsServer1 = new JMSServerManagerImpl(server1, jmsconfig);
context1 = new InVMNamingContext(); context1 = new InVMNamingContext();
jmsServer1.setContext(context1); jmsServer1.setRegistry(new JndiBindingRegistry(context1));
} }
protected boolean enablePersistence() protected boolean enablePersistence()

View File

@ -38,6 +38,7 @@ import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.api.core.management.QueueControl; import org.apache.activemq.api.core.management.QueueControl;
import org.apache.activemq.api.jms.management.JMSQueueControl; import org.apache.activemq.api.jms.management.JMSQueueControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration; import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration;
@ -159,7 +160,7 @@ public class JMSTestBase extends ServiceTestBase
addServer(server); addServer(server);
jmsServer = new JMSServerManagerImpl(server); jmsServer = new JMSServerManagerImpl(server);
namingContext = new InVMNamingContext(); namingContext = new InVMNamingContext();
jmsServer.setContext(namingContext); jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start(); jmsServer.start();
registerConnectionFactory(); registerConnectionFactory();
@ -178,7 +179,7 @@ public class JMSTestBase extends ServiceTestBase
protected void restartServer() throws Exception protected void restartServer() throws Exception
{ {
namingContext = new InVMNamingContext(); namingContext = new InVMNamingContext();
jmsServer.setContext(namingContext); jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start(); jmsServer.start();
jmsServer.activated(); jmsServer.activated();
registerConnectionFactory(); registerConnectionFactory();

View File

@ -140,7 +140,6 @@ public abstract class ActiveMQServerTestCase
{ {
// create any new server we need // create any new server we need
ActiveMQServerTestCase.servers.add(ServerManagement.create()); ActiveMQServerTestCase.servers.add(ServerManagement.create());
// start the servers if needed // start the servers if needed
if (!ActiveMQServerTestCase.servers.get(0).isStarted()) if (!ActiveMQServerTestCase.servers.get(0).isStarted())
{ {

View File

@ -37,6 +37,7 @@ import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.api.jms.management.JMSQueueControl; import org.apache.activemq.api.jms.management.JMSQueueControl;
import org.apache.activemq.api.jms.management.TopicControl; import org.apache.activemq.api.jms.management.TopicControl;
import org.apache.activemq.core.config.impl.FileConfiguration; import org.apache.activemq.core.config.impl.FileConfiguration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.core.security.Role; import org.apache.activemq.core.security.Role;
import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServer;
@ -119,6 +120,7 @@ public class LocalTestServer implements Server, Runnable
ActiveMQServerImpl activeMQServer = new ActiveMQServerImpl(fileConfiguration, beanServer, securityManager); ActiveMQServerImpl activeMQServer = new ActiveMQServerImpl(fileConfiguration, beanServer, securityManager);
jmsServerManager = new JMSServerManagerImpl(activeMQServer); jmsServerManager = new JMSServerManagerImpl(activeMQServer);
System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID()); System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
jmsServerManager.setRegistry(new JndiBindingRegistry(getInitialContext()));
fileConfiguration.start(); fileConfiguration.start();
jmsServerManager.start(); jmsServerManager.start();

View File

@ -49,6 +49,7 @@ import org.apache.activemq.api.jms.ActiveMQJMSClient;
import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.api.jms.management.JMSQueueControl; import org.apache.activemq.api.jms.management.JMSQueueControl;
import org.apache.activemq.core.config.Configuration; import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.core.server.ActiveMQServers;
@ -622,7 +623,7 @@ public class JMSBridgeImplTest extends UnitTestCase
.addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())); .addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
InVMNamingContext context = new InVMNamingContext(); InVMNamingContext context = new InVMNamingContext();
jmsServer = new JMSServerManagerImpl(ActiveMQServers.newActiveMQServer(config, false)); jmsServer = new JMSServerManagerImpl(ActiveMQServers.newActiveMQServer(config, false));
jmsServer.setContext(context); jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start(); jmsServer.start();
jmsServer.createQueue(false, JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE); jmsServer.createQueue(false, JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE);