You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Rafael Schloming <ra...@redhat.com> on 2008/09/30 19:15:45 UTC
Re: svn commit: r700077 [1/4] - in /incubator/qpid/trunk/qpid/java:
client/src/main/java/org/apache/qpid/management/ client/src/main/java/org/apache/qpid/management/configuration/
client/src/main/java/org/apache/qpid/management/domain/ client/src/main/java...
Why was this stuff added to the client module? Isn't it a stand-alone app?
--Rafael
arnaudsimon@apache.org wrote:
> Author: arnaudsimon
> Date: Mon Sep 29 05:02:54 2008
> New Revision: 700077
>
> URL: http://svn.apache.org/viewvc?rev=700077&view=rev
> Log:
> qpid-1284: Qman on behalf Andrea
>
> Added:
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Constants.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Names.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Protocol.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/config.xml
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMappingParser.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionDataParser.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ConfigurationException.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/IParser.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ManagementQueueMessageListenerParser.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MessageHandlerMapping.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MethodReplyQueueMessageListenerParser.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Tag.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMappingParser.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/UnknownAccessCodeException.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/UnknownBrokerException.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/UnknownTypeCodeException.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/base/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/base/BaseMessageHandler.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/base/ContentIndicationMessageHandler.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/base/IMessageHandler.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/impl/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/impl/ConfigurationMessageHandler.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/impl/InstrumentationMessageHandler.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/impl/MethodOrEventDataTransferObject.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/impl/MethodResponseMessageHandler.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/AccessMode.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/Direction.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/DomainModel.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/IValidator.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/JmxService.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/MissingFeatureAttributesException.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidArgument.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidAttribute.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidFeature.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidFeatureBuilder.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidMethod.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidPackage.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidProperty.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/QpidStatistic.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/UnableToBuildFeatureException.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/ValidationException.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/AbsTime.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Boolean.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/DeltaTime.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/ObjectReference.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Str16.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Str8.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Type.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint16.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint32.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint64.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint8.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/model/type/Uuid.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/services/
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/services/ManagementClient.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/services/QpidService.java
> incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/domain/services/StartupFailureException.java
> incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java
> incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Constants.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Constants.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Constants.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Constants.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,32 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management;
> +
> +/**
> + * Enumeration of literal values used to avoid code duplication.
> + *
> + * @author Andrea Gazzarini
> + */
> +public interface Constants
> +{
> + /** No expiration (used for timeout) */
> + long NO_EXPIRATION = 0;
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Names.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Names.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Names.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Names.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,52 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management;
> +
> +/**
> + * Enumeration of literal strings to avoid code duplication.
> + *
> + * @author Andrea Gazzarini
> + */
> +public interface Names
> +{
> + /** Name of the qpid management exchange. */
> + String MANAGEMENT_EXCHANGE = "qpid.management";
> + String MANAGEMENT_ROUTING_KEY = "mgmt.#";
> +
> + String MANAGEMENT_QUEUE_PREFIX = "management.";
> + String METHOD_REPLY_QUEUE_PREFIX = "reply.";
> +
> + String AMQ_DIRECT_QUEUE = "amq.direct";
> + String AGENT_ROUTING_KEY = "agent.0";
> +
> + String BROKER_ROUTING_KEY = "broker";
> +
> + // Attributes
> + String PACKAGE = "package";
> + String CLASS = "class";
> + 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";
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Protocol.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Protocol.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Protocol.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/Protocol.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,34 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management;
> +
> +/**
> + * Protocol defined constants.
> + *
> + * @author Andrea Gazzarini
> + */
> +public interface Protocol
> +{
> + String MAGIC_NUMBER = "AM1";
> +
> + byte [] METHOD_REQUEST_FIRST_FOUR_BYTES = (MAGIC_NUMBER+"M").getBytes();
> + byte [] SCHEMA_REQUEST_FIRST_FOUR_BYTES = (MAGIC_NUMBER+"S").getBytes();
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/config.xml
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/config.xml?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/config.xml (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/config.xml Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,106 @@
> +<configuration>
> + <message-handlers>
> + <management-queue>
> + <handler>
> + <opcode>i</opcode>
> + <class-name>org.apache.qpid.management.domain.handler.impl.InstrumentationMessageHandler</class-name>
> + </handler>
> + <handler>
> + <opcode>c</opcode>
> + <class-name>org.apache.qpid.management.domain.handler.impl.ConfigurationMessageHandler</class-name>
> + </handler>
> + </management-queue>
> + <method-reply-queue>
> + <handler>
> + <opcode>m</opcode>
> + <class-name>org.apache.qpid.management.domain.handler.impl.MethodResponseMessageHandler</class-name>
> + </handler>
> + <handler>
> + <opcode>s</opcode>
> + <class-name>org.apache.qpid.management.domain.handler.impl.SchemaResponseMessageHandler</class-name>
> + </handler>
> + </method-reply-queue>
> + </message-handlers>
> + <type-mappings>
> + <mapping>
> + <code>1</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Uint8</class-name>
> + <validator-class-name>org.apache.qpid.management.domain.model.QpidProperty$NumberValidator</validator-class-name>
> + </mapping>
> + <mapping>
> + <code>2</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Uint16</class-name>
> + <validator-class-name>org.apache.qpid.management.domain.model.QpidProperty$NumberValidator</validator-class-name>
> + </mapping>
> + <mapping>
> + <code>3</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Uint32</class-name>
> + <validator-class-name>org.apache.qpid.management.domain.model.QpidProperty$NumberValidator</validator-class-name>
> + </mapping>
> + <mapping>
> + <code>4</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Uint64</class-name>
> + <validator-class-name>org.apache.qpid.management.domain.model.QpidProperty$NumberValidator</validator-class-name>
> + </mapping>
> + <mapping>
> + <code>6</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Str8</class-name>
> + <validator-class-name>org.apache.qpid.management.domain.model.QpidProperty$StringValidator</validator-class-name>
> + </mapping>
> + <mapping>
> + <code>7</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Str16</class-name>
> + <validator-class-name>org.apache.qpid.management.domain.model.QpidProperty$StringValidator</validator-class-name>
> + </mapping>
> + <mapping>
> + <code>8</code>
> + <class-name>org.apache.qpid.management.domain.model.type.AbsTime</class-name>
> + </mapping>
> + <mapping>
> + <code>9</code>
> + <class-name>org.apache.qpid.management.domain.model.type.DeltaTime</class-name>
> + </mapping>
> + <mapping>
> + <code>10</code>
> + <class-name>org.apache.qpid.management.domain.model.type.ObjectReference</class-name>
> + </mapping>
> + <mapping>
> + <code>11</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Boolean</class-name>
> + </mapping>
> + <mapping>
> + <code>14</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Uuid</class-name>
> + </mapping>
> + <mapping>
> + <code>15</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Map</class-name>
> + </mapping>
> + </type-mappings>
> + <access-mode-mappings>
> + <mapping>
> + <code>1</code>
> + <value>RC</value>
> + </mapping>
> + <mapping>
> + <code>2</code>
> + <value>RW</value>
> + </mapping>
> + <mapping>
> + <code>3</code>
> + <value>RO</value>
> + </mapping>
> + </access-mode-mappings>
> + <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>4</initial-pool-capacity>
> + <max-wait-timeout>-1</max-wait-timeout>
> + </broker>
> + </brokers>
> +</configuration>
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMapping.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,94 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +import org.apache.qpid.management.domain.model.AccessMode;
> +
> +/**
> + * Class used to encapsulate a mapping between an access mode and a code.
> + *
> + * @author Andrea Gazzarini
> + */
> +class AccessModeMapping
> +{
> + private int _code;
> + private AccessMode _accessMode;
> +
> + /**
> + * Sets the code for this mapping.
> + * Note that the given string must be a valid number (integer).
> + *
> + * @param codeAsString the code value as a string.
> + * @throws NumberFormatException when the given string is not a number.
> + */
> + void setCode(String codeAsString) {
> + this._code = Integer.parseInt(codeAsString);
> + }
> +
> + /**
> + * Returns the access mode of this mapping.
> + *
> + * @return the access mode of this mapping.
> + */
> + AccessMode getAccessMode ()
> + {
> + return _accessMode;
> + }
> +
> + /**
> + * 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.
> + */
> + int getCode ()
> + {
> + return _code;
> + }
> +
> + /**
> + * Returns a string representation of this mapping.
> + * The returned string is indicating the code and the corresponding access mode.
> + *
> + * @return a string representation of this mapping.
> + */
> + @Override
> + public String toString ()
> + {
> + return new StringBuilder()
> + .append("AccessMode mapping (")
> + .append(_code)
> + .append(',')
> + .append(_accessMode)
> + .append(')').toString();
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMappingParser.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMappingParser.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMappingParser.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/AccessModeMappingParser.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,74 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Parser used for building access mode mappings.
> + * For each access-mode-mappings/mapping element found in the configuration file, a new access mode mapping
> + * is built and injected into the configuration.
> + *
> + *<mapping>
> + <code>1</code>
> + <value>RC</value>
> + </mapping>
> + *
> + * @author Andrea Gazzarini
> + */
> +class AccessModeMappingParser implements IParser
> +{
> + private AccessModeMapping _mapping = new AccessModeMapping();
> + private String _currentValue;
> +
> + /**
> + * Callback : the given value is the text content of the current node.
> + */
> + public void setCurrrentAttributeValue (String value)
> + {
> + this._currentValue = value;
> + }
> +
> + /**
> + * Callback: each time the end of an element is reached this method is called.
> + * It's here that the built mapping is injected into the configuration.
> + */
> + public void setCurrentAttributeName (String name)
> + {
> + switch (Tag.get(name))
> + {
> + case CODE:
> + {
> + _mapping.setCode(_currentValue);
> + break;
> + }
> + case VALUE :
> + {
> + _mapping.setAccessMode(_currentValue);
> + break;
> + }
> + case MAPPING:
> + {
> + Configuration.getInstance().addAccessModeMapping(_mapping);
> + _mapping = new AccessModeMapping();
> + break;
> + }
> + }
> + }
> +}
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionData.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,211 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Value object which is holding connection data for a specific broker.
> + *
> + * @author Andrea Gazzarini
> + */
> +public class BrokerConnectionData
> +{
> + private String _host;
> + private int _port;
> + private String _virtualHost;
> + private String _username;
> + private String _password;
> + private int _maxPoolCapacity;
> + private int _initialPoolCapacity;
> + private long _maxWaitTimeout;
> +
> + /**
> + * Builds a new empty broker connection data object.
> + */
> + BrokerConnectionData()
> + {
> + }
> +
> + /**
> + * Sets the value of host property for this connection data.
> + *
> + * @param host the host name.
> + */
> + void setHost (String host)
> + {
> + this._host = host;
> + }
> +
> + /**
> + * Sets the value of port property for this connection data.
> + *
> + * @param port the port.
> + */
> + void setPort (String port)
> + {
> + this._port = Integer.parseInt(port);
> + }
> +
> + /**
> + * Sets the value of virtual host property for this connection data.
> + *
> + * @param virtualHost the virtual host.
> + */
> + void setVirtualHost (String virtualHost)
> + {
> + this._virtualHost = virtualHost;
> + }
> +
> + /**
> + * Sets the value of username property for this connection data.
> + *
> + * @param username the username.
> + */
> + void setUsername(String username)
> + {
> + this._username = username;
> + }
> +
> + /**
> + * Sets the value of password property for this connection data.
> + *
> + * @param password the password.
> + */
> + void setPassword(String password)
> + {
> + this._password = password;
> + }
> +
> + /**
> + * Returns the value of the host property.
> + *
> + * @return the value of the host property.
> + */
> + public String getHost ()
> + {
> + return _host;
> + }
> +
> + /**
> + * Returns the value of the port property.
> + *
> + * @return the value of the port property.
> + */
> + public int getPort ()
> + {
> + return _port;
> + }
> +
> + /**
> + * Returns the value of the virtual host property.
> + *
> + * @return the value of the virtual host property.
> + */
> + public String getVirtualHost ()
> + {
> + return _virtualHost;
> + }
> +
> + /**
> + * Returns the value of the username property.
> + *
> + * @return the value of the username property.
> + */
> + public String getUsername ()
> + {
> + return _username;
> + }
> +
> + /**
> + * Returns the value of the password property.
> + *
> + * @return the value of the password property.
> + */
> + public String getPassword ()
> + {
> + return _password;
> + }
> +
> + // sofia:5663@pippo/sung1
> + @Override
> + public String toString ()
> + {
> + return new StringBuilder()
> + .append(_host)
> + .append(':')
> + .append(_port)
> + .append('@')
> + .append(_virtualHost)
> + .toString();
> + }
> +
> + /**
> + * Sets the max number of allowed connections that can be opened.
> + *
> + * @param value the max number of allowed connections that can be opened.
> + * @throws NumberFormatException if the given value is not a valid integer.
> + */
> + public void setMaxPoolCapacity (String value)
> + {
> + _maxPoolCapacity = Integer.parseInt(value);
> + }
> +
> + /**
> + * Sets the max wait timeout for retrieving an available connections from the pool.
> + *
> + * @param value the max wait timeout for retrieving an available connections from the pool..
> + * @throws NumberFormatException if the given value is not a valid long.
> + */
> + public void setMaxWaitTimeout (String value)
> + {
> + this._maxWaitTimeout = Long.parseLong(value);
> + }
> +
> + /**
> + * Returns the max number of allowed connections that can be opened.
> + *
> + * @return the max number of allowed connections that can be opened.
> + */
> + public int getMaxPoolCapacity ()
> + {
> + return _maxPoolCapacity;
> + }
> +
> + /**
> + * Returns the max wait timeout for retrieving an available connections from the pool.
> + *
> + * @return the max wait timeout for retrieving an available connections from the pool.
> + */
> + public long getMaxWaitTimeout ()
> + {
> + return _maxWaitTimeout;
> + }
> +
> + public void setInitialPoolCapacity (String value)
> + {
> + _initialPoolCapacity = Integer.parseInt(value);
> + }
> +
> + public int getInitialPoolCapacity ()
> + {
> + return _initialPoolCapacity;
> + }
> +
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionDataParser.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionDataParser.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionDataParser.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/BrokerConnectionDataParser.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,133 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +import java.util.UUID;
> +
> +import org.apache.qpid.transport.util.Logger;
> +
> +/**
> + * Parser used for building access mode mappings.
> + * For each access-mode-mappings/mapping element found in the configuration file, a new access mode mapping
> + * is built and injected into the bridge configuration.
> + *
> + * <broker>
> + <host>192.168.61.130</host>
> + <port>5673</port>
> + <virtual-host>test</virtual-host>
> + <user>andrea</user>
> + <password>andrea</password>
> + </broker>
> + *
> + * @author Andrea Gazzarini
> + */
> +class BrokerConnectionDataParser implements IParser
> +{
> + private final static Logger LOGGER = Logger.get(Configuration.class);
> + private BrokerConnectionData _connectionData = new BrokerConnectionData();
> + private String _currentValue;
> +
> + /**
> + * Callback : the given value is the text content of the current node.
> + */
> + public void setCurrrentAttributeValue (String value)
> + {
> + this._currentValue = value;
> + }
> +
> + /**
> + * Callback: each time the end of an element is reached this method is called.
> + * It's here that the built mapping is injected into the configuration.
> + * <broker>
> + <host>192.168.61.130</host>
> + <port>5673</port>
> + <virtual-host>test</virtual-host>
> + <user>andrea</user>
> + <password>andrea</password>
> + </broker>
> + */
> + public void setCurrentAttributeName (String name)
> + {
> + switch (Tag.get(name))
> + {
> + case HOST:
> + {
> + _connectionData.setHost(_currentValue);
> + break;
> + }
> + case PORT :
> + {
> + _connectionData.setPort(_currentValue);
> + break;
> + }
> + case VIRTUAL_HOST:
> + {
> + _connectionData.setVirtualHost(_currentValue);
> + break;
> + }
> + case USER :
> + {
> + _connectionData.setUsername(_currentValue);
> + break;
> + }
> + case MAX_POOL_CAPACITY:
> + {
> + _connectionData.setMaxPoolCapacity (_currentValue);
> + break;
> + }
> + case INITIAL_POOL_CAPACITY:
> + {
> + _connectionData.setInitialPoolCapacity(_currentValue);
> + break;
> + }
> + case MAX_WAIT_TIMEOUT:
> + {
> + _connectionData.setMaxWaitTimeout(_currentValue);
> + break;
> + }
> + case PASSWORD:
> + {
> + _connectionData.setPassword(_currentValue);
> + break;
> + }
> + case BROKER:
> + {
> + try
> + {
> + Configuration.getInstance().addBrokerConnectionData(getUUId(),_connectionData);
> + } catch(Exception exception)
> + {
> + LOGGER.error(exception, "Unable to connect with broker located on %s and. Hence this broker will be ignored.", _connectionData);
> + }
> + _connectionData = new BrokerConnectionData();
> + break;
> + }
> + }
> + }
> +
> + /**
> + * Gets an uuid in order to associate current connection data with a broker.
> + * @return
> + */
> + UUID getUUId(){
> + return UUID.randomUUID();
> + }
> +}
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configuration.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,343 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +import java.util.HashMap;
> +import java.util.Map;
> +import java.util.Set;
> +import java.util.UUID;
> +import java.util.Map.Entry;
> +
> +import org.apache.qpid.management.Names;
> +import org.apache.qpid.management.domain.handler.base.IMessageHandler;
> +import org.apache.qpid.management.domain.model.AccessMode;
> +import org.apache.qpid.management.domain.model.type.Type;
> +import org.apache.qpid.transport.DeliveryProperties;
> +import org.apache.qpid.transport.Header;
> +import org.apache.qpid.transport.MessageProperties;
> +import org.apache.qpid.transport.ReplyTo;
> +import org.apache.qpid.transport.util.Logger;
> +
> +/**
> + * Qpid Management bridge configuration.
> + * Basically iy is a singleton that is holding all the configurtion data loaded at startup.
> + *
> + * @author Andrea Gazzarini
> + */
> +public final class Configuration
> +{
> + private final static Logger LOGGER = Logger.get(Configuration.class);
> + private static Configuration INSTANCE = new Configuration();
> +
> + Map<Integer, Type> _typeMappings = new HashMap<Integer,Type>();
> + Map<Integer,AccessMode> _accessModes = new HashMap<Integer, AccessMode>();
> + Map<Type,String> _validators = new HashMap<Type, String>();
> +
> + Map<UUID,BrokerConnectionData> _brokerConnectionInfos = new HashMap<UUID, BrokerConnectionData>();
> +
> + Map<Character, String> _managementQueueHandlers = new HashMap<Character, String>();
> + Map<Character, String> _methodReplyQueueHandlers = new HashMap<Character, String>();
> +
> + private String _managementQueueName;
> + private String _methodReplyQueueName;
> +
> + private Header _headerForCommandMessages;
> +
> + // Private constructor.
> + private Configuration()
> + {
> + defineQueueNames();
> + createHeaderForCommandMessages();
> + }
> +
> + /**
> + * Returns the singleton instance.
> + *
> + * @return the singleton instance.
> + */
> + public static Configuration getInstance ()
> + {
> + return INSTANCE;
> + }
> +
> + /**
> + * Returns the type associated to the given code.
> + *
> + * @param code the code used as search criteria.
> + * @return the type associated to the given code.
> + * @throws UnknownTypeCodeException when the given code is not associated to any type.
> + */
> + public Type getType(int code) throws UnknownTypeCodeException
> + {
> + Type result = _typeMappings.get(code);
> + if (result == null)
> + {
> + throw new UnknownTypeCodeException(code);
> + }
> + return result;
> + }
> +
> + /**
> + * Returns the access mode associated to the given code.
> + *
> + * @param code the code used as search criteria.
> + * @return the access mode associated to the given code.
> + * @throws UnknownAccessCodeException when the given code is not associated to any access mode.
> + */
> + public AccessMode getAccessMode(int code) throws UnknownAccessCodeException
> + {
> + AccessMode result = _accessModes.get(code);
> + if (result == null)
> + {
> + throw new UnknownAccessCodeException(code);
> + }
> + return result;
> + }
> +
> + /**
> + * Returns the validator class name associated to the given type.
> + *
> + * @param type the type.
> + * @return the validator class name associated to the given type.
> + */
> + public String getValidatorClassName (Type type)
> + {
> + return _validators.get(type);
> + }
> +
> + /**
> + * Gets from this configuration the list of known broker (I mean, only their connection data).
> + *
> + * @return the list of known broker
> + */
> + public Set<Entry<UUID, BrokerConnectionData>> getConnectionInfos(){
> + return _brokerConnectionInfos.entrySet();
> + }
> +
> + /**
> + * Gets from this configuration the connection data of the broker associated with the given id.
> + *
> + * @param brokerId the broker identifier.
> + * @return the connection data of the broker associated with the given id.
> + * @throws UnknownBrokerException when the given id is not associated with any broker.
> + */
> + public BrokerConnectionData getBrokerConnectionData (UUID brokerId) throws UnknownBrokerException
> + {
> + BrokerConnectionData connectionData = _brokerConnectionInfos.get(brokerId);
> + if (connectionData == null)
> + {
> + throw new UnknownBrokerException(brokerId);
> + }
> + return _brokerConnectionInfos.get(brokerId);
> + }
> +
> + /**
> + * Returns the name of the management queue.
> + *
> + * @return the name of the management queue.
> + */
> + public String getManagementQueueName() {
> + return _managementQueueName;
> + }
> +
> + /**
> + * Returns the name of the method-reply queue.
> + *
> + * @return the name of the method-reply queue.
> + */
> + public String getMethodReplyQueueName() {
> + return _methodReplyQueueName;
> + }
> +
> + /**
> + * Returns a map containing all the configured management message handlers.
> + * A management message handler it is a basically a processor for a management queue incoming message associated
> + * with a specific opcode.
> + *
> + * @return a map containing all the configured management message handlers.
> + */
> + public Map<Character, IMessageHandler> getManagementQueueHandlers()
> + {
> + Map<Character, IMessageHandler> result = new HashMap<Character, IMessageHandler>();
> +
> + for (Entry<Character, String> entry : _managementQueueHandlers.entrySet())
> + {
> + Character opcode = entry.getKey();
> + String className = entry.getValue();
> + try
> + {
> + result.put(opcode, (IMessageHandler)Class.forName(className).newInstance());
> + } catch(Exception exception)
> + {
> + LOGGER.error(
> + exception,
> + "<QMAN-100020> : Management Message Handler configured for opcode %s is not available and therefore will be discarded.",
> + opcode);
> + }
> + }
> + return result;
> + }
> +
> + /**
> + * Returns a map containing all the configured method-reply message handlers.
> + * A management message handler it is a basically a processor for a method-reply queue incoming message associated
> + * with a specific opcode.
> + *
> + * @return a map containing all the configured method-reply message handlers.
> + */
> + public Map<Character, IMessageHandler> getMethodReplyQueueHandlers()
> + {
> + Map<Character, IMessageHandler> result = new HashMap<Character, IMessageHandler>();
> +
> + for (Entry<Character, String> entry : _methodReplyQueueHandlers.entrySet())
> + {
> + Character opcode = entry.getKey();
> + String className = entry.getValue();
> + try
> + {
> + result.put(opcode, (IMessageHandler)Class.forName(className).newInstance());
> + } catch(Exception exception)
> + {
> + LOGGER.error(
> + exception,
> + "<QMAN-100021> :Method-Reply Message Handler configured for opcode %s is not available and therefore will be discarded.",
> + opcode);
> + }
> + }
> + return result;
> + }
> +
> + /**
> + * Returns the message header used for sending command message on management queue.
> + *
> + * @return the message header used for sending command message on management queue.
> + */
> + public Header getCommandMessageHeader ()
> + {
> + return _headerForCommandMessages;
> + }
> +
> + /**
> + * Adds a new type mapping to this configuration.
> + *
> + * @param mapping the type mapping that will be added.
> + */
> + void addTypeMapping(TypeMapping mapping) {
> + int code = mapping.getCode();
> + Type type = mapping.getType();
> + String validatorClassName = mapping.getValidatorClassName();
> + _typeMappings.put(code, type);
> + _validators.put(type, validatorClassName);
> +
> + LOGGER.info("<QMAN-000020> : Type mapping : code = %s associated to %s (validator class is %s)", code,type,validatorClassName);
> + }
> +
> + /**
> + * Adds a new access mode mapping to this configuration.
> + *
> + * @param mapping the mapping that will be added.
> + */
> + void addAccessModeMapping(AccessModeMapping mapping){
> + int code = mapping.getCode();
> + AccessMode accessMode = mapping.getAccessMode();
> + _accessModes.put(code, accessMode);
> +
> + LOGGER.info("<QMAN-000021> : Access Mode mapping : code = %s associated to %s", code,accessMode);
> + }
> +
> + /**
> + * Adds a new management message handler to this configuration.
> + * The incoming mapping object will contains an opcode and the class (as a string) of the message handler that will be used
> + * for processing incoming messages with that opcode.
> + *
> + * @param mapping the message handler mapping.
> + */
> + void addManagementMessageHandlerMapping (MessageHandlerMapping mapping)
> + {
> + Character opcode = mapping.getOpcode();
> + String handlerClass = mapping.getMessageHandlerClass();
> + _managementQueueHandlers.put(opcode, handlerClass);
> +
> + LOGGER.info("<QMAN-000022> : Management Queue Message Handler Mapping : opcode = %s associated with %s", opcode,handlerClass);
> + }
> +
> + /**
> + * Adds a new method-reply message handler to this configuration.
> + * The incoming mapping object will contains an opcode and the class (as a string) of the message handler that will be used
> + * for processing incoming messages with that opcode.
> + *
> + * @param mapping the message handler mapping.
> + */
> + void addMethodReplyMessageHandlerMapping (MessageHandlerMapping mapping)
> + {
> + Character opcode = mapping.getOpcode();
> + String handlerClass = mapping.getMessageHandlerClass();
> + _methodReplyQueueHandlers.put(opcode, handlerClass);
> +
> + LOGGER.info("<QMAN-000023> : Method-Reply Queue Message Handler Mapping : opcode = %s associated with %s", opcode,handlerClass);
> + }
> +
> + /**
> + * Adds to this configuration a new broker connection data.
> + *
> + * @param brokerId the broker identifier.
> + * @param connectionData the connection data.
> + * @throws Exception
> + */
> + void addBrokerConnectionData (UUID brokerId, BrokerConnectionData connectionData) throws Exception
> + {
> + QpidDatasource.getInstance().addConnectionPool(brokerId, connectionData);
> + _brokerConnectionInfos.put(brokerId,connectionData);
> + LOGGER.info("<QMAN-000024> : Broker Configuration %s: %s",brokerId,connectionData);
> + }
> +
> + /**
> + * Header for command messages is created once because it only contains static values.
> + */
> + private void createHeaderForCommandMessages ()
> + {
> + MessageProperties messageProperties = new MessageProperties();
> +
> + ReplyTo replyTo=new ReplyTo();
> + replyTo.setRoutingKey(_methodReplyQueueName);
> + messageProperties.setReplyTo(replyTo);
> +
> + DeliveryProperties deliveryProperties = new DeliveryProperties();
> + deliveryProperties.setRoutingKey(Names.AGENT_ROUTING_KEY);
> +
> + _headerForCommandMessages = new Header(deliveryProperties, messageProperties);
> + }
> +
> + /**
> + * Creates the name of the queues used by this service.
> + * This is done because if a broker should be managed by one or more management client, then each of them
> + * must have its own channels to communicate with.
> + */
> + private void defineQueueNames()
> + {
> + UUID uuid = UUID.randomUUID();
> + _managementQueueName = Names.MANAGEMENT_QUEUE_PREFIX+uuid;
> + _methodReplyQueueName = Names.METHOD_REPLY_QUEUE_PREFIX+uuid;
> +
> + LOGGER.debug("<QMAN-200021> : Management queue name : %s",_managementQueueName);
> + LOGGER.debug("<QMAN-000022> : Method-reply queue name : %s",_methodReplyQueueName);
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ConfigurationException.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ConfigurationException.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ConfigurationException.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ConfigurationException.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,41 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Thrown when a problem is encountered during building the configuration.
> + *
> + * @author Andrea Gazzarini
> + */
> +public class ConfigurationException extends Exception
> +{
> + private static final long serialVersionUID = 8238481177714286259L;
> +
> + /**
> + * Builds a new ConfigurationException with the given cause.
> + *
> + * @param exception the exception cause.
> + */
> + public ConfigurationException(Exception exception)
> + {
> + super(exception);
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,145 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +import java.io.BufferedReader;
> +import java.io.InputStreamReader;
> +
> +import javax.xml.parsers.SAXParser;
> +import javax.xml.parsers.SAXParserFactory;
> +
> +import org.apache.qpid.management.Names;
> +import org.xml.sax.Attributes;
> +import org.xml.sax.InputSource;
> +import org.xml.sax.SAXException;
> +import org.xml.sax.helpers.DefaultHandler;
> +
> +/**
> + * Director used for coordinating the build process of configuration.
> + * This is the only component which has a read-write permission on Configuration object.
> + *
> + * @author Andrea Gazzarini
> + */
> +public class Configurator extends DefaultHandler
> +{
> + /**
> + * Default (empty) parser used when there's no need to process data (non relevant elements).
> + */
> + final static IParser DEFAULT_PARSER = new IParser() {
> +
> + public void setCurrrentAttributeValue (String value)
> + {
> + }
> +
> + public void setCurrentAttributeName (String name)
> + {
> + }
> + };
> +
> + IParser _typeMappingParser = new TypeMappingParser();
> + IParser _accessModeMappingParser = new AccessModeMappingParser();
> + IParser _brokerConfigurationParser = new BrokerConnectionDataParser();
> + IParser _managementQueueHandlerParser = new ManagementQueueMessageListenerParser();
> + IParser _methodReplyQueueHandlerParser = new MethodReplyQueueMessageListenerParser();
> +
> + IParser _currentParser = DEFAULT_PARSER;
> +
> + /**
> + * Delegates the processing to the current parser.
> + */
> + @Override
> + public void characters (char[] ch, int start, int length) throws SAXException
> + {
> + String value = new String(ch,start,length).trim();
> + if (value.length() != 0) {
> + _currentParser.setCurrrentAttributeValue(value);
> + }
> + }
> +
> + /**
> + * Here is defined what parser needs to be used for processing the current data.
> + */
> + @Override
> + 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;
> + break;
> + }
> + case MANAGEMENT_QUEUE:
> + {
> + _currentParser = _managementQueueHandlerParser;
> + break;
> + }
> + case METHOD_REPLY_QUEUE:
> + {
> + _currentParser = _methodReplyQueueHandlerParser;
> + break;
> + }
> + }
> + }
> +
> + @Override
> + public void endElement (String uri, String localName, String name) throws SAXException
> + {
> + _currentParser.setCurrentAttributeName(name);
> + }
> +
> + /**
> + * Builds whole configuration.
> + *
> + * @throws ConfigurationException when the build fails.
> + */
> + public void configure() throws ConfigurationException
> + {
> + 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);
> + } catch (Exception exception)
> + {
> + throw new ConfigurationException(exception);
> + }
> + }
> +
> + /**
> + * Returns the name of the configuration file.
> + *
> + * @return the name of the configuration file.
> + */
> + String getConfigurationFileName()
> + {
> + return Names.CONFIGURATION_FILE_NAME;
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/IParser.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/IParser.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/IParser.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/IParser.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,44 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Interface definition for configuration parser
> + * Concrete implementors are responsible for parsing a specific XML part of configuration data.
> + *
> + * @author Andrea Gazzarini
> + */
> +interface IParser
> +{
> + /**
> + * Main director callback : Sets the name of the current attribute.
> + *
> + * @param name the name of the current attribute.
> + */
> + void setCurrentAttributeName(String name);
> +
> + /**
> + * Main director callback : sets the value of the current attribute.
> + *
> + * @param value the value of the current attribute.
> + */
> + void setCurrrentAttributeValue(String value);
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ManagementQueueMessageListenerParser.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ManagementQueueMessageListenerParser.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ManagementQueueMessageListenerParser.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/ManagementQueueMessageListenerParser.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,72 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Parser used for building mapping between a management queue message listeners and an opcode.
> + *
> + * <handler>
> + <opcode>i</opcode>
> + <class-name>org.apache.qpid.management.domain.handler.impl.InstrumentationMessageHandler</class-name>
> + </handler>
> +
> + * @author Andrea Gazzarini
> + */
> +class ManagementQueueMessageListenerParser implements IParser
> +{
> + private MessageHandlerMapping _mapping = new MessageHandlerMapping();
> + private String _currentValue;
> +
> + /**
> + * Callback : the given value is the text content of the current node.
> + */
> + public void setCurrrentAttributeValue (String value)
> + {
> + this._currentValue = value;
> + }
> +
> + /**
> + * Callback: each time the end of an element is reached this method is called.
> + * It's here that the built mapping is injected into the configuration.
> + */
> + public void setCurrentAttributeName (String name)
> + {
> + switch (Tag.get(name))
> + {
> + case OPCODE:
> + {
> + _mapping.setOpcode(_currentValue);
> + break;
> + }
> + case CLASS_NAME:
> + {
> + _mapping.setMessageHandlerClass(_currentValue);
> + break;
> + }
> + case HANDLER:
> + {
> + Configuration.getInstance().addManagementMessageHandlerMapping(_mapping);
> + _mapping = new MessageHandlerMapping();
> + break;
> + }
> + }
> + }
> +}
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MessageHandlerMapping.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MessageHandlerMapping.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MessageHandlerMapping.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MessageHandlerMapping.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,72 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Message Handler mapping used for associating an opcode with a message handler.
> + *
> + * @author Andrea Gazzarini
> + */
> +class MessageHandlerMapping
> +{
> + private Character _opcode;
> + private String _handlerClass;
> +
> + /**
> + * Returns the opcode of this mapping.
> + *
> + * @return the code of this mapping.
> + */
> + Character getOpcode ()
> + {
> + return _opcode;
> + }
> +
> + /**
> + * Sets the opcode for this mapping.
> + *
> + * @param codeAsString the opcode as a string.
> + */
> + void setOpcode (String codeAsString)
> + {
> + this._opcode = codeAsString.charAt(0);
> + }
> +
> + /**
> + * Returns the message handler for this mapping.
> + *
> + * @return the message handler for this mapping.
> + */
> + String getMessageHandlerClass()
> + {
> + return _handlerClass;
> + }
> +
> + /**
> + * Sets the message handler of this mapping.
> + *
> + * @param handlerClass the handler class as a string.
> + */
> + void setMessageHandlerClass(String handlerClass)
> + {
> + this._handlerClass = handlerClass;
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MethodReplyQueueMessageListenerParser.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MethodReplyQueueMessageListenerParser.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MethodReplyQueueMessageListenerParser.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/MethodReplyQueueMessageListenerParser.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,72 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Parser used for building mappings between method-reply queue message listeners and an opcode.
> + *
> + * <handler>
> + <opcode>i</opcode>
> + <class-name>org.apache.qpid.management.domain.handler.impl.InstrumentationMessageHandler</class-name>
> + </handler>
> + *
> + * @author Andrea Gazzarini
> + */
> +class MethodReplyQueueMessageListenerParser implements IParser
> +{
> + private MessageHandlerMapping _mapping = new MessageHandlerMapping();
> + private String _currentValue;
> +
> + /**
> + * Callback : the given value is the text content of the current node.
> + */
> + public void setCurrrentAttributeValue (String value)
> + {
> + this._currentValue = value;
> + }
> +
> + /**
> + * Callback: each time the end of an element is reached this method is called.
> + * It's here that the built mapping is injected into the configuration.
> + */
> + public void setCurrentAttributeName (String name)
> + {
> + switch (Tag.get(name))
> + {
> + case OPCODE:
> + {
> + _mapping.setOpcode(_currentValue);
> + break;
> + }
> + case CLASS_NAME:
> + {
> + _mapping.setMessageHandlerClass(_currentValue);
> + break;
> + }
> + case HANDLER:
> + {
> + Configuration.getInstance().addMethodReplyMessageHandlerMapping(_mapping);
> + _mapping = new MessageHandlerMapping();
> + break;
> + }
> + }
> + }
> +}
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,276 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +import java.util.HashMap;
> +import java.util.Map;
> +import java.util.UUID;
> +
> +import org.apache.commons.pool.BasePoolableObjectFactory;
> +import org.apache.commons.pool.ObjectPool;
> +import org.apache.commons.pool.impl.GenericObjectPool;
> +import org.apache.commons.pool.impl.GenericObjectPoolFactory;
> +import org.apache.qpid.ErrorCode;
> +import org.apache.qpid.QpidException;
> +import org.apache.qpid.nclient.Client;
> +import org.apache.qpid.nclient.ClosedListener;
> +import org.apache.qpid.nclient.Connection;
> +import org.apache.qpid.nclient.DtxSession;
> +import org.apache.qpid.nclient.Session;
> +import org.apache.qpid.transport.util.Logger;
> +
> +/**
> + * Qpid datasource.
> + * Basically it is a connection pool manager used for optimizing broker connections usage.
> + *
> + * @author Andrea Gazzarini
> + */
> +public final class QpidDatasource
> +{
> + private final static Logger LOGGER = Logger.get(QpidDatasource.class);
> +
> + /**
> + * A connection decorator used for adding pool interaction behaviour to an existing connection.
> + *
> + * @author Andrea Gazzarini
> + */
> + public class ConnectionDecorator implements Connection,ClosedListener
> + {
> + private final Connection _decoratee;
> + private final UUID _brokerId;
> + private boolean _valid;
> +
> + /**
> + * Builds a new decorator with the given connection.
> + *
> + * @param brokerId the broker identifier.
> + * @param decoratee the underlying connection.
> + */
> + private ConnectionDecorator(UUID brokerId, Connection decoratee)
> + {
> + this._decoratee = decoratee;
> + this._brokerId = brokerId;
> + _decoratee.setClosedListener(this);
> + _valid = true;
> + }
> +
> + /**
> + * Returns true if the underlying connection is still valid and can be used.
> + *
> + * @return true if the underlying connection is still valid and can be used.
> + */
> + boolean isValid()
> + {
> + return _valid;
> + }
> +
> + /**
> + * Returns the connection to the pool. That is, marks this connections as available.
> + * After that, this connection will be available for further operations.
> + */
> + public void close () throws QpidException
> + {
> + try
> + {
> + pools.get(_brokerId).returnObject(this);
> + LOGGER.debug("<QMAN-200012> : Connection %s returned to the pool.", this);
> + } catch (Exception exception)
> + {
> + throw new QpidException("Error while closing connection.",ErrorCode.CONNECTION_ERROR,exception);
> + }
> + }
> +
> + /**
> + * Do nothing : underlying connection is already connected.
> + */
> + public void connect (String host, int port, String virtualHost, String username, String password)
> + throws QpidException
> + {
> + // DO NOTHING : DECORATEE CONNECTION IS ALREADY CONNECTED.
> + }
> +
> + /**
> + * Do nothing : underlying connection is already connected.
> + */
> + public void connect (String url) throws QpidException
> + {
> + // DO NOTHING : DECORATEE CONNECTION IS ALREADY CONNECTED.
> + }
> +
> + /**
> + * @see Connection#createDTXSession(int)
> + */
> + public DtxSession createDTXSession (int expiryInSeconds)
> + {
> + return _decoratee.createDTXSession(expiryInSeconds);
> + }
> +
> + /**
> + * @see Connection#createSession(long)
> + */
> + public Session createSession (long expiryInSeconds)
> + {
> + return _decoratee.createSession(expiryInSeconds);
> + }
> +
> + /**
> + * Do nothing : closed listener has been already injected.
> + */
> + public void setClosedListener (ClosedListener exceptionListner)
> + {
> + }
> +
> + /**
> + * Callback method used for error notifications while underlying connection is closing.
> + */
> + public void onClosed (ErrorCode errorCode, String reason, Throwable t)
> + {
> + _valid = false;
> + LOGGER.error(t,"<QMAN-100012> : Error on closing connection. Reason is : %s, error code is %s",reason,errorCode.getCode());
> + }
> + };
> +
> + /**
> + * This is the connection factory, that is, the factory used to manage the lifecycle (create, validate & destroy) of
> + * the broker connection(s).
> + *
> + * @author Andrea Gazzarini
> + */
> + class QpidConnectionFactory extends BasePoolableObjectFactory
> + {
> + private final BrokerConnectionData _connectionData;
> + private final UUID _brokerId;
> +
> + /**
> + * Builds a new connection factory with the given parameters.
> + *
> + * @param brokerId the broker identifier.
> + * @param connectionData the connecton data.
> + */
> + private QpidConnectionFactory(UUID brokerId, BrokerConnectionData connectionData)
> + {
> + this._connectionData = connectionData;
> + this._brokerId = brokerId;
> + }
> +
> + /**
> + * Creates a new underlying connection.
> + */
> + @Override
> + public Connection makeObject () throws Exception
> + {
> + Connection connection = Client.createConnection();
> + connection.connect(
> + _connectionData.getHost(),
> + _connectionData.getPort(),
> + _connectionData.getVirtualHost(),
> + _connectionData.getUsername(),
> + _connectionData.getPassword());
> + return new ConnectionDecorator(_brokerId,connection);
> + }
> +
> + /**
> + * Validates the underlying connection.
> + */
> + @Override
> + public boolean validateObject (Object obj)
> + {
> + ConnectionDecorator connection = (ConnectionDecorator) obj;
> + boolean isValid = connection.isValid();
> + LOGGER.debug("<QMAN-200013> : Test connection on reserve. Is valid? %s",isValid);
> + return isValid;
> + }
> +
> + /**
> + * Closes the underlying connection.
> + */
> + @Override
> + public void destroyObject (Object obj) throws Exception
> + {
> + try
> + {
> + ConnectionDecorator connection = (ConnectionDecorator) obj;
> + connection._decoratee.close();
> + LOGGER.debug("<QMAN-200014> : Connection has been destroyed.");
> + } catch (Exception e)
> + {
> + LOGGER.debug(e, "<QMAN-200015> : Unable to destroy a connection object");
> + }
> + }
> + }
> +
> + // Singleton instance.
> + private static QpidDatasource instance = new QpidDatasource();
> +
> + // Each entry contains a connection pool for a specific broker.
> + private Map<UUID, ObjectPool> pools = new HashMap<UUID, ObjectPool>();
> +
> + // Private constructor.
> + private QpidDatasource()
> + {
> + }
> +
> + /**
> + * Gets an available connection from the pool of the given broker.
> + *
> + * @param brokerId the broker identifier.
> + * @return a valid connection to the broker associated with the given identifier.
> + */
> + public Connection getConnection(UUID brokerId) throws Exception
> + {
> + return (Connection) pools.get(brokerId).borrowObject();
> + }
> +
> + /**
> + * Entry point method for retrieving the singleton instance of this datasource.
> + *
> + * @return the qpid datasource singleton instance.
> + */
> + public static QpidDatasource getInstance()
> + {
> + return instance;
> + }
> +
> + /**
> + * Adds a connection pool to this datasource.
> + *
> + * @param brokerId the broker identifier that will be associated with the new connection pool.
> + * @param connectionData the broker connection data.
> + * @throws Exception when the pool cannot be created.
> + */
> + void addConnectionPool(UUID brokerId,BrokerConnectionData connectionData) throws Exception {
> + GenericObjectPoolFactory factory = new GenericObjectPoolFactory(
> + new QpidConnectionFactory(brokerId,connectionData),
> + connectionData.getMaxPoolCapacity(),
> + GenericObjectPool.WHEN_EXHAUSTED_BLOCK,
> + connectionData.getMaxWaitTimeout(),-1,
> + true,
> + false);
> + ObjectPool pool = factory.createPool();
> +
> + for (int i = 0; i < connectionData.getInitialPoolCapacity(); i++)
> + {
> + pool.returnObject(pool.borrowObject());
> + }
> +
> + pools.put(brokerId,pool);
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Tag.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Tag.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Tag.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/Tag.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,42 @@
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Configuration Tag catalogue.
> + *
> + * @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"; }},
> + MAX_POOL_CAPACITY { @Override public String toString() { return "max-pool-capacity"; }},
> + MAX_WAIT_TIMEOUT { @Override public String toString() { return "max-wait-timeout"; }},
> + INITIAL_POOL_CAPACITY { @Override public String toString() { return "initial-pool-capacity"; }},
> + VIRTUAL_HOST { @Override public String toString() { return "virtual-host"; }},
> + USER { @Override public String toString() { return "user"; }},
> + PASSWORD { @Override public String toString() { return "password"; }},
> + BROKERS { @Override public String toString() { return "brokers"; }},
> + MANAGEMENT_QUEUE { @Override public String toString() { return "management-queue"; }},
> + METHOD_REPLY_QUEUE { @Override public String toString() { return "method-reply-queue"; }};
> +
> + /**
> + * Returns the enum entry associated to the given tag name.
> + *
> + * @param name the name of tag.
> + * @return the enum entry associated to the given tag name.
> + */
> + public static Tag get(String name) {
> + return valueOf(name.replaceAll("-", "_").toUpperCase());
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMapping.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,103 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +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.
> + *
> + * @author Andrea Gazzarini
> + */
> +class TypeMapping
> +{
> + private int _code;
> + private Type _type;
> + private String _validatorClass;
> +
> + /**
> + * Returns the code of this mapping.
> + *
> + * @return the code of this mapping.
> + */
> + int getCode ()
> + {
> + return _code;
> + }
> +
> + /**
> + * Sets the code for this mapping.
> + * Note that the given string must be a valid number (integer).
> + *
> + * @param codeAsString the code as a string.
> + * @throws NumberFormatException when the given string is not a valid number.
> + */
> + void setCode (String codeAsString)
> + {
> + this._code = Integer.parseInt(codeAsString);
> + }
> +
> + /**
> + * Returns the type for this mapping.
> + *
> + * @return the type for this mapping.
> + */
> + Type getType ()
> + {
> + return _type;
> + }
> +
> + /**
> + * Sets the type of this mapping.
> + *
> + * @param typeClass the type class as a string.
> + * @throw IllegalArgumentException when it's not possible to load the given class.
> + */
> + void setType (String typeClass)
> + {
> + try
> + {
> + this._type = (Type) Class.forName(typeClass).newInstance();
> + } catch (Exception exception)
> + {
> + throw new IllegalArgumentException(exception);
> + }
> + }
> +
> + /**
> + * 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.
> + */
> + public String getValidatorClassName()
> + {
> + return _validatorClass;
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMappingParser.java
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMappingParser.java?rev=700077&view=auto
> ==============================================================================
> --- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMappingParser.java (added)
> +++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/management/configuration/TypeMappingParser.java Mon Sep 29 05:02:54 2008
> @@ -0,0 +1,77 @@
> +/*
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + *
> + */
> +package org.apache.qpid.management.configuration;
> +
> +/**
> + * Parser used for building type mappings.
> + * For each type-mappings/mapping element found in the configuration file, a new type mapping is built and injected into
> + * the bridge configuration.
> + *
> + * <mapping>
> + <code>1</code>
> + <class-name>org.apache.qpid.management.domain.model.type.Uint8</class-name>
> + <validator-class-name>org.apache.qpid.management.domain.model.QpidProperty$NumberValidator</validator-class-name>
> + </mapping>
> + *
> + * @author Andrea Gazzarini
> + */
> +class TypeMappingParser implements IParser
> +{
> + private TypeMapping _mapping = new TypeMapping();
> + private String _currentValue;
> +
> + /**
> + * Callback : the given value is the text content of the current node.
> + */
> + public void setCurrrentAttributeValue (String value)
> + {
> + this._currentValue = value;
> + }
> +
> + /**
> + * Callback: each time the end of an element is reached this method is called.
> + * It's here that the built mapping is injected into the configuration.
> + */
> + public void setCurrentAttributeName (String name)
> + {
> + switch (Tag.get(name))
> + {
> + case CODE:
> + {
> + _mapping.setCode(_currentValue);
> + break;
> + }
> + case CLASS_NAME : {
> + _mapping.setType(_currentValue);
> + break;
> + }
> + case VALIDATOR_CLASS_NAME : {
> + _mapping.setValidatorClassName(_currentValue);
> + break;
> + }
> + case MAPPING : {
> + Configuration.getInstance().addTypeMapping(_mapping);
> + _mapping = new TypeMapping();
> + break;
> + }
> + }
> + }
> +}
>
>