Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MULE-8473: Configs should be optional when using Ext-api operations i…
…n a flow
- Loading branch information
1 parent
c88dd00
commit ffa7f69
Showing
48 changed files
with
1,389 additions
and
695 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
...port/src/main/java/org/mule/module/extension/internal/config/BaseResolverFactoryBean.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
...ort/src/main/java/org/mule/module/extension/internal/config/ConfigurationFactoryBean.java
This file was deleted.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
...a/org/mule/module/extension/internal/config/ConfigurationInstanceProviderFactoryBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | ||
* The software in this package is published under the terms of the CPAL v1.0 | ||
* license, a copy of which has been included with this distribution in the | ||
* LICENSE.txt file. | ||
*/ | ||
package org.mule.module.extension.internal.config; | ||
|
||
import static org.mule.MessageExchangePattern.REQUEST_RESPONSE; | ||
import static org.mule.module.extension.internal.config.XmlExtensionParserUtils.getResolverSet; | ||
import org.mule.DefaultMuleEvent; | ||
import org.mule.DefaultMuleMessage; | ||
import org.mule.api.MuleContext; | ||
import org.mule.api.MuleEvent; | ||
import org.mule.api.MuleRuntimeException; | ||
import org.mule.api.construct.FlowConstruct; | ||
import org.mule.extension.introspection.Configuration; | ||
import org.mule.extension.runtime.ConfigurationInstanceProvider; | ||
import org.mule.module.extension.internal.runtime.ConfigurationObjectBuilder; | ||
import org.mule.module.extension.internal.runtime.DynamicConfigurationInstanceProvider; | ||
import org.mule.module.extension.internal.runtime.StaticConfigurationInstanceProvider; | ||
import org.mule.module.extension.internal.runtime.resolver.ResolverSet; | ||
|
||
import org.springframework.beans.factory.FactoryBean; | ||
|
||
/** | ||
* A {@link FactoryBean} which returns a {@link ConfigurationInstanceProvider} that provides the actual instances | ||
* that implement a given {@link Configuration}. Subsequent invokations to {@link #getObject()} method | ||
* returns always the same {@link ConfigurationInstanceProvider}. | ||
* | ||
* @since 3.7.0 | ||
*/ | ||
final class ConfigurationInstanceProviderFactoryBean implements FactoryBean<ConfigurationInstanceProvider<Object>> | ||
{ | ||
|
||
private final ConfigurationInstanceProvider<Object> configurationInstanceProvider; | ||
|
||
ConfigurationInstanceProviderFactoryBean(String name, | ||
Configuration configuration, | ||
ElementDescriptor element, | ||
MuleContext muleContext) | ||
{ | ||
ResolverSet resolverSet = getResolverSet(element, configuration.getParameters()); | ||
ConfigurationObjectBuilder configurationObjectBuilder = new ConfigurationObjectBuilder(configuration, resolverSet); | ||
|
||
if (resolverSet.isDynamic()) | ||
{ | ||
configurationInstanceProvider = new DynamicConfigurationInstanceProvider(name, configuration, configurationObjectBuilder, resolverSet); | ||
} | ||
else | ||
{ | ||
Object configurationInstance = instantiateStaticConfiguration(muleContext, configurationObjectBuilder); | ||
configurationInstanceProvider = new StaticConfigurationInstanceProvider<>(name, configuration, configurationInstance); | ||
} | ||
} | ||
|
||
private Object instantiateStaticConfiguration(MuleContext muleContext, ConfigurationObjectBuilder configurationObjectBuilder) | ||
{ | ||
try | ||
{ | ||
return configurationObjectBuilder.build(getInitialiserEvent(muleContext)); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new MuleRuntimeException(e); | ||
} | ||
} | ||
|
||
private MuleEvent getInitialiserEvent(MuleContext muleContext) | ||
{ | ||
return new DefaultMuleEvent(new DefaultMuleMessage(null, muleContext), REQUEST_RESPONSE, (FlowConstruct) null); | ||
} | ||
|
||
@Override | ||
public ConfigurationInstanceProvider<Object> getObject() throws Exception | ||
{ | ||
return configurationInstanceProvider; | ||
} | ||
|
||
/** | ||
* @return {@link ConfigurationInstanceProvider} | ||
*/ | ||
@Override | ||
public Class<ConfigurationInstanceProvider> getObjectType() | ||
{ | ||
return ConfigurationInstanceProvider.class; | ||
} | ||
|
||
@Override | ||
public boolean isSingleton() | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.