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();
/**
* 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
@ -380,14 +380,14 @@ public interface ConnectionFactoryControl
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")
void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
@Operation(desc = "Adds the factory to another Registry binding")
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")
void removeJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
@Operation(desc = "Remove an existing Registry binding")
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 ----------------------------------------------------
/**
* 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")
String[] getJNDIBindings();
@Operation(desc = "Returns the list of Registry bindings associated")
String[] getRegistryBindings();
/**
* Add the JNDI binding to this destination
*/
@Operation(desc = "Adds the queue to another JNDI binding")
void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
@Operation(desc = "Adds the queue to another Registry binding")
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.

View File

@ -57,16 +57,16 @@ public interface TopicControl extends DestinationControl
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")
String[] getJNDIBindings();
@Operation(desc = "Returns the list of Registry bindings associated")
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")
void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
@Operation(desc = "Adds the queue to another Registry binding")
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 ------------------
public String[] getJNDIBindings()
public String[] getRegistryBindings()
{
return jmsManager.getJNDIOnConnectionFactory(name);
return jmsManager.getBindingsOnConnectionFactory(name);
}
public boolean isCompressLargeMessages()
@ -331,14 +331,14 @@ public class JMSConnectionFactoryControlImpl extends StandardMBean implements Co
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()

View File

@ -159,19 +159,19 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro
}
@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

View File

