ACTIVEMQ6-14 Replace JNDI server with client impl
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/e6a3d3a0 Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/e6a3d3a0 Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/e6a3d3a0 Branch: refs/heads/master Commit: e6a3d3a0c5962b7c83b2fa3693bc12cb3e5ed02e Parents: e419feb Author: jbertram <jbert...@redhat.com> Authored: Wed Dec 3 08:50:16 2014 -0600 Committer: jbertram <jbert...@redhat.com> Committed: Fri Dec 5 09:27:52 2014 -0600 ---------------------------------------------------------------------- .gitignore | 5 - .../org/apache/activemq/cli/commands/Run.java | 16 - .../java/org/apache/activemq/dto/BrokerDTO.java | 3 - .../java/org/apache/activemq/dto/NamingDTO.java | 39 - .../org/apache/activemq/dto/jaxb.index | 1 - .../jndi/ActiveMQInitialContextFactory.java | 496 +++++++++++++ .../apache/activemq/jndi/LazyCreateContext.java | 43 ++ .../apache/activemq/jndi/NameParserImpl.java | 30 + .../apache/activemq/jndi/ReadOnlyContext.java | 534 ++++++++++++++ activemq-jms-server/pom.xml | 4 - .../jms/server/JMSServerConfigParser.java | 9 - .../jms/server/embedded/EmbeddedJMS.java | 6 + .../server/impl/JMSServerConfigParserImpl.java | 339 +-------- .../jms/server/impl/JMSServerDeployer.java | 48 +- .../jms/server/impl/JMSServerManagerImpl.java | 14 +- .../jms/server/impl/StandaloneNamingServer.java | 170 ----- .../src/main/resources/schema/activemq-jms.xsd | 272 +------ activemq-ra/pom.xml | 7 + .../integration/EmbeddedRestActiveMQJMS.java | 4 + .../rest/queue/QueueDestinationsResource.java | 7 - .../rest/topic/TopicDestinationsResource.java | 7 - .../apache/activemq/rest/test/EmbeddedTest.java | 14 +- .../src/test/resources/activemq-jms.xml | 13 +- distribution/activemq/pom.xml | 5 - distribution/activemq/src/main/assembly/dep.xml | 1 - .../activemq/src/main/resources/bin/activemq | 4 +- .../src/main/resources/bin/activemq.cmd | 2 +- .../resources/config/clustered/activemq-jms.xml | 48 +- .../resources/config/clustered/jndi.properties | 2 - .../config/non-clustered/activemq-jms.xml | 48 +- .../config/non-clustered/jndi.properties | 2 - .../replicated/activemq-configuration.xml | 2 +- .../config/replicated/activemq-jms.xml | 48 +- .../resources/config/replicated/jndi.properties | 2 - .../shared-store/activemq-configuration.xml | 2 +- .../config/shared-store/activemq-jms.xml | 48 +- .../config/shared-store/jndi.properties | 2 - distribution/jnp-client/pom.xml | 75 -- distribution/pom.xml | 5 - docs/user-manual/en/appserver-integration.xml | 53 +- docs/user-manual/en/client-classpath.xml | 7 - docs/user-manual/en/client-reconnection.xml | 25 +- docs/user-manual/en/clusters.xml | 65 +- docs/user-manual/en/configuration-index.xml | 330 +-------- docs/user-manual/en/configuring-transports.xml | 29 +- docs/user-manual/en/flow-control.xml | 79 +- docs/user-manual/en/interoperability.xml | 5 +- docs/user-manual/en/large-messages.xml | 41 +- docs/user-manual/en/logging.xml | 18 +- docs/user-manual/en/message-grouping.xml | 37 +- docs/user-manual/en/pre-acknowledge.xml | 16 +- docs/user-manual/en/spring-integration.xml | 13 +- docs/user-manual/en/thread-pooling.xml | 22 +- docs/user-manual/en/using-jms.xml | 388 +++++----- examples/core/embedded-remote/pom.xml | 5 - examples/core/embedded/pom.xml | 5 - examples/core/perf/pom.xml | 10 - examples/core/vertx-connector/pom.xml | 10 - .../src/main/resources/server0/activemq-jms.xml | 13 +- .../config/server.properties | 2 +- .../common/example/ActiveMQExample.java | 5 +- examples/jms/aerogear/pom.xml | 7 +- .../activemq/jms/example/AerogearExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/applet/pom.xml | 7 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/application-layer-failover/pom.xml | 9 +- .../ApplicationLayerFailoverExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- examples/jms/bridge/pom.xml | 9 +- .../activemq/jms/example/BridgeExample.java | 8 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- examples/jms/browser/pom.xml | 7 +- .../jms/example/QueueBrowserExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/client-kickoff/pom.xml | 7 +- .../jms/example/ClientKickoffExample.java | 2 +- .../resources/hornetq/server0/activemq-jms.xml | 9 - .../jms/client-side-failoverlistener/pom.xml | 9 +- .../ClientSideFailoverListerExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 27 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- examples/jms/client-side-load-balancing/pom.xml | 9 +- .../example/ClientSideLoadBalancingExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 11 +- .../resources/hornetq/server1/activemq-jms.xml | 11 +- .../resources/hornetq/server2/activemq-jms.xml | 11 +- .../jms/clustered-durable-subscription/pom.xml | 9 +- .../ClusteredDurableSubscriptionExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- examples/jms/clustered-grouping/pom.xml | 11 +- .../jms/example/ClusteredGroupingExample.java | 8 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- .../resources/hornetq/server2/activemq-jms.xml | 13 +- examples/jms/clustered-jgroups/pom.xml | 9 +- .../jms/example/ClusteredJgroupsExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../hornetq/server0/client-jndi.properties | 5 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- .../hornetq/server1/client-jndi.properties | 5 +- examples/jms/clustered-queue/pom.xml | 9 +- .../jms/example/ClusteredQueueExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- examples/jms/clustered-standalone/pom.xml | 11 +- .../jms/example/ClusteredStandaloneExample.java | 8 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 12 +- .../resources/hornetq/server2/activemq-jms.xml | 13 +- examples/jms/clustered-static-discovery/pom.xml | 13 +- .../example/StaticClusteredQueueExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 25 +- .../resources/hornetq/server0/jndi.properties | 2 - .../resources/hornetq/server1/activemq-jms.xml | 25 +- .../resources/hornetq/server1/jndi.properties | 2 - .../resources/hornetq/server2/activemq-jms.xml | 26 +- .../resources/hornetq/server2/jndi.properties | 17 - .../resources/hornetq/server3/activemq-jms.xml | 26 +- .../resources/hornetq/server3/jndi.properties | 2 - examples/jms/clustered-static-oneway/pom.xml | 11 +- .../jms/example/ClusterStaticOnewayExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 25 +- .../resources/hornetq/server0/jndi.properties | 2 - .../resources/hornetq/server1/activemq-jms.xml | 25 +- .../resources/hornetq/server1/jndi.properties | 2 - .../resources/hornetq/server2/activemq-jms.xml | 26 +- .../resources/hornetq/server2/jndi.properties | 18 - examples/jms/clustered-topic/pom.xml | 9 +- .../jms/example/ClusteredTopicExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- .../jms/colocated-failover-scale-down/pom.xml | 9 +- .../ColocatedFailoverScaleDownExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 24 +- .../resources/hornetq/server1/activemq-jms.xml | 24 +- examples/jms/colocated-failover/pom.xml | 9 +- .../jms/example/ColocatedFailoverExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 24 +- .../resources/hornetq/server1/activemq-jms.xml | 25 +- examples/jms/consumer-rate-limit/pom.xml | 7 +- .../jms/example/ConsumerRateLimitExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 18 +- .../hornetq/server0/client-jndi.properties | 5 +- examples/jms/dead-letter/pom.xml | 7 +- .../activemq/jms/example/DeadLetterExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 17 +- .../hornetq/server0/client-jndi.properties | 5 +- examples/jms/delayed-redelivery/pom.xml | 7 +- .../jms/example/DelayedRedeliveryExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 17 +- .../hornetq/server0/client-jndi.properties | 5 +- examples/jms/divert/pom.xml | 9 +- .../activemq/jms/example/DivertExample.java | 12 +- .../resources/hornetq/server0/activemq-jms.xml | 28 +- .../resources/hornetq/server1/activemq-jms.xml | 15 +- examples/jms/durable-subscription/pom.xml | 7 +- .../jms/example/DurableSubscriptionExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../hornetq/server0/client-jndi.properties | 5 +- examples/jms/embedded-simple/pom.xml | 9 +- .../activemq/jms/example/EmbeddedExample.java | 2 +- .../src/main/resources/activemq-jms.xml | 13 +- examples/jms/embedded/pom.xml | 9 +- examples/jms/embedded/readme.html | 27 +- .../activemq/jms/example/EmbeddedExample.java | 4 +- examples/jms/expiry/pom.xml | 7 +- .../activemq/jms/example/ExpiryExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 17 +- examples/jms/ha-policy-autobackup/pom.xml | 9 +- .../jms/example/HAPolicyAutoBackupExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 24 +- examples/jms/http-transport/pom.xml | 7 +- .../jms/example/HttpTransportExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../jms/instantiate-connection-factory/pom.xml | 7 +- examples/jms/interceptor/pom.xml | 7 +- .../jms/example/InterceptorExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/jaas/pom.xml | 7 +- .../activemq/jms/example/JAASExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/jms-auto-closeable/pom.xml | 7 +- .../jms/example/JMSAutoCloseableExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/jms-bridge/pom.xml | 9 +- examples/jms/jms-bridge/readme.html | 20 +- .../activemq/jms/example/JMSBridgeExample.java | 15 +- .../resources/hornetq/server0/activemq-jms.xml | 22 +- .../resources/hornetq/server0/jndi.properties | 2 - .../resources/hornetq/server1/activemq-jms.xml | 22 +- .../resources/hornetq/server1/jndi.properties | 2 - examples/jms/jms-completion-listener/pom.xml | 7 +- .../example/JMSCompletionListenerExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/jms-context/pom.xml | 7 +- .../activemq/jms/example/JMSContextExample.java | 4 +- examples/jms/jms-shared-consumer/pom.xml | 7 +- .../jms/example/JMSSharedConsumerExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/jmx/pom.xml | 7 +- .../apache/activemq/jms/example/JMXExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 12 +- examples/jms/large-message/pom.xml | 7 +- .../jms/example/LargeMessageExample.java | 8 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/last-value-queue/pom.xml | 7 +- .../jms/example/LastValueQueueExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/management-notifications/pom.xml | 7 +- .../example/ManagementNotificationExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 18 +- examples/jms/management/pom.xml | 7 +- .../activemq/jms/example/ManagementExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/message-counters/pom.xml | 7 +- .../jms/example/MessageCounterExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 17 +- examples/jms/message-group/pom.xml | 7 +- .../jms/example/MessageGroupExample.java | 4 +- .../resources/hornetq/server0/hornetq-jms.xml | 13 +- examples/jms/message-group2/pom.xml | 7 +- .../jms/example/MessageGroup2Example.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/message-priority/pom.xml | 7 +- .../jms/example/MessagePriorityExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/multiple-failover-failback/pom.xml | 11 +- .../MultipleFailoverFailbackExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 27 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- .../resources/hornetq/server2/activemq-jms.xml | 26 +- examples/jms/multiple-failover/pom.xml | 11 +- .../jms/example/MultipleFailoverExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 27 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- .../resources/hornetq/server2/activemq-jms.xml | 26 +- examples/jms/no-consumer-buffering/pom.xml | 7 +- .../jms/example/NoConsumerBufferingExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 18 +- examples/jms/non-transaction-failover/pom.xml | 9 +- .../example/NonTransactionFailoverExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 26 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- examples/jms/openwire/pom.xml | 7 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/paging/pom.xml | 7 +- .../activemq/jms/example/PagingExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 17 +- examples/jms/perf/pom.xml | 10 - .../src/main/resources/client.jndi.properties | 5 +- .../resources/hornetq/server0/activemq-jms.xml | 15 +- examples/jms/pre-acknowledge/pom.xml | 7 +- .../jms/example/PreacknowledgeExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/producer-rate-limit/pom.xml | 7 +- .../jms/example/ProducerRateLimitExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 18 +- examples/jms/proton-cpp/pom.xml | 10 - examples/jms/proton-j/pom.xml | 7 +- examples/jms/proton-ruby/pom.xml | 5 - .../jms/queue-message-redistribution/pom.xml | 9 +- .../QueueMessageRedistributionExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../resources/hornetq/server1/activemq-jms.xml | 13 +- examples/jms/queue-requestor/pom.xml | 7 +- .../jms/example/QueueRequestorExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/queue-selector/pom.xml | 7 +- .../jms/example/QueueSelectorExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/queue/pom.xml | 7 +- .../activemq/jms/example/QueueExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/reattach-node/pom.xml | 7 +- .../activemq/jms/example/ReattachExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 45 +- examples/jms/replicated-failback-static/pom.xml | 9 +- .../ReplicatedFailbackStaticExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 27 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- examples/jms/replicated-failback/pom.xml | 9 +- .../jms/example/ReplicatedFailbackExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 27 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- .../jms/replicated-multiple-failover/pom.xml | 11 +- .../ReplicatedMultipleFailoverExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 27 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- .../resources/hornetq/server2/activemq-jms.xml | 26 +- .../jms/replicated-transaction-failover/pom.xml | 9 +- .../ReplicatedTransactionFailoverExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 25 +- .../resources/hornetq/server1/activemq-jms.xml | 25 +- examples/jms/request-reply/pom.xml | 7 +- .../jms/example/RequestReplyExample.java | 8 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../src/main/resources/activemq-jms.xml | 13 +- .../src/main/resources/activemq-jms.xml | 13 +- .../src/main/resources/activemq-jms.xml | 13 +- .../push/src/main/resources/activemq-jms.xml | 19 +- examples/jms/scale-down/pom.xml | 9 +- .../activemq/jms/example/ScaleDownExample.java | 6 +- .../resources/hornetq/server0/activemq-jms.xml | 24 +- .../resources/hornetq/server1/activemq-jms.xml | 24 +- examples/jms/scheduled-message/pom.xml | 7 +- .../jms/example/ScheduledMessageExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/security/pom.xml | 7 +- .../activemq/jms/example/SecurityExample.java | 8 +- .../resources/hornetq/server0/activemq-jms.xml | 23 +- examples/jms/send-acknowledgements/pom.xml | 7 +- .../example/SendAcknowledgementsExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/spring-integration/pom.xml | 7 +- .../src/main/resources/activemq-jms.xml | 13 +- examples/jms/ssl-enabled/pom.xml | 7 +- .../apache/activemq/jms/example/SSLExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/static-selector-jms/pom.xml | 7 +- .../jms/example/StaticSelectorJMSExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 12 +- examples/jms/static-selector/pom.xml | 7 +- .../jms/example/StaticSelectorExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/stomp-websockets/pom.xml | 7 +- .../jms/example/StompWebSocketExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/stomp/pom.xml | 7 +- .../activemq/jms/example/StompExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/stomp1.1/pom.xml | 7 +- .../activemq/jms/example/StompExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/stomp1.2/pom.xml | 7 +- .../activemq/jms/example/StompExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/stop-server-failover/pom.xml | 9 +- .../jms/example/StopServerFailoverExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 26 +- .../resources/hornetq/server1/activemq-jms.xml | 26 +- examples/jms/symmetric-cluster/pom.xml | 17 +- .../resources/hornetq/server0/activemq-jms.xml | 17 +- .../resources/hornetq/server1/activemq-jms.xml | 17 +- .../resources/hornetq/server2/activemq-jms.xml | 17 +- .../resources/hornetq/server3/activemq-jms.xml | 17 +- .../resources/hornetq/server4/activemq-jms.xml | 17 +- .../resources/hornetq/server5/activemq-jms.xml | 17 +- examples/jms/temp-queue/pom.xml | 7 +- .../jms/example/TemporaryQueueExample.java | 2 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/topic-hierarchies/pom.xml | 7 +- .../jms/example/TopicHierarchyExample.java | 2 +- .../resources/hornetq/server0/activemq-jms.xml | 33 +- examples/jms/topic-selector-example1/pom.xml | 7 +- .../jms/example/TopicSelectorExample1.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/topic-selector-example2/pom.xml | 7 +- .../jms/example/TopicSelectorExample2.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/topic/pom.xml | 7 +- .../activemq/jms/example/TopicExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- .../hornetq/server0/client-jndi.properties | 5 +- examples/jms/transaction-failover/pom.xml | 9 +- .../jms/example/TransactionFailoverExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 25 +- .../resources/hornetq/server1/activemq-jms.xml | 25 +- examples/jms/transactional/pom.xml | 7 +- .../jms/example/TransactionalExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 13 +- examples/jms/xa-heuristic/pom.xml | 7 +- .../jms/example/XAHeuristicExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/xa-receive/pom.xml | 7 +- .../activemq/jms/example/XAReceiveExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/xa-send/pom.xml | 7 +- .../activemq/jms/example/XASendExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/jms/xa-with-jta/pom.xml | 7 +- .../activemq/jms/example/XAwithJTAExample.java | 4 +- .../resources/hornetq/server0/activemq-jms.xml | 14 +- examples/soak/normal/pom.xml | 13 +- examples/soak/normal/server0/activemq-jms.xml | 18 +- .../activemq/jms/soak/example/SoakReceiver.java | 5 +- .../activemq/jms/soak/example/SoakSender.java | 5 +- pom.xml | 11 - tests/byteman-tests/pom.xml | 4 - .../server-start-stop-backup-jms-config1.xml | 11 +- .../server-start-stop-live-jms-config1.xml | 13 +- tests/integration-tests/pom.xml | 7 + .../integration/jms/SimpleJNDIClientTest.java | 722 +++++++++++++++++++ .../jms/server/JMSServerDeployerTest.java | 207 +----- .../config/JMSServerConfigParserTest.java | 35 - .../integration/ra/ActiveMQRATestBase.java | 9 + .../spring/SpringIntegrationTest.java | 17 +- .../tests/util/NonSerializableFactory.java | 84 ++- .../activemq-jms-for-JMSServerDeployerTest.xml | 48 +- .../activemq-jms-for-JMSServerDeployerTest2.xml | 48 +- .../colocated-server-start-stop-jms-config1.xml | 13 +- .../colocated-server-start-stop-jms-config2.xml | 13 +- .../resources/server-start-stop-jms-config1.xml | 13 +- .../src/test/resources/spring-activemq-jms.xml | 13 +- .../src/test/resources/spring-jms-beans.xml | 21 +- tests/jms-tests/pom.xml | 4 - .../jms/tests/ActiveMQServerTestCase.java | 14 + .../jms/tests/ConnectionFactoryTest.java | 49 ++ .../apache/activemq/jms/tests/SessionTest.java | 2 + .../tests/message/SimpleJMSStreamMessage.java | 4 +- .../jms/tests/tools/WrappedJNDIServer.java | 92 --- .../jms/tests/tools/container/InVMContext.java | 1 - .../container/InVMInitialContextFactory.java | 2 - .../tests/tools/container/LocalTestServer.java | 32 +- .../tools/container/NonSerializableFactory.java | 85 ++- .../jms/tests/tools/container/Server.java | 6 + .../src/test/resources/activemq-jms.xml | 120 --- .../src/test/resources/jndi.properties | 3 +- tests/joram-tests/pom.xml | 4 - .../org/apache/activemq/jms/AbstractAdmin.java | 13 +- .../org/apache/activemq/jms/ActiveMQAdmin.java | 339 +++++++++ .../org/apache/activemq/jms/ActiveMQQAdmin.java | 340 --------- .../apache/activemq/jms/SpawnedJMSServer.java | 25 - .../jtests/jms/admin/AdminFactory.java | 8 +- .../message/headers/MessageHeaderTest.java | 10 +- .../jms/conform/queue/QueueBrowserTest.java | 3 +- .../jms/conform/session/UnifiedSessionTest.java | 3 +- .../jtests/jms/framework/PTPTestCase.java | 15 +- .../jtests/jms/framework/PubSubTestCase.java | 15 +- .../jtests/jms/framework/UnifiedTestCase.java | 17 +- .../src/test/resources/provider.properties | 2 +- tests/performance-tests/pom.xml | 4 - tests/soak-tests/pom.xml | 4 - tests/stress-tests/pom.xml | 4 - tests/timing-tests/pom.xml | 4 - .../activemq/tests/unit/util/InVMContext.java | 1 - .../tests/unit/util/InVMNamingContext.java | 1 - .../tests/unit/util/NonSerializableFactory.java | 81 +-- 441 files changed, 3471 insertions(+), 6318 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 7af8f9f..015033e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,11 +58,6 @@ integration/activemq-*-integration/.project # /distribution/activemq/ /distribution/activemq/.project -# /distribution/jnp-client/ -/distribution/jnp-client/target -/distribution/jnp-client/bin -/distribution/jnp-client/.project - # /docs/ /docs/.project http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Run.java ---------------------------------------------------------------------- diff --git a/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Run.java b/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Run.java index 8bab07e..a83be75 100644 --- a/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Run.java +++ b/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Run.java @@ -34,7 +34,6 @@ import org.apache.activemq.integration.bootstrap.ActiveMQBootstrapLogger; import org.apache.activemq.jms.server.JMSServerManager; import org.apache.activemq.jms.server.config.JMSConfiguration; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; -import org.apache.activemq.jms.server.impl.StandaloneNamingServer; import org.apache.activemq.spi.core.security.ActiveMQSecurityManager; import javax.management.MBeanServer; @@ -51,7 +50,6 @@ public class Run implements Action @Arguments(description = "Broker Configuration URI, default 'xml:${ACTIVEMQ_HOME}/config/non-clustered/bootstrap.xml'") String configuration; - private StandaloneNamingServer namingServer; private JMSServerManager jmsServerManager; private ArrayList<ActiveMQComponent> components = new ArrayList<>(); @@ -84,20 +82,6 @@ public class Run implements Action ActiveMQServerImpl server = new ActiveMQServerImpl(core, mBeanServer, security); - namingServer = new StandaloneNamingServer(server); - - namingServer.setBindAddress(broker.naming.bindAddress); - - namingServer.setPort(broker.naming.port); - - namingServer.setRmiBindAddress(broker.naming.rmiBindAddress); - - namingServer.setRmiPort(broker.naming.rmiPort); - - namingServer.start(); - - ActiveMQBootstrapLogger.LOGGER.startedNamingService(broker.naming.bindAddress, broker.naming.port, broker.naming.rmiBindAddress, broker.naming.rmiPort); - if (jms != null) { jmsServerManager = new JMSServerManagerImpl(server, jms); http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java ---------------------------------------------------------------------- diff --git a/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java b/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java index 70e6767..c6f8974 100644 --- a/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java +++ b/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java @@ -40,9 +40,6 @@ public class BrokerDTO @XmlElementRef public SecurityDTO security; - @XmlElementRef - public NamingDTO naming; - @XmlElementRef(required = false) public WebServerDTO web; http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-dto/src/main/java/org/apache/activemq/dto/NamingDTO.java ---------------------------------------------------------------------- diff --git a/activemq-dto/src/main/java/org/apache/activemq/dto/NamingDTO.java b/activemq-dto/src/main/java/org/apache/activemq/dto/NamingDTO.java deleted file mode 100644 index a2aa5b6..0000000 --- a/activemq-dto/src/main/java/org/apache/activemq/dto/NamingDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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.activemq.dto; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "naming") -@XmlAccessorType(XmlAccessType.FIELD) -public class NamingDTO -{ - @XmlAttribute - public String bindAddress = "localhost"; - - @XmlAttribute - public int port = 1099; - - @XmlAttribute - public String rmiBindAddress = "localhost"; - - @XmlAttribute - public int rmiPort = 1098; -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index ---------------------------------------------------------------------- diff --git a/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index b/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index index d4f5b1f..9cffb01 100644 --- a/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index +++ b/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index @@ -19,5 +19,4 @@ CoreDTO JmsDTO SecurityDTO BasicSecurityDTO -NamingDTO http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java ---------------------------------------------------------------------- diff --git a/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java new file mode 100644 index 0000000..18b145d --- /dev/null +++ b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java @@ -0,0 +1,496 @@ +/** + * 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.activemq.jndi; + +import javax.jms.Queue; +import javax.jms.Topic; +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.spi.InitialContextFactory; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.StringTokenizer; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.activemq.api.core.DiscoveryGroupConfiguration; +import org.apache.activemq.api.core.JGroupsBroadcastGroupConfiguration; +import org.apache.activemq.api.core.TransportConfiguration; +import org.apache.activemq.api.core.UDPBroadcastGroupConfiguration; +import org.apache.activemq.api.core.client.ActiveMQClient; +import org.apache.activemq.api.jms.ActiveMQJMSClient; +import org.apache.activemq.api.jms.JMSFactoryType; +import org.apache.activemq.core.client.ActiveMQClientLogger; +import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory; +import org.apache.activemq.core.remoting.impl.netty.TransportConstants; +import org.apache.activemq.jms.client.ActiveMQConnectionFactory; + +/** + * A factory of the ActiveMQ InitialContext which contains + * {@link javax.jms.ConnectionFactory} instances as well as a child context called + * <i>destinations</i> which contain all of the current active destinations, in + * child context depending on the QoS such as transient or durable and queue or + * topic. + */ +public class ActiveMQInitialContextFactory implements InitialContextFactory +{ + public static final String CONNECTION_FACTORY_NAMES = "connectionFactoryNames"; + public static final String REFRESH_TIMEOUT = "refresh-timeout"; + public static final String DISCOVERY_INITIAL_WAIT_TIMEOUT = "discovery-initial-wait-timeout"; + + private static final String[] DEFAULT_CONNECTION_FACTORY_NAMES = {"ConnectionFactory", "XAConnectionFactory", "QueueConnectionFactory", "TopicConnectionFactory"}; + public static final String TCP_SCHEME = "tcp"; + public static final String JGROUPS_SCHEME = "jgroups"; + public static final String UDP_SCHEME = "udp"; + public static final String VM_SCHEME = "vm"; + public static final String HA = "ha"; + public static final String CF_TYPE = "type"; + public static final String QUEUE_CF = "QUEUE_CF"; + public static final String TOPIC_CF = "TOPIC_CF"; + public static final String QUEUE_XA_CF = "QUEUE_XA_CF"; + public static final String TOPIC_XA_CF = "TOPIC_XA_CF"; + public static final String XA_CF = "XA_CF"; + public static final String DYNAMIC_QUEUE_CONTEXT = "dynamicQueues"; + public static final String DYNAMIC_TOPIC_CONTEXT = "dynamicTopics"; + + private String connectionPrefix = "connection."; + private String queuePrefix = "queue."; + private String topicPrefix = "topic."; + + public Context getInitialContext(Hashtable environment) throws NamingException + { + // lets create a factory + Map<String, Object> data = new ConcurrentHashMap<String, Object>(); + String[] names = getConnectionFactoryNames(environment); + for (int i = 0; i < names.length; i++) + { + ActiveMQConnectionFactory factory = null; + String name = names[i]; + + try + { + factory = createConnectionFactory(name, environment); + } + catch (Exception e) + { + e.printStackTrace(); + throw new NamingException("Invalid broker URL"); + } + + data.put(name, factory); + } + + createQueues(data, environment); + createTopics(data, environment); + + data.put(DYNAMIC_QUEUE_CONTEXT, new LazyCreateContext() + { + private static final long serialVersionUID = 6503881346214855588L; + + protected Object createEntry(String name) + { + return ActiveMQJMSClient.createQueue(name); + } + }); + data.put(DYNAMIC_TOPIC_CONTEXT, new LazyCreateContext() + { + private static final long serialVersionUID = 2019166796234979615L; + + protected Object createEntry(String name) + { + return ActiveMQJMSClient.createTopic(name); + } + }); + + return createContext(environment, data); + } + + // Properties + // ------------------------------------------------------------------------- + public String getTopicPrefix() + { + return topicPrefix; + } + + public void setTopicPrefix(String topicPrefix) + { + this.topicPrefix = topicPrefix; + } + + public String getQueuePrefix() + { + return queuePrefix; + } + + public void setQueuePrefix(String queuePrefix) + { + this.queuePrefix = queuePrefix; + } + + // Implementation methods + // ------------------------------------------------------------------------- + + protected ReadOnlyContext createContext(Hashtable environment, Map<String, Object> data) + { + return new ReadOnlyContext(environment, data); + } + + protected ActiveMQConnectionFactory createConnectionFactory(String name, Hashtable environment) throws URISyntaxException, MalformedURLException + { + Hashtable connectionFactoryProperties = new Hashtable(environment); + if (DEFAULT_CONNECTION_FACTORY_NAMES[1].equals(name)) + { + connectionFactoryProperties.put(CF_TYPE, XA_CF); + } + if (DEFAULT_CONNECTION_FACTORY_NAMES[2].equals(name)) + { + connectionFactoryProperties.put(CF_TYPE, QUEUE_CF); + } + if (DEFAULT_CONNECTION_FACTORY_NAMES[3].equals(name)) + { + connectionFactoryProperties.put(CF_TYPE, TOPIC_CF); + } + String prefix = connectionPrefix + name + "."; + for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) + { + Map.Entry entry = (Map.Entry) iter.next(); + String key = (String) entry.getKey(); + if (key.startsWith(prefix)) + { + // Rename the key... + connectionFactoryProperties.remove(key); + key = key.substring(prefix.length()); + connectionFactoryProperties.put(key, entry.getValue()); + } + } + return createConnectionFactory(connectionFactoryProperties); + } + + protected String[] getConnectionFactoryNames(Map environment) + { + String factoryNames = (String) environment.get(CONNECTION_FACTORY_NAMES); + if (factoryNames != null) + { + List<String> list = new ArrayList<String>(); + for (StringTokenizer enumeration = new StringTokenizer(factoryNames, ","); enumeration.hasMoreTokens(); ) + { + list.add(enumeration.nextToken().trim()); + } + int size = list.size(); + if (size > 0) + { + String[] answer = new String[size]; + list.toArray(answer); + return answer; + } + } + return DEFAULT_CONNECTION_FACTORY_NAMES; + } + + protected void createQueues(Map<String, Object> data, Hashtable environment) + { + for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) + { + Map.Entry entry = (Map.Entry) iter.next(); + String key = entry.getKey().toString(); + if (key.startsWith(queuePrefix)) + { + String jndiName = key.substring(queuePrefix.length()); + data.put(jndiName, createQueue(entry.getValue().toString())); + } + } + } + + protected void createTopics(Map<String, Object> data, Hashtable environment) + { + for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) + { + Map.Entry entry = (Map.Entry) iter.next(); + String key = entry.getKey().toString(); + if (key.startsWith(topicPrefix)) + { + String jndiName = key.substring(topicPrefix.length()); + data.put(jndiName, createTopic(entry.getValue().toString())); + } + } + } + + /** + * Factory method to create new Queue instances + */ + protected Queue createQueue(String name) + { + return ActiveMQJMSClient.createQueue(name); + } + + /** + * Factory method to create new Topic instances + */ + protected Topic createTopic(String name) + { + return ActiveMQJMSClient.createTopic(name); + } + + /** + * Factory method to create a new connection factory from the given environment + */ + protected ActiveMQConnectionFactory createConnectionFactory(Hashtable environment) throws URISyntaxException, MalformedURLException + { + ActiveMQConnectionFactory connectionFactory; + Map transportConfig = new HashMap(); + + if (environment.containsKey(Context.PROVIDER_URL)) + { + URI providerURI = new URI(((String)environment.get(Context.PROVIDER_URL))); + + if (providerURI.getQuery() != null) + { + try + { + transportConfig = parseQuery(providerURI.getQuery()); + } + catch (URISyntaxException e) + { + } + } + + if (providerURI.getScheme().equals(TCP_SCHEME)) + { + String[] connectors = providerURI.getAuthority().split(","); + TransportConfiguration[] transportConfigurations = new TransportConfiguration[connectors.length]; + for (int i = 0; i < connectors.length; i++) + { + Map individualTransportConfig = new HashMap(transportConfig); + String[] hostAndPort = connectors[i].split(":"); + individualTransportConfig.put(TransportConstants.HOST_PROP_NAME, hostAndPort[0]); + individualTransportConfig.put(TransportConstants.PORT_PROP_NAME, hostAndPort[1]); + transportConfigurations[i] = new TransportConfiguration(NettyConnectorFactory.class.getCanonicalName(), individualTransportConfig); + } + + if (Boolean.TRUE.equals(environment.get(HA))) + { + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithHA(getJmsFactoryType(environment), transportConfigurations); + } + else + { + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(getJmsFactoryType(environment), transportConfigurations); + } + } + else if (providerURI.getScheme().equals(UDP_SCHEME)) + { + DiscoveryGroupConfiguration dgc = new DiscoveryGroupConfiguration() + .setRefreshTimeout(transportConfig.containsKey(REFRESH_TIMEOUT) ? Long.parseLong((String) transportConfig.get(REFRESH_TIMEOUT)) : ActiveMQClient.DEFAULT_DISCOVERY_REFRESH_TIMEOUT) + .setDiscoveryInitialWaitTimeout(transportConfig.containsKey(DISCOVERY_INITIAL_WAIT_TIMEOUT) ? Long.parseLong((String) transportConfig.get(DISCOVERY_INITIAL_WAIT_TIMEOUT)) : ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT) + .setBroadcastEndpointFactoryConfiguration(new UDPBroadcastGroupConfiguration() + .setGroupAddress(providerURI.getHost()) + .setGroupPort(providerURI.getPort()) + .setLocalBindAddress(transportConfig.containsKey(TransportConstants.LOCAL_ADDRESS_PROP_NAME) ? (String) transportConfig.get(TransportConstants.LOCAL_ADDRESS_PROP_NAME) : null) + .setLocalBindPort(transportConfig.containsKey(TransportConstants.LOCAL_PORT_PROP_NAME) ? Integer.parseInt((String) transportConfig.get(TransportConstants.LOCAL_PORT_PROP_NAME)) : -1)); + if (Boolean.TRUE.equals(environment.get(HA))) + { + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithHA(dgc, getJmsFactoryType(environment)); + } + else + { + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dgc, getJmsFactoryType(environment)); + } + } + else if (providerURI.getScheme().equals(JGROUPS_SCHEME)) + { + JGroupsBroadcastGroupConfiguration config = new JGroupsBroadcastGroupConfiguration(providerURI.getAuthority(), providerURI.getPath() != null ? providerURI.getPath() : UUID.randomUUID().toString()); + + DiscoveryGroupConfiguration dgc = new DiscoveryGroupConfiguration() + .setRefreshTimeout(transportConfig.containsKey(REFRESH_TIMEOUT) ? Long.parseLong((String) transportConfig.get(REFRESH_TIMEOUT)) : ActiveMQClient.DEFAULT_DISCOVERY_REFRESH_TIMEOUT) + .setDiscoveryInitialWaitTimeout(transportConfig.containsKey(DISCOVERY_INITIAL_WAIT_TIMEOUT) ? Long.parseLong((String) transportConfig.get(DISCOVERY_INITIAL_WAIT_TIMEOUT)) : ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT) + .setBroadcastEndpointFactoryConfiguration(config); + if (Boolean.TRUE.equals(environment.get(HA))) + { + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithHA(dgc, getJmsFactoryType(environment)); + } + else + { + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dgc, getJmsFactoryType(environment)); + } + } + else if (providerURI.getScheme().equals(VM_SCHEME)) + { + Map inVmTransportConfig = new HashMap(); + inVmTransportConfig.put("server-id", providerURI.getHost()); + TransportConfiguration tc = new TransportConfiguration("org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory", inVmTransportConfig); + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(getJmsFactoryType(environment), tc); + } + else + { + throw new IllegalArgumentException("Invalid scheme"); + } + } + else + { + TransportConfiguration tc = new TransportConfiguration("org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory"); + connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(getJmsFactoryType(environment), tc); + } + + Properties properties = new Properties(); + properties.putAll(environment); + + for (Object key : environment.keySet()) + { + invokeSetter(connectionFactory, (String) key, environment.get(key)); + } + + return connectionFactory; + } + + private JMSFactoryType getJmsFactoryType(Hashtable environment) + { + JMSFactoryType ultimateType = JMSFactoryType.CF; // default value + if (environment.containsKey(CF_TYPE)) + { + String tempType = (String) environment.get(CF_TYPE); + if (QUEUE_CF.equals(tempType)) + { + ultimateType = JMSFactoryType.QUEUE_CF; + } + else if (TOPIC_CF.equals(tempType)) + { + ultimateType = JMSFactoryType.TOPIC_CF; + } + else if (QUEUE_XA_CF.equals(tempType)) + { + ultimateType = JMSFactoryType.QUEUE_XA_CF; + } + else if (TOPIC_XA_CF.equals(tempType)) + { + ultimateType = JMSFactoryType.TOPIC_XA_CF; + } + else if (XA_CF.equals(tempType)) + { + ultimateType = JMSFactoryType.XA_CF; + } + } + return ultimateType; + } + + + public static Map<String, String> parseQuery(String uri) throws URISyntaxException + { + try + { + uri = uri.substring(uri.lastIndexOf("?") + 1); // get only the relevant part of the query + Map<String, String> rc = new HashMap<String, String>(); + if (uri != null && !uri.isEmpty()) + { + String[] parameters = uri.split("&"); + for (int i = 0; i < parameters.length; i++) + { + int p = parameters[i].indexOf("="); + if (p >= 0) + { + String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8"); + String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8"); + rc.put(name, value); + } + else + { + rc.put(parameters[i], null); + } + } + } + return rc; + } + catch (UnsupportedEncodingException e) + { + throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); + } + } + + public String getConnectionPrefix() + { + return connectionPrefix; + } + + public void setConnectionPrefix(String connectionPrefix) + { + this.connectionPrefix = connectionPrefix; + } + + private void invokeSetter(Object target, final String propertyName, final Object propertyValue) + { + Method setter = null; + + Method[] methods = target.getClass().getMethods(); + + // turn something like "consumerWindowSize" to "setConsumerWindowSize" + String setterMethodName = "set" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); + + for (Method m : methods) + { + if (m.getName().equals(setterMethodName)) + { + setter = m; + break; + } + } + + try + { + if (setter != null) + { + ActiveMQClientLogger.LOGGER.info("Invoking: " + setter + " that takes a " + setter.getParameterTypes()[0] + " with a " + propertyValue.getClass()); + if (propertyValue.getClass() == String.class && setter.getParameterTypes()[0] != String.class) + { + String stringPropertyValue = (String) propertyValue; + if (setter.getParameterTypes()[0] == Integer.TYPE) + { + setter.invoke(target, Integer.parseInt(stringPropertyValue)); + } + else if (setter.getParameterTypes()[0] == Long.TYPE) + { + setter.invoke(target, Long.parseLong(stringPropertyValue)); + } + else if (setter.getParameterTypes()[0] == Double.TYPE) + { + setter.invoke(target, Double.parseDouble(stringPropertyValue)); + } + else if (setter.getParameterTypes()[0] == Boolean.TYPE) + { + setter.invoke(target, Boolean.parseBoolean(stringPropertyValue)); + } + } + else + { + setter.invoke(target, propertyValue); + } + } + } + catch (Exception e) + { + ActiveMQClientLogger.LOGGER.warn("Caught exception during invocation of: " + setter, e); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-jms-client/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java ---------------------------------------------------------------------- diff --git a/activemq-jms-client/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java new file mode 100644 index 0000000..0fe51bc --- /dev/null +++ b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/LazyCreateContext.java @@ -0,0 +1,43 @@ +/** + * 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.activemq.jndi; + +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; + +public abstract class LazyCreateContext extends ReadOnlyContext +{ + public Object lookup(String name) throws NamingException + { + try + { + return super.lookup(name); + } + catch (NameNotFoundException e) + { + Object answer = createEntry(name); + if (answer == null) + { + throw e; + } + internalBind(name, answer); + return answer; + } + } + + protected abstract Object createEntry(String name); +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-jms-client/src/main/java/org/apache/activemq/jndi/NameParserImpl.java ---------------------------------------------------------------------- diff --git a/activemq-jms-client/src/main/java/org/apache/activemq/jndi/NameParserImpl.java b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/NameParserImpl.java new file mode 100644 index 0000000..8ae21cf --- /dev/null +++ b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/NameParserImpl.java @@ -0,0 +1,30 @@ +/** + * 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.activemq.jndi; + +import javax.naming.CompositeName; +import javax.naming.Name; +import javax.naming.NameParser; +import javax.naming.NamingException; + +public class NameParserImpl implements NameParser +{ + public Name parse(String name) throws NamingException + { + return new CompositeName(name); + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java ---------------------------------------------------------------------- diff --git a/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java new file mode 100644 index 0000000..9602d1a --- /dev/null +++ b/activemq-jms-client/src/main/java/org/apache/activemq/jndi/ReadOnlyContext.java @@ -0,0 +1,534 @@ +/** + * 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.activemq.jndi; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; +import javax.naming.Binding; +import javax.naming.CompositeName; +import javax.naming.Context; +import javax.naming.LinkRef; +import javax.naming.Name; +import javax.naming.NameClassPair; +import javax.naming.NameNotFoundException; +import javax.naming.NameParser; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.NotContextException; +import javax.naming.OperationNotSupportedException; +import javax.naming.Reference; +import javax.naming.spi.NamingManager; + +import org.apache.activemq.core.client.ActiveMQClientLogger; + +/** + * A read-only Context <p/> This version assumes it and all its subcontext are + * read-only and any attempt to modify (e.g. through bind) will result in an + * OperationNotSupportedException. Each Context in the tree builds a cache of + * the entries in all sub-contexts to optimise the performance of lookup. + * </p> + * <p> + * This implementation is intended to optimise the performance of lookup(String) + * to about the level of a HashMap get. It has been observed that the scheme + * resolution phase performed by the JVM takes considerably longer, so for + * optimum performance lookups should be coded like: + * </p> + * <code> + * Context componentContext = (Context)new InitialContext().lookup("java:comp"); + * String envEntry = (String) componentContext.lookup("env/myEntry"); + * String envEntry2 = (String) componentContext.lookup("env/myEntry2"); + * </code> + */ +@SuppressWarnings("unchecked") +public class ReadOnlyContext implements Context, Serializable +{ + public static final String SEPARATOR = "/"; + protected static final NameParser NAME_PARSER = new NameParserImpl(); + private static final long serialVersionUID = -5754338187296859149L; + + protected final Hashtable<String, Object> environment; // environment for this context + protected final Map<String, Object> bindings; // bindings at my level + protected final Map<String, Object> treeBindings; // all bindings under me + + private boolean frozen; + private String nameInNamespace = ""; + + public ReadOnlyContext() + { + environment = new Hashtable<String, Object>(); + bindings = new HashMap<String, Object>(); + treeBindings = new HashMap<String, Object>(); + } + + public ReadOnlyContext(Hashtable env) + { + if (env == null) + { + this.environment = new Hashtable<String, Object>(); + } + else + { + this.environment = new Hashtable<String, Object>(env); + } + this.bindings = Collections.EMPTY_MAP; + this.treeBindings = Collections.EMPTY_MAP; + } + + public ReadOnlyContext(Hashtable environment, Map<String, Object> bindings) + { + if (environment == null) + { + this.environment = new Hashtable<String, Object>(); + } + else + { + this.environment = new Hashtable<String, Object>(environment); + } + this.bindings = new HashMap<String, Object>(); + treeBindings = new HashMap<String, Object>(); + if (bindings != null) + { + for (Map.Entry<String, Object> binding : bindings.entrySet()) + { + try + { + internalBind(binding.getKey(), binding.getValue()); + } + catch (Throwable e) + { + ActiveMQClientLogger.LOGGER.error("Failed to bind " + binding.getKey() + "=" + binding.getValue(), e); + } + } + } + frozen = true; + } + + public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace) + { + this(environment, bindings); + this.nameInNamespace = nameInNamespace; + } + + protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env) + { + this.bindings = clone.bindings; + this.treeBindings = clone.treeBindings; + this.environment = new Hashtable<String, Object>(env); + } + + protected ReadOnlyContext(ReadOnlyContext clone, Hashtable<String, Object> env, String nameInNamespace) + { + this(clone, env); + this.nameInNamespace = nameInNamespace; + } + + public void freeze() + { + frozen = true; + } + + boolean isFrozen() + { + return frozen; + } + + /** + * internalBind is intended for use only during setup or possibly by + * suitably synchronized superclasses. It binds every possible lookup into a + * map in each context. To do this, each context strips off one name segment + * and if necessary creates a new context for it. Then it asks that context + * to bind the remaining name. It returns a map containing all the bindings + * from the next context, plus the context it just created (if it in fact + * created it). (the names are suitably extended by the segment originally + * lopped off). + * + * @param name + * @param value + * @return + * @throws javax.naming.NamingException + */ + protected Map<String, Object> internalBind(String name, Object value) throws NamingException + { + assert name != null && name.length() > 0; + assert !frozen; + + Map<String, Object> newBindings = new HashMap<String, Object>(); + int pos = name.indexOf('/'); + if (pos == -1) + { + if (treeBindings.put(name, value) != null) + { + throw new NamingException("Something already bound at " + name); + } + bindings.put(name, value); + newBindings.put(name, value); + } + else + { + String segment = name.substring(0, pos); + assert segment != null; + assert !segment.equals(""); + Object o = treeBindings.get(segment); + if (o == null) + { + o = newContext(); + treeBindings.put(segment, o); + bindings.put(segment, o); + newBindings.put(segment, o); + } + else if (!(o instanceof ReadOnlyContext)) + { + throw new NamingException("Something already bound where a subcontext should go"); + } + ReadOnlyContext readOnlyContext = (ReadOnlyContext) o; + String remainder = name.substring(pos + 1); + Map<String, Object> subBindings = readOnlyContext.internalBind(remainder, value); + for (Iterator iterator = subBindings.entrySet().iterator(); iterator.hasNext(); ) + { + Map.Entry entry = (Map.Entry) iterator.next(); + String subName = segment + "/" + (String) entry.getKey(); + Object bound = entry.getValue(); + treeBindings.put(subName, bound); + newBindings.put(subName, bound); + } + } + return newBindings; + } + + protected ReadOnlyContext newContext() + { + return new ReadOnlyContext(); + } + + public Object addToEnvironment(String propName, Object propVal) throws NamingException + { + return environment.put(propName, propVal); + } + + public Hashtable<String, Object> getEnvironment() throws NamingException + { + return (Hashtable<String, Object>) environment.clone(); + } + + public Object removeFromEnvironment(String propName) throws NamingException + { + return environment.remove(propName); + } + + public Object lookup(String name) throws NamingException + { + if (name.length() == 0) + { + return this; + } + Object result = treeBindings.get(name); + if (result == null) + { + result = bindings.get(name); + } + if (result == null) + { + int pos = name.indexOf(':'); + if (pos > 0) + { + String scheme = name.substring(0, pos); + Context ctx = NamingManager.getURLContext(scheme, environment); + if (ctx == null) + { + throw new NamingException("scheme " + scheme + " not recognized"); + } + return ctx.lookup(name); + } + else + { + // Split out the first name of the path + // and look for it in the bindings map. + CompositeName path = new CompositeName(name); + + if (path.size() == 0) + { + return this; + } + else + { + String first = path.get(0); + Object obj = bindings.get(first); + if (obj == null) + { + throw new NameNotFoundException(name); + } + else if (obj instanceof Context && path.size() > 1) + { + Context subContext = (Context) obj; + obj = subContext.lookup(path.getSuffix(1)); + } + return obj; + } + } + } + if (result instanceof LinkRef) + { + LinkRef ref = (LinkRef) result; + result = lookup(ref.getLinkName()); + } + if (result instanceof Reference) + { + try + { + result = NamingManager.getObjectInstance(result, null, null, this.environment); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + throw (NamingException) new NamingException("could not look up : " + name).initCause(e); + } + } + if (result instanceof ReadOnlyContext) + { + String prefix = getNameInNamespace(); + if (prefix.length() > 0) + { + prefix = prefix + SEPARATOR; + } + result = new ReadOnlyContext((ReadOnlyContext) result, environment, prefix + name); + } + return result; + } + + public Object lookup(Name name) throws NamingException + { + return lookup(name.toString()); + } + + public Object lookupLink(String name) throws NamingException + { + return lookup(name); + } + + public Name composeName(Name name, Name prefix) throws NamingException + { + Name result = (Name) prefix.clone(); + result.addAll(name); + return result; + } + + public String composeName(String name, String prefix) throws NamingException + { + CompositeName result = new CompositeName(prefix); + result.addAll(new CompositeName(name)); + return result.toString(); + } + + public NamingEnumeration list(String name) throws NamingException + { + Object o = lookup(name); + if (o == this) + { + return new ListEnumeration(); + } + else if (o instanceof Context) + { + return ((Context) o).list(""); + } + else + { + throw new NotContextException(); + } + } + + public NamingEnumeration listBindings(String name) throws NamingException + { + Object o = lookup(name); + if (o == this) + { + return new ListBindingEnumeration(); + } + else if (o instanceof Context) + { + return ((Context) o).listBindings(""); + } + else + { + throw new NotContextException(); + } + } + + public Object lookupLink(Name name) throws NamingException + { + return lookupLink(name.toString()); + } + + public NamingEnumeration list(Name name) throws NamingException + { + return list(name.toString()); + } + + public NamingEnumeration listBindings(Name name) throws NamingException + { + return listBindings(name.toString()); + } + + public void bind(Name name, Object obj) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void bind(String name, Object obj) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void close() throws NamingException + { + // ignore + } + + public Context createSubcontext(Name name) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public Context createSubcontext(String name) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void destroySubcontext(Name name) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void destroySubcontext(String name) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public String getNameInNamespace() throws NamingException + { + return nameInNamespace; + } + + public NameParser getNameParser(Name name) throws NamingException + { + return NAME_PARSER; + } + + public NameParser getNameParser(String name) throws NamingException + { + return NAME_PARSER; + } + + public void rebind(Name name, Object obj) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void rebind(String name, Object obj) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void rename(Name oldName, Name newName) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void rename(String oldName, String newName) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void unbind(Name name) throws NamingException + { + throw new OperationNotSupportedException(); + } + + public void unbind(String name) throws NamingException + { + throw new OperationNotSupportedException(); + } + + private abstract class LocalNamingEnumeration implements NamingEnumeration + { + private final Iterator i = bindings.entrySet() + .iterator(); + + public boolean hasMore() throws NamingException + { + return i.hasNext(); + } + + public boolean hasMoreElements() + { + return i.hasNext(); + } + + protected Map.Entry getNext() + { + return (Map.Entry) i.next(); + } + + public void close() throws NamingException + { + } + } + + private class ListEnumeration extends LocalNamingEnumeration + { + ListEnumeration() + { + } + + public Object next() throws NamingException + { + return nextElement(); + } + + public Object nextElement() + { + Map.Entry entry = getNext(); + return new NameClassPair((String) entry.getKey(), entry.getValue() + .getClass() + .getName()); + } + } + + private class ListBindingEnumeration extends LocalNamingEnumeration + { + ListBindingEnumeration() + { + } + + public Object next() throws NamingException + { + return nextElement(); + } + + public Object nextElement() + { + Map.Entry entry = getNext(); + return new Binding((String) entry.getKey(), entry.getValue()); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-jms-server/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-jms-server/pom.xml b/activemq-jms-server/pom.xml index 476914b..c39a31e 100644 --- a/activemq-jms-server/pom.xml +++ b/activemq-jms-server/pom.xml @@ -53,10 +53,6 @@ <groupId>org.jboss</groupId> <artifactId>jboss-transaction-spi</artifactId> </dependency> - <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnpserver</artifactId> - </dependency> </dependencies> <profiles> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/JMSServerConfigParser.java ---------------------------------------------------------------------- diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/JMSServerConfigParser.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/JMSServerConfigParser.java index 3b6bca8..67d7ef6 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/JMSServerConfigParser.java +++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/JMSServerConfigParser.java @@ -18,7 +18,6 @@ package org.apache.activemq.jms.server; import java.io.InputStream; -import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration; import org.apache.activemq.jms.server.config.JMSConfiguration; import org.apache.activemq.jms.server.config.JMSQueueConfiguration; import org.apache.activemq.jms.server.config.TopicConfiguration; @@ -58,12 +57,4 @@ public interface JMSServerConfigParser * @throws Exception */ JMSQueueConfiguration parseQueueConfiguration(final Node node) throws Exception; - - /** - * Parse the Connection Configuration node as a ConnectionFactoryConfiguration object - * @param node - * @return - * @throws Exception - */ - ConnectionFactoryConfiguration parseConnectionFactoryConfiguration(final Node node) throws Exception; } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java ---------------------------------------------------------------------- diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java index 376e4ce..e2d5550 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java +++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java @@ -21,6 +21,7 @@ import javax.naming.Context; import org.apache.activemq.core.registry.JndiBindingRegistry; import org.apache.activemq.core.registry.MapBindingRegistry; import org.apache.activemq.core.server.embedded.EmbeddedActiveMQ; +import org.apache.activemq.jms.server.JMSServerManager; import org.apache.activemq.jms.server.config.JMSConfiguration; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.spi.core.naming.BindingRegistry; @@ -58,6 +59,11 @@ public class EmbeddedJMS extends EmbeddedActiveMQ return registry; } + public JMSServerManager getJMSServerManager() + { + return serverManager; + } + /** * Only set this property if you are using a custom BindingRegistry *