camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r983197 [1/4] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ camel-core/src/main/java/org/apache/camel/spi/ camel-core/src/...
Date Sat, 07 Aug 2010 10:18:06 GMT
Author: davsclaus
Date: Sat Aug  7 10:17:59 2010
New Revision: 983197

URL: http://svn.apache.org/viewvc?rev=983197&view=rev
Log:
CAMEL-3031: Camel fails to start if an existing CamelContext has been registered in MBeanServer. Introduced pluggable strategy to auto assign camel context name.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/VetoCamelContextStartException.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextNameStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExplicitCamelContextNameStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/CamelContextNameStrategy.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextAutoAssignedNameClashTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedAutoAssignedNameTest.java
      - copied, changed from r982899, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedAutoAssignedNameTest.xml
      - copied, changed from r982899, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LifecycleStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlerAsyncDelayedTest.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DependencyInjectCamelTemplateTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextCustomThreadPoolProfileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextThreadPoolProfilesTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java
    camel/trunk/components/camel-spring/src/test/resources/META-INF/spring/camel-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/RegistryInjection.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringConsumerTemplateOutOfCamelContextTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringConsumerTemplateTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringLogDebugBodyMaxCharsTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/aop/SpringAopClassLevelCamelBeanTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/processorAsEndpoint.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/NamespacePrefixTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/SpringCamelContextCustomThreadPoolProfileTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/SpringCamelContextThreadPoolProfilesTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/SpringProduceInjectedPrototypeBeanTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/SpringProduceInjectedSingletonBeanTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/scan/componentScan.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/dataformat/dataFormatWithNonChildElementTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/defaultJmxConfig.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxConfig.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxTheOldWayConfig.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/contentBasedRoute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/fooEventRoute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoConsumer.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoSender.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/simpleRoute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/xpathFilter.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/examples.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileLanguageCBRTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/delayerInterceptorTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSource.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceMinimalConfiguration.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceUsingTransacted.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataWithOnExceptionAndRollbackUsingTransacted.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/traceFormatterTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/tracerConfigurationTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientDataSourceWithSpringRouteBuilder.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CamelRouteRefInjectionIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/FileWireTapWithXMLPayloadIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/MisspelledRouteRefTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/ProduceSplitMethodCallIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringCatchNestedFailTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringCharlesSplitAndTryCatchRollbackIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringFinallyNestedFailTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringMainStartFailedIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringPackageTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringRenameFileOnCommitIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringSingletonScopedBeanIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringTransactionErrorHandlerAndContextScopedOnExceptionIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringTryCatchFinallyAndErrorHandlerTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringTryCatchWithSplitIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringTryCatchWithSplitNotHandledIssueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringTryNestedFailTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/contextscan/SpringRouteIsComponentAnnotatedTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/contextscan2/SpringRouteIsComponentAnnotated2Test.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/stringDataFormatTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfig.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfigUsingProperties.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/lifecycleStrategyInjection.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringDualLoggingEventNotifierTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringPublishEventNotifierTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/multipleLifecycleStrategyInjection.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/postprocessor/camelCustomPostProcessorOnRouteBuilderTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/BatchResequencerAllowDuplicatesTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/BatchResequencerJMSPriorityTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/CBRHeaderPredicateTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/CustomProcessorFactoryTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/EventNotifierExchangeSentExampleTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/FailoverMaximumFailoverAttemptsTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/FailoverRoundRobinTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/InheritErrorHandlerDefaultTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/InheritErrorHandlerFalseTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/InheritErrorHandlerTrueTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/PolicyPerProcessorTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/PolicyPerRouteTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/RecipientListAggregationStrategyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/RecipientListDoNotStopOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/RecipientListStopOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/RouteNoAutoStartupTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/RouteStartupOrderSimpleTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/RouteStartupOrderTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/RouteStartupOrderWithDefaultTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteCurrentTaskOnlyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownDeferTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownNotDeferTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringAggregateFromWireTapTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringComplexBlockWithEndTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringCustomExpressionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringCustomPredicateTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyNewTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelHandledPolicyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandledPolicyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalBodyNewTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalBodyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDefaultErrorHandlerNotHandledPolicyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDefaultErrorHandlerOnExceptionTraceTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromUriRegexTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromUriSimpleLogTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromUriWildcardTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromWhenNoStopTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromWhenTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromWhenWithChoiceTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptFromWithStopTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTraceTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMethodCallTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMulticastNoStopOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringMulticastStopOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionAndInterceptAndOnExceptionGlobalTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionAndInterceptGlobalTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionAndInterceptTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionGlobalTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionGlobalTraceTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionOnCompleteOnlyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionOnFailureOnlyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionRouteScopeOverrideGlobalScopeTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionUseOriginalBodyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringOnCompletionWhenTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRecipientListParallelStreamingTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRecipientListParallelTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSplitterNoStopOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSplitterStopOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringThrowExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorHandledTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorMultipleExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTryProcessorOnWhenTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetCopyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringWireTapUsingFireAndForgetTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringXPathHeaderTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsDefaultTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsExternalThreadPoolFactoryBeanTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsThreadPoolFactoryBeanTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlingInflightRoutePolicyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ValidateSimpleTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator-custom-strategy.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateCompletionIntervalTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateExpressionSizeFallbackTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateExpressionSizeTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateExpressionTimeoutFallbackTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateExpressionTimeoutPerGroupTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateExpressionTimeoutTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimplePredicateEagerTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimplePredicateTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimpleSizeTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimpleTimeoutTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateThreadPoolProfileTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopafter.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopafterfinally.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aoparoundfinally.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopbefore.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopnestedroute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/choice.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/convertBody.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayerperroute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/enricher.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/enricherref.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/failOverLoadBalance.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/faultRoute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromEndpointTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/handlefaultperroute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/idempotent/fileConsumerIdempotentTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/interceptSendToEndpoint.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/interceptSendToEndpointDynamic.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/interceptSendToEndpointInOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/interceptSendToEndpointSkip.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/interceptSendToEndpointWhen.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/logProcessorTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/loop.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/markrollbackonly.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/multicast.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/pollEnricher.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/pollEnricherRef.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/randomLoadBalance.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListIgnoreInvalidEndpoints.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithArrayHeader.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedHeader.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedProperty.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/removeHeader.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/removeHeaders.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/removeProperty.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/resequencer.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/rollback.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/roundRobinLoadBalance.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/routingSlip.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/routingSlipIgnoreInvalidEndpoints.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottler.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/samplingThrottlerWithDefault.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/scattergather/scatter-gather.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setOutHeader.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setOutHeaderWithConstant.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setProperty.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/splitterMethodCallTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/splitterTokenizerTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/splitterWithCustomThreadPoolExecutor.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/staticRecipientList.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/stickyLoadBalance.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/streamResequencer.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/streamcachingperroute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/topicLoadBalance.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/traceInterceptorWithOutBodyTrace.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/traceperroute.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/transform.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/validate.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathFilter.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathFilterWithNamespace.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo-direct.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo-out-of-camelContext.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-namespace.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-proxy.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/routingUsingCamelContextFactory.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Sat Aug  7 10:17:59 2010
