You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ar...@apache.org on 2008/10/31 11:04:14 UTC
svn commit: r709374 [1/2] - in
/incubator/qpid/trunk/qpid/java/management/client: ./ src/main/java/
src/main/java/org/apache/qpid/management/
src/main/java/org/apache/qpid/management/configuration/
src/main/java/org/apache/qpid/management/domain/handle...
Author: arnaudsimon
Date: Fri Oct 31 03:04:12 2008
New Revision: 709374
URL: http://svn.apache.org/viewvc?rev=709374&view=rev
Log:
QPID-1411: Applied Andrea's patch; added config file sample
Added:
incubator/qpid/trunk/qpid/java/management/client/qman-config.xml
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerAlreadyConnectedException.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionException.java
Removed:
incubator/qpid/trunk/qpid/java/management/client/src/main/java/log4j.xml
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/config.xml
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMappingParser.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/TypeMappingParser.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/AccessModeMappingTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/StubConfigurator.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/TypeMappingTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/online/TestMethodInvocation.java
Modified:
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Tag.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/ConfigurationMessageHandler.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InstrumentationMessageHandler.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/JmxService.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java
incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidMethodBuilderTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidNumberPropertyTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidPropertyBuilderTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStatisticBuilderTest.java
incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidStringPropertyTest.java
Added: incubator/qpid/trunk/qpid/java/management/client/qman-config.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/qman-config.xml?rev=709374&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/qman-config.xml (added)
+++ incubator/qpid/trunk/qpid/java/management/client/qman-config.xml Fri Oct 31 03:04:12 2008
@@ -0,0 +1,26 @@
+<configuration>
+ <brokers>
+ <broker>
+ <host>localhost</host>
+ <port>5672</port>
+ <virtual-host>test</virtual-host>
+ <user>guest</user>
+ <password>guest</password>
+ <max-pool-capacity>4</max-pool-capacity>
+ <initial-pool-capacity>0</initial-pool-capacity>
+ <max-wait-timeout>-1</max-wait-timeout>
+ </broker>
+<!--
+ <broker>
+ <host>myhost</host>
+ <port>5672</port>
+ <virtual-host>test</virtual-host>
+ <user>guest</user>
+ <password>guest</password>
+ <max-pool-capacity>4</max-pool-capacity>
+ <initial-pool-capacity>0</initial-pool-capacity>
+ <max-wait-timeout>-1</max-wait-timeout>
+ </broker>
+-->
+ </brokers>
+</configuration>
\ No newline at end of file
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java Fri Oct 31 03:04:12 2008
@@ -29,6 +29,8 @@
String QMAN_000019_QMAN_STARTED = "<QMAN-000019> : Q-Man open for e-business.";
String QMAN_000020_SHUTTING_DOWN_QMAN = "<QMAN-000020> : Shutting down Q-Man...";
String QMAN_000021_SHUT_DOWN = "<QMAN-000021> : Q-Man shut down.";
+ String QMAN_000022_NO_BROKER_CONFIGURED = "<QMAN-000022> : Q-Man has no configured broker : in order to connect with a running one use Q-Man Administration interface.";
+ String QMAN_000023_QMAN_REGISTERED_AS_MBEAN = "<QMAN-000023> : Q-Man service is now available on MBeanServer.";
// DEBUG
String QMAN_200001_INCOMING_MESSAGE_HAS_BEEN_RECEIVED = "<QMAN-200001> : New incoming message has been received. Message content is %s";
@@ -67,7 +69,9 @@
// WARNING
String QMAN_300001_MESSAGE_DISCARDED = "<QMAN-300001> : No handler has been configured for processing messages with \"%s\" as opcode. Message will be discarded.";
String QMAN_300002_UNKNOWN_SEQUENCE_NUMBER = "<QMAN-300002> : Unable to deal with incoming message because it contains a unknown sequence number (%s).";
-
+ String QMAN_300003_BROKER_ALREADY_CONNECTED = "<QMAN-300003> : Unable to enlist given broker connection data : QMan is already connected with broker %s";
+ String QMAN_300004_UNVALID_CONFIGURATION_FILE = "<QMAN-300004> : The given configuration file (%s) is not valid (it doesn't exist or cannot be read)";
+
// ERROR
String QMAN_100001_BAD_MAGIC_NUMBER_FAILURE = "<QMAN-100001> : Message processing failure : incoming message contains a bad magic number (%s) and therefore will be discaded.";
String QMAN_100002_MESSAGE_READ_FAILURE = "<QMAN-100002> : Message I/O failure : unable to read byte message content and therefore it will be discarded.";
@@ -86,9 +90,9 @@
String QMAN_100015_UNABLE_TO_SEND_SCHEMA_REQUEST = "<QMAN-100015> : Unable to send a schema request schema for %s.%s";
String QMAN_100016_UNABLE_TO_DECODE_FEATURE_VALUE = "<QMAN-100016> : Unable to decode value for %s::%s::%s";
String QMAN_100017_UNABLE_TO_CONNECT = "<QMAN-100017>: Cannot connect to broker %s on %s";
+ String QMAN_100018_UNABLE_TO_STARTUP_CORRECTLY = "<QMAN-100018> : Q-Man was unable to startup correctly : see logs for further details.";
// MESSAGES
String EVENT_SEVERITY_ATTRIBUTE_DESCRIPTION = "Severity level for this event.";
String EVENT_TIMESTAMP_ATTRIBUTE_DESCRIPTION = "Current timestamp of this event.";
- String UNABLE_TO_STARTUP_CORRECTLY = "<QMAN-100002> : Q-Man was unable to startup correctly : a configuration error occurred.";
}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java Fri Oct 31 03:04:12 2008
@@ -35,9 +35,8 @@
String METHOD_REPLY_QUEUE_PREFIX = "reply.";
String AMQ_DIRECT_QUEUE = "amq.direct";
- String AGENT_ROUTING_KEY = "agent.1.0";
-
- String BROKER_ROUTING_KEY = "broker";
+ String AGENT_ROUTING_KEY_PREFIX = "agent.";
+ String AGENT_ROUTING_KEY = AGENT_ROUTING_KEY_PREFIX+"1.0";
// Attributes
String PACKAGE = "package";
@@ -45,9 +44,14 @@
String OBJECT_ID="objectID";
String BROKER_ID = "brokerID";
String DOMAIN_NAME = "Q-MAN";
-
- String CONFIGURATION_FILE_NAME = "/org/apache/qpid/management/config.xml";
-
+
String ARG_COUNT_PARAM_NAME = "argCount";
String DEFAULT_PARAM_NAME ="default";
+
+ String NUMBER_VALIDATOR = "org.apache.qpid.management.domain.model.QpidProperty$NumberValidator";
+ String STRING_VALIDATOR = "org.apache.qpid.management.domain.model.QpidProperty$StringValidator";
+
+ String QMAN_CONFIG_OPTION_NAME = "qman-config";
+
+ String ADD_BROKER_OPERATION_NAME = "addBroker";
}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java Fri Oct 31 03:04:12 2008
@@ -29,20 +29,21 @@
*/
class AccessModeMapping
{
- private int _code;
- private AccessMode _accessMode;
+ private final int _code;
+ private final AccessMode _accessMode;
/**
- * Sets the code for this mapping.
- * Note that the given string must be a valid number (integer).
+ * Builds a new access mode mapping with the given parameters.
*
- * @param codeAsString the code value as a string.
- * @throws NumberFormatException when the given string is not a number.
+ * @param code the access code.
+ * @param accessMode the access mode.
*/
- void setCode(String codeAsString) {
- this._code = Integer.parseInt(codeAsString);
+ AccessModeMapping(int code, AccessMode accessMode)
+ {
+ this._code = code;
+ this._accessMode = accessMode;
}
-
+
/**
* Returns the access mode of this mapping.
*
@@ -54,18 +55,6 @@
}
/**
- * Sets the access mode for this mapping.
- * Note that the given string must correspond to a valid access mode value (RW,RC, RO).
- *
- * @param accessModeAsString acces mode as a string.
- * @throws IllegalArgumentException when the given string is not a valid access code.
- */
- void setAccessMode (String accessModeAsString)
- {
- this._accessMode = AccessMode.valueOf(accessModeAsString);
- }
-
- /**
* Returns the code of this mapping.
*
* @return the code of this mapping.
@@ -91,4 +80,4 @@
.append(_accessMode)
.append(')').toString();
}
-}
\ No newline at end of file
+}
Added: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerAlreadyConnectedException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerAlreadyConnectedException.java?rev=709374&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerAlreadyConnectedException.java (added)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerAlreadyConnectedException.java Fri Oct 31 03:04:12 2008
@@ -0,0 +1,32 @@
+package org.apache.qpid.management.configuration;
+
+/**
+ * Thrown when an attempt is made in order to connect QMan with an already connected broker.
+ *
+ * @author Andrea Gazzarini
+ */
+public class BrokerAlreadyConnectedException extends Exception {
+
+ private static final long serialVersionUID = -5082431738056504669L;
+
+ private BrokerConnectionData _connectionData;
+
+ /**
+ * Builds a new exception with the given data.
+ *
+ * @param connectionData the broker connection data.
+ */
+ public BrokerAlreadyConnectedException(BrokerConnectionData connectionData) {
+ this._connectionData = connectionData;
+ }
+
+ /**
+ * Returns the connection data of the connected broker.
+ *
+ * @return the connection data of the connected broker.
+ */
+ public BrokerConnectionData getBrokerConnectionData()
+ {
+ return _connectionData;
+ }
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java Fri Oct 31 03:04:12 2008
@@ -37,6 +37,38 @@
private long _maxWaitTimeout;
/**
+ * Builds a connection data with the given parameters.
+ *
+ * @param host the hostname where the broker is running.
+ * @param port the port where the broker is running.
+ * @param username the username for connecting with the broker.
+ * @param password the password for connecting with the broker.
+ * @param virtualHost the virtual host.
+ * @param initialPoolCapacity the number of the connection that must be immediately opened.
+ * @param maxPoolCapacity the maximum number of opened connection.
+ * @param maxWaitTimeout the maximum amount of time that a client will wait for obtaining a connection.
+ */
+ public BrokerConnectionData(
+ String host,
+ int port,
+ String virtualHost,
+ String username,
+ String password,
+ int initialPoolCapacity,
+ int maxPoolCapacity,
+ long waitTimeout) {
+
+ this._host = host;
+ this._port = port;
+ this._virtualHost = virtualHost;
+ this._username = username;
+ this._password = password;
+ _maxPoolCapacity = maxPoolCapacity;
+ _initialPoolCapacity = initialPoolCapacity;
+ _maxWaitTimeout = waitTimeout;
+ }
+
+ /**
* Builds a new empty broker connection data object.
*/
BrokerConnectionData()
@@ -198,14 +230,41 @@
return _maxWaitTimeout;
}
- public void setInitialPoolCapacity (String value)
+ /**
+ * Sets the initial connection pool capacity.
+ *
+ * @param capacity the initial connection pool capacity.
+ */
+ public void setInitialPoolCapacity (String capacity)
{
- _initialPoolCapacity = Integer.parseInt(value);
+ _initialPoolCapacity = Integer.parseInt(capacity);
}
+ /**
+ * Returns the initial connection pool capacity.
+ *
+ * @return the initial connection pool capacity.
+ */
public int getInitialPoolCapacity ()
{
return _initialPoolCapacity;
}
-}
\ No newline at end of file
+ @Override
+ public boolean equals(Object object) {
+ try
+ {
+ BrokerConnectionData connectionData = (BrokerConnectionData) object;
+ return (_host.equals(connectionData._host) )
+ && (_port == connectionData._port)
+ && (_virtualHost.equals(connectionData._virtualHost));
+ } catch (Exception exception) {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return _host.hashCode()+_port+_virtualHost.hashCode();
+ }
+}
Added: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionException.java?rev=709374&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionException.java (added)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionException.java Fri Oct 31 03:04:12 2008
@@ -0,0 +1,21 @@
+package org.apache.qpid.management.configuration;
+
+/**
+ * Thrown when a connection to a broker cannot be estabilished.
+ *
+ * @author Andrea Gazzarini
+ */
+public class BrokerConnectionException extends Exception
+{
+ private static final long serialVersionUID = 8170112238862494025L;
+
+ /**
+ * Builds a new exception with the given cause.
+ *
+ * @param cause the exception cause.
+ */
+ BrokerConnectionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java Fri Oct 31 03:04:12 2008
@@ -86,6 +86,16 @@
}
/**
+ * Returns true if this configuration has at least one broker connection data.
+ *
+ * @return true if this configuration has at least one broker connection data.
+ */
+ public boolean hasOneOrMoreBrokersDefined()
+ {
+ return !_brokerConnectionInfos.isEmpty();
+ }
+
+ /**
* Returns the type associated to the given code.
*
* @param code the code used as search criteria.
@@ -321,14 +331,27 @@
*
* @param brokerId the broker identifier.
* @param connectionData the connection data.
- * @throws Exception
+ * @throws BrokerAlreadyConnectedException when the broker is already connected.
+ * @throws BrokerConnectionException when a connection cannot be estabilished.
*/
- void addBrokerConnectionData (UUID brokerId, BrokerConnectionData connectionData) throws Exception
+ void addBrokerConnectionData (UUID brokerId, BrokerConnectionData connectionData) throws BrokerAlreadyConnectedException, BrokerConnectionException
{
- QpidDatasource.getInstance().addConnectionPool(brokerId, connectionData);
- _brokerConnectionInfos.put(brokerId,connectionData);
+ if (_brokerConnectionInfos.containsValue(connectionData))
+ {
+ throw new BrokerAlreadyConnectedException(connectionData);
+ }
+
+ try
+ {
+ QpidDatasource.getInstance().addConnectionPool(brokerId, connectionData);
+ _brokerConnectionInfos.put(brokerId,connectionData);
+
+ LOGGER.info(Messages.QMAN_000009_BROKER_DATA_CONFIGURED,brokerId,connectionData);
+ } catch(Exception exception)
+ {
+ throw new BrokerConnectionException(exception);
+ }
- LOGGER.info(Messages.QMAN_000009_BROKER_DATA_CONFIGURED,brokerId,connectionData);
}
/**
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java Fri Oct 31 03:04:12 2008
@@ -21,11 +21,15 @@
package org.apache.qpid.management.configuration;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.InputStreamReader;
+import java.util.UUID;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import org.apache.qpid.management.Messages;
import org.apache.qpid.management.Names;
import org.apache.qpid.management.Protocol;
import org.apache.qpid.management.domain.handler.impl.ConfigurationMessageHandler;
@@ -34,6 +38,17 @@
import org.apache.qpid.management.domain.handler.impl.InstrumentationMessageHandler;
import org.apache.qpid.management.domain.handler.impl.MethodResponseMessageHandler;
import org.apache.qpid.management.domain.handler.impl.SchemaResponseMessageHandler;
+import org.apache.qpid.management.domain.model.AccessMode;
+import org.apache.qpid.management.domain.model.type.AbsTime;
+import org.apache.qpid.management.domain.model.type.DeltaTime;
+import org.apache.qpid.management.domain.model.type.ObjectReference;
+import org.apache.qpid.management.domain.model.type.Str16;
+import org.apache.qpid.management.domain.model.type.Str8;
+import org.apache.qpid.management.domain.model.type.Uint16;
+import org.apache.qpid.management.domain.model.type.Uint32;
+import org.apache.qpid.management.domain.model.type.Uint64;
+import org.apache.qpid.management.domain.model.type.Uint8;
+import org.apache.qpid.transport.util.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -47,7 +62,9 @@
*/
public class Configurator extends DefaultHandler
{
- /**
+ private final static Logger LOGGER = Logger.get(Configurator.class);
+
+ /**
* Default (empty) parser used when there's no need to process data (non relevant elements).
*/
final static IParser DEFAULT_PARSER = new IParser() {
@@ -61,11 +78,9 @@
}
};
- IParser _typeMappingParser = new TypeMappingParser();
- IParser _accessModeMappingParser = new AccessModeMappingParser();
IParser _brokerConfigurationParser = new BrokerConnectionDataParser();
IParser _currentParser = DEFAULT_PARSER;
-
+
/**
* Delegates the processing to the current parser.
*/
@@ -85,15 +100,6 @@
public void startElement (String uri, String localName, String name, Attributes attributes) throws SAXException
{
switch(Tag.get(name)) {
- case TYPE_MAPPINGS : {
- _currentParser = _typeMappingParser;
- break;
- }
- case ACCESS_MODE_MAPPINGS:
- {
- _currentParser = _accessModeMappingParser;
- break;
- }
case BROKERS:
{
_currentParser = _brokerConfigurationParser;
@@ -115,22 +121,116 @@
*/
public void configure() throws ConfigurationException
{
+ BufferedReader reader = null;
try
{
- SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
- BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(getConfigurationFileName()),"UTF8"));
- InputSource source = new InputSource(reader);
- parser.parse(source, this);
+ String initialConfigFileName = System.getProperty(Names.QMAN_CONFIG_OPTION_NAME);
+ if (initialConfigFileName != null && initialConfigFileName.trim().length() != 0)
+ {
+ File initialConfigurationFile = new File(initialConfigFileName);
+ if (initialConfigurationFile.canRead())
+ {
+ SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
+ reader = new BufferedReader(new InputStreamReader(new FileInputStream(initialConfigFileName)));
+ InputSource source = new InputSource(reader);
+ parser.parse(source, this);
+ } else {
+ LOGGER.warn(Messages.QMAN_300004_UNVALID_CONFIGURATION_FILE, initialConfigFileName);
+ }
+ }
+
+ addTypeMappings();
+ addAccessModeMappings();
- // Hard-coded configuration for message handlers : we need that because those handler mustn't be configurable.
- // QMan is not able to work without them!
addMandatoryManagementMessageHandlers();
addMandatoryMethodReplyMessageHandlers();
} catch (Exception exception)
{
throw new ConfigurationException(exception);
+ } finally
+ {
+ try
+ {
+ reader.close();
+ } catch (Exception ignore)
+ {
+ }
}
}
+
+ /**
+ * Creates and return a value object (BrokerConnectionData) with the given parameters.
+ * Note that that object will be stored on configuration and it could be used to set a connection with the broker.
+ * This happens when the "initialPoolCapacity" is greater than 0 : in this case the caller is indicatinf that it wants to open
+ * one or more connections immediately at startup and therefore Q-Man will try to do that.
+ *
+ * @param host the hostname where the broker is running.
+ * @param port the port where the broker is running.
+ * @param username the username for connecting with the broker.
+ * @param password the password for connecting with the broker.
+ * @param virtualHost the virtual host.
+ * @param initialPoolCapacity the number of the connection that must be immediately opened.
+ * @param maxPoolCapacity the maximum number of opened connection.
+ * @param maxWaitTimeout the maximum amount of time that a client will wait for obtaining a connection.
+ * @return the value object containing the data above.
+ * @throws BrokerAlreadyConnectedException when the broker is already connected.
+ * @throws BrokerConnectionException when a connection cannot be estabilished.
+ */
+ public BrokerConnectionData createAndReturnBrokerConnectionData(
+ UUID brokerId,
+ String host,
+ int port,
+ String username,
+ String password,
+ String virtualHost,
+ int initialPoolCapacity,
+ int maxPoolCapacity,
+ long maxWaitTimeout) throws BrokerAlreadyConnectedException, BrokerConnectionException
+ {
+ BrokerConnectionData data = new BrokerConnectionData(
+ host,
+ port,
+ virtualHost,
+ username,
+ password,
+ initialPoolCapacity,
+ maxPoolCapacity,
+ maxWaitTimeout);
+ Configuration.getInstance().addBrokerConnectionData(brokerId, data);
+ return data;
+ }
+
+ /**
+ * Configures access mode mappings.
+ * An access mode mapping is an association between a code and an access mode.
+ */
+ private void addAccessModeMappings() {
+ Configuration configuration = Configuration.getInstance();
+ configuration.addAccessModeMapping(new AccessModeMapping(1,AccessMode.RC));
+ configuration.addAccessModeMapping(new AccessModeMapping(2,AccessMode.RW));
+ configuration.addAccessModeMapping(new AccessModeMapping(3,AccessMode.RO));
+ }
+
+ /**
+ * Configures type mappings.
+ * A type mapping is an association between a code and a management type.
+ */
+ private void addTypeMappings()
+ {
+ Configuration configuration = Configuration.getInstance();
+ configuration.addTypeMapping(new TypeMapping(1,new Uint8(),Names.NUMBER_VALIDATOR));
+ configuration.addTypeMapping(new TypeMapping(2,new Uint16(),Names.NUMBER_VALIDATOR));
+ configuration.addTypeMapping(new TypeMapping(3,new Uint32(),Names.NUMBER_VALIDATOR));
+ configuration.addTypeMapping(new TypeMapping(4,new Uint64(),Names.NUMBER_VALIDATOR));
+ configuration.addTypeMapping(new TypeMapping(6,new Str8(),Names.STRING_VALIDATOR));
+ configuration.addTypeMapping(new TypeMapping(7,new Str16(),Names.STRING_VALIDATOR));
+ configuration.addTypeMapping(new TypeMapping(8,new AbsTime()));
+ configuration.addTypeMapping(new TypeMapping(9,new DeltaTime()));
+ configuration.addTypeMapping(new TypeMapping(10,new ObjectReference()));
+ configuration.addTypeMapping(new TypeMapping(11,new org.apache.qpid.management.domain.model.type.Boolean()));
+ configuration.addTypeMapping(new TypeMapping(14,new org.apache.qpid.management.domain.model.type.Uuid()));
+ configuration.addTypeMapping(new TypeMapping(15,new org.apache.qpid.management.domain.model.type.Map()));
+ }
/**
* Configures the mandatory management message handlers.
@@ -146,11 +246,6 @@
new MessageHandlerMapping(
Protocol.SCHEMA_RESPONSE_OPCODE,
SchemaResponseMessageHandler.class.getName()));
-
- Configuration.getInstance().addMethodReplyMessageHandlerMapping(
- new MessageHandlerMapping(
- Protocol.HEARTBEAT_INDICATION_RESPONSE_OPCODE,
- HeartBeatIndicationMessageHandler.class.getName()));
}
/**
@@ -172,15 +267,10 @@
new MessageHandlerMapping(
Protocol.EVENT_CONTENT_RESPONSE_OPCDE,
EventContentMessageHandler.class.getName()));
- }
-
- /**
- * Returns the name of the configuration file.
- *
- * @return the name of the configuration file.
- */
- String getConfigurationFileName()
- {
- return Names.CONFIGURATION_FILE_NAME;
+
+ Configuration.getInstance().addManagementMessageHandlerMapping(
+ new MessageHandlerMapping(
+ Protocol.HEARTBEAT_INDICATION_RESPONSE_OPCODE,
+ HeartBeatIndicationMessageHandler.class.getName()));
}
}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Tag.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Tag.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Tag.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/Tag.java Fri Oct 31 03:04:12 2008
@@ -6,17 +6,7 @@
* @author Andrea Gazzarini
*/
public enum Tag {
- HANDLER { @Override public String toString() { return "handler"; }},
- MAPPING { @Override public String toString() { return "mapping"; }},
- CODE { @Override public String toString() { return "code"; }},
- CLASS_NAME { @Override public String toString() { return "class-name"; }},
- TYPE_MAPPINGS { @Override public String toString() { return "type-mappings"; }},
- ACCESS_MODE_MAPPINGS { @Override public String toString() { return "access-mode-mappings"; }},
- VALUE { @Override public String toString() { return "value"; }},
CONFIGURATION { @Override public String toString() { return "configuration"; }},
- MESSAGE_HANDLERS { @Override public String toString() { return "message-handlers"; }},
- OPCODE { @Override public String toString() { return "opcode"; }},
- VALIDATOR_CLASS_NAME { @Override public String toString() { return "validator-class-name"; }},
BROKER { @Override public String toString() { return "broker"; }},
HOST { @Override public String toString() { return "host"; }},
PORT { @Override public String toString() { return "port"; }},
@@ -37,4 +27,4 @@
public static Tag get(String name) {
return valueOf(name.replaceAll("-", "_").toUpperCase());
}
-}
\ No newline at end of file
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java Fri Oct 31 03:04:12 2008
@@ -21,6 +21,7 @@
package org.apache.qpid.management.configuration;
import org.apache.qpid.management.domain.model.type.Type;
+
/**
* Type Mapping used for associating a code with a management type.
*
@@ -28,70 +29,56 @@
*/
class TypeMapping
{
- private int _code;
- private Type _type;
- private String _validatorClass;
+ private final int _code;
+ private final Type _type;
+ private final String _validatorClass;
/**
- * Returns the code of this mapping.
+ * Builds a new type mapping with the given parameters and no validator.
*
- * @return the code of this mapping.
+ * @param code the code.
+ * @param type the management type.
*/
- int getCode ()
+ TypeMapping(int code, Type type)
{
- return _code;
+ this(code,type,null);
}
-
+
/**
- * Sets the code for this mapping.
- * Note that the given string must be a valid number (integer).
+ * Builds a new type mapping with the given parameters.
*
- * @param codeAsString the code as a string.
- * @throws NumberFormatException when the given string is not a valid number.
+ * @param code the code.
+ * @param type the management type.
+ * @param validatorClassName the class name of the validator to be used.
*/
- void setCode (String codeAsString)
+ TypeMapping(int code, Type type, String validatorClassName)
{
- this._code = Integer.parseInt(codeAsString);
+ this._code = code;
+ this._type = type;
+ this._validatorClass = validatorClassName;
}
-
+
/**
- * Returns the type for this mapping.
+ * Returns the code of this mapping.
*
- * @return the type for this mapping.
+ * @return the code of this mapping.
*/
- Type getType ()
+ int getCode ()
{
- return _type;
+ return _code;
}
/**
- * Sets the type of this mapping.
+ * Returns the type for this mapping.
*
- * @param typeClass the type class as a string.
- * @throw IllegalArgumentException when it's not possible to load the given class.
+ * @return the type for this mapping.
*/
- void setType (String typeClass)
+ Type getType ()
{
- try
- {
- this._type = (Type) Class.forName(typeClass).newInstance();
- } catch (Exception exception)
- {
- throw new IllegalArgumentException(exception);
- }
+ return _type;
}
/**
- * Sets the validator class that will be used for validation.
- *
- * @param className the fully qualified name of the validation class.
- */
- public void setValidatorClassName (String className)
- {
- this._validatorClass = className;
- }
-
- /**
* Returns the validator class of this mapping.
*
* @return the validator class (as a string) of this mapping.
@@ -100,4 +87,4 @@
{
return _validatorClass;
}
-}
\ No newline at end of file
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/ConfigurationMessageHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/ConfigurationMessageHandler.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/ConfigurationMessageHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/ConfigurationMessageHandler.java Fri Oct 31 03:04:12 2008
@@ -52,7 +52,6 @@
long timeObjectWasDeleted,
byte[] contentData)
{
- // TODO : deal with timestamps, too
_domainModel.addConfigurationRawData(packageName,className,classHash,objectId,contentData);
}
- }
\ No newline at end of file
+ }
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java Fri Oct 31 03:04:12 2008
@@ -11,7 +11,6 @@
*/
public class HeartBeatIndicationMessageHandler extends BaseMessageHandler
{
- @Override
public void process(ManagementDecoder decoder, int sequenceNumber)
{
_domainModel.updateLastRefreshDate();
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InstrumentationMessageHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InstrumentationMessageHandler.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InstrumentationMessageHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InstrumentationMessageHandler.java Fri Oct 31 03:04:12 2008
@@ -52,7 +52,6 @@
long timeObjectWasDeleted,
byte[] contentData)
{
- // TODO : deal with timestamps, too
_domainModel.addInstrumentationRawData(packageName,className,classHash,objectId,contentData);
}
- }
\ No newline at end of file
+ }
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java Fri Oct 31 03:04:12 2008
@@ -60,7 +60,6 @@
*/
final IProcessor _classSchemaProcessor = new IProcessor()
{
- @Override
public void process(ManagementDecoder decoder)
{
try
@@ -93,7 +92,6 @@
*/
final IProcessor _eventSchemaProcessor = new IProcessor()
{
- @Override
public void process(ManagementDecoder decoder)
{
try
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/JmxService.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/JmxService.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/JmxService.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/JmxService.java Fri Oct 31 03:04:12 2008
@@ -24,6 +24,7 @@
import java.util.Set;
import java.util.UUID;
+import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -33,6 +34,7 @@
import org.apache.qpid.management.domain.model.QpidClass.QpidManagedObject;
import org.apache.qpid.management.domain.model.QpidEvent.QpidManagedEvent;
import org.apache.qpid.management.domain.model.type.Binary;
+import org.apache.qpid.management.domain.services.QMan;
import org.apache.qpid.transport.util.Logger;
/**
@@ -40,11 +42,31 @@
*
* @author Andrea Gazzarini
*/
-class JmxService
+public class JmxService
{
private final static Logger LOGGER = Logger.get(JmxService.class);
MBeanServer _mxServer = ManagementFactory.getPlatformMBeanServer();
+ /**
+ * Registers QMan with the MBeanServer.
+ * After that QMan management interface will be JMX-exposed.
+ *
+ * @param qman QMan
+ * @throws MBeanException when some error occurs during registration.
+ */
+ public void registerQManService(QMan qman) throws MBeanException
+ {
+ ObjectName name = createQManName();
+ if (!_mxServer.isRegistered(name))
+ {
+ try {
+ _mxServer.registerMBean(qman, name);
+ } catch (Exception exception) {
+ throw new MBeanException(exception);
+ }
+ }
+ }
+
void registerEventInstance(
QpidManagedEvent eventInstance,
UUID brokerId,
@@ -220,6 +242,50 @@
throw new RuntimeException(exception);
}
}
+
+ /**
+ * Creates an object name that will be used for searching all registered events.
+ *
+ * @return the object name that will be used for searching all registered events.
+ */
+ ObjectName createEventSearchName()
+ {
+ String asString = new StringBuilder()
+ .append(Names.DOMAIN_NAME)
+ .append(':')
+ .append('*')
+ .append(",type=Event")
+ .toString();
+ try
+ {
+ return new ObjectName(asString);
+ } catch (MalformedObjectNameException exception)
+ {
+ throw new RuntimeException(exception);
+ }
+ }
+
+ /**
+ * Creates an object name that will be used for searching all registered object instances.
+ *
+ * @return the object name that will be used for searching all registered object instances.
+ */
+ private ObjectName createObjectInstanceSearchName()
+ {
+ String asString = new StringBuilder()
+ .append(Names.DOMAIN_NAME)
+ .append(':')
+ .append('*')
+ .append(",type=Object")
+ .toString();
+ try
+ {
+ return new ObjectName(asString);
+ } catch (MalformedObjectNameException exception)
+ {
+ throw new RuntimeException(exception);
+ }
+ }
/**
* Factory method for ObjectNames.
@@ -257,42 +323,19 @@
{
throw new RuntimeException(exception);
}
- }
-
- /**
- * Creates an object name that will be used for searching all registered events.
- *
- * @return the object name that will be used for searching all registered events.
- */
- ObjectName createEventSearchName()
- {
- String asString = new StringBuilder()
- .append(Names.DOMAIN_NAME)
- .append(':')
- .append('*')
- .append(",type=Event")
- .toString();
- try
- {
- return new ObjectName(asString);
- } catch (MalformedObjectNameException exception)
- {
- throw new RuntimeException(exception);
- }
}
/**
- * Creates an object name that will be used for searching all registered object instances.
+ * Creates the QMan object name.
*
- * @return the object name that will be used for searching all registered object instances.
+ * @return the QMan object name.
*/
- private ObjectName createObjectInstanceSearchName()
+ private ObjectName createQManName()
{
String asString = new StringBuilder()
.append(Names.DOMAIN_NAME)
.append(':')
- .append('*')
- .append(",type=Object")
+ .append("Type=Service")
.toString();
try
{
@@ -301,5 +344,5 @@
{
throw new RuntimeException(exception);
}
- }
+ }
}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java Fri Oct 31 03:04:12 2008
@@ -662,7 +662,6 @@
_methodInvocationListener.operationIsGoingToBeInvoked(new InvocationEvent(this,sequenceNumber,_exchangeChannelForMethodInvocations));
_service.invoke(_parent.getName(), _name, _hash,objectId,parameters, method,sequenceNumber,objectId.getBankId(),objectId.getBrokerId());
- // TODO : Shoudl be configurable?
InvocationResult result = _exchangeChannelForMethodInvocations.poll(5000,TimeUnit.MILLISECONDS);
if (result == null)
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java Fri Oct 31 03:04:12 2008
@@ -150,7 +150,6 @@
{
ByteBuffer buffer = message.readData();
- // TODO : Should be better...!
String magicNumber = new String(new byte[] {buffer.get(),buffer.get(),buffer.get()});
if (!Protocol.MAGIC_NUMBER.equals(magicNumber))
{
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java Fri Oct 31 03:04:12 2008
@@ -52,13 +52,11 @@
build(compoundMessage);
}
- @Override
public boolean hasMoreElements()
{
return _iterator.hasNext();
}
- @Override
public Message nextElement()
{
return _iterator.next();
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java Fri Oct 31 03:04:12 2008
@@ -28,12 +28,24 @@
import java.util.UUID;
import java.util.Map.Entry;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.DynamicMBean;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.ReflectionException;
+
import org.apache.log4j.xml.DOMConfigurator;
import org.apache.qpid.management.Messages;
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.configuration.BrokerAlreadyConnectedException;
import org.apache.qpid.management.configuration.BrokerConnectionData;
+import org.apache.qpid.management.configuration.BrokerConnectionException;
import org.apache.qpid.management.configuration.Configuration;
-import org.apache.qpid.management.configuration.ConfigurationException;
import org.apache.qpid.management.configuration.Configurator;
+import org.apache.qpid.management.domain.model.JmxService;
import org.apache.qpid.transport.util.Logger;
/**
@@ -41,11 +53,11 @@
*
* @author Andrea Gazzarini
*/
-public class QMan
+public class QMan implements DynamicMBean
{
private final static Logger LOGGER = Logger.get(QMan.class);
private final List<ManagementClient> managementClients = new ArrayList<ManagementClient>();
-
+
/**
* Starts QMan.
* @throws StartupFailureException when it's not possible to proceed with startup.
@@ -59,45 +71,92 @@
try
{
configurator.configure();
- LOGGER.info(Messages.QMAN_000003_CREATING_MANAGEMENT_CLIENTS);
- for (Entry<UUID, BrokerConnectionData> entry : Configuration.getInstance().getConnectionInfos())
+ Configuration configuration = Configuration.getInstance();
+ if (configuration.hasOneOrMoreBrokersDefined())
{
- UUID brokerId = entry.getKey();
- BrokerConnectionData data = entry.getValue();
- try
- {
- ManagementClient client = new ManagementClient(brokerId,data);
- managementClients.add(client);
- client.estabilishFirstConnectionWithBroker();
-
- LOGGER.info(Messages.QMAN_000004_MANAGEMENT_CLIENT_CONNECTED,brokerId);
- } catch(StartupFailureException exception) {
- LOGGER.error(exception, Messages.QMAN_100017_UNABLE_TO_CONNECT,brokerId,data);
- }
+ LOGGER.info(Messages.QMAN_000003_CREATING_MANAGEMENT_CLIENTS);
+ for (Entry<UUID, BrokerConnectionData> entry : Configuration.getInstance().getConnectionInfos())
+ {
+ createManagementClient(entry.getKey(), entry.getValue());
+ }
+ } else
+ {
+ LOGGER.info(Messages.QMAN_000022_NO_BROKER_CONFIGURED);
}
+
+ registerQManService();
+
LOGGER.info(Messages.QMAN_000019_QMAN_STARTED);
- } catch(ConfigurationException exception) {
- LOGGER.error(exception,Messages.UNABLE_TO_STARTUP_CORRECTLY);
+ } catch(Exception exception) {
+ LOGGER.error(exception,Messages.QMAN_100018_UNABLE_TO_STARTUP_CORRECTLY );
throw new StartupFailureException(exception);
}
}
- /**
- * Compose method used for adding a "graceful" shutdown hook.
+ /**
+ * Creates a management client using the given data.
+ *
+ * @param brokerId the broker identifier.
+ * @param data the broker connection data.
*/
- private void addShutDownHook()
+ private void createManagementClient(UUID brokerId, BrokerConnectionData data)
{
- // SHUTDOWN HOOK
- Runtime.getRuntime().addShutdownHook(new Thread()
+ try
{
- @Override
- public void run ()
- {
- QMan.this.stop();
- }
- });
+ ManagementClient client = new ManagementClient(brokerId,data);
+ client.estabilishFirstConnectionWithBroker();
+ managementClients.add(client);
+
+ LOGGER.info(Messages.QMAN_000004_MANAGEMENT_CLIENT_CONNECTED,brokerId);
+ } catch(StartupFailureException exception) {
+ LOGGER.error(exception, Messages.QMAN_100017_UNABLE_TO_CONNECT,brokerId,data);
+ }
}
+ /**
+ * Connects Q-Man with a broker defined by the given parameter.
+ *
+ * @param host the hostname where the broker is running.
+ * @param port the port where the broker is running.
+ * @param username the username for connecting with the broker.
+ * @param password the password for connecting with the broker.
+ * @param virtualHost the virtual host.
+ * @param initialPoolCapacity the number of the connection that must be immediately opened.
+ * @param maxPoolCapacity the maximum number of opened connection.
+ * @param maxWaitTimeout the maximum amount of time that a client will wait for obtaining a connection.
+ * @throws MBeanException when it's not possible to connect with the broker.
+ */
+ public void addBroker(
+ String host,
+ int port,
+ String username,
+ String password,
+ String virtualHost,
+ int initialPoolCapacity,
+ int maxPoolCapacity,
+ long maxWaitTimeout) throws BrokerAlreadyConnectedException, BrokerConnectionException
+ {
+ Configurator configurator = new Configurator();
+ try {
+ UUID brokerId = UUID.randomUUID();
+ BrokerConnectionData data = configurator.createAndReturnBrokerConnectionData(
+ brokerId,
+ host,
+ port,
+ username,
+ password,
+ virtualHost,
+ initialPoolCapacity,
+ maxPoolCapacity,
+ maxWaitTimeout);
+ createManagementClient(brokerId, data);
+ } catch (BrokerAlreadyConnectedException exception)
+ {
+ LOGGER.warn(Messages.QMAN_300003_BROKER_ALREADY_CONNECTED, exception.getBrokerConnectionData());
+ throw exception;
+ }
+ }
+
/**
* Stop Qman
*/
@@ -129,27 +188,178 @@
DOMConfigurator.configureAndWatch(logFileName,5000);
}
- QMan qman = new QMan();
- qman.addShutDownHook();
+ final QMan qman = new QMan();
+
+ Thread hook = new Thread()
+ {
+ @Override
+ public void run ()
+ {
+ qman.stop();
+ }
+ };
+
+ Runtime.getRuntime().addShutdownHook(hook);
try
{
qman.start();
- // TODO : console enhancement (i.e. : connect another broker)
- System.out.println("Type \"q\" to quit.");
+ System.out.println("Type \"q\" to quit.");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while ( !"q".equals(reader.readLine()) )
{
}
+ Runtime.getRuntime().removeShutdownHook(hook);
+ qman.stop();
System.exit(-1);
} catch (StartupFailureException exception)
{
- exception.printStackTrace();
+ qman.stop();
System.exit(-1);
} catch (IOException exception)
{
System.exit(-1);
}
}
+
+ /**
+ * Not implemented for this MBean.
+ */
+ public Object getAttribute(String attribute)
+ {
+ return null;
+ }
+
+ /**
+ * Not implemented for this MBean.
+ */
+ public AttributeList getAttributes(String[] attributes)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the metadata for this MBean
+ *
+ * @return the metadata for this MBean
+ */
+ public MBeanInfo getMBeanInfo()
+ {
+ MBeanParameterInfo parameters [] = new MBeanParameterInfo[8];
+
+ parameters[0] = new MBeanParameterInfo(
+ "host",
+ String.class.getName(),
+ "The IP address or DNS name that Qpid Broker uses to listen for incoming connections.");
+ parameters[1] = new MBeanParameterInfo(
+ "port",
+ int.class.getName(),
+ "The port number that Qpid Broker uses to listen for incoming connections.");
+ parameters[2] = new MBeanParameterInfo(
+ "username",
+ String.class.getName(),
+ "The Qpid account name used in the physical connection.");
+ parameters[3] = new MBeanParameterInfo(
+ "password",
+ String.class.getName(),
+ "The Qpid account password used in the physical connection.");
+ parameters[4]= new MBeanParameterInfo(
+ "virtualHost",
+ String.class.getName(),
+ "The virtualHost name.");
+ parameters[5]= new MBeanParameterInfo(
+ "initialPoolCapacity",
+ int.class.getName(),
+ "The number of physical connections (between 0 and a positive 32-bit integer) to create when creating the (Qpid) connection pool.");
+ parameters[6]= new MBeanParameterInfo(
+ "maxPoolCapacity",
+ int.class.getName(),
+ "The maximum number of physical database connections (between 0 and a positive 32-bit integer) that the (Qpid) connection pool can contain. ");
+ parameters[7]= new MBeanParameterInfo(
+ "maxWaitTimeout",
+ long.class.getName(),
+ "The maximum amount of time to wait for an idle connection.A value of -1 indicates an illimted amount of time (i.e. forever)");
+
+ MBeanOperationInfo operation = new MBeanOperationInfo(
+ "addBroker",
+ "Connects QMan with a broker.",
+ parameters,
+ void.class.getName(),
+ MBeanOperationInfo.ACTION);
+
+ MBeanInfo mbean = new MBeanInfo(
+ QMan.class.getName(),
+ "QMan Management & Administration interface.",
+ null,
+ null,
+ new MBeanOperationInfo[]{operation},
+ null);
+
+ return mbean;
+ }
+
+ /**
+ * Invokes an operation on QMan (MBean).
+ *
+ * @param actionName the operation name.
+ * @param params the operation parameters.
+ * @param signature the operation signature.
+ * @return the result of the invocation (if the operation is not void);
+ * @exception MBeanException Wraps a <CODE>java.lang.Exception</CODE> thrown by the MBean's invoked method.
+ * @exception ReflectionException Wraps a <CODE>java.lang.Exception</CODE> thrown while trying to invoke the method
+ */
+ public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException
+ {
+ if (Names.ADD_BROKER_OPERATION_NAME.equals(actionName))
+ {
+ try
+ {
+ addBroker(
+ (String)params[0],
+ (Integer)params[1],
+ (String)params[2],
+ (String)params[3],
+ (String)params[4],
+ (Integer)params[5],
+ (Integer)params[6],
+ (Long)params[7]);
+ } catch(Exception exception)
+ {
+ throw new MBeanException(exception);
+ }
+ } else
+ {
+ throw new ReflectionException(new NoSuchMethodException(actionName));
+ }
+ return null;
+ }
+
+ /**
+ * Not implemented for this MBean.
+ */
+ public void setAttribute(Attribute attribute)
+ {
+ }
+
+ /**
+ * Not implemented for this MBean.
+ */
+ public AttributeList setAttributes(AttributeList attributes)
+ {
+ return null;
+ }
+
+ /**
+ * Registers QMan as an MBean on MBeanServer.
+ *
+ * @throws MBeanException when it's not possible to proceeed with registration.
+ */
+ private void registerQManService() throws MBeanException
+ {
+ JmxService service = new JmxService();
+ service.registerQManService(this);
+
+ LOGGER.info(Messages.QMAN_000023_QMAN_REGISTERED_AS_MBEAN);
+ }
}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java Fri Oct 31 03:04:12 2008
@@ -21,6 +21,7 @@
package org.apache.qpid.management.messages;
import org.apache.qpid.management.Messages;
+import org.apache.qpid.management.Names;
import org.apache.qpid.management.Protocol;
import org.apache.qpid.management.configuration.Configuration;
import org.apache.qpid.management.domain.model.QpidMethod;
@@ -58,7 +59,7 @@
_messageProperties = new MessageProperties();
_messageProperties.setReplyTo(replyTo);
- String routingKey = String.format("agent.%s.%s", brokerId,bankId);
+ String routingKey = String.format(Names.AGENT_ROUTING_KEY_PREFIX+"%s.%s", brokerId,bankId);
LOGGER.debug(Messages.QMAN_200032_COMMAND_MESSAGE_ROUTING_KEY, routingKey);
Modified: incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java Fri Oct 31 03:04:12 2008
@@ -57,11 +57,8 @@
*/
public void testGetTypeOk() throws UnknownTypeCodeException
{
- TypeMapping mapping = new TypeMapping();
- mapping.setCode(String.valueOf(TestConstants.VALID_CODE));
- mapping.setType(Uint8.class.getName());
+ TypeMapping mapping = new TypeMapping(TestConstants.VALID_CODE,new Uint8());
Configuration.getInstance().addTypeMapping(mapping);
-
Type type = Configuration.getInstance().getType(TestConstants.VALID_CODE);
assertTrue(type instanceof Uint8);
@@ -93,14 +90,10 @@
*/
public void testGetAccessModeOk() throws UnknownAccessCodeException
{
- String accessModeAsString = "RW";
-
- AccessModeMapping mapping = new AccessModeMapping();
- mapping.setCode(String.valueOf(TestConstants.VALID_CODE));
- mapping.setAccessMode(accessModeAsString);
+ AccessModeMapping mapping = new AccessModeMapping(TestConstants.VALID_CODE,AccessMode.RW);
Configuration.getInstance().addAccessModeMapping(mapping);
-
AccessMode accessMode = Configuration.getInstance().getAccessMode(TestConstants.VALID_CODE);
+
assertSame(AccessMode.RW,accessMode);
}
@@ -234,4 +227,4 @@
assertEquals(schemaMessageHandlerClassName,handlerMappings.get(schemaMapping.getOpcode()).getClass().getName());
}
-}
\ No newline at end of file
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfiguratorTest.java Fri Oct 31 03:04:12 2008
@@ -20,10 +20,32 @@
*/
package org.apache.qpid.management.configuration;
-import org.xml.sax.SAXException;
+import java.util.Map;
+import java.util.UUID;
import junit.framework.TestCase;
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.Protocol;
+import org.apache.qpid.management.domain.handler.base.IMessageHandler;
+import org.apache.qpid.management.domain.handler.impl.ConfigurationMessageHandler;
+import org.apache.qpid.management.domain.handler.impl.EventContentMessageHandler;
+import org.apache.qpid.management.domain.handler.impl.HeartBeatIndicationMessageHandler;
+import org.apache.qpid.management.domain.handler.impl.InstrumentationMessageHandler;
+import org.apache.qpid.management.domain.handler.impl.MethodResponseMessageHandler;
+import org.apache.qpid.management.domain.handler.impl.SchemaResponseMessageHandler;
+import org.apache.qpid.management.domain.model.AccessMode;
+import org.apache.qpid.management.domain.model.type.AbsTime;
+import org.apache.qpid.management.domain.model.type.DeltaTime;
+import org.apache.qpid.management.domain.model.type.ObjectReference;
+import org.apache.qpid.management.domain.model.type.Str16;
+import org.apache.qpid.management.domain.model.type.Str8;
+import org.apache.qpid.management.domain.model.type.Uint16;
+import org.apache.qpid.management.domain.model.type.Uint32;
+import org.apache.qpid.management.domain.model.type.Uint64;
+import org.apache.qpid.management.domain.model.type.Uint8;
+import org.xml.sax.SAXException;
+
/**
* Test case for configurator.
*
@@ -32,40 +54,65 @@
*/
public class ConfiguratorTest extends TestCase
{
-
- /**
- * Tests the execution of the configure() method when a inexistent configuration file is used.
- *
- * <br>precondition : the configuration file doesn't exist.
- * <br>postcondition : an exception is thrown indicating the failure.
- */
- public void testConfigureKO_WithConfigFileNotFound()
- {
- Configurator configurator = getConfiguratorWithDatafileInjected("pippo/pluto/paperino.xml");
- try {
- configurator.configure();
- fail("If there's no configuration file the configuration cannot be built.");
- } catch(ConfigurationException expected) {
-
- }
- }
-
/**
- * Tests the execution of the configure() method when configuration file is null.
+ * Tests the execution of the configure() method when no configuration file is given.
*
- * <br>precondition : the configuration file is null.
- * <br>postcondition : an exception is thrown indicating the failure.
+ * <br>precondition : configuration file option is not set
+ * <br>postcondition : no exception is thrown, the configuration is holding no broker data and the predefined mappings are
+ * stored in configuration.
*/
- public void testConfigureKO_WithNullConfig()
- {
- Configurator configurator = getConfiguratorWithDatafileInjected(null);
- try {
- configurator.configure();
- fail("If there's no configuration file the configuration cannot be built.");
- } catch(ConfigurationException expected) {
-
- }
- }
+ public void testConfigureOK_WithNoConfigurationFile() throws Exception
+ {
+ Configurator configurator = new Configurator();
+ configurator.configure();
+ Configuration configuration = Configuration.getInstance();
+
+ assertEquals(new Uint8(), configuration.getType(1));
+ assertEquals(new Uint16(), configuration.getType(2));
+ assertEquals(new Uint32(), configuration.getType(3));
+ assertEquals(new Uint64(), configuration.getType(4));
+ assertEquals(new Str8(), configuration.getType(6));
+ assertEquals(new Str16(), configuration.getType(7));
+ assertEquals(new AbsTime(), configuration.getType(8));
+ assertEquals(new DeltaTime(), configuration.getType(9));
+ assertEquals(new ObjectReference(), configuration.getType(10));
+ assertEquals(new org.apache.qpid.management.domain.model.type.Boolean(), configuration.getType(11));
+ assertEquals(new org.apache.qpid.management.domain.model.type.Uuid(), configuration.getType(14));
+ assertEquals(new org.apache.qpid.management.domain.model.type.Map(), configuration.getType(15));
+
+ assertEquals(AccessMode.RC,configuration.getAccessMode(1));
+ assertEquals(AccessMode.RW,configuration.getAccessMode(2));
+ assertEquals(AccessMode.RO,configuration.getAccessMode(3));
+
+ Map<Character, IMessageHandler> managementHandlers = configuration.getManagementQueueHandlers();
+ assertEquals(4,managementHandlers.size());
+ assertEquals(
+ InstrumentationMessageHandler.class,
+ managementHandlers.get(Protocol.INSTRUMENTATION_CONTENT_RESPONSE_OPCODE).getClass());
+
+ assertEquals(
+ ConfigurationMessageHandler.class,
+ managementHandlers.get(Protocol.CONFIGURATION_CONTENT_RESPONSE_OPCDE).getClass());
+
+ assertEquals(
+ EventContentMessageHandler.class,
+ managementHandlers.get(Protocol.EVENT_CONTENT_RESPONSE_OPCDE).getClass());
+
+ assertEquals(
+ HeartBeatIndicationMessageHandler.class,
+ managementHandlers.get(Protocol.HEARTBEAT_INDICATION_RESPONSE_OPCODE).getClass());
+
+ Map<Character, IMessageHandler> methodReplyHandlers = configuration.getMethodReplyQueueHandlers();
+ assertEquals(2, methodReplyHandlers.size());
+
+ assertEquals(
+ MethodResponseMessageHandler.class,
+ methodReplyHandlers.get(Protocol.OPERATION_INVOCATION_RESPONSE_OPCODE).getClass());
+
+ assertEquals(
+ SchemaResponseMessageHandler.class,
+ methodReplyHandlers.get(Protocol.SCHEMA_RESPONSE_OPCODE).getClass());
+ }
/**
* Tests the changes of the configurator internal state while configuration file is parsed.
@@ -77,30 +124,41 @@
Configurator configurator = new Configurator();
assertSame(Configurator.DEFAULT_PARSER,configurator._currentParser);
-
- configurator.startElement(null, null, Tag.TYPE_MAPPINGS.toString(), null);
- assertSame(configurator._typeMappingParser,configurator._currentParser);
-
- configurator.startElement(null, null, Tag.ACCESS_MODE_MAPPINGS.toString(), null);
- assertSame(configurator._accessModeMappingParser,configurator._currentParser);
configurator.startElement(null, null, Tag.BROKERS.toString(), null);
assertSame(configurator._brokerConfigurationParser,configurator._currentParser);
}
+
/**
- * Create a stub configurator which returns the given datafile path.
+ * It's not possibile to add twice the same broker connection data.
+ * Is so an exception must be thrown indicating that the given broker is already connected.
*
- * @param filename the configuration file to be injected.
- * @return a configurator which returns the given datafile path.
+ * <br>precondition : the given data identifies an already connected broker.
+ * <br>postcondition : an exception is thrown indicating the failure.
*/
- private Configurator getConfiguratorWithDatafileInjected(final String filename) {
- return new Configurator()
- {
- @Override
- String getConfigurationFileName ()
- {
- return filename;
- }
- };
+ public void testAddTwoIdenticalBrokers() throws ConfigurationException, BrokerConnectionException
+ {
+ Configurator configurator = new Configurator();
+ configurator.configure();
+
+ BrokerConnectionData data = new BrokerConnectionData("sofia.gazzax.com",5672,"virtualHost","user","pwd",1,4,-1);
+
+ Configuration.getInstance()._brokerConnectionInfos.put(UUID.randomUUID(),data);
+
+ try {
+ configurator.createAndReturnBrokerConnectionData(
+ UUID.randomUUID(),
+ data.getHost(),
+ data.getPort(),
+ "anotherUser",
+ "anotherPassword",
+ data.getVirtualHost(),
+ 33,
+ 12,
+ 1000);
+ fail("If a broker is added twice an exception must be thrown.");
+ } catch (BrokerAlreadyConnectedException expected) {
+ assertEquals(data,expected.getBrokerConnectionData());
+ }
}
-}
\ No newline at end of file
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/configuration/MappingParsersTest.java Fri Oct 31 03:04:12 2008
@@ -25,9 +25,6 @@
import junit.framework.TestCase;
import org.apache.qpid.management.TestConstants;
-import org.apache.qpid.management.domain.model.AccessMode;
-import org.apache.qpid.management.domain.model.type.Type;
-import org.apache.qpid.management.domain.model.type.Uint8;
/**
* Test case for mapping parsers.
@@ -37,25 +34,6 @@
public class MappingParsersTest extends TestCase
{
/**
- * Tests the execution of the access mode mapping parser.
- *
- * <br>precondition: An access mode mapping is built by the parser;
- * <br>postcondition: the corresponding access mode is available on the configuration.
- */
- public void testAccessModeMappingParser() throws UnknownAccessCodeException
- {
- AccessModeMappingParser parser = new AccessModeMappingParser();
- parser.setCurrrentAttributeValue(String.valueOf(TestConstants.VALID_CODE));
- parser.setCurrentAttributeName(Tag.CODE.toString());
- parser.setCurrrentAttributeValue("RW");
- parser.setCurrentAttributeName(Tag.VALUE.toString());
- parser.setCurrentAttributeName(Tag.MAPPING.toString());
-
- AccessMode result = Configuration.getInstance().getAccessMode(TestConstants.VALID_CODE);
- assertEquals(AccessMode.RW,result);
- }
-
- /**
* Tests the execution of the broker connection data mapping parser.
*
* <br>precondition: A broker connection datamapping is built by the parser;
@@ -98,32 +76,4 @@
assertEquals(username,result.getUsername());
assertEquals(password,result.getPassword());
}
-
- /**
- * Tests the execution of the type mapping parser.
- *
- * <br>precondition: two type mappings are built by the parser;
- * <br>postcondition: the corresponding types are available on the configuration.
- */
- public void testMappingParser() throws NumberFormatException, UnknownTypeCodeException
- {
- TypeMappingParser parser = new TypeMappingParser();
-
- String className = Uint8.class.getName();
- String validatorClassName = "a.b.c.Validator";
-
- parser.setCurrrentAttributeValue(String.valueOf(TestConstants.VALID_CODE));
- parser.setCurrentAttributeName(Tag.CODE.toString());
- parser.setCurrrentAttributeValue(className);
- parser.setCurrentAttributeName(Tag.CLASS_NAME.toString());
- parser.setCurrrentAttributeValue(validatorClassName);
- parser.setCurrentAttributeName(Tag.VALIDATOR_CLASS_NAME.toString());
- parser.setCurrentAttributeName(Tag.MAPPING.toString());
-
- Type type =Configuration.getInstance().getType(TestConstants.VALID_CODE);
- String vClassName = Configuration.getInstance().getValidatorClassName(type);
-
- assertEquals(Uint8.class, type.getClass());
- assertEquals(validatorClassName,vClassName);
- }
-}
\ No newline at end of file
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java Fri Oct 31 03:04:12 2008
@@ -22,7 +22,7 @@
import org.apache.qpid.management.configuration.Configurator;
-import junit.framework.TestCase;;
+import junit.framework.TestCase;
/**
* Layer supertype for all domain model related test cases.
Modified: incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseQpidFeatureBuilderTestCase.java Fri Oct 31 03:04:12 2008
@@ -28,9 +28,8 @@
import junit.framework.TestCase;
-import org.apache.qpid.management.configuration.StubConfigurator;
+import org.apache.qpid.management.configuration.Configurator;
import org.apache.qpid.management.domain.model.QpidFeatureBuilder.Attribute;
-import org.apache.qpid.management.domain.model.type.Uint16;
/**
* Layer supertype for feature builder test cases.
@@ -42,23 +41,18 @@
protected final static String NAME = "aName";
protected final static String DESCRIPTION = "A description.";
- protected Integer _type;
protected Map <String,Object> _featureDefinition;
protected QpidFeatureBuilder _builder;
- protected StubConfigurator configurator;
-
/**
* Set up fixture for all concrete builder test cases.
*/
@Override
protected void setUp () throws Exception
{
- _type = 1;
- configurator = new StubConfigurator();
- configurator.addTypeMapping(_type.toString(),Uint16.class.getName());
-
+ Configurator configurator = new Configurator();
+ configurator.configure();
_featureDefinition = new HashMap<String, Object>();
_featureDefinition.put(name.name(),NAME);
_featureDefinition.put(desc.name(), DESCRIPTION);
@@ -99,4 +93,4 @@
}
-}
\ No newline at end of file
+}
Modified: incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidClassTest.java Fri Oct 31 03:04:12 2008
@@ -14,7 +14,7 @@
import org.apache.qpid.management.TestConstants;
import org.apache.qpid.management.configuration.ConfigurationException;
-import org.apache.qpid.management.configuration.StubConfigurator;
+import org.apache.qpid.management.configuration.Configurator;
import org.apache.qpid.management.domain.handler.impl.MethodOrEventDataTransferObject;
import org.apache.qpid.management.domain.model.QpidClass.QpidManagedObject;
@@ -31,7 +31,7 @@
@Override
protected void setUp () throws ConfigurationException
{
- StubConfigurator configurator = new StubConfigurator();
+ Configurator configurator = new Configurator();
configurator.configure();
_package = new QpidPackage(TestConstants.QPID_PACKAGE_NAME,TestConstants.DOMAIN_MODEL);
_class = new QpidClass(TestConstants.EXCHANGE_CLASS_NAME,TestConstants.HASH,_package);
@@ -214,7 +214,7 @@
assertEquals(TestConstants.SAMPLE_MAX_VALUE,property.getMaxValue());
assertEquals(Integer.MIN_VALUE,property.getMaxLength());
assertEquals(TestConstants.AGE_ATTRIBUTE_DESCRIPTION,property.getDescription());
- assertEquals(String.class,property.getJavaType());
+ assertEquals(Short.class,property.getJavaType());
assertFalse(property.isOptional());
property = _class._properties.get(TestConstants.SURNAME_ATTRIBUTE_NAME);
@@ -225,7 +225,7 @@
assertEquals(Integer.MIN_VALUE,property.getMaxValue());
assertEquals(TestConstants.SAMPLE_MAX_VALUE,property.getMaxLength());
assertEquals(TestConstants.SURNAME_ATTRIBUTE_DESCRIPTION,property.getDescription());
- assertEquals(String.class,property.getJavaType());
+ assertEquals(Short.class,property.getJavaType());
assertTrue(property.isOptional());
MBeanInfo mbeanInfo = _class._metadata;
@@ -239,14 +239,14 @@
assertEquals(TestConstants.AGE_ATTRIBUTE_DESCRIPTION,attribute.getDescription());
assertFalse(attribute.isWritable());
assertTrue(attribute.isReadable());
- assertEquals(String.class.getName(),attribute.getType());
+ assertEquals(Short.class.getName(),attribute.getType());
attribute = attributes[1];
assertEquals(TestConstants.SURNAME_ATTRIBUTE_NAME,attribute.getName());
assertEquals(TestConstants.SURNAME_ATTRIBUTE_DESCRIPTION,attribute.getDescription());
assertFalse(attribute.isWritable());
assertTrue(attribute.isReadable());
- assertEquals(String.class.getName(),attribute.getType());
+ assertEquals(Short.class.getName(),attribute.getType());
}
/**
Modified: incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java?rev=709374&r1=709373&r2=709374&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java (original)
+++ incubator/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/domain/model/QpidEventTest.java Fri Oct 31 03:04:12 2008
@@ -35,7 +35,7 @@
import org.apache.qpid.management.TestConstants;
import org.apache.qpid.management.configuration.ConfigurationException;
-import org.apache.qpid.management.configuration.StubConfigurator;
+import org.apache.qpid.management.configuration.Configurator;
import org.apache.qpid.management.domain.model.QpidEvent.QpidManagedEvent;
/**
@@ -142,7 +142,7 @@
}
};
- StubConfigurator configurator = new StubConfigurator();
+ Configurator configurator = new Configurator();
configurator.configure();
List<Map<String,Object>> arguments = new ArrayList<Map<String, Object>>();
@@ -168,14 +168,14 @@
assertEquals(TestConstants.AGE_ATTRIBUTE_NAME,argument.getName());
assertEquals(AccessMode.RO,argument.getAccessMode());
assertEquals(TestConstants.AGE_ATTRIBUTE_DESCRIPTION,argument.getDescription());
- assertEquals(String.class,argument.getJavaType());
+ assertEquals(Short.class,argument.getJavaType());
assertFalse(argument.isOptional());
argument = _event._arguments.get(TestConstants.SURNAME_ATTRIBUTE_NAME);
assertEquals(TestConstants.SURNAME_ATTRIBUTE_NAME,argument.getName());
assertEquals(AccessMode.RO,argument.getAccessMode());
assertEquals(TestConstants.SURNAME_ATTRIBUTE_DESCRIPTION,argument.getDescription());
- assertEquals(String.class,argument.getJavaType());
+ assertEquals(Short.class,argument.getJavaType());
assertFalse(argument.isOptional());
assertEquals(1,_event._eventInstances.size());