Skip to content

Commit

Permalink
Merge branch 'main' into flowable-release-7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphr committed Oct 2, 2023
2 parents 2712eff + 8f7342d commit 6501345
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 33 deletions.
5 changes: 2 additions & 3 deletions modules/flowable-cxf/src/main/resources/flowable-bindings.xjc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd" version="2.1">
xsi:schemaLocation="https://jakarta.ee/xml/ns/jaxb https://jakarta.ee/xml/ns/jaxb/bindingschema_3_0.xsd" version="3.0">
<jaxb:globalBindings>
<!--
Use java.util.Date instead of jakarta.xml.datatype.XMLGregorianCalendar for xsd:date, xsd:dateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class DefaultExpressionManager implements ExpressionManager {

protected ExpressionFactory expressionFactory;
protected List<FlowableFunctionDelegate> functionDelegates;
protected BiFunction<String, String, FlowableFunctionDelegate> functionResolver;
protected FlowableFunctionResolver functionResolver;
protected FlowableFunctionResolverFactory functionResolverFactory = FunctionDelegatesFlowableFunctionResolver::new;
protected List<FlowableAstFunctionCreator> astFunctionCreators;

protected ELContext parsingElContext;
Expand Down Expand Up @@ -196,18 +197,7 @@ public void setFunctionDelegates(List<FlowableFunctionDelegate> functionDelegate

protected void updateFunctionResolver() {
if (this.functionDelegates != null) {
Map<String, FlowableFunctionDelegate> functionDelegateMap = new LinkedHashMap<>();
for (FlowableFunctionDelegate functionDelegate : functionDelegates) {
for (String prefix : functionDelegate.prefixes()) {
for (String localName : functionDelegate.localNames()) {
functionDelegateMap.put(prefix + ":" + localName, functionDelegate);
}

}

}

this.functionResolver = (prefix, localName) -> functionDelegateMap.get(prefix + ":" + localName);
this.functionResolver = this.functionResolverFactory.create(this.functionDelegates);

} else {
this.functionResolver = null;
Expand All @@ -228,6 +218,17 @@ public void setAstFunctionCreators(List<FlowableAstFunctionCreator> astFunctionC
}
}

@Override
public FlowableFunctionResolverFactory getFunctionResolverFactory() {
return functionResolverFactory;
}

@Override
public void setFunctionResolverFactory(FlowableFunctionResolverFactory functionResolverFactory) {
this.functionResolverFactory = functionResolverFactory;
updateFunctionResolver();
}

public DeploymentCache<Expression> getExpressionCache() {
return expressionCache;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ public interface ExpressionManager {
*/
void setAstFunctionCreators(List<FlowableAstFunctionCreator> astFunctionCreators);

FlowableFunctionResolverFactory getFunctionResolverFactory();

void setFunctionResolverFactory(FlowableFunctionResolverFactory functionResolverFactory);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
package org.flowable.common.engine.impl.el;

import java.util.function.BiFunction;

import org.flowable.common.engine.api.delegate.FlowableFunctionDelegate;
import org.flowable.common.engine.impl.javax.el.ELContext;
import org.flowable.common.engine.impl.javax.el.ELResolver;
import org.flowable.common.engine.impl.javax.el.FunctionMapper;
Expand All @@ -27,9 +24,9 @@
public class FlowableElContext extends ELContext {

protected ELResolver elResolver;
protected BiFunction<String, String, FlowableFunctionDelegate> functionResolver;
protected FlowableFunctionResolver functionResolver;

public FlowableElContext(ELResolver elResolver, BiFunction<String, String, FlowableFunctionDelegate> functionResolver) {
public FlowableElContext(ELResolver elResolver, FlowableFunctionResolver functionResolver) {
this.elResolver = elResolver;
this.functionResolver = functionResolver;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
package org.flowable.common.engine.impl.el;

import java.lang.reflect.Method;
import java.util.function.BiFunction;

import org.flowable.common.engine.api.delegate.FlowableFunctionDelegate;
import org.flowable.common.engine.impl.javax.el.FunctionMapper;

/**
Expand All @@ -27,22 +25,21 @@
*/
public class FlowableFunctionMapper extends FunctionMapper {

protected BiFunction<String, String, FlowableFunctionDelegate> functionResolver; // first parameter = prefix, second parameter = localName
protected FlowableFunctionResolver functionResolver;

public FlowableFunctionMapper(BiFunction<String, String, FlowableFunctionDelegate> functionResolver) {
public FlowableFunctionMapper(FlowableFunctionResolver functionResolver) {
setFunctionResolver(functionResolver);

}

public void setFunctionResolver(BiFunction<String, String, FlowableFunctionDelegate> functionResolver) {
public void setFunctionResolver(FlowableFunctionResolver functionResolver) {
this.functionResolver = functionResolver;
}

@Override
public Method resolveFunction(String prefix, String localName) {
if (functionResolver != null) {
FlowableFunctionDelegate functionDelegate = functionResolver.apply(prefix, localName);
return functionDelegate != null ? functionDelegate.functionMethod() : null;
return functionResolver.resolveFunction(prefix, localName);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* 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.common.engine.impl.el;

import java.lang.reflect.Method;

/**
* @author Filip Hrisafov
*/
@FunctionalInterface
public interface FlowableFunctionResolver {

Method resolveFunction(String prefix, String localName);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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.common.engine.impl.el;

import java.util.Collection;

import org.flowable.common.engine.api.delegate.FlowableFunctionDelegate;

/**
* @author Filip Hrisafov
*/
@FunctionalInterface
public interface FlowableFunctionResolverFactory {

FlowableFunctionResolver create(Collection<FlowableFunctionDelegate> functionDelegates);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* 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.common.engine.impl.el;

import java.lang.reflect.Method;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

import org.flowable.common.engine.api.delegate.FlowableFunctionDelegate;

/**
* @author Filip Hrisafov
*/
public class FunctionDelegatesFlowableFunctionResolver implements FlowableFunctionResolver {

protected final Map<String, FlowableFunctionDelegate> functionDelegateMap;

public FunctionDelegatesFlowableFunctionResolver(Collection<FlowableFunctionDelegate> functionDelegates) {
functionDelegateMap = new LinkedHashMap<>();
for (FlowableFunctionDelegate functionDelegate : functionDelegates) {
for (String prefix : functionDelegate.prefixes()) {
for (String localName : functionDelegate.localNames()) {
functionDelegateMap.put(prefix + ":" + localName, functionDelegate);
}

}

}
}

@Override
public Method resolveFunction(String prefix, String localName) {
return resolveFunction(functionDelegateMap.get(prefix + ":" + localName));
}

protected Method resolveFunction(FlowableFunctionDelegate functionDelegate) {
return functionDelegate != null ? functionDelegate.functionMethod() : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
package org.flowable.common.engine.impl.el;

import java.util.function.BiFunction;

import org.flowable.common.engine.api.delegate.FlowableFunctionDelegate;
import org.flowable.common.engine.impl.javax.el.ELContext;
import org.flowable.common.engine.impl.javax.el.ELResolver;
import org.flowable.common.engine.impl.javax.el.ExpressionFactory;
Expand All @@ -32,9 +29,9 @@
*/
public class ParsingElContext extends ELContext {

protected BiFunction<String, String, FlowableFunctionDelegate> functionResolver;
protected FlowableFunctionResolver functionResolver;

public ParsingElContext(BiFunction<String, String, FlowableFunctionDelegate> functionResolver) {
public ParsingElContext(FlowableFunctionResolver functionResolver) {
this.functionResolver = functionResolver;
}

Expand Down

0 comments on commit 6501345

Please sign in to comment.