@@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.spi.CamelContextNameStrategy;
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.DataFormatResolver;
@@ -80,6 +81,10 @@ public interface CamelContext extends Su
      */
     String getName();
 
+    CamelContextNameStrategy getNameStrategy();
+
+    void setNameStrategy(CamelContextNameStrategy nameStrategy);
+
     /**
      * Gets the version of the this context.
      *

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/VetoCamelContextStartException.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/VetoCamelContextStartException.java?rev=983197&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/VetoCamelContextStartException.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/VetoCamelContextStartException.java Sat Aug  7 10:17:59 2010
@@ -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.camel;
+
+/**
+ * An exception to veto starting {@link CamelContext}.
+ *
+ * @version $Revision$
+ */
+public class VetoCamelContextStartException extends Exception {
+    private static final long serialVersionUID = 8046489554418284256L;
+    private final CamelContext context;
+
+    public VetoCamelContextStartException(String message, CamelContext context) {
+        super(message);
+        this.context = context;
+    }
+
+    public VetoCamelContextStartException(String message, Throwable cause, CamelContext context) {
+        super(message, cause);
+        this.context = context;
+    }
+
+    public CamelContext getContext() {
+        return context;
+    }
+}

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Sat Aug  7 10:17:59 2010
@@ -58,6 +58,7 @@ import org.apache.camel.ShutdownRunningT
 import org.apache.camel.StartupListener;
 import org.apache.camel.SuspendableService;
 import org.apache.camel.TypeConverter;