@ -76,14 +76,14 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
// Static --------------------------------------------------------
private static String[] convert(final Object[] jndiBindings)
private static String[] convert(final Object[] bindings)
{
String[] bindings = new String[jndiBindings.length];
for (int i = 0, jndiBindingsLength = jndiBindings.length; i < jndiBindingsLength; i++)
String[] theBindings = new String[bindings.length];
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)
@ -217,7 +217,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
boolean useDiscovery,
int cfType,
String connectors,
String jndiBindings,
String bindings,
String clientID,
long clientFailureCheckPeriod,
long connectionTTL,
@ -253,7 +253,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
useDiscovery,
cfType,
toArray(connectors),
toArray(jndiBindings),
toArray(bindings),
clientID,
clientFailureCheckPeriod,
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.
* <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,
boolean ha,
boolean useDiscovery,
int cfType,
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
@ -409,19 +409,19 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
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
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,
@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 = "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
{
return server.createQueue(true, name, selector, durable,
JMSServerControlImpl.toArray(jndiBindings));
JMSServerControlImpl.toArray(bindings));
}
finally
{
@ -466,7 +466,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
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();
@ -474,7 +474,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
try
{
return server.createTopic(true, topicName, JMSServerControlImpl.toArray(jndiBindings));
return server.createTopic(true, topicName, JMSServerControlImpl.toArray(bindings));
}
finally
{

View File

@ -80,14 +80,14 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl
// TopicControlMBean implementation ------------------------------
@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()

View File

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.activemq.core.server.ActiveMQComponent;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
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;
/**
@ -48,11 +48,11 @@ public interface JMSStorageManager extends ActiveMQComponent
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;
/**
* A PersistedJNDI
* A PersistedBinding
*
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
*/
public class PersistedJNDI implements EncodingSupport
public class PersistedBindings implements EncodingSupport
{
// Constants -----------------------------------------------------
@ -42,13 +42,13 @@ public class PersistedJNDI implements EncodingSupport
private String name;
private ArrayList<String> jndi = new ArrayList<String>();
private ArrayList<String> bindings = new ArrayList<String>();
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
public PersistedJNDI()
public PersistedBindings()
{
}
@ -56,7 +56,7 @@ public class PersistedJNDI implements EncodingSupport
* @param type
* @param name
*/
public PersistedJNDI(PersistedType type, String name)
public PersistedBindings(PersistedType type, String name)
{
super();
this.type = type;
@ -69,12 +69,12 @@ public class PersistedJNDI implements EncodingSupport
{
type = PersistedType.getType(buffer.readByte());
name = buffer.readSimpleString().toString();
int jndiArraySize = buffer.readInt();
jndi = new ArrayList<String>(jndiArraySize);
int bindingArraySize = buffer.readInt();
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());
BufferHelper.writeAsSimpleString(buffer, name);
buffer.writeInt(jndi.size());
for (String jndiEl : jndi)
buffer.writeInt(bindings.size());
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 +
BufferHelper.sizeOfSimpleString(name) +
sizeOfJNDI();
sizeOfBindings();
}
private int sizeOfJNDI()
private int sizeOfBindings()
{
int size = DataConstants.SIZE_INT; // for the number of elements written
for (String str : jndi)
for (String str : bindings)
{
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 ---------------------------------------------

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.config.PersistedConnectionFactory;
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.utils.IDGenerator;
@ -56,7 +56,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
public static final byte DESTINATION_RECORD = 2;
public static final byte JNDI_RECORD = 3;
public static final byte BINDING_RECORD = 3;
// 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>, PersistedJNDI> mapJNDI = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedJNDI>();
private final Map<Pair<PersistedType, String>, PersistedBindings> mapBindings = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedBindings>();
// Static --------------------------------------------------------
@ -166,87 +166,87 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
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;
}
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);
long tx = idGenerator.generateID();
PersistedJNDI currentJNDI = mapJNDI.get(key);
if (currentJNDI != null)
PersistedBindings currentBindings = mapBindings.get(key);
if (currentBindings != null)
{
jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId());
jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId());
}
else
{
currentJNDI = new PersistedJNDI(type, name);
currentBindings = new PersistedBindings(type, name);
}
mapJNDI.put(key, currentJNDI);
mapBindings.put(key, currentBindings);
for (String adItem : address)
{
currentJNDI.addJNDI(adItem);
currentBindings.addBinding(adItem);
}
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);
}
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);
long tx = idGenerator.generateID();
PersistedJNDI currentJNDI = mapJNDI.get(key);
if (currentJNDI == null)
PersistedBindings currentBindings = mapBindings.get(key);
if (currentBindings == null)
{
return;
}
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
{
long newId = idGenerator.generateID();
currentJNDI.setId(newId);
jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI);
currentBindings.setId(newId);
jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings);
}
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);
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);
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();
jndi.decode(buffer);
jndi.setId(id);
Pair<PersistedType, String> key = new Pair<PersistedType, String>(jndi.getType(), jndi.getName());
mapJNDI.put(key, jndi);
PersistedBindings bindings = new PersistedBindings();
bindings.decode(buffer);
bindings.setId(id);
Pair<PersistedType, String> key = new Pair<PersistedType, String>(bindings.getType(), bindings.getName());
mapBindings.put(key, bindings);
}
else
{

View File

@ -22,7 +22,7 @@ import java.util.List;
import org.apache.activemq.jms.persistence.JMSStorageManager;
import org.apache.activemq.jms.persistence.config.PersistedConnectionFactory;
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;
/**
@ -80,12 +80,12 @@ public class NullJMSStorageManagerImpl implements JMSStorageManager
}
@Override
public void addJNDI(PersistedType type, String name, String ... address) throws Exception
public void addBindings(PersistedType type, String name, String... address) throws Exception
{
}
@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
public void deleteJNDI(PersistedType type, String name) throws Exception
public void deleteBindings(PersistedType type, String name) throws Exception
{
}
@Override
public List<PersistedJNDI> recoverPersistedJNDI() throws Exception
public List<PersistedBindings> recoverPersistedBindings() throws Exception
{
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)
ActiveMQIllegalStateException noConnectorNameConfiguredOnCF(String name);
@Message(id = 129006, value = "JNDI {0} is already being used by another connection factory", format = Message.Format.MESSAGE_FORMAT)
ActiveMQAddressExistsException cfJndiExists(String name);
@Message(id = 129006, value = "Binding {0} is already being used by another connection factory", format = Message.Format.MESSAGE_FORMAT)
ActiveMQAddressExistsException cfBindingsExists(String name);
@Message(id = 129007, value = "Error decoding password using codec instance", format = Message.Format.MESSAGE_FORMAT)
ActiveMQIllegalStateException errorDecodingPassword(@Cause Exception e);

View File

@ -73,8 +73,8 @@ public interface ActiveMQJMSServerLogger extends BasicLogger
void recoveryConnectFailed(String s);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 122011, value = "error unbinding {0} from JNDI" , format = Message.Format.MESSAGE_FORMAT)
void jndiUnbindError(@Cause Exception e, String key);
@Message(id = 122011, value = "error unbinding {0} from Registry" , format = Message.Format.MESSAGE_FORMAT)
void bindingsUnbindError(@Cause Exception e, String key);
@LogMessage(level = Logger.Level.WARN)
@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.Set;
import javax.naming.Context;
import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.security.Role;
import org.apache.activemq.core.server.ActiveMQComponent;
@ -56,17 +54,17 @@ public interface JMSServerManager extends ActiveMQComponent
* @param selectorString
* @param durable
* @return true if the queue is created or if it existed and was added to
* JNDI
* the Binding Registry
* @throws Exception
* if problems were encountered creating the queue.
*/
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
@ -74,68 +72,68 @@ public interface JMSServerManager extends ActiveMQComponent
* @param topicName
* the name of the topic
* @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
* JNDI
* the Binding Registry
* @throws Exception
* if a problem occurred creating the topic
*/
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.
*
* @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
* @throws Exception
* 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.
*
* @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
* @throws Exception
* 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.
*
* @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
* @throws Exception
* 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.
*
* @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
* @throws Exception
* 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
* the name of the queue to destroy
@ -146,7 +144,7 @@ public interface JMSServerManager extends ActiveMQComponent
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.
*
* @param name
@ -157,14 +155,14 @@ public interface JMSServerManager extends ActiveMQComponent
*/
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
* the name of the topic to destroy
@ -175,7 +173,7 @@ public interface JMSServerManager extends ActiveMQComponent
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
* the name of the topic to destroy
@ -185,11 +183,11 @@ public interface JMSServerManager extends ActiveMQComponent
*/
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 */
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,
boolean ha,
@ -300,8 +298,6 @@ public interface JMSServerManager extends ActiveMQComponent
String listPreparedTransactionDetailsAsHTML() throws Exception;
void setContext(final Context context);
ActiveMQServer getActiveMQServer();
void addAddressSettings(String address, AddressSettings addressSettings);
@ -315,7 +311,7 @@ public interface JMSServerManager extends ActiveMQComponent
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
*/

View File

@ -18,8 +18,6 @@ package org.apache.activemq.jms.server.config;
import java.util.List;
import javax.naming.Context;
/**
* A JMSConfiguration
*
@ -29,10 +27,6 @@ import javax.naming.Context;
*/
public interface JMSConfiguration
{
JMSConfiguration setContext(Context context);
Context getContext();
List<JMSQueueConfiguration> getQueueConfigurations();
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.List;
import javax.naming.Context;
import org.apache.activemq.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration;
import org.apache.activemq.jms.server.config.JMSConfiguration;
@ -42,8 +40,6 @@ public class JMSConfigurationImpl implements JMSConfiguration
private String domain = ActiveMQDefaultConfiguration.getDefaultJmxDomain();
private Context context = null;
// JMSConfiguration implementation -------------------------------
public JMSConfigurationImpl()
@ -83,17 +79,6 @@ public class JMSConfigurationImpl implements JMSConfiguration
return this;
}
public Context getContext()
{
return context;
}
public JMSConfigurationImpl setContext(final Context context)
{
this.context = context;
return this;
}
public String getDomain()
{
return domain;

View File

@ -115,12 +115,12 @@ public class JMSServerDeployer extends XmlDeployer
if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
{
String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
jmsServerManager.removeQueueFromJNDI(queueName);
jmsServerManager.removeQueueFromBindingRegistry(queueName);
}
else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
{
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;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
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.postoffice.Binding;
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.TransportConstants;
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.config.PersistedConnectionFactory;
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.impl.journal.JMSJournalStorageManagerImpl;
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;
/**
* 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.
* <p>
* 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, 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
private final List<Runnable> cachedCommands = new ArrayList<Runnable>();
@ -143,15 +140,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
private final String configFileName;
private boolean contextSet;
private JMSConfiguration config;
private Configuration coreConfig;
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
{
@ -269,7 +264,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
// do not clear the cachedCommands - HORNETQ-1047
recoverJndiBindings();
recoverBindings();
}
catch (Exception e)
{
@ -306,11 +301,11 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
storage.stop();
}
unbindJNDI(queueJNDI);
unbindBindings(queueBindings);
unbindJNDI(topicJNDI);
unbindBindings(topicBindings);
unbindJNDI(connectionFactoryJNDI);
unbindBindings(connectionFactoryBindings);
for (String connectionFactory : new HashSet<String>(connectionFactories.keySet()))
{
@ -318,12 +313,12 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
connectionFactories.clear();
connectionFactoryJNDI.clear();
connectionFactoryBindings.clear();
queueJNDI.clear();
queueBindings.clear();
queues.clear();
topicJNDI.clear();
topicBindings.clear();
topics.clear();
// 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))
{
Map<String, List<String>> mapJNDI;
Map<String, List<String>> mapBindings;
Map<String, ?> objects;
switch (type)
{
case Queue:
mapJNDI = queueJNDI;
mapBindings = queueBindings;
objects = queues;
break;
case Topic:
mapJNDI = topicJNDI;
mapBindings = topicBindings;
objects = topics;
break;
default:
case ConnectionFactory:
mapJNDI = connectionFactoryJNDI;
mapBindings = connectionFactoryBindings;
objects = connectionFactories;
break;
}
Object objectToBind = objects.get(name);
List<String> jndiList = mapJNDI.get(name);
List<String> bindingsList = mapBindings.get(name);
if (objectToBind == null)
{
return;
}
if (jndiList == null)
if (bindingsList == null)
{
jndiList = new ArrayList<String>();
mapJNDI.put(name, jndiList);
bindingsList = new ArrayList<String>();
mapBindings.put(name, bindingsList);
}
for (String jndi : bindings)
for (String binding : bindings)
{
jndiList.add(jndi);
bindToJndi(jndi, objectToBind);
bindingsList.add(binding);
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
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;
switch (record.getType())
{
case Queue:
mapJNDI = queueJNDI;
mapBindings = queueBindings;
objects = queues;
break;
case Topic:
mapJNDI = topicJNDI;
mapBindings = topicBindings;
objects = topics;
break;
default:
case ConnectionFactory:
mapJNDI = connectionFactoryJNDI;
mapBindings = connectionFactoryBindings;
objects = connectionFactories;
break;
}
Object objectToBind = objects.get(record.getName());
List<String> jndiList = mapJNDI.get(record.getName());
List<String> bindingsList = mapBindings.get(record.getName());
if (objectToBind == null)
{
unRecoveredJndi.put(record.getName(), record.getJndi());
unRecoveredBindings.put(record.getName(), record.getBindings());
continue;
}
if (jndiList == null)
if (bindingsList == null)
{
jndiList = new ArrayList<String>();
mapJNDI.put(record.getName(), jndiList);
bindingsList = new ArrayList<String>();
mapBindings.put(record.getName(), bindingsList);
}
for (String jndi : record.getJndi())
for (String bindings : record.getBindings())
{
jndiList.add(jndi);
bindToJndi(jndi, objectToBind);
bindingsList.add(bindings);
bindToBindings(bindings, objectToBind);
}
}
@ -477,17 +472,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
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());
server.registerActivateCallback(this);
/**
@ -567,17 +551,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
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()
{
checkInitialised();
@ -589,7 +562,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final String queueName,
final String selectorString,
final boolean durable,
final String... jndi) throws Exception
final String... bindings) throws Exception
{
if (active && queues.get(queueName) != null)
@ -608,7 +581,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override
public void runException() throws Exception
{
checkJNDI(jndi);
checkBindings(bindings);
if (internalCreateQueue(queueName, selectorString, durable))
{
@ -620,22 +593,22 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
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()]);
addToBindings(queueJNDI, queueName, usedJNDI);
usedBindings = bindingsToAdd.toArray(new String[bindingsToAdd.size()]);
addToBindings(queueBindings, queueName, usedBindings);
}
if (storeConfig && durable)
@ -644,9 +617,9 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
queueName,
selectorString,
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;
}
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)
{
@ -675,7 +648,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override
public void runException() throws Exception
{
checkJNDI(jndi);
checkBindings(bindings);
if (internalCreateTopic(topicName))
{
@ -687,23 +660,23 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
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()]);
addToBindings(topicJNDI, topicName, usedJNDI);
String[] usedBindings = bindingsToAdd.toArray(new String[bindingsToAdd.size()]);
addToBindings(topicBindings, topicName, usedBindings);
if (storeConfig)
{
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();
checkJNDI(jndiBinding);
checkBindings(registryBinding);
ActiveMQTopic destination = topics.get(topicName);
if (destination == null)
@ -729,36 +702,36 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{
throw new IllegalArgumentException(topicName + " is not a topic");
}
boolean added = bindToJndi(jndiBinding, destination);
boolean added = bindToBindings(registryBinding, destination);
if (added)
{
addToBindings(topicJNDI, topicName, jndiBinding);
storage.addJNDI(PersistedType.Topic, topicName, jndiBinding);
addToBindings(topicBindings, topicName, registryBinding);
storage.addBindings(PersistedType.Topic, topicName, registryBinding);
}
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();
checkJNDI(jndiBinding);
checkBindings(registryBinding);
ActiveMQQueue destination = queues.get(queueName);
if (destination == null)
@ -769,56 +742,56 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{
throw new IllegalArgumentException(queueName + " is not a queue");
}
boolean added = bindToJndi(jndiBinding, destination);
boolean added = bindToBindings(registryBinding, destination);
if (added)
{
addToBindings(queueJNDI, queueName, jndiBinding);
storage.addJNDI(PersistedType.Queue, queueName, jndiBinding);
addToBindings(queueBindings, queueName, registryBinding);
storage.addBindings(PersistedType.Queue, queueName, registryBinding);
}
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();
checkJNDI(jndiBinding);
checkBindings(registryBinding);
ActiveMQConnectionFactory factory = connectionFactories.get(name);
if (factory == null)
{
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)
{
addToBindings(connectionFactoryJNDI, name, jndiBinding);
storage.addJNDI(PersistedType.ConnectionFactory, name, jndiBinding);
addToBindings(connectionFactoryBindings, name, registryBinding);
storage.addBindings(PersistedType.ConnectionFactory, name, registryBinding);
}
return added;
}
@Override
public boolean removeQueueFromJNDI(String name, String jndi) throws Exception
public boolean removeQueueFromBindingRegistry(String name, String bindings) throws Exception
{
checkInitialised();
boolean removed = removeFromJNDI(queueJNDI, name, jndi);
boolean removed = removeFromBindings(queueBindings, name, bindings);
if (removed)
{
storage.deleteJNDI(PersistedType.Queue, name, jndi);
storage.deleteBindings(PersistedType.Queue, name, bindings);
}
return removed;
}
@Override
public boolean removeQueueFromJNDI(final String name) throws Exception
public boolean removeQueueFromBindingRegistry(final String name) throws Exception
{
final AtomicBoolean valueReturn = new AtomicBoolean(false);
@ -828,7 +801,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override
public String toString()
{
return "removeQueueFromJNDI for " + name;
return "removeQueueFromBindings for " + name;
}
@Override
@ -836,7 +809,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{
checkInitialised();
if (removeFromJNDI(queues, queueJNDI, name))
if (removeFromBindings(queues, queueBindings, name))
{
storage.deleteDestination(PersistedType.Queue, name);
valueReturn.set(true);
@ -848,13 +821,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
@Override
public boolean removeTopicFromJNDI(String name, String jndi) throws Exception
public boolean removeTopicFromBindingRegistry(String name, String bindings) throws Exception
{
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;
}
else
@ -864,9 +837,9 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
/* (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);
@ -876,7 +849,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override
public String toString()
{
return "removeTopicFromJNDI for " + name;
return "removeTopicFromBindings for " + name;
}
@Override
@ -884,7 +857,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
{
checkInitialised();
if (removeFromJNDI(topics, topicJNDI, name))
if (removeFromBindings(topics, topicBindings, name))
{
storage.deleteDestination(PersistedType.Topic, name);
valueReturn.set(true);
@ -896,23 +869,23 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
@Override
public boolean removeConnectionFactoryFromJNDI(String name, String jndi) throws Exception
public boolean removeConnectionFactoryFromBindingRegistry(String name, String bindings) throws Exception
{
checkInitialised();
removeFromJNDI(connectionFactoryJNDI, name, jndi);
removeFromBindings(connectionFactoryBindings, name, bindings);
storage.deleteJNDI(PersistedType.ConnectionFactory, name, jndi);
storage.deleteBindings(PersistedType.ConnectionFactory, name, bindings);
return true;
}
@Override
public boolean removeConnectionFactoryFromJNDI(String name) throws Exception
public boolean removeConnectionFactoryFromBindingRegistry(String name) throws Exception
{
checkInitialised();
removeFromJNDI(connectionFactories, connectionFactoryJNDI, name);
removeFromBindings(connectionFactories, connectionFactoryBindings, name);
storage.deleteConnectionFactory(name);
@ -931,13 +904,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
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
// 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)
{
removeFromJNDI(queues, queueJNDI, name);
removeFromBindings(queues, queueBindings, name);
queues.remove(name);
queueJNDI.remove(name);
queueBindings.remove(name);
jmsManagementService.unregisterQueue(name);
@ -982,10 +955,10 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
if (addressControl.getQueueNames().length == 0)
{
removeFromJNDI(topics, topicJNDI, name);
removeFromBindings(topics, topicBindings, name);
topics.remove(name);
topicJNDI.remove(name);
topicBindings.remove(name);
jmsManagementService.unregisterTopic(name);
@ -1009,7 +982,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final boolean ha,
final JMSFactoryType cfType,
final List<String> connectorNames,
String... jndiBindings) throws Exception
String... registryBindings) throws Exception
{
checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1021,7 +994,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
.setConnectorNames(connectorNames)
.setFactoryType(cfType);
createConnectionFactory(true, configuration, jndiBindings);
createConnectionFactory(true, configuration, registryBindings);
}
}
@ -1059,7 +1032,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final int reconnectAttempts,
final boolean failoverOnInitialConnection,
final String groupId,
String... jndiBindings) throws Exception
String... registryBindings) throws Exception
{
checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1100,7 +1073,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
.setFailoverOnInitialConnection(failoverOnInitialConnection)
.setGroupID(groupId);
createConnectionFactory(true, configuration, jndiBindings);
createConnectionFactory(true, configuration, registryBindings);
}
}
@ -1138,7 +1111,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final int reconnectAttempts,
final boolean failoverOnInitialConnection,
final String groupId,
final String... jndiBindings) throws Exception
final String... registryBindings) throws Exception
{
checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1147,7 +1120,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl()
.setName(name)
.setHA(ha)
.setBindings(jndiBindings)
.setBindings(registryBindings)
.setDiscoveryGroupName(discoveryGroupName)
.setFactoryType(cfType)
.setClientID(clientID)
@ -1179,7 +1152,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
.setMaxRetryInterval(maxRetryInterval)
.setReconnectAttempts(reconnectAttempts)
.setFailoverOnInitialConnection(failoverOnInitialConnection);
createConnectionFactory(true, configuration, jndiBindings);
createConnectionFactory(true, configuration, registryBindings);
}
}
@ -1187,7 +1160,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
final boolean ha,
final JMSFactoryType cfType,
final String discoveryGroupName,
final String... jndiBindings) throws Exception
final String... registryBindings) throws Exception
{
checkInitialised();
ActiveMQConnectionFactory cf = connectionFactories.get(name);
@ -1196,34 +1169,34 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl()
.setName(name)
.setHA(ha)
.setBindings(jndiBindings)
.setBindings(registryBindings)
.setDiscoveryGroupName(discoveryGroupName);
createConnectionFactory(true, configuration, jndiBindings);
createConnectionFactory(true, configuration, registryBindings);
}
}
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);
}
String[] usedJNDI = jndi.toArray(new String[jndi.size()]);
String[] usedBindings = bindings.toArray(new String[bindings.size()]);
ActiveMQConnectionFactory realCF = internalCreateCFPOJO(cf);
if (cf.isPersisted())
{
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;
@ -1231,7 +1204,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
public synchronized void createConnectionFactory(final boolean storeConfig,
final ConnectionFactoryConfiguration cfConfig,
final String... jndi) throws Exception
final String... bindings) throws Exception
{
runAfterActive(new WrappedRunnable()
{
@ -1245,30 +1218,30 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
@Override
public void runException() throws Exception
{
checkJNDI(jndi);
checkBindings(bindings);
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()]);
addToBindings(connectionFactoryJNDI, cfConfig.getName(), usedJNDI);
String[] usedBindings = bindingsToAdd.toArray(new String[bindingsToAdd.size()]);
addToBindings(connectionFactoryBindings, cfConfig.getName(), usedBindings);
if (storeConfig)
{
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());
}
});
@ -1300,7 +1273,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
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);
if (result == null)
@ -1341,7 +1314,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
queues.put(queueName, activeMQQueue);
this.recoverJndiBindings(queueName, PersistedType.Queue);
this.recoverregistryBindings(queueName, PersistedType.Queue);
jmsManagementService.registerQueue(activeMQQueue, queue);
@ -1379,7 +1352,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
topics.put(topicName, activeMQTopic);
this.recoverJndiBindings(topicName, PersistedType.Topic);
this.recoverregistryBindings(topicName, PersistedType.Topic);
jmsManagementService.registerTopic(activeMQTopic);
@ -1541,17 +1514,17 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
protected boolean shutdownConnectionFactory(final String name) throws Exception
{
checkInitialised();
List<String> jndiBindings = connectionFactoryJNDI.get(name);
List<String> registryBindings = connectionFactoryBindings.get(name);
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);
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);
if (list == null)
@ -1734,32 +1707,32 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
list = new ArrayList<String>();
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)
{
registry.unbind(jndiName);
registry.bind(jndiName, objectToBind);
registry.unbind(bindingsName);
registry.bind(bindingsName, objectToBind);
}
return true;
}
@ -1771,11 +1744,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
return;
}
if (config.getContext() != null)
{
setContext(config.getContext());
}
List<ConnectionFactoryConfiguration> connectionFactoryConfigurations = config.getConnectionFactoryConfigurations();
for (ConnectionFactoryConfiguration cfConfig : connectionFactoryConfigurations)
{
@ -1798,7 +1766,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
/**
* @param param
*/
private void unbindJNDI(Map<String, List<String>> param)
private void unbindBindings(Map<String, List<String>> param)
{
if (registry != null)
{
@ -1812,7 +1780,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
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();
}
private synchronized boolean removeFromJNDI(final Map<String, ?> keys,
final Map<String, List<String>> jndiMap,
private synchronized boolean removeFromBindings(final Map<String, ?> keys,
final Map<String, List<String>> bindingsMap,
final String name) throws Exception
{
checkInitialised();
List<String> jndiBindings = jndiMap.remove(name);
if (jndiBindings == null || jndiBindings.size() == 0)
List<String> registryBindings = bindingsMap.remove(name);
if (registryBindings == null || registryBindings.size() == 0)
{
return false;
}
@ -1897,31 +1865,31 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
if (registry != null)
{
Iterator<String> iter = jndiBindings.iterator();
Iterator<String> iter = registryBindings.iterator();
while (iter.hasNext())
{
String jndiBinding = iter.next();
registry.unbind(jndiBinding);
String registryBinding = iter.next();
registry.unbind(registryBinding);
iter.remove();
}
}
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 jndi) throws Exception
final String bindings) throws Exception
{
checkInitialised();
List<String> jndiBindings = jndiMap.get(name);
if (jndiBindings == null || jndiBindings.size() == 0)
List<String> registryBindings = bindingsMap.get(name);
if (registryBindings == null || registryBindings.size() == 0)
{
return false;
}
if (jndiBindings.remove(jndi))
if (registryBindings.remove(bindings))
{
registry.unbind(jndi);
registry.unbind(bindings);
return true;
}
else

View File

@ -52,14 +52,4 @@ public class ServletContextBindingRegistry implements BindingRegistry
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;
/**
* @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)
{
this.context = context;

View File

@ -47,15 +47,4 @@ public class MapBindingRegistry implements BindingRegistry
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
{
/** 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);
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.jms.persistence.config.PersistedConnectionFactory;
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.impl.journal.JMSJournalStorageManagerImpl;
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>, PersistedJNDI> jmsJNDI = new ConcurrentHashMap<>();
private final Map<Pair<PersistedType, String>, PersistedBindings> jmsJNDI = new ConcurrentHashMap<>();
long messagesPrinted = 0L;
@ -392,14 +392,14 @@ public final class XmlDataExporter
ActiveMQServerLogger.LOGGER.info("Found JMS destination: " + destination.getName());
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.setId(id);
Pair<PersistedType, String> key = new Pair<>(jndi.getType(), jndi.getName());
StringBuilder builder = new StringBuilder();
for (String binding : jndi.getJndi())
for (String binding : jndi.getBindings())
{
builder.append(binding).append(" ");
}
@ -680,8 +680,8 @@ public final class XmlDataExporter
xmlWriter.writeEndElement();
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRIES);
PersistedJNDI jndi = jmsJNDI.get(new Pair<>(PersistedType.ConnectionFactory, jmsConnectionFactory.getName()));
for (String jndiEntry : jndi.getJndi())
PersistedBindings jndi = jmsJNDI.get(new Pair<>(PersistedType.ConnectionFactory, jmsConnectionFactory.getName()));
for (String jndiEntry : jndi.getBindings())
{
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRY);
xmlWriter.writeCharacters(jndiEntry);
@ -719,8 +719,8 @@ public final class XmlDataExporter
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRIES);
PersistedJNDI jndi = jmsJNDI.get(new Pair<>(jmsDestination.getType(), jmsDestination.getName()));
for (String jndiEntry : jndi.getJndi())
PersistedBindings jndi = jmsJNDI.get(new Pair<>(jmsDestination.getType(), jmsDestination.getName()));
for (String jndiEntry : jndi.getBindings())
{
xmlWriter.writeStartElement(XmlDataConstants.JMS_JNDI_ENTRY);
xmlWriter.writeCharacters(jndiEntry);

View File

@ -60,16 +60,4 @@ public class SpringBindingRegistry implements BindingRegistry
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.ha.SharedStoreMasterPolicyConfiguration;
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.ActiveMQServers;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -101,7 +102,7 @@ public class StartStopDeadlockTest extends ServiceTestBase
final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
final InVMNamingContext context = new InVMNamingContext();
jmsServer.setContext(context);
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();

View File

@ -16,6 +16,7 @@
*/
package org.apache.activemq.tests.integration.client;
import org.apache.activemq.api.core.ActiveMQNotConnectedException;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before;
import org.junit.After;
@ -71,7 +72,7 @@ public class FailureDeadlockTest extends ServiceTestBase
.addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
server = createServer(false, conf);
jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(new NullInitialContext());
jmsServer.setRegistry(new JndiBindingRegistry(new NullInitialContext()));
jmsServer.start();
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.Bindings;
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.Queue;
import org.apache.activemq.core.server.impl.QueueImpl;
@ -726,7 +727,7 @@ public class PagingOrderTest extends ServiceTestBase
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext();
jmsServer.setContext(context);
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
jmsServer.createTopic(true, "tt", "/topic/TT");
@ -775,7 +776,7 @@ public class PagingOrderTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setContext(context);
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.topic.TT");
@ -803,7 +804,7 @@ public class PagingOrderTest extends ServiceTestBase
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext();
jmsServer.setContext(context);
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
server.getActiveMQServerControl().addAddressSettings("jms.queue.Q1",
@ -858,7 +859,7 @@ public class PagingOrderTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setContext(context);
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("jms.queue.Q1");

View File

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

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.activemq.tests.integration.jms;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before;
import org.junit.After;
@ -160,7 +161,9 @@ public class ManualReconnectionToSingleServerTest extends ServiceTestBase
server = createServer(false, conf);
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));
ArrayList<TransportConfiguration> configs = new ArrayList<TransportConfiguration>();
@ -169,10 +172,9 @@ public class ManualReconnectionToSingleServerTest extends ServiceTestBase
.setName("cf")
.setConnectorNames(registerConnectors(server, configs))
.setBindings("/cf")
.setRetryInterval(1000)
.setRetryInterval(1000)
.setReconnectAttempts(-1);
configuration.getConnectionFactoryConfigurations().add(cfConfig);
serverManager = new JMSServerManagerImpl(server, configuration);
serverManager.start();
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.TopicControl;
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.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers;
@ -122,7 +123,7 @@ public abstract class BridgeTestBase extends UnitTestCase
context0 = new InVMNamingContext();
jmsServer0 = new JMSServerManagerImpl(server0);
jmsServer0.setContext(context0);
jmsServer0.setRegistry(new JndiBindingRegistry(context0));
jmsServer0.start();
params1 = new HashMap<String, Object>();
@ -138,7 +139,7 @@ public abstract class BridgeTestBase extends UnitTestCase
context1 = new InVMNamingContext();
jmsServer1 = new JMSServerManagerImpl(server1);
jmsServer1.setContext(context1);
jmsServer1.setRegistry(new JndiBindingRegistry(context1));
jmsServer1.start();
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.ha.ReplicaPolicyConfiguration;
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.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers;
@ -168,7 +169,7 @@ public abstract class ClusteredBridgeTestBase extends ServiceTestBase
liveContext = new InVMContext();
liveNode = new JMSServerManagerImpl(server0);
liveNode.setContext(liveContext);
liveNode.setRegistry(new JndiBindingRegistry(liveContext));
//backup
Configuration conf = createBasicConfig()
@ -185,7 +186,7 @@ public abstract class ClusteredBridgeTestBase extends ServiceTestBase
Context context = new InVMContext();
backupNode = new JMSServerManagerImpl(backup);
backupNode.setContext(context);
backupNode.setRegistry(new JndiBindingRegistry(context));
}
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.JMSFactoryType;
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.ActiveMQServers;
import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
@ -64,7 +65,7 @@ public class RemoteConnectionStressTest extends ServiceTestBase
InVMNamingContext namingContext = new InVMNamingContext();
jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(namingContext);
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();

View File

@ -75,7 +75,7 @@ public class StoreConfigTest extends JMSTestBase
try
{
jmsServer.addConnectionFactoryToJNDI("np", "/someCF");
jmsServer.addConnectionFactoryToBindingRegistry("np", "/someCF");
fail("Failure expected and the API let duplicates");
}
catch (NamingException expected)
@ -100,10 +100,10 @@ public class StoreConfigTest extends JMSTestBase
jmsServer.start();
jmsServer.addConnectionFactoryToJNDI("tst", "/newJNDI");
jmsServer.addConnectionFactoryToBindingRegistry("tst", "/newJNDI");
try
{
jmsServer.addConnectionFactoryToJNDI("tst", "/newJNDI");
jmsServer.addConnectionFactoryToBindingRegistry("tst", "/newJNDI");
fail("Failure expected and the API let duplicates");
}
catch (NamingException expected)
@ -176,7 +176,7 @@ public class StoreConfigTest extends JMSTestBase
assertNullJNDI("/t2");
assertNullJNDI("/t.2");
jmsServer.addTopicToJndi("topicOne", "/tI");
jmsServer.addTopicToBindingRegistry("topicOne", "/tI");
jmsServer.stop();
jmsServer.start();
@ -189,11 +189,11 @@ public class StoreConfigTest extends JMSTestBase
assertNullJNDI("/t.2");
assertTrue(jmsServer.removeTopicFromJNDI("topicOne", "/tI"));
assertTrue(jmsServer.removeTopicFromBindingRegistry("topicOne", "/tI"));
assertFalse(jmsServer.removeTopicFromJNDI("topicOne","nothing"));
assertFalse(jmsServer.removeTopicFromJNDI("nothing","nothing"));
assertFalse(jmsServer.removeTopicFromJNDI("nothing"));
assertFalse(jmsServer.removeTopicFromBindingRegistry("topicOne", "nothing"));
assertFalse(jmsServer.removeTopicFromBindingRegistry("nothing", "nothing"));
assertFalse(jmsServer.removeTopicFromBindingRegistry("nothing"));
assertNullJNDI("/tI");
checkDestination("/t1");
@ -208,7 +208,7 @@ public class StoreConfigTest extends JMSTestBase
checkDestination("/t.1");
jmsServer.removeTopicFromJNDI("topicOne");
jmsServer.removeTopicFromBindingRegistry("topicOne");
assertTrue(jmsServer.createTopic(true, "topicOne", "/topicx.1", "/topicx.2"));
@ -292,7 +292,7 @@ public class StoreConfigTest extends JMSTestBase
assertNullJNDI("/q2");
assertNullJNDI("/q.2");
jmsServer.addQueueToJndi("queue1", "/qI");
jmsServer.addQueueToBindingRegistry("queue1", "/qI");
jmsServer.stop();
jmsServer.start();
@ -305,9 +305,9 @@ public class StoreConfigTest extends JMSTestBase
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");
checkDestination("/q.1");
@ -321,7 +321,7 @@ public class StoreConfigTest extends JMSTestBase
checkDestination("/q.1");
checkDestination("/qI");
jmsServer.removeQueueFromJNDI("queue1");
jmsServer.removeQueueFromBindingRegistry("queue1");
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.ha.SharedStoreMasterPolicyConfiguration;
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.TransportConstants;
import org.apache.activemq.core.server.ActiveMQServer;
@ -315,7 +316,7 @@ public class JMSFailoverListenerTest extends ServiceTestBase
backupJMSService = new JMSServerManagerImpl(backupService);
backupJMSService.setContext(ctx2);
backupJMSService.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSService.getActiveMQServer().setIdentity("JMSBackup");
log.info("Starting backup");
@ -340,7 +341,7 @@ public class JMSFailoverListenerTest extends ServiceTestBase
liveJMSService = new JMSServerManagerImpl(liveService);
liveJMSService.setContext(ctx1);
liveJMSService.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSService.getActiveMQServer().setIdentity("JMSLive");
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.protocol.core.Packet;
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.TransportConstants;
import org.apache.activemq.core.server.ActiveMQServer;
@ -543,7 +544,7 @@ public class JMSFailoverTest extends ServiceTestBase
backupJMSService = new JMSServerManagerImpl(backupService);
backupJMSService.setContext(ctx2);
backupJMSService.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSService.getActiveMQServer().setIdentity("JMSBackup");
log.info("Starting backup");
@ -569,7 +570,7 @@ public class JMSFailoverTest extends ServiceTestBase
liveJMSService = new JMSServerManagerImpl(liveService);
liveJMSService.setContext(ctx1);
liveJMSService.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSService.getActiveMQServer().setIdentity("JMSLive");
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.core.config.ha.ReplicaPolicyConfiguration;
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.server.ActiveMQServers;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -55,7 +56,7 @@ public class ReplicatedJMSFailoverTest extends JMSFailoverTest
backupJMSService = new JMSServerManagerImpl(backupService);
backupJMSService.setContext(ctx2);
backupJMSService.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSService.start();
@ -74,7 +75,7 @@ public class ReplicatedJMSFailoverTest extends JMSFailoverTest
liveJMSService = new JMSServerManagerImpl(liveService);
liveJMSService.setContext(ctx1);
liveJMSService.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSService.start();
}

View File

@ -16,6 +16,7 @@
*/
package org.apache.activemq.tests.integration.jms.connection;
import org.apache.activemq.api.core.ActiveMQInternalErrorException;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before;
import org.junit.After;
@ -73,7 +74,7 @@ public class ExceptionListenerTest extends UnitTestCase
.addAcceptorConfiguration(new TransportConfiguration("org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory"));
server = addServer(ActiveMQServers.newActiveMQServer(conf, false));
jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(new NullInitialContext());
jmsServer.setRegistry(new JndiBindingRegistry(new NullInitialContext()));
jmsServer.start();
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"));

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.deployers.DeploymentManager;
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.server.ActiveMQServer;
import org.apache.activemq.jms.server.JMSServerManager;
@ -157,7 +158,7 @@ public class JMSServerDeployerTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setContext(context);
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
}

View File

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

View File

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

View File

@ -20,6 +20,7 @@ import java.util.List;
import javax.management.Notification;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
@ -171,7 +172,7 @@ public class ConnectionFactoryControlTest extends ManagementTestBase
ctx = new InVMNamingContext();
serverManager.setContext(ctx);
serverManager.setRegistry(new JndiBindingRegistry(ctx));
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.JMSServerControl;
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.server.ActiveMQServer;
import org.apache.activemq.core.settings.impl.AddressFullMessagePolicy;
@ -1229,7 +1230,7 @@ public class JMSQueueControlTest extends ManagementTestBase
ActiveMQQueue testQueue = (ActiveMQQueue) ActiveMQJMSClient.createQueue(testQueueName);
JMSQueueControl queueControl = createManagementControl(testQueue);
String[] bindings = queueControl.getJNDIBindings();
String[] bindings = queueControl.getRegistryBindings();
String newJndi = "newTestQueueAddJndi";
@ -1237,9 +1238,9 @@ public class JMSQueueControlTest extends ManagementTestBase
{
assertFalse(b.equals(newJndi));
}
queueControl.addJNDI(newJndi);
queueControl.addBinding(newJndi);
bindings = queueControl.getJNDIBindings();
bindings = queueControl.getRegistryBindings();
boolean newBindingAdded = false;
for (String b : bindings)
{
@ -1258,7 +1259,7 @@ public class JMSQueueControlTest extends ManagementTestBase
queueControl = createManagementControl(testQueue);
bindings = queueControl.getJNDIBindings();
bindings = queueControl.getRegistryBindings();
newBindingAdded = false;
for (String b : bindings)
{
@ -1327,7 +1328,7 @@ public class JMSQueueControlTest extends ManagementTestBase
serverManager = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
serverManager.setContext(context);
serverManager.setRegistry(new JndiBindingRegistry(context));
serverManager.start();
serverManager.activated();

View File

@ -293,13 +293,13 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest
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
proxy.invokeOperation("addJNDI", jndi);
proxy.invokeOperation("addBindings", jndi);
}
public String[] getJNDIBindings()
public String[] getRegistryBindings()
{
// TODO: Add a test for this
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.JMSSessionInfo;
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.InVMConnectorFactory;
import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
@ -89,7 +90,7 @@ public class JMSServerControl2Test extends ManagementTestBase
context = new InVMNamingContext();
serverManager = new JMSServerManagerImpl(server);
addActiveMQComponent(serverManager);
serverManager.setContext(context);
serverManager.setRegistry(new JndiBindingRegistry(context));
serverManager.start();
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.JMSServerControl;
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.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServer;
@ -161,7 +162,7 @@ public class JMSServerControlRestartTest extends ManagementTestBase
context = new InVMNamingContext();
serverManager = new JMSServerManagerImpl(server);
serverManager.setContext(context);
serverManager.setRegistry(new JndiBindingRegistry(context));
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.core.config.Configuration;
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.server.ActiveMQServer;
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.config.PersistedConnectionFactory;
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.server.impl.JMSServerManagerImpl;
import org.apache.activemq.tests.integration.management.ManagementControlHelper;
@ -1073,7 +1074,7 @@ public class JMSServerControlTest extends ManagementTestBase
serverManager = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
serverManager.setContext(context);
serverManager.setRegistry(new JndiBindingRegistry(context));
serverManager.start();
serverManager.activated();
@ -1207,31 +1208,31 @@ public class JMSServerControlTest extends ManagementTestBase
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>());
for (String ad : address)
{
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);
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();
delegate.deleteJNDI(type, name);
delegate.deleteBindings(type, name);
}
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.postoffice.Binding;
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.server.ActiveMQServer;
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.getAddress(), topicControl.getAddress());
Assert.assertEquals(topic.isTemporary(), topicControl.isTemporary());
Object[] bindings = topicControl.getJNDIBindings();
Object[] bindings = topicControl.getRegistryBindings();
assertEquals(1, bindings.length);
Assert.assertEquals(topicBinding, bindings[0]);
}
@ -607,7 +608,7 @@ public class TopicControlTest extends ManagementTestBase
serverManager = new JMSServerManagerImpl(server);
serverManager.start();
serverManager.setContext(new InVMNamingContext());
serverManager.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
serverManager.activated();
clientID = RandomUtil.randomString();

