Search in sources :

Example 36 with MuleContext

use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.

the class ParametersResolver method getParametersAsResolverSet.

/**
 * Constructs a {@link ResolverSet} from the parameters groups, using {@link #toValueResolver(Object, Set)} to process the values.
 *
 * @return a {@link ResolverSet}
 */
public ResolverSet getParametersAsResolverSet(MuleContext muleContext, ParameterizedModel model, List<ParameterGroupModel> groups) throws ConfigurationException {
    List<ParameterGroupModel> inlineGroups = getInlineGroups(groups);
    List<ParameterModel> allParameters = groups.stream().flatMap(g -> g.getParameterModels().stream()).collect(toList());
    ResolverSet resolverSet = getParametersAsResolverSet(model, getFlatParameters(inlineGroups, allParameters), muleContext);
    for (ParameterGroupModel group : inlineGroups) {
        getInlineGroupResolver(group, resolverSet, muleContext);
    }
    return resolverSet;
}
Also used : ResolverUtils.getDefaultValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverUtils.getDefaultValueResolver) CollectionUtils.intersection(org.apache.commons.collections.CollectionUtils.intersection) IntrospectionUtils.getMemberName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getMemberName) NameUtils.getModelName(org.mule.runtime.extension.api.util.NameUtils.getModelName) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ConfigOverrideTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.ConfigOverrideTypeAnnotation) NullSafeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.NullSafeModelProperty) Map(java.util.Map) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) ModelProperty(org.mule.runtime.api.meta.model.ModelProperty) MuleExtensionUtils.isNullSafe(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.isNullSafe) MetadataTypeUtils.getLocalPart(org.mule.metadata.api.utils.MetadataTypeUtils.getLocalPart) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ResolverUtils.getFieldDefaultValueValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverUtils.getFieldDefaultValueValueResolver) Collectors.toImmutableList(org.mule.runtime.api.util.collection.Collectors.toImmutableList) ObjectType(org.mule.metadata.api.model.ObjectType) ParameterGroupDescriptor(org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor) ExclusiveParametersModel(org.mule.runtime.api.meta.model.parameter.ExclusiveParametersModel) ObjectStore(org.mule.runtime.api.store.ObjectStore) ConfigurationProvider(org.mule.runtime.extension.api.runtime.config.ConfigurationProvider) Collection(java.util.Collection) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) IntrospectionUtils.getFieldByNameOrAlias(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getFieldByNameOrAlias) ExclusiveOptionalsTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.ExclusiveOptionalsTypeAnnotation) List(java.util.List) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) NameUtils.getComponentModelTypeName(org.mule.runtime.extension.api.util.NameUtils.getComponentModelTypeName) ExclusiveParameterGroupObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.ExclusiveParameterGroupObjectBuilder) MetadataType(org.mule.metadata.api.model.MetadataType) Optional(java.util.Optional) IntrospectionUtils.getContainerName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getContainerName) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) Joiner(com.google.common.base.Joiner) StackedTypesModelProperty.getStackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty.getStackedTypesModelProperty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) MetadataTypeUtils.getDefaultValue(org.mule.metadata.api.utils.MetadataTypeUtils.getDefaultValue) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) HashMap(java.util.HashMap) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) LinkedHashMap(java.util.LinkedHashMap) ExtensionMetadataTypeUtils.isFlattenedParameterGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isFlattenedParameterGroup) MuleContext(org.mule.runtime.core.api.MuleContext) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder) RequiredParameterNotSetException(org.mule.runtime.module.extension.internal.runtime.exception.RequiredParameterNotSetException) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) LinkedList(java.util.LinkedList) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) Collections.emptySet(java.util.Collections.emptySet) NullSafeTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.NullSafeTypeAnnotation) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ImmutableList.copyOf(com.google.common.collect.ImmutableList.copyOf) IntrospectionUtils.getMetadataType(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getMetadataType) Field(java.lang.reflect.Field) Collectors.toList(java.util.stream.Collectors.toList) ExtensionMetadataTypeUtils(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils) JavaTypeUtils.getType(org.mule.metadata.java.api.utils.JavaTypeUtils.getType) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)

Example 37 with MuleContext

use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.

the class ApplicationContextBuilder method doBuildContext.

protected MuleContext doBuildContext() throws Exception {
    MuleContext context;
    MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
    List<ConfigurationBuilder> builders = new ArrayList<>();
    builders.add(getAppBuilder(this.applicationResources));
    addBuilders(builders);
    configureMuleContext(muleContextBuilder);
    context = muleContextFactory.createMuleContext(builders, muleContextBuilder);
    return context;
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) SpringXmlConfigurationBuilderFactory.createConfigurationBuilder(org.mule.runtime.config.api.SpringXmlConfigurationBuilderFactory.createConfigurationBuilder) ConfigurationBuilder(org.mule.runtime.core.api.config.ConfigurationBuilder) MuleContextFactory(org.mule.runtime.core.api.context.MuleContextFactory) DefaultMuleContextFactory(org.mule.runtime.core.api.context.DefaultMuleContextFactory) ArrayList(java.util.ArrayList)

Example 38 with MuleContext

use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.

the class ApplicationContextBuilder method build.

public MuleContext build() throws Exception {
    // Should we set up the manager for every method?
    MuleContext context = doBuildContext();
    context.start();
    return context;
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext)

Example 39 with MuleContext

use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.

the class CollectionValueResolverTestCase method before.

@Before
public void before() throws Exception {
    muleContext = mock(MuleContext.class);
    event = mock(CoreEvent.class);
    resolvingContext = mock(ValueResolvingContext.class);
    when(resolvingContext.getEvent()).thenReturn(event);
    when(resolvingContext.getConfig()).thenReturn(Optional.empty());
    collectionType = ArrayList.class;
    childResolvers = new ArrayList();
    expectedValues = new ArrayList<>();
    for (int i = 0; i < getChildResolversCount(); i++) {
        ValueResolver childResolver = getResolver(i, resolvingContext, false, MuleContextAware.class, Lifecycle.class);
        childResolvers.add(childResolver);
        expectedValues.add(i);
    }
    resolver = createCollectionResolver(childResolvers);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 40 with MuleContext

use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.

the class ConfigurationInjectionLifecycleTestCase method addBuilders.

@Override
protected void addBuilders(List<ConfigurationBuilder> builders) {
    builders.add(new AbstractConfigurationBuilder() {

        @Override
        protected void doConfigure(MuleContext muleContext) throws Exception {
            muleContext.getCustomizationService().registerCustomServiceClass("lifecycleTracker", LifecycleTracker.class);
        }
    });
    super.addBuilders(builders);
}
Also used : AbstractConfigurationBuilder(org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder) MuleContext(org.mule.runtime.core.api.MuleContext) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) OnException(org.mule.runtime.extension.api.annotation.OnException) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException)

Aggregations

MuleContext (org.mule.runtime.core.api.MuleContext)46 Test (org.junit.Test)17 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Before (org.junit.Before)8 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)8 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)8 MuleException (org.mule.runtime.api.exception.MuleException)7 LifecycleUtils.initialiseIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded)7 Map (java.util.Map)6 Optional (java.util.Optional)6 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)6 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)5 ConfigurationBuilder (org.mule.runtime.core.api.config.ConfigurationBuilder)5 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)5 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 Optional.ofNullable (java.util.Optional.ofNullable)4 MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)4