+import org.apache.camel.VetoCamelContextStartException;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.impl.converter.DefaultTypeConverter;
@@ -73,6 +74,7 @@ import org.apache.camel.processor.interc
 import org.apache.camel.processor.interceptor.HandleFault;
 import org.apache.camel.processor.interceptor.StreamCaching;
 import org.apache.camel.processor.interceptor.Tracer;
+import org.apache.camel.spi.CamelContextNameStrategy;
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.spi.ComponentResolver;
 import org.apache.camel.spi.DataFormat;
@@ -120,10 +122,8 @@ import org.apache.commons.logging.LogFac
  */
 public class DefaultCamelContext extends ServiceSupport implements CamelContext, SuspendableService {
     private static final transient Log LOG = LogFactory.getLog(DefaultCamelContext.class);
-    private static final String NAME_PREFIX = "camel-";
-    private static final AtomicInteger CONTEXT_COUNTER = new AtomicInteger(0);
+    private CamelContextNameStrategy nameStrategy = new DefaultCamelContextNameStrategy();
     private ClassLoader applicationContextClassLoader;
-    private String name;
     private final Map<String, Endpoint> endpoints = new EndpointRegistry();
     private final AtomicInteger endpointKeyCounter = new AtomicInteger();
     private final List<EndpointStrategy> endpointStrategies = new ArrayList<EndpointStrategy>();
@@ -145,9 +145,6 @@ public class DefaultCamelContext extends
     private final List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
     private List<InterceptStrategy> interceptStrategies = new ArrayList<InterceptStrategy>();
 
-    private final AtomicBoolean suspending = new AtomicBoolean(false);
-    private final AtomicBoolean suspended = new AtomicBoolean(false);
-    private final AtomicBoolean resuming = new AtomicBoolean(false);
     // special flags to control the first startup which can are special
     private volatile boolean firstStartDone;
     private volatile boolean doNotStartRoutesOnFirstStart;
@@ -189,7 +186,6 @@ public class DefaultCamelContext extends
 
     public DefaultCamelContext() {
         super();
-        name = NAME_PREFIX + CONTEXT_COUNTER.incrementAndGet();
 
         // use WebSphere specific resolver if running on WebSphere
         if (WebSpherePackageScanClassResolver.isWebSphereClassLoader(this.getClass().getClassLoader())) {
@@ -221,7 +217,7 @@ public class DefaultCamelContext extends
     }
 
     public String getName() {
-        return name;
+        return getNameStrategy().getName();
     }
 
     /**
@@ -230,7 +226,16 @@ public class DefaultCamelContext extends
      * @param name the name
      */
     public void setName(String name) {
-        this.name = name;
+        // use an explicit name strategy since an explicit name was provided to be used
+        this.nameStrategy = new ExplicitCamelContextNameStrategy(name);
+    }
+
+    public CamelContextNameStrategy getNameStrategy() {
+        return nameStrategy;
+    }
+
+    public void setNameStrategy(CamelContextNameStrategy nameStrategy) {
+        this.nameStrategy = nameStrategy;
     }
 
     public Component hasComponent(String componentName) {
@@ -1255,6 +1260,10 @@ public class DefaultCamelContext extends
             LifecycleStrategy strategy = it.next();
             try {
                 strategy.onContextStart(this);
+            } catch (VetoCamelContextStartException e) {
+                // okay we should not start Camel since it was vetoed
+                LOG.warn("Lifecycle strategy vetoed starting CamelContext (" + getName() + ")", e);
+                throw e;
             } catch (Exception e) {
                 // not all containers allow access to its MBeanServer (such as OC4j)
                 // so here we remove the troublesome strategy to be able to continue
@@ -1317,7 +1326,6 @@ public class DefaultCamelContext extends
 
         // but clear any suspend routes
         suspendedRouteServices.clear();
-        suspended.set(false);
 
         // the stop order is important
 
@@ -2143,11 +2151,11 @@ public class DefaultCamelContext extends
     }
 
     /**
-     * Reset CONTEXT_COUNTER to a preset value. Mostly used for tests to ensure a predictable getName()
+     * Reset conext counter to a preset value. Mostly used for tests to ensure a predictable getName()
      *
-     * @param value new value for the CONTEXT_COUNTER
+     * @param value new value for the context counter
      */
     public static void setContextCounter(int value) {
-        CONTEXT_COUNTER.set(value);
+        DefaultCamelContextNameStrategy.setCounter(value);
     }
 }

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextNameStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextNameStrategy.java?rev=983197&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextNameStrategy.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextNameStrategy.java Sat Aug  7 10:17:59 2010
@@ -0,0 +1,55 @@
+/**
+ * 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.camel.impl;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.spi.CamelContextNameStrategy;
+
+/**
+ * A default name strategy which auto assigns a name using a prefix-counter pattern.
+ *
+ * @version $Revision$
+ */
+public class DefaultCamelContextNameStrategy implements CamelContextNameStrategy {
+
+    private static final String NAME_PREFIX = "camel-";
+    private static final AtomicInteger CONTEXT_COUNTER = new AtomicInteger(0);
+    private String name;
+
+    public DefaultCamelContextNameStrategy() {
+        name = getNextName();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static String getNextName() {
+        return NAME_PREFIX + CONTEXT_COUNTER.incrementAndGet();
+    }
+
+    /**
+     * To reset the counter, should only be used for testing purposes.
+     *
+     * @param value the counter value
+     */
+    public static void setCounter(int value) {
+        CONTEXT_COUNTER.set(value);
+    }
+
+}

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExplicitCamelContextNameStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExplicitCamelContextNameStrategy.java?rev=983197&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExplicitCamelContextNameStrategy.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExplicitCamelContextNameStrategy.java Sat Aug  7 10:17:59 2010
@@ -0,0 +1,37 @@
+/**
+ * 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.camel.impl;
+
+import org.apache.camel.spi.CamelContextNameStrategy;
+
+/**
+ * Strategy to used an explicit (fixed) name for {@link org.apache.camel.CamelContext}.
+ *
+ * @version $Revision$
+ */
+public class ExplicitCamelContextNameStrategy implements CamelContextNameStrategy {
+
+    private final String name;
+
+    public ExplicitCamelContextNameStrategy(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java Sat Aug  7 10:17:59 2010
@@ -232,6 +232,9 @@ public class DefaultManagementAgent exte
     public void unregister(ObjectName name) throws JMException {
         if (server.isRegistered(name)) {
             server.unregisterMBean(name);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Unregistered MBean with objectname: " + name);
+            }
         }
         mbeansRegistered.remove(name);
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java Sat Aug  7 10:17:59 2010
@@ -22,6 +22,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ThreadPoolExecutor;
 import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
@@ -33,8 +35,11 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.Route;
 import org.apache.camel.Service;
+import org.apache.camel.VetoCamelContextStartException;
 import org.apache.camel.builder.ErrorHandlerBuilder;
+import org.apache.camel.impl.DefaultCamelContextNameStrategy;
 import org.apache.camel.impl.EventDrivenConsumerRoute;
+import org.apache.camel.impl.ExplicitCamelContextNameStrategy;
 import org.apache.camel.impl.ProducerCache;
 import org.apache.camel.impl.ScheduledPollConsumer;
 import org.apache.camel.impl.ThrottlingInflightRoutePolicy;
@@ -113,19 +118,74 @@ public class DefaultManagementLifecycleS
         this.camelContext = camelContext;
     }
 
-    public void onContextStart(CamelContext context) {
+    public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
+        ManagedCamelContext mc = new ManagedCamelContext(context);
+        mc.init(context.getManagementStrategy());
+
         try {
-            initialized = true;
+            boolean done = false;
+            while (!done) {
+                ObjectName on = getManagementStrategy().getManagementNamingStrategy().getObjectNameForCamelContext(context);
+                boolean exists = getManagementStrategy().isManaged(mc, on);
+                if (!exists) {
+                    done = true;
+                } else {
+                    // okay there exists already a CamelContext with this name, we can try to fix it
+                    boolean fixed = false;
+                    if (context.getNameStrategy() instanceof DefaultCamelContextNameStrategy) {
+                        // if we use the default name strategy we can find a free name to use
+                        String name = findFreeName(mc);
+                        if (name != null) {
+                            // use this as the fixed name
+                            LOG.warn("Reassigned auto assigned name on CamelContext from: " + context.getName()
+                                    + " to: " + name + " due to clash with existing name already registered in MBeanServer.");
+                            // now set the fixed name we are using onwards
+                            context.setNameStrategy(new ExplicitCamelContextNameStrategy(name));
+                            fixed = true;
+                            done = true;
+                        }
+                    }
+                    // we could not fix it so veto starting camel
+                    if (!fixed) {
+                        throw new VetoCamelContextStartException("CamelContext (" + context.getName() + ") with ObjectName[" + on + "] is already registered."
+                            + " Make sure to use unique names on CamelContext when using multiple CamelContexts in the same MBeanServer.", context);
+                    }
+                }
+            }
+        } catch (VetoCamelContextStartException e) {
+            // rethrow veto
+            throw e;
+        } catch (Exception e) {
+            // must rethrow to allow CamelContext fallback to non JMX agent to allow
+            // Camel to continue to run
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
 
-            ManagedCamelContext mc = new ManagedCamelContext(context);
-            mc.init(context.getManagementStrategy());
+        try {
             getManagementStrategy().manageObject(mc);
-
         } catch (Exception e) {
             // must rethrow to allow CamelContext fallback to non JMX agent to allow
             // Camel to continue to run
             throw ObjectHelper.wrapRuntimeCamelException(e);
         }
+
+        // yes we made it and are initialized
+        initialized = true;
+    }
+
+    private String findFreeName(ManagedCamelContext mc) throws MalformedObjectNameException {
+        boolean done = false;
+        String name = null;
+        while (!done) {
+            // try next name
+            name = DefaultCamelContextNameStrategy.getNextName();
+            ObjectName on = getManagementStrategy().getManagementNamingStrategy().getObjectNameForCamelContext(name);
+            done = !getManagementStrategy().isManaged(mc, on);
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Using name: " + name + " in ObjectName[" + on + "] exists? " + done);
+            }
+        }
+        return name;
     }
 
     public void onContextStop(CamelContext context) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java Sat Aug  7 10:17:59 2010
@@ -78,6 +78,15 @@ public class DefaultManagementNamingStra
         }
     }
 
+    public ObjectName getObjectNameForCamelContext(String name) throws MalformedObjectNameException {
+        StringBuilder buffer = new StringBuilder();
+        buffer.append(domainName).append(":");
+        buffer.append(KEY_CONTEXT + "=").append(getContextId(name)).append(",");
+        buffer.append(KEY_TYPE + "=" + TYPE_CONTEXT + ",");
+        buffer.append(KEY_NAME + "=").append(ObjectName.quote(name));
+        return createObjectName(buffer);
+    }
+
     public ObjectName getObjectNameForCamelContext(CamelContext context) throws MalformedObjectNameException {
         StringBuilder buffer = new StringBuilder();
         buffer.append(domainName).append(":");
@@ -278,7 +287,12 @@ public class DefaultManagementNamingStra
     }
 
     protected String getContextId(CamelContext context) {
-        return hostName + "/" + (context != null ? context.getName() : VALUE_UNKNOWN);
+        String name = context != null ? context.getName() : VALUE_UNKNOWN;
+        return getContextId(name);
+    }
+
+    protected String getContextId(String name) {
+        return hostName + "/" + (name != null ? name : VALUE_UNKNOWN);
     }
 
     protected String getEndpointId(Endpoint ep) {

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/CamelContextNameStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/CamelContextNameStrategy.java?rev=983197&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/CamelContextNameStrategy.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/CamelContextNameStrategy.java Sat Aug  7 10:17:59 2010
@@ -0,0 +1,27 @@
+/**
+ * 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.camel.spi;
+
+/**
+ * Strategy for assigning name to a {@link org.apache.camel.CamelContext}.
+ *
+ * @version $Revision$
+ */
+public interface CamelContextNameStrategy {
+
+    String getName();
+}

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LifecycleStrategy.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LifecycleStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LifecycleStrategy.java Sat Aug  7 10:17:59 2010
@@ -25,6 +25,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
 import org.apache.camel.Service;
+import org.apache.camel.VetoCamelContextStartException;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 
 /**
@@ -36,8 +37,10 @@ public interface LifecycleStrategy {
      * Notification on starting a {@link CamelContext}.
      *
      * @param context the camel context
+     * @throws VetoCamelContextStartException can be thrown to veto starting {@link CamelContext}.
+     * Any other runtime exceptions will be logged at <tt>WARN</tt> level by Camel will continue starting itself.
      */
-    void onContextStart(CamelContext context);
+    void onContextStart(CamelContext context) throws VetoCamelContextStartException;
 
     /**
      * Notification on stopping a {@link CamelContext}.

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java Sat Aug  7 10:17:59 2010
@@ -38,6 +38,8 @@ import org.apache.camel.model.ProcessorD
  */
 public interface ManagementNamingStrategy {
 
+    ObjectName getObjectNameForCamelContext(String name) throws MalformedObjectNameException;
+
     ObjectName getObjectNameForCamelContext(CamelContext context) throws MalformedObjectNameException;
 
     ObjectName getObjectNameForComponent(Component component, String name) throws MalformedObjectNameException;

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextAutoAssignedNameClashTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextAutoAssignedNameClashTest.java?rev=983197&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextAutoAssignedNameClashTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextAutoAssignedNameClashTest.java Sat Aug  7 10:17:59 2010
@@ -0,0 +1,71 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.TestSupport;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultCamelContextNameStrategy;
+
+/**
+ * @version $Revision$
+ */
+public class TwoManagedCamelContextAutoAssignedNameClashTest extends TestSupport {
+
+    private CamelContext camel1;
+    private CamelContext camel2;
+
+    protected CamelContext createCamelContext() throws Exception {
+        DefaultCamelContext context = new DefaultCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testTwoManagedCamelContextClash() throws Exception {
+        camel1 = createCamelContext();
+        camel1.start();
+        assertTrue("Should be started", camel1.getStatus().isStarted());
+
+        MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer();
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=context,name=\"camel-1\"");
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+
+        // now cheat and reset the counter so we can test for a clash
+        DefaultCamelContextNameStrategy.setCounter(0);
+
+        camel2 = createCamelContext();
+        camel2.start();
+        ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=localhost/camel-2,type=context,name=\"camel-2\"");
+        assertTrue("Should be registered", mbeanServer.isRegistered(on2));
+
+        assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on));
+        assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on2));
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        camel1.stop();
+        camel2.stop();
+        super.tearDown();
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java?rev=983197&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java Sat Aug  7 10:17:59 2010
@@ -0,0 +1,73 @@
+/**
+ * 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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.TestSupport;
+import org.apache.camel.VetoCamelContextStartException;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class TwoManagedCamelContextClashTest extends TestSupport {
+
+    private CamelContext camel1;
+    private CamelContext camel2;
+
+    protected CamelContext createCamelContext(String name) throws Exception {
+        DefaultCamelContext context = new DefaultCamelContext();
+        context.setName(name);
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testTwoManagedCamelContextClash() throws Exception {
+        camel1 = createCamelContext("foo");
+        camel2 = createCamelContext("foo");
+
+        camel1.start();
+        assertTrue("Should be started", camel1.getStatus().isStarted());
+
+        MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer();
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/foo,type=context,name=\"foo\"");
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+
+        try {
+            camel2.start();
+            fail("Should throw an exception");
+        } catch (VetoCamelContextStartException e) {
+            assertEquals("foo", e.getContext().getName());
+        }
+        assertFalse("Should not be started", camel2.getStatus().isStarted());
+
+        assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on));
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        camel1.stop();
+        camel2.stop();
+        super.tearDown();
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextTest.java?rev=983197&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/TwoManagedCamelContextTest.java Sat Aug  7 10:17:59 2010
@@ -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.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.TestSupport;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class TwoManagedCamelContextTest extends TestSupport {
+
+    private CamelContext camel1;
+    private CamelContext camel2;
+
+    protected CamelContext createCamelContext(String name) throws Exception {
+        DefaultCamelContext context = new DefaultCamelContext();
+        context.setName(name);
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+        return context;
+    }
+
+    public void testTwoManagedCamelContext() throws Exception {
+        camel1 = createCamelContext("foo");
+        camel2 = createCamelContext("bar");
+
+        camel1.start();
+        camel2.start();
+
+        MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/foo,type=context,name=\"foo\"");
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+
+        ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=localhost/bar,type=context,name=\"bar\"");
+        assertTrue("Should be registered", mbeanServer.isRegistered(on2));
+
+        camel1.stop();
+        camel2.stop();
+
+        assertFalse("Should be unregistered", mbeanServer.isRegistered(on));
+        assertFalse("Should be unregistered", mbeanServer.isRegistered(on2));
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        camel1.stop();
+        camel2.stop();
+        super.tearDown();
+    }
+
+}

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlerAsyncDelayedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlerAsyncDelayedTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlerAsyncDelayedTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlerAsyncDelayedTest.java Sat Aug  7 10:17:59 2010
@@ -63,7 +63,8 @@ public class ThrottlerAsyncDelayedTest e
 
         // now assert that they have actually been throttled
         long minimumTime = (messageCount - 1) * INTERVAL;
-        assertTrue("Should take at least " + minimumTime + "ms", System.currentTimeMillis() - start >= minimumTime);
+        long delta = System.currentTimeMillis() - start;
+        assertTrue("Should take at least " + minimumTime + "ms, was: " + delta, delta >= minimumTime);
     }
 
     protected RouteBuilder createRouteBuilder() {

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java Sat Aug  7 10:17:59 2010
@@ -26,6 +26,7 @@ import javax.xml.bind.Binder;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 
+import org.apache.camel.impl.DefaultCamelContextNameStrategy;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -242,7 +243,8 @@ public class CamelNamespaceHandler exten
 
             // lets avoid folks having to explicitly give an ID to a camel context
             if (ObjectHelper.isEmpty(contextId)) {
-                contextId = "camelContext";
+                // if no explicit id was set then use a default auto generated name
+                contextId = DefaultCamelContextNameStrategy.getNextName();
                 element.setAttribute("id", contextId);
             }
 

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java Sat Aug  7 10:17:59 2010
@@ -38,7 +38,7 @@ public class RoutingUsingCamelContextFac
     public void testXMLRouteLoading() throws Exception {
         applicationContext = createApplicationContext();
 
-        SpringCamelContext context = (SpringCamelContext) applicationContext.getBean("camel");
+        SpringCamelContext context = (SpringCamelContext) applicationContext.getBean("camel-A");
         assertValidContext(context);
 
         MockEndpoint resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:result");

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextAutoStartupTest.java Sat Aug  7 10:17:59 2010
@@ -20,7 +20,7 @@ import junit.framework.TestCase;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spring.SpringCamelContext;
-import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
@@ -28,8 +28,10 @@ import org.springframework.context.suppo
  */
 public class CamelContextAutoStartupTest extends TestCase {
 
+    private AbstractXmlApplicationContext ac;
+
     public void testAutoStartupFalse() throws Exception {
-        ApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml");
+        ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml");
 
         SpringCamelContext camel = (SpringCamelContext) ac.getBean("myCamel");
         assertEquals("myCamel", camel.getName());
@@ -59,7 +61,7 @@ public class CamelContextAutoStartupTest
     }
 
     public void testAutoStartupTrue() throws Exception {
-        ApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestTrue.xml");
+        ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestTrue.xml");
 
         SpringCamelContext camel = (SpringCamelContext) ac.getBean("myCamel");
         assertEquals("myCamel", camel.getName());
@@ -79,4 +81,11 @@ public class CamelContextAutoStartupTest
         mock.assertIsSatisfied();
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (ac != null) {
+            ac.close();
+        }
+        super.tearDown();
+    }
 }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DependencyInjectCamelTemplateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DependencyInjectCamelTemplateTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DependencyInjectCamelTemplateTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DependencyInjectCamelTemplateTest.java Sat Aug  7 10:17:59 2010
@@ -36,8 +36,6 @@ public class DependencyInjectCamelTempla
     @EndpointInject(uri = "mock:results")
     private MockEndpoint endpoint;
 
-
-
     public void testBeanHasCamelTemplateInjected() throws Exception {
         assertNotNull("Bean should be injected", bean);
         ProducerTemplate template = bean.getTemplate();

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextCustomThreadPoolProfileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextCustomThreadPoolProfileTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextCustomThreadPoolProfileTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextCustomThreadPoolProfileTest.java Sat Aug  7 10:17:59 2010
@@ -30,7 +30,7 @@ public class SpringCamelContextCustomThr
     }
 
     public void testDefaultThreadPoolProfile() throws Exception {
-        CamelContext context = getMandatoryBean(CamelContext.class, "camel");
+        CamelContext context = getMandatoryBean(CamelContext.class, "camel-D");
 
         ThreadPoolProfile profile = context.getExecutorServiceStrategy().getDefaultThreadPoolProfile();
         assertEquals(5, profile.getPoolSize().intValue());

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest.java Sat Aug  7 10:17:59 2010
@@ -30,7 +30,7 @@ public class SpringCamelContextSimpleCus
     }
 
     public void testDefaultThreadPoolProfile() throws Exception {
-        CamelContext context = getMandatoryBean(CamelContext.class, "camel");
+        CamelContext context = getMandatoryBean(CamelContext.class, "camel-B");
 
         ThreadPoolProfile profile = context.getExecutorServiceStrategy().getDefaultThreadPoolProfile();
         assertEquals(25, profile.getMaxPoolSize().intValue());

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextThreadPoolProfilesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextThreadPoolProfilesTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextThreadPoolProfilesTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextThreadPoolProfilesTest.java Sat Aug  7 10:17:59 2010
@@ -34,7 +34,7 @@ public class SpringCamelContextThreadPoo
     }
 
     public void testLowProfile() throws Exception {
-        CamelContext context = getMandatoryBean(CamelContext.class, "camel");
+        CamelContext context = getMandatoryBean(CamelContext.class, "camel-C");
 
         ThreadPoolProfile profile = context.getExecutorServiceStrategy().getThreadPoolProfile("low");
         assertEquals(1, profile.getPoolSize().intValue());
@@ -54,7 +54,7 @@ public class SpringCamelContextThreadPoo
     }
 
     public void testBigProfile() throws Exception {
-        CamelContext context = getMandatoryBean(CamelContext.class, "camel");
+        CamelContext context = getMandatoryBean(CamelContext.class, "camel-C");
 
         ThreadPoolProfile profile = context.getExecutorServiceStrategy().getThreadPoolProfile("big");
         assertEquals(50, profile.getPoolSize().intValue());

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java Sat Aug  7 10:17:59 2010
@@ -29,8 +29,11 @@ public class SpringComponentScanTest ext
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+        if (context != null) {
+            context.stop();
+        }
         ApplicationContext c = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScan.xml");
-        context = (CamelContext)c.getBean("camelContext");
+        context = (CamelContext)c.getBean("camelScan");
         template = context.createProducerTemplate();
         template.start();
     }

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedAutoAssignedNameTest.java (from r982899, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedAutoAssignedNameTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedAutoAssignedNameTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java&r1=982899&r2=983197&rev=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedAutoAssignedNameTest.java Sat Aug  7 10:17:59 2010
@@ -16,39 +16,25 @@
  */
 package org.apache.camel.spring.management;
 
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.Set;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.apache.camel.Endpoint;
-import org.apache.camel.spring.SpringTestSupport;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version $Revision$
  */
-public class DualCamelContextManagedTest extends SpringTestSupport {
-
-    @Override
-    protected boolean useJmx() {
-        return true;
-    }
-
-    @Override
-    protected int getExpectedRouteCount() {
-        return 0;
-    }
+public class DualCamelContextManagedAutoAssignedNameTest extends DualCamelContextManagedTest {
 
     protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/spring/management/dualCamelContextManagedTest.xml");
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/management/dualCamelContextManagedAutoAssignedNameTest.xml");
     }
 
-    @SuppressWarnings("unchecked")
     public void testDualCamelContextManaged() throws Exception {
-        
+
         MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
 
         Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
@@ -66,19 +52,19 @@ public class DualCamelContextManagedTest
 
         for (ObjectName on : set) {
             String name = on.getCanonicalName();
-            
+
             if (name.contains("mock://mock1")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel1", id);
+                assertEquals("camel-1", id);
             } else if (name.contains("mock://mock2")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel2", id);
+                assertEquals("camel-2", id);
             } else if (name.contains("file://target/route1")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel1", id);
+                assertEquals("camel-1", id);
             } else if (name.contains("file://target/route2")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel2", id);
+                assertEquals("camel-2", id);
             }
         }
     }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/DualCamelContextManagedTest.java Sat Aug  7 10:17:59 2010
@@ -69,16 +69,16 @@ public class DualCamelContextManagedTest
             
             if (name.contains("mock://mock1")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel1", id);
+                assertEquals("camel-A", id);
             } else if (name.contains("mock://mock2")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel2", id);
+                assertEquals("camel-B", id);
             } else if (name.contains("file://target/route1")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel1", id);
+                assertEquals("camel-A", id);
             } else if (name.contains("file://target/route2")) {
                 String id = (String) mbeanServer.getAttribute(on, "CamelId");
-                assertEquals("camel2", id);
+                assertEquals("camel-B", id);
             }
         }
     }

Modified: camel/trunk/components/camel-spring/src/test/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/META-INF/spring/camel-context.xml?rev=983197&r1=983196&r2=983197&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/META-INF/spring/camel-context.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/META-INF/spring/camel-context.xml Sat Aug  7 10:17:59 2010
@@ -29,7 +29,7 @@
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
-  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
       <from uri="direct:a.start"/>
       <choice>



Mime
View raw message