View File

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

View File

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.List;
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.impl.ConnectionFactoryConfigurationImpl;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -69,7 +70,7 @@ public class ManagementActivationTest extends FailoverTestBase
super.setUp();
backupJmsServer = new JMSServerManagerImpl(backupServer.getServer());
context = new InVMNamingContext();
backupJmsServer.setContext(context);
backupJmsServer.setRegistry(new JndiBindingRegistry(context));
backupJmsServer.start();
}
@ -265,7 +266,7 @@ public class ManagementActivationTest extends FailoverTestBase
boolean exception = false;
try
{
backupJmsServer.removeQueueFromJNDI("fakeQueue");
backupJmsServer.removeQueueFromBindingRegistry("fakeQueue");
}
catch (Exception e)
{
@ -287,7 +288,7 @@ public class ManagementActivationTest extends FailoverTestBase
boolean exception = false;
try
{
backupJmsServer.removeTopicFromJNDI("fakeTopic");
backupJmsServer.removeTopicFromBindingRegistry("fakeTopic");
}
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.jms.management.JMSServerControl;
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.security.Role;
import org.apache.activemq.core.server.ActiveMQServer;
@ -128,7 +129,7 @@ public class OpenWireTestBase extends ServiceTestBase
}
jmsServer = new JMSServerManagerImpl(server);
namingContext = new InVMNamingContext();
jmsServer.setContext(namingContext);
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
registerConnectionFactory();

