All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.flowable.engine.test.mock.MockResolverFactory Maven / Gradle / Ivy

There is a newer version: 7.0.1
Show newest version
/* Licensed 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.flowable.engine.test.mock;

import org.flowable.common.engine.impl.AbstractEngineConfiguration;
import org.flowable.common.engine.impl.scripting.Resolver;
import org.flowable.common.engine.impl.scripting.ResolverFactory;
import org.flowable.variable.api.delegate.VariableScope;

/**
 * This is a bridge resolver, making available any objects registered through {@link org.flowable.engine.test.mock.Mocks#register} inside scripts supported by process execution. 
*
* In order to use it, you need to declare it as ResolverFactory, for example by using flowable.cfg.xml like this:
*
* * <?xml version="1.0" encoding="UTF-8"?>
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
*
* <bean id="processEngineConfiguration"
* class="org.flowable.engine.impl.cfg. StandaloneInMemProcessEngineConfiguration">
* <property name="expressionManager">
* <bean class="org.flowable.engine.test.mock.MockExpressionManager" />
* </property>
* <property name="resolverFactories">
* <list>
* <bean class="org.flowable.common.engine.impl.scripting.VariableScopeResolverFactory " />
* <bean class="org.flowable.common.engine.impl.scripting.BeansResolverFactory" />
* <bean class="com.deenero.activiti.MockResolverFactory" />
* </list>
* </property>
* </bean>
*
* </beans>
*
* or by any other means of creating configuration. * * @author Emil Genov (http://www.emil-genov.info/) * */ public class MockResolverFactory implements ResolverFactory { @Override public Resolver createResolver(AbstractEngineConfiguration engineConfiguration, VariableScope variableScope) { return new Resolver() { @Override public Object get(Object key) { return Mocks.get(key); } @Override public boolean containsKey(Object key) { return Mocks.get(key) != null; } }; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy