This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit ac4b5cf638e765a55c47b336c01fcda700b789d0 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Apr 24 20:06:09 2023 +0200 CAMEL-19292: camel-core - Remove experimental LightweightCamelContext --- .../camel/impl/lw/LightweightCamelContext.java | 1480 -------------------- .../impl/lw/LightweightCamelContextExtension.java | 600 -------- .../impl/lw/LightweightRuntimeCamelContext.java | 1350 ------------------ .../java/org/apache/camel/ContextTestSupport.java | 20 +- 4 files changed, 1 insertion(+), 3449 deletions(-) diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java deleted file mode 100644 index aa6423fc0fb..00000000000 --- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java +++ /dev/null @@ -1,1480 +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.camel.impl.lw; - -import java.io.IOException; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; - -import org.apache.camel.CamelContext; -import org.apache.camel.CatalogCamelContext; -import org.apache.camel.Component; -import org.apache.camel.ConsumerTemplate; -import org.apache.camel.Endpoint; -import org.apache.camel.Experimental; -import org.apache.camel.Expression; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.FluentProducerTemplate; -import org.apache.camel.GlobalEndpointConfiguration; -import org.apache.camel.NoSuchLanguageException; -import org.apache.camel.Predicate; -import org.apache.camel.Processor; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.Route; -import org.apache.camel.RouteConfigurationsBuilder; -import org.apache.camel.RouteTemplateContext; -import org.apache.camel.RoutesBuilder; -import org.apache.camel.ServiceStatus; -import org.apache.camel.ShutdownRoute; -import org.apache.camel.ShutdownRunningTask; -import org.apache.camel.StartupListener; -import org.apache.camel.StartupSummaryLevel; -import org.apache.camel.TypeConverter; -import org.apache.camel.ValueHolder; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.model.DataFormatDefinition; -import org.apache.camel.model.FaultToleranceConfigurationDefinition; -import org.apache.camel.model.ModelCamelContext; -import org.apache.camel.model.ModelLifecycleStrategy; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.Resilience4jConfigurationDefinition; -import org.apache.camel.model.RouteConfigurationDefinition; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.RouteTemplateDefinition; -import org.apache.camel.model.TemplatedRouteDefinition; -import org.apache.camel.model.cloud.ServiceCallConfigurationDefinition; -import org.apache.camel.model.language.ExpressionDefinition; -import org.apache.camel.model.rest.RestDefinition; -import org.apache.camel.model.transformer.TransformerDefinition; -import org.apache.camel.model.validator.ValidatorDefinition; -import org.apache.camel.spi.BeanRepository; -import org.apache.camel.spi.CamelContextNameStrategy; -import org.apache.camel.spi.ClassResolver; -import org.apache.camel.spi.DataFormat; -import org.apache.camel.spi.DataType; -import org.apache.camel.spi.Debugger; -import org.apache.camel.spi.EndpointRegistry; -import org.apache.camel.spi.ExecutorServiceManager; -import org.apache.camel.spi.InflightRepository; -import org.apache.camel.spi.Injector; -import org.apache.camel.spi.Language; -import org.apache.camel.spi.LifecycleStrategy; -import org.apache.camel.spi.ManagementNameStrategy; -import org.apache.camel.spi.ManagementStrategy; -import org.apache.camel.spi.MessageHistoryFactory; -import org.apache.camel.spi.ModelReifierFactory; -import org.apache.camel.spi.PropertiesComponent; -import org.apache.camel.spi.Registry; -import org.apache.camel.spi.RestConfiguration; -import org.apache.camel.spi.RestRegistry; -import org.apache.camel.spi.RouteController; -import org.apache.camel.spi.RoutePolicyFactory; -import org.apache.camel.spi.RuntimeEndpointRegistry; -import org.apache.camel.spi.ShutdownStrategy; -import org.apache.camel.spi.StreamCachingStrategy; -import org.apache.camel.spi.Tracer; -import org.apache.camel.spi.Transformer; -import org.apache.camel.spi.TransformerRegistry; -import org.apache.camel.spi.TypeConverterRegistry; -import org.apache.camel.spi.UuidGenerator; -import org.apache.camel.spi.Validator; -import org.apache.camel.spi.ValidatorRegistry; -import org.apache.camel.support.DefaultRegistry; -import org.apache.camel.support.jsse.SSLContextParameters; -import org.apache.camel.vault.VaultConfiguration; - -@Experimental -public class LightweightCamelContext implements CamelContext, CatalogCamelContext, ModelCamelContext { - - protected volatile CamelContext delegate; - - protected LightweightCamelContext(CamelContext delegate) { - this.delegate = delegate; - } - - /** - * Creates the {@link ModelCamelContext} using {@link org.apache.camel.support.DefaultRegistry} as registry. - * <p/> - * Use one of the other constructors to force use an explicit registry. - */ - public LightweightCamelContext() { - DefaultCamelContext d = new DefaultCamelContext(false) { - @Override - public CamelContext getCamelContextReference() { - return LightweightCamelContext.this; - } - }; - delegate = d; - d.build(); - } - - /** - * Creates the {@link CamelContext} using the given {@link BeanRepository} as first-choice repository, and the - * {@link org.apache.camel.support.SimpleRegistry} as fallback, via the {@link DefaultRegistry} implementation. - * - * @param repository the bean repository. - */ - public LightweightCamelContext(BeanRepository repository) { - this(new DefaultRegistry(repository)); - } - - /** - * Creates the {@link ModelCamelContext} using the given registry - * - * @param registry the registry - */ - public LightweightCamelContext(Registry registry) { - this(); - - getCamelContextExtension().setRegistry(registry); - } - - @Override - public boolean isStarted() { - return delegate.isStarted(); - } - - @Override - public boolean isStarting() { - return delegate.isStarting(); - } - - @Override - public boolean isStopped() { - return delegate.isStopped(); - } - - @Override - public boolean isStopping() { - return delegate.isStopping(); - } - - @Override - public boolean isSuspended() { - return delegate.isSuspended(); - } - - @Override - public boolean isRunAllowed() { - return delegate.isRunAllowed(); - } - - @Override - public boolean isSuspending() { - return delegate.isSuspending(); - } - - @Override - public void build() { - delegate.build(); - } - - @Override - public void suspend() { - delegate.suspend(); - } - - @Override - public void resume() { - delegate.resume(); - } - - @Override - public void shutdown() { - delegate.shutdown(); - } - - @Override - public void close() throws Exception { - delegate.close(); - } - - @Override - public void start() { - delegate.start(); - } - - @Override - public void stop() { - delegate.stop(); - } - - @Override - public boolean isVetoStarted() { - return delegate.isVetoStarted(); - } - - @Override - public String getName() { - return delegate.getName(); - } - - @Override - public CamelContextNameStrategy getNameStrategy() { - return delegate.getNameStrategy(); - } - - @Override - public void setNameStrategy(CamelContextNameStrategy nameStrategy) { - delegate.setNameStrategy(nameStrategy); - } - - @Override - public String getDescription() { - return delegate.getDescription(); - } - - @Override - public ManagementNameStrategy getManagementNameStrategy() { - return delegate.getManagementNameStrategy(); - } - - @Override - public void setManagementNameStrategy(ManagementNameStrategy nameStrategy) { - delegate.setManagementNameStrategy(nameStrategy); - } - - @Override - public String getManagementName() { - return delegate.getManagementName(); - } - - @Override - public void setManagementName(String name) { - delegate.setManagementName(name); - } - - @Override - public String getVersion() { - return delegate.getVersion(); - } - - @Override - public ServiceStatus getStatus() { - return delegate.getStatus(); - } - - @Override - public String getUptime() { - return delegate.getUptime(); - } - - @Override - public long getUptimeMillis() { - return delegate.getUptimeMillis(); - } - - @Override - public Date getStartDate() { - return delegate.getStartDate(); - } - - @Override - public void addService(Object object) throws Exception { - delegate.addService(object); - } - - @Override - public void addService(Object object, boolean stopOnShutdown) throws Exception { - delegate.addService(object, stopOnShutdown); - } - - @Override - public void addService(Object object, boolean stopOnShutdown, boolean forceStart) throws Exception { - delegate.addService(object, stopOnShutdown, forceStart); - } - - @Override - public void addPrototypeService(Object object) throws Exception { - delegate.addPrototypeService(object); - } - - @Override - public boolean removeService(Object object) throws Exception { - return delegate.removeService(object); - } - - @Override - public boolean hasService(Object object) { - return delegate.hasService(object); - } - - @Override - public <T> T hasService(Class<T> type) { - return delegate.hasService(type); - } - - @Override - public <T> Set<T> hasServices(Class<T> type) { - return delegate.hasServices(type); - } - - @Override - public void deferStartService(Object object, boolean stopOnShutdown) throws Exception { - delegate.deferStartService(object, stopOnShutdown); - } - - @Override - public void addStartupListener(StartupListener listener) throws Exception { - delegate.addStartupListener(listener); - } - - @Override - public void addComponent(String componentName, Component component) { - delegate.addComponent(componentName, component); - } - - @Override - public Component hasComponent(String componentName) { - return delegate.hasComponent(componentName); - } - - @Override - public Component getComponent(String componentName) { - return delegate.getComponent(componentName); - } - - @Override - public Component getComponent(String name, boolean autoCreateComponents) { - return delegate.getComponent(name, autoCreateComponents); - } - - @Override - public Component getComponent(String name, boolean autoCreateComponents, boolean autoStart) { - return delegate.getComponent(name, autoCreateComponents, autoStart); - } - - @Override - public <T extends Component> T getComponent(String name, Class<T> componentType) { - return delegate.getComponent(name, componentType); - } - - @Override - public Set<String> getComponentNames() { - return delegate.getComponentNames(); - } - - @Override - public Component removeComponent(String componentName) { - return delegate.removeComponent(componentName); - } - - @Override - public EndpointRegistry<? extends ValueHolder<String>> getEndpointRegistry() { - return delegate.getEndpointRegistry(); - } - - @Override - public Endpoint getEndpoint(String uri) { - return delegate.getEndpoint(uri); - } - - @Override - public Endpoint getEndpoint(String uri, Map<String, Object> parameters) { - return delegate.getEndpoint(uri, parameters); - } - - @Override - public <T extends Endpoint> T getEndpoint(String name, Class<T> endpointType) { - return delegate.getEndpoint(name, endpointType); - } - - @Override - public Collection<Endpoint> getEndpoints() { - return delegate.getEndpoints(); - } - - @Override - public Endpoint hasEndpoint(String uri) { - return delegate.hasEndpoint(uri); - } - - @Override - public Endpoint addEndpoint(String uri, Endpoint endpoint) throws Exception { - return delegate.addEndpoint(uri, endpoint); - } - - @Override - public void removeEndpoint(Endpoint endpoint) throws Exception { - delegate.removeEndpoint(endpoint); - } - - @Override - public Collection<Endpoint> removeEndpoints(String pattern) throws Exception { - return delegate.removeEndpoints(pattern); - } - - @Override - public GlobalEndpointConfiguration getGlobalEndpointConfiguration() { - return delegate.getGlobalEndpointConfiguration(); - } - - @Override - public void setRouteController(RouteController routeController) { - delegate.setRouteController(routeController); - } - - @Override - public RouteController getRouteController() { - return delegate.getRouteController(); - } - - @Override - public List<Route> getRoutes() { - return delegate.getRoutes(); - } - - @Override - public int getRoutesSize() { - return delegate.getRoutesSize(); - } - - @Override - public Route getRoute(String id) { - return delegate.getRoute(id); - } - - @Override - public Processor getProcessor(String id) { - return delegate.getProcessor(id); - } - - @Override - public <T extends Processor> T getProcessor(String id, Class<T> type) { - return delegate.getProcessor(id, type); - } - - @Override - public void addRoutes(RoutesBuilder builder) throws Exception { - delegate.addRoutes(builder); - } - - @Override - public void addTemplatedRoutes(RoutesBuilder builder) throws Exception { - delegate.addTemplatedRoutes(builder); - } - - @Override - public void addRoutesConfigurations(RouteConfigurationsBuilder builder) throws Exception { - delegate.addRoutesConfigurations(builder); - } - - @Override - public boolean removeRoute(String routeId) throws Exception { - return delegate.removeRoute(routeId); - } - - @Override - public void addRoutePolicyFactory(RoutePolicyFactory routePolicyFactory) { - delegate.addRoutePolicyFactory(routePolicyFactory); - } - - @Override - public List<RoutePolicyFactory> getRoutePolicyFactories() { - return delegate.getRoutePolicyFactories(); - } - - @Override - public void setRestConfiguration(RestConfiguration restConfiguration) { - delegate.setRestConfiguration(restConfiguration); - } - - @Override - public RestConfiguration getRestConfiguration() { - return delegate.getRestConfiguration(); - } - - @Override - public void setVaultConfiguration(VaultConfiguration vaultConfiguration) { - delegate.setVaultConfiguration(vaultConfiguration); - } - - @Override - public VaultConfiguration getVaultConfiguration() { - return delegate.getVaultConfiguration(); - } - - @Override - public RestRegistry getRestRegistry() { - return delegate.getRestRegistry(); - } - - @Override - public void setRestRegistry(RestRegistry restRegistry) { - delegate.setRestRegistry(restRegistry); - } - - @Override - public TypeConverter getTypeConverter() { - return delegate.getTypeConverter(); - } - - @Override - public TypeConverterRegistry getTypeConverterRegistry() { - return delegate.getTypeConverterRegistry(); - } - - @Override - public void setTypeConverterRegistry(TypeConverterRegistry typeConverterRegistry) { - delegate.setTypeConverterRegistry(typeConverterRegistry); - } - - @Override - public Registry getRegistry() { - return delegate.getRegistry(); - } - - @Override - public <T> T getRegistry(Class<T> type) { - return delegate.getRegistry(type); - } - - @Override - public Injector getInjector() { - return delegate.getInjector(); - } - - @Override - public void setInjector(Injector injector) { - delegate.setInjector(injector); - } - - @Override - public List<LifecycleStrategy> getLifecycleStrategies() { - return delegate.getLifecycleStrategies(); - } - - @Override - public void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy) { - delegate.addLifecycleStrategy(lifecycleStrategy); - } - - @Override - public Language resolveLanguage(String language) throws NoSuchLanguageException { - return delegate.resolveLanguage(language); - } - - @Override - public String resolvePropertyPlaceholders(String text) { - return delegate.resolvePropertyPlaceholders(text); - } - - @Override - public PropertiesComponent getPropertiesComponent() { - return delegate.getPropertiesComponent(); - } - - @Override - public void setPropertiesComponent(PropertiesComponent propertiesComponent) { - delegate.setPropertiesComponent(propertiesComponent); - } - - @Override - public Set<String> getLanguageNames() { - return delegate.getLanguageNames(); - } - - @Override - public ProducerTemplate createProducerTemplate() { - return delegate.createProducerTemplate(); - } - - @Override - public ProducerTemplate createProducerTemplate(int maximumCacheSize) { - return delegate.createProducerTemplate(maximumCacheSize); - } - - @Override - public FluentProducerTemplate createFluentProducerTemplate() { - return delegate.createFluentProducerTemplate(); - } - - @Override - public FluentProducerTemplate createFluentProducerTemplate(int maximumCacheSize) { - return delegate.createFluentProducerTemplate(maximumCacheSize); - } - - @Override - public ConsumerTemplate createConsumerTemplate() { - return delegate.createConsumerTemplate(); - } - - @Override - public ConsumerTemplate createConsumerTemplate(int maximumCacheSize) { - return delegate.createConsumerTemplate(maximumCacheSize); - } - - @Override - public DataFormat resolveDataFormat(String name) { - return delegate.resolveDataFormat(name); - } - - @Override - public DataFormat createDataFormat(String name) { - return delegate.createDataFormat(name); - } - - @Override - public Set<String> getDataFormatNames() { - return delegate.getDataFormatNames(); - } - - @Override - public Transformer resolveTransformer(String model) { - return delegate.resolveTransformer(model); - } - - @Override - public Transformer resolveTransformer(DataType from, DataType to) { - return delegate.resolveTransformer(from, to); - } - - @Override - public TransformerRegistry getTransformerRegistry() { - return delegate.getTransformerRegistry(); - } - - @Override - public Validator resolveValidator(DataType type) { - return delegate.resolveValidator(type); - } - - @Override - public ValidatorRegistry getValidatorRegistry() { - return delegate.getValidatorRegistry(); - } - - @Override - public void setGlobalOptions(Map<String, String> globalOptions) { - delegate.setGlobalOptions(globalOptions); - } - - @Override - public Map<String, String> getGlobalOptions() { - return delegate.getGlobalOptions(); - } - - @Override - public String getGlobalOption(String key) { - return delegate.getGlobalOption(key); - } - - @Override - public ClassResolver getClassResolver() { - return delegate.getClassResolver(); - } - - @Override - public void setClassResolver(ClassResolver resolver) { - delegate.setClassResolver(resolver); - } - - @Override - public ManagementStrategy getManagementStrategy() { - return delegate.getManagementStrategy(); - } - - @Override - public void setManagementStrategy(ManagementStrategy strategy) { - delegate.setManagementStrategy(strategy); - } - - @Override - public void disableJMX() throws IllegalStateException { - delegate.disableJMX(); - } - - @Override - public InflightRepository getInflightRepository() { - return delegate.getInflightRepository(); - } - - @Override - public void setInflightRepository(InflightRepository repository) { - delegate.setInflightRepository(repository); - } - - @Override - public ClassLoader getApplicationContextClassLoader() { - return delegate.getApplicationContextClassLoader(); - } - - @Override - public void setApplicationContextClassLoader(ClassLoader classLoader) { - delegate.setApplicationContextClassLoader(classLoader); - } - - @Override - public ShutdownStrategy getShutdownStrategy() { - return delegate.getShutdownStrategy(); - } - - @Override - public void setShutdownStrategy(ShutdownStrategy shutdownStrategy) { - delegate.setShutdownStrategy(shutdownStrategy); - } - - @Override - public ExecutorServiceManager getExecutorServiceManager() { - return delegate.getExecutorServiceManager(); - } - - @Override - public void setExecutorServiceManager(ExecutorServiceManager executorServiceManager) { - delegate.setExecutorServiceManager(executorServiceManager); - } - - @Override - public MessageHistoryFactory getMessageHistoryFactory() { - return delegate.getMessageHistoryFactory(); - } - - @Override - public void setMessageHistoryFactory(MessageHistoryFactory messageHistoryFactory) { - delegate.setMessageHistoryFactory(messageHistoryFactory); - } - - @Override - public Debugger getDebugger() { - return delegate.getDebugger(); - } - - @Override - public void setDebugger(Debugger debugger) { - delegate.setDebugger(debugger); - } - - @Override - public Tracer getTracer() { - return delegate.getTracer(); - } - - @Override - public void setTracer(Tracer tracer) { - delegate.setTracer(tracer); - } - - @Override - public void setTracingStandby(boolean tracingStandby) { - delegate.setTracingStandby(tracingStandby); - } - - @Override - public boolean isTracingStandby() { - return delegate.isTracingStandby(); - } - - @Override - public void setBacklogTracingStandby(boolean backlogTracingStandby) { - delegate.setBacklogTracingStandby(backlogTracingStandby); - } - - @Override - public boolean isBacklogTracingStandby() { - return delegate.isBacklogTracingStandby(); - } - - @Override - public UuidGenerator getUuidGenerator() { - return delegate.getUuidGenerator(); - } - - @Override - public void setUuidGenerator(UuidGenerator uuidGenerator) { - delegate.setUuidGenerator(uuidGenerator); - } - - @Override - public Boolean isLoadTypeConverters() { - return delegate.isLoadTypeConverters(); - } - - @Override - public void setLoadTypeConverters(Boolean loadTypeConverters) { - delegate.setLoadTypeConverters(loadTypeConverters); - } - - @Override - public Boolean isTypeConverterStatisticsEnabled() { - return delegate.isTypeConverterStatisticsEnabled(); - } - - @Override - public void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled) { - delegate.setTypeConverterStatisticsEnabled(typeConverterStatisticsEnabled); - } - - @Override - public Boolean isLoadHealthChecks() { - return delegate.isLoadHealthChecks(); - } - - @Override - public void setLoadHealthChecks(Boolean loadHealthChecks) { - delegate.setLoadHealthChecks(loadHealthChecks); - } - - @Override - public Boolean isSourceLocationEnabled() { - return delegate.isSourceLocationEnabled(); - } - - @Override - public void setSourceLocationEnabled(Boolean sourceLocationEnabled) { - delegate.setSourceLocationEnabled(sourceLocationEnabled); - } - - @Override - public Boolean isModeline() { - return delegate.isModeline(); - } - - @Override - public void setModeline(Boolean modeline) { - delegate.setModeline(modeline); - } - - @Override - public Boolean isDevConsole() { - return delegate.isDevConsole(); - } - - @Override - public void setDevConsole(Boolean loadDevConsoles) { - delegate.setDevConsole(loadDevConsoles); - } - - @Override - public Boolean isDumpRoutes() { - return delegate.isDumpRoutes(); - } - - @Override - public void setDumpRoutes(Boolean dumpRoutes) { - delegate.setDumpRoutes(dumpRoutes); - } - - @Override - public Boolean isUseMDCLogging() { - return delegate.isUseMDCLogging(); - } - - @Override - public void setUseMDCLogging(Boolean useMDCLogging) { - delegate.setUseMDCLogging(useMDCLogging); - } - - @Override - public String getMDCLoggingKeysPattern() { - return delegate.getMDCLoggingKeysPattern(); - } - - @Override - public void setMDCLoggingKeysPattern(String pattern) { - delegate.setMDCLoggingKeysPattern(pattern); - } - - @Override - public Boolean isUseDataType() { - return delegate.isUseDataType(); - } - - @Override - public void setUseDataType(Boolean useDataType) { - delegate.setUseDataType(useDataType); - } - - @Override - public Boolean isUseBreadcrumb() { - return delegate.isUseBreadcrumb(); - } - - @Override - public void setUseBreadcrumb(Boolean useBreadcrumb) { - delegate.setUseBreadcrumb(useBreadcrumb); - } - - @Override - public StreamCachingStrategy getStreamCachingStrategy() { - return delegate.getStreamCachingStrategy(); - } - - @Override - public void setStreamCachingStrategy(StreamCachingStrategy streamCachingStrategy) { - delegate.setStreamCachingStrategy(streamCachingStrategy); - } - - @Override - public RuntimeEndpointRegistry getRuntimeEndpointRegistry() { - return delegate.getRuntimeEndpointRegistry(); - } - - @Override - public void setRuntimeEndpointRegistry(RuntimeEndpointRegistry runtimeEndpointRegistry) { - delegate.setRuntimeEndpointRegistry(runtimeEndpointRegistry); - } - - @Override - public void setSSLContextParameters(SSLContextParameters sslContextParameters) { - delegate.setSSLContextParameters(sslContextParameters); - } - - @Override - public SSLContextParameters getSSLContextParameters() { - return delegate.getSSLContextParameters(); - } - - @Override - public void setStartupSummaryLevel(StartupSummaryLevel startupSummaryLevel) { - delegate.setStartupSummaryLevel(startupSummaryLevel); - } - - @Override - public StartupSummaryLevel getStartupSummaryLevel() { - return delegate.getStartupSummaryLevel(); - } - - @Override - public void setStreamCaching(Boolean cache) { - delegate.setStreamCaching(cache); - } - - @Override - public Boolean isStreamCaching() { - return delegate.isStreamCaching(); - } - - @Override - public void setTracing(Boolean tracing) { - delegate.setTracing(tracing); - } - - @Override - public Boolean isTracing() { - return delegate.isTracing(); - } - - @Override - public String getTracingPattern() { - return delegate.getTracingPattern(); - } - - @Override - public void setTracingPattern(String tracePattern) { - delegate.setTracingPattern(tracePattern); - } - - @Override - public String getTracingLoggingFormat() { - return delegate.getTracingLoggingFormat(); - } - - @Override - public void setTracingLoggingFormat(String format) { - delegate.setTracingLoggingFormat(format); - } - - @Override - public void setBacklogTracing(Boolean backlogTrace) { - delegate.setBacklogTracing(backlogTrace); - } - - @Override - public Boolean isBacklogTracing() { - return delegate.isBacklogTracing(); - } - - @Override - public void setDebugging(Boolean debugging) { - delegate.setDebugging(debugging); - } - - @Override - public Boolean isDebugging() { - return delegate.isDebugging(); - } - - @Override - public void setMessageHistory(Boolean messageHistory) { - delegate.setMessageHistory(messageHistory); - } - - @Override - public Boolean isMessageHistory() { - return delegate.isMessageHistory(); - } - - @Override - public void setLogMask(Boolean logMask) { - delegate.setLogMask(logMask); - } - - @Override - public Boolean isLogMask() { - return delegate.isLogMask(); - } - - @Override - public void setLogExhaustedMessageBody(Boolean logExhaustedMessageBody) { - delegate.setLogExhaustedMessageBody(logExhaustedMessageBody); - } - - @Override - public Boolean isLogExhaustedMessageBody() { - return delegate.isLogExhaustedMessageBody(); - } - - @Override - public void setDelayer(Long delay) { - delegate.setDelayer(delay); - } - - @Override - public Long getDelayer() { - return delegate.getDelayer(); - } - - @Override - public void setAutoStartup(Boolean autoStartup) { - delegate.setAutoStartup(autoStartup); - } - - @Override - public Boolean isAutoStartup() { - return delegate.isAutoStartup(); - } - - @Override - public void setShutdownRoute(ShutdownRoute shutdownRoute) { - delegate.setShutdownRoute(shutdownRoute); - } - - @Override - public ShutdownRoute getShutdownRoute() { - return delegate.getShutdownRoute(); - } - - @Override - public void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask) { - delegate.setShutdownRunningTask(shutdownRunningTask); - } - - @Override - public ShutdownRunningTask getShutdownRunningTask() { - return delegate.getShutdownRunningTask(); - } - - @Override - public void setAllowUseOriginalMessage(Boolean allowUseOriginalMessage) { - delegate.setAllowUseOriginalMessage(allowUseOriginalMessage); - } - - @Override - public Boolean isAllowUseOriginalMessage() { - return delegate.isAllowUseOriginalMessage(); - } - - @Override - public Boolean isCaseInsensitiveHeaders() { - return delegate.isCaseInsensitiveHeaders(); - } - - @Override - public void setCaseInsensitiveHeaders(Boolean caseInsensitiveHeaders) { - delegate.setCaseInsensitiveHeaders(caseInsensitiveHeaders); - } - - @Override - public Boolean isAutowiredEnabled() { - return delegate.isAutowiredEnabled(); - } - - @Override - public void setAutowiredEnabled(Boolean autowiredEnabled) { - delegate.setAutowiredEnabled(autowiredEnabled); - } - - @Override - public void removeRouteTemplates(String pattern) throws Exception { - delegate.removeRouteTemplates(pattern); - } - - @Override - public ExtendedCamelContext getCamelContextExtension() { - return delegate.getCamelContextExtension(); - } - - // - // CatalogCamelContext - // - - protected CatalogCamelContext getCatalogCamelContext() { - return (CatalogCamelContext) delegate; - } - - @Override - public String getComponentParameterJsonSchema(String componentName) throws IOException { - return getCatalogCamelContext().getComponentParameterJsonSchema(componentName); - } - - @Override - public String getDataFormatParameterJsonSchema(String dataFormatName) throws IOException { - return getCatalogCamelContext().getDataFormatParameterJsonSchema(dataFormatName); - } - - @Override - public String getLanguageParameterJsonSchema(String languageName) throws IOException { - return getCatalogCamelContext().getLanguageParameterJsonSchema(languageName); - } - - @Override - public String getEipParameterJsonSchema(String eipName) throws IOException { - return getCatalogCamelContext().getEipParameterJsonSchema(eipName); - } - - // - // ModelCamelContext - // - - protected ModelCamelContext getModelCamelContext() { - return (ModelCamelContext) delegate; - } - - @Override - public void addModelLifecycleStrategy(ModelLifecycleStrategy modelLifecycleStrategy) { - getModelCamelContext().addModelLifecycleStrategy(modelLifecycleStrategy); - } - - @Override - public List<ModelLifecycleStrategy> getModelLifecycleStrategies() { - return getModelCamelContext().getModelLifecycleStrategies(); - } - - @Override - public void addRouteConfiguration(RouteConfigurationDefinition routesConfiguration) { - getModelCamelContext().addRouteConfiguration(routesConfiguration); - } - - @Override - public void addRouteConfigurations(List<RouteConfigurationDefinition> routesConfigurations) { - getModelCamelContext().addRouteConfigurations(routesConfigurations); - } - - @Override - public List<RouteConfigurationDefinition> getRouteConfigurationDefinitions() { - return getModelCamelContext().getRouteConfigurationDefinitions(); - } - - @Override - public void removeRouteConfiguration(RouteConfigurationDefinition routeConfigurationDefinition) throws Exception { - getModelCamelContext().removeRouteConfiguration(routeConfigurationDefinition); - } - - @Override - public RouteConfigurationDefinition getRouteConfigurationDefinition(String id) { - return getModelCamelContext().getRouteConfigurationDefinition(id); - } - - @Override - public List<RouteDefinition> getRouteDefinitions() { - return getModelCamelContext().getRouteDefinitions(); - } - - @Override - public RouteDefinition getRouteDefinition(String id) { - return getModelCamelContext().getRouteDefinition(id); - } - - @Override - public void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception { - getModelCamelContext().addRouteDefinitions(routeDefinitions); - } - - @Override - public void addRouteDefinition(RouteDefinition routeDefinition) throws Exception { - getModelCamelContext().addRouteDefinition(routeDefinition); - } - - @Override - public void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception { - getModelCamelContext().removeRouteDefinitions(routeDefinitions); - } - - @Override - public void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception { - getModelCamelContext().removeRouteDefinition(routeDefinition); - } - - @Override - public List<RouteTemplateDefinition> getRouteTemplateDefinitions() { - return getModelCamelContext().getRouteTemplateDefinitions(); - } - - @Override - public RouteTemplateDefinition getRouteTemplateDefinition(String id) { - return getModelCamelContext().getRouteTemplateDefinition(id); - } - - @Override - public void addRouteTemplateDefinitions(Collection<RouteTemplateDefinition> routeTemplateDefinitions) throws Exception { - getModelCamelContext().addRouteTemplateDefinitions(routeTemplateDefinitions); - } - - @Override - public void addRouteTemplateDefinition(RouteTemplateDefinition routeTemplateDefinition) throws Exception { - getModelCamelContext().addRouteTemplateDefinition(routeTemplateDefinition); - } - - @Override - public void removeRouteTemplateDefinitions(Collection<RouteTemplateDefinition> routeTemplateDefinitions) throws Exception { - getModelCamelContext().removeRouteTemplateDefinitions(routeTemplateDefinitions); - } - - @Override - public void removeRouteTemplateDefinition(RouteTemplateDefinition routeTemplateDefinition) throws Exception { - getModelCamelContext().removeRouteTemplateDefinition(routeTemplateDefinition); - } - - @Override - public void addRouteTemplateDefinitionConverter(String templateIdPattern, RouteTemplateDefinition.Converter converter) { - getModelCamelContext().addRouteTemplateDefinitionConverter(templateIdPattern, converter); - } - - @Override - public String addRouteFromTemplate(String routeId, String routeTemplateId, Map<String, Object> parameters) - throws Exception { - return getModelCamelContext().addRouteFromTemplate(routeId, routeTemplateId, parameters); - } - - @Override - public String addRouteFromTemplate(String routeId, String routeTemplateId, String prefixId, Map<String, Object> parameters) - throws Exception { - return getModelCamelContext().addRouteFromTemplate(routeId, routeTemplateId, prefixId, parameters); - } - - @Override - public String addRouteFromTemplate( - String routeId, String routeTemplateId, String prefixId, RouteTemplateContext routeTemplateContext) - throws Exception { - return getModelCamelContext().addRouteFromTemplate(routeId, routeTemplateId, prefixId, routeTemplateContext); - } - - @Override - public void addRouteFromTemplatedRoute(TemplatedRouteDefinition templatedRouteDefinition) - throws Exception { - getModelCamelContext().addRouteFromTemplatedRoute(templatedRouteDefinition); - } - - @Override - public void removeRouteTemplateDefinitions(String pattern) throws Exception { - getModelCamelContext().removeRouteTemplateDefinitions(pattern); - } - - @Override - public List<RestDefinition> getRestDefinitions() { - return getModelCamelContext().getRestDefinitions(); - } - - @Override - public void addRestDefinitions(Collection<RestDefinition> restDefinitions, boolean addToRoutes) throws Exception { - getModelCamelContext().addRestDefinitions(restDefinitions, addToRoutes); - } - - @Override - public void setDataFormats(Map<String, DataFormatDefinition> dataFormats) { - getModelCamelContext().setDataFormats(dataFormats); - } - - @Override - public Map<String, DataFormatDefinition> getDataFormats() { - return getModelCamelContext().getDataFormats(); - } - - @Override - public DataFormatDefinition resolveDataFormatDefinition(String name) { - return getModelCamelContext().resolveDataFormatDefinition(name); - } - - @Override - public ProcessorDefinition<?> getProcessorDefinition(String id) { - return getModelCamelContext().getProcessorDefinition(id); - } - - @Override - public <T extends ProcessorDefinition<T>> T getProcessorDefinition(String id, Class<T> type) { - return getModelCamelContext().getProcessorDefinition(id, type); - } - - @Override - public void setValidators(List<ValidatorDefinition> validators) { - getModelCamelContext().setValidators(validators); - } - - @Override - public Resilience4jConfigurationDefinition getResilience4jConfiguration(String id) { - return getModelCamelContext().getResilience4jConfiguration(id); - } - - @Override - public void setResilience4jConfiguration(Resilience4jConfigurationDefinition configuration) { - getModelCamelContext().setResilience4jConfiguration(configuration); - } - - @Override - public void setResilience4jConfigurations(List<Resilience4jConfigurationDefinition> configurations) { - getModelCamelContext().setResilience4jConfigurations(configurations); - } - - @Override - public void addResilience4jConfiguration(String id, Resilience4jConfigurationDefinition configuration) { - getModelCamelContext().addResilience4jConfiguration(id, configuration); - } - - @Override - public FaultToleranceConfigurationDefinition getFaultToleranceConfiguration(String id) { - return getModelCamelContext().getFaultToleranceConfiguration(id); - } - - @Override - public void setFaultToleranceConfiguration(FaultToleranceConfigurationDefinition configuration) { - getModelCamelContext().setFaultToleranceConfiguration(configuration); - } - - @Override - public void setFaultToleranceConfigurations(List<FaultToleranceConfigurationDefinition> configurations) { - getModelCamelContext().setFaultToleranceConfigurations(configurations); - } - - @Override - public void addFaultToleranceConfiguration(String id, FaultToleranceConfigurationDefinition configuration) { - getModelCamelContext().addFaultToleranceConfiguration(id, configuration); - } - - @Override - public List<ValidatorDefinition> getValidators() { - return getModelCamelContext().getValidators(); - } - - @Override - public void setTransformers(List<TransformerDefinition> transformers) { - getModelCamelContext().setTransformers(transformers); - } - - @Override - public List<TransformerDefinition> getTransformers() { - return getModelCamelContext().getTransformers(); - } - - @Override - public ServiceCallConfigurationDefinition getServiceCallConfiguration(String serviceName) { - return getModelCamelContext().getServiceCallConfiguration(serviceName); - } - - @Override - public void setServiceCallConfiguration(ServiceCallConfigurationDefinition configuration) { - getModelCamelContext().setServiceCallConfiguration(configuration); - } - - @Override - public void setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> configurations) { - getModelCamelContext().setServiceCallConfigurations(configurations); - } - - @Override - public void addServiceCallConfiguration(String serviceName, ServiceCallConfigurationDefinition configuration) { - getModelCamelContext().addServiceCallConfiguration(serviceName, configuration); - } - - @Override - public void startRouteDefinitions() throws Exception { - getModelCamelContext().startRouteDefinitions(); - } - - @Override - public void startRouteDefinitions(List<RouteDefinition> routeDefinitions) throws Exception { - getModelCamelContext().startRouteDefinitions(routeDefinitions); - } - - @Override - public void setRouteFilterPattern(String include, String exclude) { - getModelCamelContext().setRouteFilterPattern(include, exclude); - } - - @Override - public void setRouteFilter(Function<RouteDefinition, Boolean> filter) { - getModelCamelContext().setRouteFilter(filter); - } - - @Override - public Function<RouteDefinition, Boolean> getRouteFilter() { - return getModelCamelContext().getRouteFilter(); - } - - @Override - public ModelReifierFactory getModelReifierFactory() { - return getModelCamelContext().getModelReifierFactory(); - } - - @Override - public void setModelReifierFactory(ModelReifierFactory modelReifierFactory) { - getModelCamelContext().setModelReifierFactory(modelReifierFactory); - } - - @Override - public Expression createExpression(ExpressionDefinition definition) { - return getModelCamelContext().createExpression(definition); - } - - @Override - public Predicate createPredicate(ExpressionDefinition definition) { - return getModelCamelContext().createPredicate(definition); - } - - @Override - public void registerValidator(ValidatorDefinition validator) { - getModelCamelContext().registerValidator(validator); - } - - @Override - public void registerTransformer(TransformerDefinition transformer) { - getModelCamelContext().registerTransformer(transformer); - } - - // - // Immutable - // - - public void init() { - if (delegate instanceof LightweightRuntimeCamelContext) { - return; - } - delegate.init(); - for (Route route : delegate.getRoutes()) { - route.clearRouteModel(); - } - delegate = new LightweightRuntimeCamelContext(this, delegate); - } - - public void startImmutable() { - delegate.start(); - } - -} diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContextExtension.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContextExtension.java deleted file mode 100644 index a93330ad9c9..00000000000 --- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContextExtension.java +++ /dev/null @@ -1,600 +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.camel.impl.lw; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; - -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.ErrorHandlerFactory; -import org.apache.camel.ExchangeConstantProvider; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.LoggingLevel; -import org.apache.camel.NoSuchEndpointException; -import org.apache.camel.Processor; -import org.apache.camel.ResolveEndpointFailedException; -import org.apache.camel.Route; -import org.apache.camel.Service; -import org.apache.camel.ServiceStatus; -import org.apache.camel.spi.BootstrapCloseable; -import org.apache.camel.spi.EndpointStrategy; -import org.apache.camel.spi.EndpointUriFactory; -import org.apache.camel.spi.ExchangeFactory; -import org.apache.camel.spi.ExchangeFactoryManager; -import org.apache.camel.spi.FactoryFinder; -import org.apache.camel.spi.HeadersMapFactory; -import org.apache.camel.spi.InterceptStrategy; -import org.apache.camel.spi.LogListener; -import org.apache.camel.spi.ManagementMBeanAssembler; -import org.apache.camel.spi.NormalizedEndpointUri; -import org.apache.camel.spi.PluginManager; -import org.apache.camel.spi.ProcessorExchangeFactory; -import org.apache.camel.spi.PropertiesComponent; -import org.apache.camel.spi.ReactiveExecutor; -import org.apache.camel.spi.Registry; -import org.apache.camel.spi.RouteController; -import org.apache.camel.spi.RouteStartupOrder; -import org.apache.camel.spi.StartupStepRecorder; -import org.apache.camel.spi.SupervisingRouteController; -import org.apache.camel.support.NormalizedUri; -import org.apache.camel.util.StringHelper; -import org.apache.camel.util.URISupport; - -class LightweightCamelContextExtension implements ExtendedCamelContext { - private final CamelContext camelContext; - - public LightweightCamelContextExtension(CamelContext camelContext) { - this.camelContext = camelContext; - } - - @Override - public byte getStatusPhase() { - return camelContext.getCamelContextExtension().getStatusPhase(); - } - - @Override - public void disposeModel() { - // noop - } - - @Override - public Registry getRegistry() { - return camelContext.getCamelContextExtension().getRegistry(); - } - - @Override - public void setRegistry(Registry registry) { - throw new UnsupportedOperationException(); - } - - @Override - public String getName() { - return camelContext.getCamelContextExtension().getName(); - } - - @Override - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public String getDescription() { - return camelContext.getCamelContextExtension().getDescription(); - } - - @Override - public void setDescription(String description) { - throw new UnsupportedOperationException(); - } - - @Override - public void addBootstrap(BootstrapCloseable bootstrap) { - } - - @Override - public List<Service> getServices() { - return null; - } - - @Override - public String resolvePropertyPlaceholders(String text, boolean keepUnresolvedOptional) { - if (text != null && text.contains(PropertiesComponent.PREFIX_TOKEN)) { - // the parser will throw exception if property key was not found - return camelContext.getPropertiesComponent().parseUri(text, keepUnresolvedOptional); - } - // is the value a known field (currently we only support - // constants from Exchange.class) - if (text != null && text.startsWith("Exchange.")) { - String field = StringHelper.after(text, "Exchange."); - String constant = ExchangeConstantProvider.lookup(field); - if (constant != null) { - return constant; - } else { - throw new IllegalArgumentException("Constant field with name: " + field + " not found on Exchange.class"); - } - } - // return original text as is - return text; - } - - @Override - public String getBasePackageScan() { - return camelContext.getCamelContextExtension().getBasePackageScan(); - } - - @Override - public void setBasePackageScan(String basePackageScan) { - throw new UnsupportedOperationException(); - } - - @Override - public Endpoint getPrototypeEndpoint(String uri) { - throw new UnsupportedOperationException(); - } - - @Override - public Endpoint getPrototypeEndpoint(NormalizedEndpointUri uri) { - throw new UnsupportedOperationException(); - } - - @Override - public Endpoint hasEndpoint(NormalizedEndpointUri uri) { - return camelContext.getEndpointRegistry().get(uri); - } - - @Override - public Endpoint getEndpoint(NormalizedEndpointUri uri) { - return doGetEndpoint(uri.getUri(), true, false); - } - - @Override - public Endpoint getEndpoint(NormalizedEndpointUri uri, Map<String, Object> parameters) { - return doGetEndpoint(uri.getUri(), parameters, true); - } - - @Override - public NormalizedEndpointUri normalizeUri(String uri) { - try { - uri = resolvePropertyPlaceholders(uri, false); - return NormalizedUri.newNormalizedUri(uri, false); - } catch (Exception e) { - throw new ResolveEndpointFailedException(uri, e); - } - } - - @Override - public List<RouteStartupOrder> getRouteStartupOrder() { - throw new UnsupportedOperationException(); - } - - @Override - public ManagementMBeanAssembler getManagementMBeanAssembler() { - throw new UnsupportedOperationException(); - } - - @Override - public ErrorHandlerFactory getErrorHandlerFactory() { - throw new UnsupportedOperationException(); - } - - @Override - public void setErrorHandlerFactory(ErrorHandlerFactory errorHandlerFactory) { - throw new UnsupportedOperationException(); - } - - @Override - public FactoryFinder getDefaultFactoryFinder() { - throw new UnsupportedOperationException(); - } - - @Override - public FactoryFinder getBootstrapFactoryFinder() { - throw new UnsupportedOperationException(); - } - - @Override - public void setBootstrapFactoryFinder(FactoryFinder factoryFinder) { - throw new UnsupportedOperationException(); - } - - @Override - public FactoryFinder getBootstrapFactoryFinder(String path) { - throw new UnsupportedOperationException(); - } - - @Override - public FactoryFinder getFactoryFinder(String path) { - throw new UnsupportedOperationException(); - } - - @Override - public List<InterceptStrategy> getInterceptStrategies() { - throw new UnsupportedOperationException(); - } - - @Override - public Set<LogListener> getLogListeners() { - throw new UnsupportedOperationException(); - } - - @Override - public HeadersMapFactory getHeadersMapFactory() { - return camelContext.getCamelContextExtension().getHeadersMapFactory(); - } - - @Override - public void setHeadersMapFactory(HeadersMapFactory factory) { - throw new UnsupportedOperationException(); - } - - @Override - public ExchangeFactory getExchangeFactory() { - return camelContext.getCamelContextExtension().getExchangeFactory(); - } - - @Override - public ExchangeFactoryManager getExchangeFactoryManager() { - return camelContext.getCamelContextExtension().getExchangeFactoryManager(); - } - - @Override - public void setExchangeFactoryManager(ExchangeFactoryManager exchangeFactoryManager) { - throw new UnsupportedOperationException(); - } - - @Override - public void setExchangeFactory(ExchangeFactory exchangeFactory) { - throw new UnsupportedOperationException(); - } - - @Override - public ProcessorExchangeFactory getProcessorExchangeFactory() { - return camelContext.getCamelContextExtension().getProcessorExchangeFactory(); - } - - @Override - public void setProcessorExchangeFactory(ProcessorExchangeFactory processorExchangeFactory) { - throw new UnsupportedOperationException(); - } - - @Override - public ReactiveExecutor getReactiveExecutor() { - return camelContext.getCamelContextExtension().getReactiveExecutor(); - } - - @Override - public void setReactiveExecutor(ReactiveExecutor reactiveExecutor) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isEventNotificationApplicable() { - return camelContext.getCamelContextExtension().isEventNotificationApplicable(); - } - - @Override - public void setEventNotificationApplicable(boolean eventNotificationApplicable) { - throw new UnsupportedOperationException(); - } - - @Override - public void addRoute(Route route) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeRoute(Route route) { - throw new UnsupportedOperationException(); - } - - @Override - public Processor createErrorHandler(Route route, Processor processor) throws Exception { - // TODO: need to revisit this in order to support dynamic endpoints uri - throw new UnsupportedOperationException(); - } - - @Override - public void setupRoutes(boolean done) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isSetupRoutes() { - return false; - } - - @Override - public void addInterceptStrategy(InterceptStrategy interceptStrategy) { - throw new UnsupportedOperationException(); - } - - @Override - public void setupManagement(Map<String, Object> options) { - throw new UnsupportedOperationException(); - } - - @Override - public void addLogListener(LogListener listener) { - throw new UnsupportedOperationException(); - } - - @Override - public void registerEndpointCallback(EndpointStrategy strategy) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLightweight(boolean lightweight) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isLightweight() { - return true; - } - - @Override - public String getTestExcludeRoutes() { - return null; - } - - @Override - public RouteController getInternalRouteController() { - return new RouteController() { - @Override - public LoggingLevel getLoggingLevel() { - throw new UnsupportedOperationException(); - } - - @Override - public void setLoggingLevel(LoggingLevel loggingLevel) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isSupervising() { - return false; - } - - @Override - public SupervisingRouteController supervising() { - throw new UnsupportedOperationException(); - } - - @Override - public <T extends RouteController> T adapt(Class<T> type) { - return type.cast(this); - } - - @Override - public Collection<Route> getControlledRoutes() { - return camelContext.getRoutes(); - } - - @Override - public void startAllRoutes() throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void stopAllRoutes() throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void removeAllRoutes() throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isStartingRoutes() { - return false; - } - - @Override - public void reloadAllRoutes() throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isReloadingRoutes() { - return false; - } - - @Override - public ServiceStatus getRouteStatus(String routeId) { - return ServiceStatus.Started; - } - - @Override - public void startRoute(String routeId) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void stopRoute(String routeId) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void stopRoute(String routeId, Throwable cause) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) - throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void suspendRoute(String routeId) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void resumeRoute(String routeId) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public CamelContext getCamelContext() { - throw new UnsupportedOperationException(); - } - - @Override - public void setCamelContext(CamelContext camelContext) { - throw new UnsupportedOperationException(); - } - - @Override - public void start() { - throw new UnsupportedOperationException(); - } - - @Override - public void stop() { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public EndpointUriFactory getEndpointUriFactory(String scheme) { - throw new UnsupportedOperationException(); - } - - @Override - public StartupStepRecorder getStartupStepRecorder() { - throw new UnsupportedOperationException(); - } - - @Override - public void setStartupStepRecorder(StartupStepRecorder startupStepRecorder) { - throw new UnsupportedOperationException(); - } - - @Override - public PluginManager getPluginManager() { - return camelContext.getCamelContextExtension().getPluginManager(); - } - - @Override - public <T> T getContextPlugin(Class<T> type) { - return camelContext.getCamelContextExtension().getPluginManager().getContextPlugin(type); - } - - @Override - public <T> void addContextPlugin(Class<T> type, T module) { - camelContext.getCamelContextExtension().addContextPlugin(type, module); - } - - @Override - public <T> void lazyAddContextPlugin(Class<T> type, Supplier<T> module) { - camelContext.getCamelContextExtension().lazyAddContextPlugin(type, module); - } - - Endpoint doGetEndpoint(String uri, boolean normalized, boolean prototype) { - StringHelper.notEmpty(uri, "uri"); - // in case path has property placeholders then try to let property - // component resolve those - if (!normalized) { - try { - uri = camelContext.getCamelContextExtension().resolvePropertyPlaceholders(uri, false); - } catch (Exception e) { - throw new ResolveEndpointFailedException(uri, e); - } - } - // normalize uri so we can do endpoint hits with minor mistakes and - // parameters is not in the same order - if (!normalized) { - uri = normalizeEndpointUri(uri); - } - Endpoint answer = null; - if (!prototype) { - // use optimized method to get the endpoint uri - NormalizedUri key = NormalizedUri.newNormalizedUri(uri, true); - // only lookup and reuse existing endpoints if not prototype scoped - answer = camelContext.getEndpointRegistry().get(key); - } - // unknown scheme - if (answer == null) { - throw new NoSuchEndpointException(uri); - } - return answer; - } - - protected Endpoint doGetEndpoint(String uri, Map<String, Object> parameters, boolean normalized) { - StringHelper.notEmpty(uri, "uri"); - // in case path has property placeholders then try to let property - // component resolve those - if (!normalized) { - try { - uri = resolvePropertyPlaceholders(uri, false); - } catch (Exception e) { - throw new ResolveEndpointFailedException(uri, e); - } - } - // normalize uri so we can do endpoint hits with minor mistakes and - // parameters is not in the same order - if (!normalized) { - uri = normalizeEndpointUri(uri); - } - Endpoint answer; - String scheme = null; - // use optimized method to get the endpoint uri - NormalizedUri key = NormalizedUri.newNormalizedUri(uri, true); - answer = camelContext.getEndpointRegistry().get(key); - // unknown scheme - if (answer == null) { - throw new ResolveEndpointFailedException(uri, "No component found with scheme: " + scheme); - } - return answer; - } - - /** - * Normalize uri so we can do endpoint hits with minor mistakes and parameters is not in the same order. - * - * @param uri the uri - * @return normalized uri - * @throws ResolveEndpointFailedException if uri cannot be normalized - */ - static String normalizeEndpointUri(String uri) { - try { - uri = URISupport.normalizeUri(uri); - } catch (Exception e) { - throw new ResolveEndpointFailedException(uri, e); - } - return uri; - } -} diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java deleted file mode 100644 index 3989b7273bc..00000000000 --- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java +++ /dev/null @@ -1,1350 +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.camel.impl.lw; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.CatalogCamelContext; -import org.apache.camel.Component; -import org.apache.camel.ConsumerTemplate; -import org.apache.camel.Endpoint; -import org.apache.camel.Experimental; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.FluentProducerTemplate; -import org.apache.camel.GlobalEndpointConfiguration; -import org.apache.camel.IsSingleton; -import org.apache.camel.NoSuchEndpointException; -import org.apache.camel.NoSuchLanguageException; -import org.apache.camel.Processor; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.Route; -import org.apache.camel.RouteConfigurationsBuilder; -import org.apache.camel.RouteTemplateContext; -import org.apache.camel.RoutesBuilder; -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.Service; -import org.apache.camel.ServiceStatus; -import org.apache.camel.ShutdownRoute; -import org.apache.camel.ShutdownRunningTask; -import org.apache.camel.StartupListener; -import org.apache.camel.StartupSummaryLevel; -import org.apache.camel.TypeConverter; -import org.apache.camel.ValueHolder; -import org.apache.camel.impl.converter.CoreTypeConverterRegistry; -import org.apache.camel.impl.engine.DefaultComponentResolver; -import org.apache.camel.impl.engine.DefaultDataFormatResolver; -import org.apache.camel.impl.engine.DefaultLanguageResolver; -import org.apache.camel.spi.CamelContextNameStrategy; -import org.apache.camel.spi.ClassResolver; -import org.apache.camel.spi.DataFormat; -import org.apache.camel.spi.DataType; -import org.apache.camel.spi.Debugger; -import org.apache.camel.spi.EndpointRegistry; -import org.apache.camel.spi.ExecutorServiceManager; -import org.apache.camel.spi.InflightRepository; -import org.apache.camel.spi.Injector; -import org.apache.camel.spi.InterceptSendToEndpoint; -import org.apache.camel.spi.Language; -import org.apache.camel.spi.LifecycleStrategy; -import org.apache.camel.spi.ManagementNameStrategy; -import org.apache.camel.spi.ManagementStrategy; -import org.apache.camel.spi.MessageHistoryFactory; -import org.apache.camel.spi.PropertiesComponent; -import org.apache.camel.spi.Registry; -import org.apache.camel.spi.RestConfiguration; -import org.apache.camel.spi.RestRegistry; -import org.apache.camel.spi.RouteController; -import org.apache.camel.spi.RoutePolicyFactory; -import org.apache.camel.spi.RuntimeEndpointRegistry; -import org.apache.camel.spi.ShutdownStrategy; -import org.apache.camel.spi.StreamCachingStrategy; -import org.apache.camel.spi.Tracer; -import org.apache.camel.spi.Transformer; -import org.apache.camel.spi.TransformerRegistry; -import org.apache.camel.spi.TypeConverterRegistry; -import org.apache.camel.spi.UuidGenerator; -import org.apache.camel.spi.Validator; -import org.apache.camel.spi.ValidatorRegistry; -import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.NormalizedUri; -import org.apache.camel.support.PluginHelper; -import org.apache.camel.support.jsse.SSLContextParameters; -import org.apache.camel.util.IOHelper; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.TimeUtils; -import org.apache.camel.vault.VaultConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Experimental -public class LightweightRuntimeCamelContext implements CamelContext, CatalogCamelContext { - - private static final Logger LOG = LoggerFactory.getLogger(LightweightRuntimeCamelContext.class); - - private final CamelContext reference; - private final Registry registry; - private final CoreTypeConverterRegistry typeConverter; - private final UuidGenerator uuidGenerator; - private final EndpointRegistry<? extends ValueHolder<String>> endpoints; - private final Map<String, Component> components; - private final Map<String, Language> languages; - private final PropertiesComponent propertiesComponent; - private final ExecutorServiceManager executorServiceManager; - private final ShutdownStrategy shutdownStrategy; - private final ClassLoader applicationContextClassLoader; - private final RouteController routeController; - private final InflightRepository inflightRepository; - private final Injector injector; - private final ClassResolver classResolver; - private final Map<String, String> globalOptions; - private final String name; - private final boolean useDataType; - private final boolean useBreadcrumb; - private final boolean dumpRoutes; - private final String mdcLoggingKeysPattern; - private final boolean useMDCLogging; - private final List<Route> routes; - private final boolean messageHistory; - private final boolean allowUseOriginalMessage; - private final boolean logExhaustedMessageBody; - private final String version; - private final LightweightCamelContextExtension lwCamelContextExtension = new LightweightCamelContextExtension(this); - private Date startDate; - private StartupSummaryLevel startupSummaryLevel; - - LightweightRuntimeCamelContext(CamelContext reference, CamelContext context) { - this.reference = reference; - registry = context.getRegistry(); - typeConverter = new CoreTypeConverterRegistry(context.getTypeConverterRegistry()); - routes = Collections.unmodifiableList(context.getRoutes()); - uuidGenerator = context.getUuidGenerator(); - endpoints = context.getEndpointRegistry(); - components = context.getComponentNames().stream().collect(Collectors.toMap(s -> s, context::hasComponent)); - languages = context.getLanguageNames().stream().collect(Collectors.toMap(s -> s, context::resolveLanguage)); - propertiesComponent = context.getPropertiesComponent(); - executorServiceManager = context.getExecutorServiceManager(); - shutdownStrategy = context.getShutdownStrategy(); - applicationContextClassLoader = context.getApplicationContextClassLoader(); - routeController = context.getRouteController(); - inflightRepository = context.getInflightRepository(); - globalOptions = context.getGlobalOptions(); - injector = context.getInjector(); - classResolver = context.getClassResolver(); - name = context.getName(); - useDataType = context.isUseDataType(); - useBreadcrumb = context.isUseBreadcrumb(); - dumpRoutes = context.isDumpRoutes(); - mdcLoggingKeysPattern = context.getMDCLoggingKeysPattern(); - useMDCLogging = context.isUseMDCLogging(); - messageHistory = context.isMessageHistory(); - allowUseOriginalMessage = context.isAllowUseOriginalMessage(); - logExhaustedMessageBody = context.isLogExhaustedMessageBody(); - version = context.getVersion(); - startupSummaryLevel = context.getStartupSummaryLevel(); - } - - // - // Lifecycle - // - @Override - public boolean isStarted() { - return false; - } - - @Override - public boolean isStarting() { - return false; - } - - @Override - public boolean isStopped() { - return false; - } - - @Override - public boolean isStopping() { - return false; - } - - @Override - public boolean isSuspended() { - return false; - } - - @Override - public boolean isRunAllowed() { - return false; - } - - @Override - public boolean isSuspending() { - return false; - } - - @Override - public void build() { - throw new UnsupportedOperationException(); - } - - @Override - public void init() { - throw new UnsupportedOperationException(); - } - - @Override - public void suspend() { - throw new UnsupportedOperationException(); - } - - @Override - public void resume() { - throw new UnsupportedOperationException(); - } - - @Override - public void start() { - startDate = new Date(); - LOG.info("Apache Camel {} ({}) is starting", getVersion(), lwCamelContextExtension.getName()); - for (Route route : routes) { - route.getConsumer().start(); - } - if (LOG.isInfoEnabled()) { - long l = System.currentTimeMillis() - startDate.getTime(); - LOG.info("Apache Camel {} ({}) {} routes started in {}", - getVersion(), lwCamelContextExtension.getName(), routes.size(), TimeUtils.printDuration(l, true)); - } - } - - @Override - public void stop() { - for (Route route : routes) { - route.getConsumer().stop(); - } - } - - @Override - public void shutdown() { - } - - // - // RuntimeConfig - // - - @Override - public void close() throws IOException { - stop(); - } - - @Override - public void setStreamCaching(Boolean cache) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isStreamCaching() { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isTracing() { - throw new UnsupportedOperationException(); - } - - @Override - public String getTracingPattern() { - throw new UnsupportedOperationException(); - } - - @Override - public void setTracingPattern(String tracePattern) { - throw new UnsupportedOperationException(); - } - - @Override - public String getTracingLoggingFormat() { - throw new UnsupportedOperationException(); - } - - @Override - public void setTracingLoggingFormat(String format) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isBacklogTracing() { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isDebugging() { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isMessageHistory() { - return messageHistory; - } - - @Override - public Boolean isLogMask() { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isLogExhaustedMessageBody() { - return logExhaustedMessageBody; - } - - @Override - public Long getDelayer() { - throw new UnsupportedOperationException(); - } - - @Override - public void setDelayer(Long delay) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isAutoStartup() { - throw new UnsupportedOperationException(); - } - - @Override - public ShutdownRoute getShutdownRoute() { - throw new UnsupportedOperationException(); - } - - @Override - public void setShutdownRoute(ShutdownRoute shutdownRoute) { - throw new UnsupportedOperationException(); - } - - @Override - public ShutdownRunningTask getShutdownRunningTask() { - throw new UnsupportedOperationException(); - } - - // - // Model - // - - @Override - public void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask) { - throw new UnsupportedOperationException(); - } - - @Override - public void setAllowUseOriginalMessage(Boolean allowUseOriginalMessage) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isAllowUseOriginalMessage() { - return allowUseOriginalMessage; - } - - @Override - public Boolean isCaseInsensitiveHeaders() { - throw new UnsupportedOperationException(); - } - - @Override - public void setCaseInsensitiveHeaders(Boolean caseInsensitiveHeaders) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isAutowiredEnabled() { - throw new UnsupportedOperationException(); - } - - @Override - public void setAutowiredEnabled(Boolean autowiredEnabled) { - throw new UnsupportedOperationException(); - } - - @Override - public TypeConverterRegistry getTypeConverterRegistry() { - return typeConverter; - } - - @Override - public void setTypeConverterRegistry(TypeConverterRegistry typeConverterRegistry) { - throw new UnsupportedOperationException(); - } - - @Override - public Registry getRegistry() { - return null; - } - - @Override - public UuidGenerator getUuidGenerator() { - return uuidGenerator; - } - - @Override - public void setUuidGenerator(UuidGenerator uuidGenerator) { - throw new UnsupportedOperationException(); - } - - @Override - public ExtendedCamelContext getCamelContextExtension() { - return lwCamelContextExtension; - } - - @Override - public boolean isVetoStarted() { - throw new UnsupportedOperationException(); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getDescription() { - return lwCamelContextExtension.getDescription(); - } - - @Override - public CamelContextNameStrategy getNameStrategy() { - throw new UnsupportedOperationException(); - } - - @Override - public void setNameStrategy(CamelContextNameStrategy nameStrategy) { - throw new UnsupportedOperationException(); - } - - @Override - public ManagementNameStrategy getManagementNameStrategy() { - throw new UnsupportedOperationException(); - } - - @Override - public void setManagementNameStrategy(ManagementNameStrategy nameStrategy) { - throw new UnsupportedOperationException(); - } - - @Override - public String getManagementName() { - throw new UnsupportedOperationException(); - } - - @Override - public void setManagementName(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public String getVersion() { - return version; - } - - @Override - public ServiceStatus getStatus() { - return ServiceStatus.Started; - } - - @Override - public String getUptime() { - long delta = getUptimeMillis(); - if (delta == 0) { - return ""; - } - return TimeUtils.printDuration(delta); - } - - @Override - public long getUptimeMillis() { - if (startDate == null) { - return 0; - } - return new Date().getTime() - startDate.getTime(); - } - - @Override - public Date getStartDate() { - return startDate; - } - - @Override - public void addService(Object object) throws Exception { - } - - @Override - public void addService(Object object, boolean stopOnShutdown) throws Exception { - - } - - @Override - public void addService(Object object, boolean stopOnShutdown, boolean forceStart) throws Exception { - - } - - @Override - public void addPrototypeService(Object object) throws Exception { - - } - - @Override - public boolean removeService(Object object) throws Exception { - return false; - } - - @Override - public boolean hasService(Object object) { - return false; - } - - @Override - public <T> T hasService(Class<T> type) { - return null; - } - - @Override - public <T> Set<T> hasServices(Class<T> type) { - return null; - } - - @Override - public void deferStartService(Object object, boolean stopOnShutdown) throws Exception { - } - - @Override - public void addStartupListener(StartupListener listener) throws Exception { - } - - @Override - public Component hasComponent(String componentName) { - return components.get(componentName); - } - - @Override - public Component getComponent(String componentName) { - return getComponent(name, true, true); - } - - @Override - public Component getComponent(String name, boolean autoCreateComponents) { - return getComponent(name, autoCreateComponents, true); - } - - @Override - public Component getComponent(String name, boolean autoCreateComponents, boolean autoStart) { - return components.get(name); - } - - @Override - public <T extends Component> T getComponent(String name, Class<T> componentType) { - return componentType.cast(hasComponent(name)); - } - - @Override - public Set<String> getComponentNames() { - return Collections.unmodifiableSet(components.keySet()); - } - - @Override - public EndpointRegistry<? extends ValueHolder<String>> getEndpointRegistry() { - return endpoints; - } - - @Override - public Endpoint getEndpoint(String uri) { - return lwCamelContextExtension.doGetEndpoint(uri, false, false); - } - - @Override - public Endpoint getEndpoint(String uri, Map<String, Object> parameters) { - return lwCamelContextExtension.doGetEndpoint(uri, parameters, false); - } - - @Override - public <T extends Endpoint> T getEndpoint(String name, Class<T> endpointType) { - Endpoint endpoint = getEndpoint(name); - if (endpoint == null) { - throw new NoSuchEndpointException(name); - } - if (endpoint instanceof InterceptSendToEndpoint) { - endpoint = ((InterceptSendToEndpoint) endpoint).getOriginalEndpoint(); - } - if (endpointType.isInstance(endpoint)) { - return endpointType.cast(endpoint); - } else { - throw new IllegalArgumentException( - "The endpoint is not of type: " + endpointType + " but is: " + endpoint.getClass().getCanonicalName()); - } - } - - @Override - public Collection<Endpoint> getEndpoints() { - return new ArrayList<>(endpoints.values()); - } - - @Override - public Endpoint hasEndpoint(String uri) { - return endpoints.get(NormalizedUri.newNormalizedUri(uri, false)); - } - - @Override - public GlobalEndpointConfiguration getGlobalEndpointConfiguration() { - throw new UnsupportedOperationException(); - } - - @Override - public RouteController getRouteController() { - return routeController; - } - - @Override - public void setRouteController(RouteController routeController) { - throw new UnsupportedOperationException(); - } - - @Override - public List<Route> getRoutes() { - return routes; - } - - @Override - public int getRoutesSize() { - return routes.size(); - } - - @Override - public Route getRoute(String id) { - throw new UnsupportedOperationException(); - } - - @Override - public Processor getProcessor(String id) { - throw new UnsupportedOperationException(); - } - - @Override - public <T extends Processor> T getProcessor(String id, Class<T> type) { - throw new UnsupportedOperationException(); - } - - @Override - public List<RoutePolicyFactory> getRoutePolicyFactories() { - throw new UnsupportedOperationException(); - } - - @Override - public RestConfiguration getRestConfiguration() { - throw new UnsupportedOperationException(); - } - - @Override - public void setRestConfiguration(RestConfiguration restConfiguration) { - throw new UnsupportedOperationException(); - } - - @Override - public void setVaultConfiguration(VaultConfiguration vaultConfiguration) { - throw new UnsupportedOperationException(); - } - - @Override - public VaultConfiguration getVaultConfiguration() { - throw new UnsupportedOperationException(); - } - - @Override - public RestRegistry getRestRegistry() { - throw new UnsupportedOperationException(); - } - - @Override - public void setRestRegistry(RestRegistry restRegistry) { - throw new UnsupportedOperationException(); - } - - @Override - public TypeConverter getTypeConverter() { - return typeConverter; - } - - @Override - public <T> T getRegistry(Class<T> type) { - return type.cast(registry); - } - - @Override - public Injector getInjector() { - return injector; - } - - @Override - public void setInjector(Injector injector) { - throw new UnsupportedOperationException(); - } - - @Override - public List<LifecycleStrategy> getLifecycleStrategies() { - throw new UnsupportedOperationException(); - } - - @Override - public Language resolveLanguage(String language) throws NoSuchLanguageException { - Language answer; - synchronized (languages) { - answer = languages.get(language); - // check if the language is singleton, if so return the shared - // instance - if (answer instanceof IsSingleton) { - boolean singleton = ((IsSingleton) answer).isSingleton(); - if (singleton) { - return answer; - } - } - // language not known or not singleton, then use resolver - answer = PluginHelper.getLanguageResolver(lwCamelContextExtension).resolveLanguage(language, reference); - // inject CamelContext if aware - if (answer != null) { - CamelContextAware.trySetCamelContext(answer, reference); - if (answer instanceof Service) { - try { - startService((Service) answer); - } catch (Exception e) { - throw RuntimeCamelException.wrapRuntimeCamelException(e); - } - } - languages.put(language, answer); - } - } - return answer; - } - - @Override - public String resolvePropertyPlaceholders(String text) { - return lwCamelContextExtension.resolvePropertyPlaceholders(text, false); - } - - @Override - public PropertiesComponent getPropertiesComponent() { - return propertiesComponent; - } - - @Override - public void setPropertiesComponent(PropertiesComponent propertiesComponent) { - throw new UnsupportedOperationException(); - } - - @Override - public Set<String> getLanguageNames() { - throw new UnsupportedOperationException(); - } - - @Override - public ProducerTemplate createProducerTemplate() { - throw new UnsupportedOperationException(); - } - - @Override - public ProducerTemplate createProducerTemplate(int maximumCacheSize) { - throw new UnsupportedOperationException(); - } - - @Override - public FluentProducerTemplate createFluentProducerTemplate() { - throw new UnsupportedOperationException(); - } - - @Override - public FluentProducerTemplate createFluentProducerTemplate(int maximumCacheSize) { - throw new UnsupportedOperationException(); - } - - @Override - public ConsumerTemplate createConsumerTemplate() { - throw new UnsupportedOperationException(); - } - - @Override - public ConsumerTemplate createConsumerTemplate(int maximumCacheSize) { - throw new UnsupportedOperationException(); - } - - @Override - public DataFormat resolveDataFormat(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public DataFormat createDataFormat(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public Set<String> getDataFormatNames() { - throw new UnsupportedOperationException(); - } - - @Override - public Transformer resolveTransformer(String model) { - throw new UnsupportedOperationException(); - } - - @Override - public Transformer resolveTransformer(DataType from, DataType to) { - throw new UnsupportedOperationException(); - } - - @Override - public TransformerRegistry getTransformerRegistry() { - throw new UnsupportedOperationException(); - } - - @Override - public Validator resolveValidator(DataType type) { - throw new UnsupportedOperationException(); - } - - @Override - public ValidatorRegistry getValidatorRegistry() { - throw new UnsupportedOperationException(); - } - - @Override - public Map<String, String> getGlobalOptions() { - return globalOptions; - } - - @Override - public void setGlobalOptions(Map<String, String> globalOptions) { - throw new UnsupportedOperationException(); - } - - @Override - public String getGlobalOption(String key) { - String value = getGlobalOptions().get(key); - if (ObjectHelper.isNotEmpty(value)) { - try { - value = resolvePropertyPlaceholders(value); - } catch (Exception e) { - throw new RuntimeCamelException("Error getting global option: " + key, e); - } - } - return value; - } - - @Override - public ClassResolver getClassResolver() { - return classResolver; - } - - @Override - public void setClassResolver(ClassResolver resolver) { - throw new UnsupportedOperationException(); - } - - @Override - public ManagementStrategy getManagementStrategy() { - return null; - } - - @Override - public void setManagementStrategy(ManagementStrategy strategy) { - throw new UnsupportedOperationException(); - } - - @Override - public void disableJMX() throws IllegalStateException { - throw new UnsupportedOperationException(); - } - - @Override - public InflightRepository getInflightRepository() { - return inflightRepository; - } - - @Override - public void setInflightRepository(InflightRepository repository) { - throw new UnsupportedOperationException(); - } - - @Override - public void setTracingStandby(boolean tracingStandby) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isTracingStandby() { - return false; - } - - @Override - public void setBacklogTracingStandby(boolean backlogTracingStandby) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isBacklogTracingStandby() { - return false; - } - - // - // ExtendedCamelContext - // - - @Override - public ClassLoader getApplicationContextClassLoader() { - return applicationContextClassLoader; - } - - @Override - public void setApplicationContextClassLoader(ClassLoader classLoader) { - throw new UnsupportedOperationException(); - } - - @Override - public ShutdownStrategy getShutdownStrategy() { - return shutdownStrategy; - } - - @Override - public void setShutdownStrategy(ShutdownStrategy shutdownStrategy) { - throw new UnsupportedOperationException(); - } - - @Override - public ExecutorServiceManager getExecutorServiceManager() { - return executorServiceManager; - } - - @Override - public void setExecutorServiceManager(ExecutorServiceManager executorServiceManager) { - throw new UnsupportedOperationException(); - } - - @Override - public MessageHistoryFactory getMessageHistoryFactory() { - throw new UnsupportedOperationException(); - } - - @Override - public void setMessageHistoryFactory(MessageHistoryFactory messageHistoryFactory) { - throw new UnsupportedOperationException(); - } - - @Override - public Debugger getDebugger() { - throw new UnsupportedOperationException(); - } - - @Override - public void setDebugger(Debugger debugger) { - throw new UnsupportedOperationException(); - } - - @Override - public Tracer getTracer() { - throw new UnsupportedOperationException(); - } - - @Override - public void setTracer(Tracer tracer) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isLoadTypeConverters() { - throw new UnsupportedOperationException(); - } - - @Override - public void setLoadTypeConverters(Boolean loadTypeConverters) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isLoadHealthChecks() { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isDevConsole() { - throw new UnsupportedOperationException(); - } - - @Override - public void setDevConsole(Boolean loadDevConsoles) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isModeline() { - throw new UnsupportedOperationException(); - } - - @Override - public void setModeline(Boolean modeline) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLoadHealthChecks(Boolean loadHealthChecks) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isSourceLocationEnabled() { - throw new UnsupportedOperationException(); - } - - @Override - public void setSourceLocationEnabled(Boolean sourceLocationEnabled) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isTypeConverterStatisticsEnabled() { - throw new UnsupportedOperationException(); - } - - @Override - public void setTypeConverterStatisticsEnabled(Boolean typeConverterStatisticsEnabled) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isDumpRoutes() { - return dumpRoutes; - } - - @Override - public void setDumpRoutes(Boolean dumpRoutes) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isUseMDCLogging() { - return useMDCLogging; - } - - @Override - public void setUseMDCLogging(Boolean useMDCLogging) { - throw new UnsupportedOperationException(); - } - - @Override - public String getMDCLoggingKeysPattern() { - return mdcLoggingKeysPattern; - } - - @Override - public void setMDCLoggingKeysPattern(String pattern) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isUseDataType() { - return useDataType; - } - - @Override - public void setUseDataType(Boolean useDataType) { - throw new UnsupportedOperationException(); - } - - @Override - public Boolean isUseBreadcrumb() { - return useBreadcrumb; - } - - @Override - public void setUseBreadcrumb(Boolean useBreadcrumb) { - throw new UnsupportedOperationException(); - } - - @Override - public StreamCachingStrategy getStreamCachingStrategy() { - throw new UnsupportedOperationException(); - } - - @Override - public void setStreamCachingStrategy(StreamCachingStrategy streamCachingStrategy) { - throw new UnsupportedOperationException(); - } - - @Override - public RuntimeEndpointRegistry getRuntimeEndpointRegistry() { - throw new UnsupportedOperationException(); - } - - @Override - public void setRuntimeEndpointRegistry(RuntimeEndpointRegistry runtimeEndpointRegistry) { - throw new UnsupportedOperationException(); - } - - @Override - public SSLContextParameters getSSLContextParameters() { - throw new UnsupportedOperationException(); - } - - @Override - public void setSSLContextParameters(SSLContextParameters sslContextParameters) { - throw new UnsupportedOperationException(); - } - - @Override - public void setStartupSummaryLevel(StartupSummaryLevel startupSummaryLevel) { - throw new UnsupportedOperationException(); - } - - @Override - public StartupSummaryLevel getStartupSummaryLevel() { - return startupSummaryLevel; - } - - // - // Unsupported mutable methods - // - - @Override - public String getComponentParameterJsonSchema(String componentName) throws IOException { - Class<?> clazz; - Object instance = lwCamelContextExtension.getRegistry().lookupByNameAndType(componentName, Component.class); - if (instance != null) { - clazz = instance.getClass(); - } else { - clazz = lwCamelContextExtension.getFactoryFinder(DefaultComponentResolver.RESOURCE_PATH).findClass(componentName) - .orElse(null); - if (clazz == null) { - instance = hasComponent(componentName); - if (instance != null) { - clazz = instance.getClass(); - } else { - return null; - } - } - } - - return getJsonSchema(clazz.getPackage().getName(), componentName); - } - - @Override - public String getDataFormatParameterJsonSchema(String dataFormatName) throws IOException { - Class<?> clazz; - Object instance = lwCamelContextExtension.getRegistry().lookupByNameAndType(dataFormatName, DataFormat.class); - if (instance != null) { - clazz = instance.getClass(); - } else { - clazz = lwCamelContextExtension.getFactoryFinder(DefaultDataFormatResolver.DATAFORMAT_RESOURCE_PATH) - .findClass(dataFormatName).orElse(null); - if (clazz == null) { - return null; - } - } - return getJsonSchema(clazz.getPackage().getName(), dataFormatName); - } - - @Override - public String getLanguageParameterJsonSchema(String languageName) throws IOException { - Class<?> clazz; - Object instance = lwCamelContextExtension.getRegistry().lookupByNameAndType(languageName, Language.class); - if (instance != null) { - clazz = instance.getClass(); - } else { - clazz = lwCamelContextExtension.getFactoryFinder(DefaultLanguageResolver.LANGUAGE_RESOURCE_PATH) - .findClass(languageName).orElse(null); - if (clazz == null) { - return null; - } - } - return getJsonSchema(clazz.getPackage().getName(), languageName); - } - - @Override - public String getEipParameterJsonSchema(String eipName) throws IOException { - // the eip json schema may be in some of the sub-packages so look until - // we find it - String[] subPackages = new String[] { "", "/config", "/dataformat", "/language", "/loadbalancer", "/rest" }; - for (String sub : subPackages) { - String path = CamelContextHelper.MODEL_DOCUMENTATION_PREFIX + sub + "/" + eipName + ".json"; - InputStream inputStream = getClassResolver().loadResourceAsStream(path); - if (inputStream != null) { - try { - return IOHelper.loadText(inputStream); - } finally { - IOHelper.close(inputStream); - } - } - } - return null; - } - - private String getJsonSchema(String packageName, String name) throws IOException { - String path = packageName.replace('.', '/') + "/" + name + ".json"; - InputStream inputStream = getClassResolver().loadResourceAsStream(path); - if (inputStream != null) { - try { - return IOHelper.loadText(inputStream); - } finally { - IOHelper.close(inputStream); - } - } - return null; - } - - @Override - public Endpoint addEndpoint(String uri, Endpoint endpoint) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void removeEndpoint(Endpoint endpoint) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public Collection<Endpoint> removeEndpoints(String pattern) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void addComponent(String componentName, Component component) { - throw new UnsupportedOperationException(); - } - - @Override - public Component removeComponent(String componentName) { - throw new UnsupportedOperationException(); - } - - @Override - public void addRoutes(RoutesBuilder builder) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void addTemplatedRoutes(RoutesBuilder builder) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void addRoutesConfigurations(RouteConfigurationsBuilder builder) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public boolean removeRoute(String routeId) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void addRoutePolicyFactory(RoutePolicyFactory routePolicyFactory) { - throw new UnsupportedOperationException(); - } - - @Override - public void setTracing(Boolean tracing) { - throw new UnsupportedOperationException(); - } - - @Override - public void setBacklogTracing(Boolean backlogTrace) { - throw new UnsupportedOperationException(); - } - - @Override - public void setDebugging(Boolean debugging) { - throw new UnsupportedOperationException(); - } - - @Override - public void setMessageHistory(Boolean messageHistory) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLogMask(Boolean logMask) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLogExhaustedMessageBody(Boolean logExhaustedMessageBody) { - throw new UnsupportedOperationException(); - } - - @Override - public void setAutoStartup(Boolean autoStartup) { - throw new UnsupportedOperationException(); - } - - @Override - public void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy) { - throw new UnsupportedOperationException(); - } - - @Override - public String addRouteFromTemplate(String routeId, String routeTemplateId, Map<String, Object> parameters) - throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public String addRouteFromTemplate(String routeId, String routeTemplateId, String prefixId, Map<String, Object> parameters) - throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public String addRouteFromTemplate( - String routeId, String routeTemplateId, String prefixId, RouteTemplateContext routeTemplateContext) - throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void removeRouteTemplates(String pattern) throws Exception { - throw new UnsupportedOperationException(); - } - - private void startService(Service service) throws Exception { - // and register startup aware so they can be notified when - // camel context has been started - if (service instanceof StartupListener) { - StartupListener listener = (StartupListener) service; - addStartupListener(listener); - } - CamelContextAware.trySetCamelContext(service, reference); - service.start(); - } - - public ExtendedCamelContext getLwCamelContextExtension() { - return lwCamelContextExtension; - } - -} diff --git a/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java b/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java index d12d63fa565..48da1aad119 100644 --- a/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java +++ b/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java @@ -27,7 +27,6 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.seda.SedaComponent; import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.impl.lw.LightweightCamelContext; import org.apache.camel.model.ModelCamelContext; import org.apache.camel.spi.Language; import org.apache.camel.spi.Registry; @@ -49,7 +48,6 @@ public abstract class ContextTestSupport extends TestSupport { protected volatile ConsumerTemplate consumer; protected volatile NotifyBuilder oneExchangeDone; private boolean useRouteBuilder = true; - private boolean useLightweightContext; private Service camelContextService; /** @@ -66,14 +64,6 @@ public abstract class ContextTestSupport extends TestSupport { this.useRouteBuilder = useRouteBuilder; } - public boolean isUseLightweightContext() { - return useLightweightContext; - } - - public void setUseLightweightContext(boolean useLightweightContext) { - this.useLightweightContext = useLightweightContext; - } - public Service getCamelContextService() { return camelContextService; } @@ -199,15 +189,7 @@ public abstract class ContextTestSupport extends TestSupport { } protected CamelContext createCamelContext() throws Exception { - CamelContext context; - if (useLightweightContext) { - LightweightCamelContext ctx = new LightweightCamelContext(createRegistry()); - context = ctx; - } else { - DefaultCamelContext ctx = new DefaultCamelContext(true); - ctx.getCamelContextExtension().setRegistry(createRegistry()); - context = ctx; - } + CamelContext context = new DefaultCamelContext(true); if (!useJmx()) { context.disableJMX(); }