View File

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

View File

@ -21,7 +21,7 @@ import org.junit.Test;
import java.util.List;
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;
/**
@ -42,11 +42,11 @@ public class JMSStorageManagerTest extends StorageManagerTestBase
jmsJournal.storeDestination(new PersistedDestination(PersistedType.Queue,
"jndiPersistQueue", null, true));
jmsJournal.addJNDI(PersistedType.Queue, "jndiPersistQueue", "jndi-1");
jmsJournal.addBindings(PersistedType.Queue, "jndiPersistQueue", "jndi-1");
List<PersistedDestination> destinations = jmsJournal.recoverDestinations();
List<PersistedJNDI> jndiList = jmsJournal.recoverPersistedJNDI();
List<PersistedBindings> jndiList = jmsJournal.recoverPersistedBindings();
assertEquals(1, destinations.size());
@ -66,13 +66,13 @@ public class JMSStorageManagerTest extends StorageManagerTestBase
assertEquals(0, destinations.size());
jndiList = jmsJournal.recoverPersistedJNDI();
jndiList = jmsJournal.recoverPersistedBindings();
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());

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.jms.JMSFactoryType;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.jms.server.JMSServerManager;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
@ -172,7 +173,7 @@ public class XmlImportExportTest extends ServiceTestBase
jmsServer = new JMSServerManagerImpl(server);
addActiveMQComponent(jmsServer);
namingContext = new InVMContext();
jmsServer.setContext(namingContext);
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
locator = createInVMNonHALocator();
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.protocol.stomp.Stomp;
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.netty.NettyAcceptorFactory;
import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
@ -703,7 +704,7 @@ public class ExtraStompTest extends StompTestBase
.setName(getTopicName())
.setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext());
server.setRegistry(new JndiBindingRegistry((new InVMNamingContext())));
return server;
}
@ -810,7 +811,7 @@ public class ExtraStompTest extends StompTestBase
.setName(getTopicName())
.setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext());
server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
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.core.config.Configuration;
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.InVMConnectorFactory;
import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
@ -215,7 +216,7 @@ public abstract class StompTestBase extends UnitTestCase
.setName(getTopicName())
.setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext());
server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
return server;
}

View File

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

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.activemq.tests.integration.stomp.v11;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.junit.Before;
import org.junit.After;
@ -121,7 +122,7 @@ public abstract class StompV11TestBase extends UnitTestCase
.setName(getTopicName())
.setBindings(getTopicName()));
server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
server.setContext(new InVMNamingContext());
server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
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.core.config.ClusterConnectionConfiguration;
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.server.ActiveMQServer;
import org.apache.activemq.core.server.ActiveMQServers;
@ -155,7 +156,7 @@ public class JMSClusteredTestBase extends ServiceTestBase
server2 = ActiveMQServers.newActiveMQServer(conf2, mBeanServer2, enablePersistence());
jmsServer2 = new JMSServerManagerImpl(server2, jmsconfig);
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());
jmsServer1 = new JMSServerManagerImpl(server1, jmsconfig);
context1 = new InVMNamingContext();
jmsServer1.setContext(context1);
jmsServer1.setRegistry(new JndiBindingRegistry(context1));
}
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.jms.management.JMSQueueControl;
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.ActiveMQServers;
import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration;
@ -159,7 +160,7 @@ public class JMSTestBase extends ServiceTestBase
addServer(server);
jmsServer = new JMSServerManagerImpl(server);
namingContext = new InVMNamingContext();
jmsServer.setContext(namingContext);
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
registerConnectionFactory();
@ -178,7 +179,7 @@ public class JMSTestBase extends ServiceTestBase
protected void restartServer() throws Exception
{
namingContext = new InVMNamingContext();
jmsServer.setContext(namingContext);
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
jmsServer.activated();
registerConnectionFactory();

View File

@ -140,7 +140,6 @@ public abstract class ActiveMQServerTestCase
{
// create any new server we need
ActiveMQServerTestCase.servers.add(ServerManagement.create());
// start the servers if needed
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.TopicControl;
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.security.Role;
import org.apache.activemq.core.server.ActiveMQServer;
@ -119,6 +120,7 @@ public class LocalTestServer implements Server, Runnable
ActiveMQServerImpl activeMQServer = new ActiveMQServerImpl(fileConfiguration, beanServer, securityManager);
jmsServerManager = new JMSServerManagerImpl(activeMQServer);
System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
jmsServerManager.setRegistry(new JndiBindingRegistry(getInitialContext()));
fileConfiguration.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.management.JMSQueueControl;
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.InVMConnectorFactory;
import org.apache.activemq.core.server.ActiveMQServers;
@ -622,7 +623,7 @@ public class JMSBridgeImplTest extends UnitTestCase
.addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
InVMNamingContext context = new InVMNamingContext();
jmsServer = new JMSServerManagerImpl(ActiveMQServers.newActiveMQServer(config, false));
jmsServer.setContext(context);
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
jmsServer.createQueue(false, JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE);