Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

* [new] Java 9 compatibility.
* [new] Refactored and improved integration testing API.
* [brk] Removed Arquillian support (to its own add-on) in favor of Undertow-based Web integration testing.
* [fix] Defer JNDI lookup through `@Resource` annotation until the instance containing the injection is created.

* [fix] Fix lack of injection in custom ConstraintValidators.

# Version 3.4.2 (2018-01-12)

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ class ELContextBuilderImpl implements ELContextBuilder {
private ExpressionFactory expressionFactory;

static ELContext createDefaultELContext(ExpressionFactory expressionFactory) {
if (ELPlugin.EL3_OPTIONAL.isPresent()) {
if (ELPlugin.EL_3_CONTEXT_CLASS != null) {
try {
return ELPlugin.EL3_OPTIONAL.get().getConstructor(ExpressionFactory.class).newInstance(
return ELPlugin.EL_3_CONTEXT_CLASS.getConstructor(ExpressionFactory.class).newInstance(
expressionFactory);
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException |
InstantiationException e) {
throw new RuntimeException("Unable to instantiate StandardELContext", e);
}
} else if (ELPlugin.JUEL_OPTIONAL.isPresent()) {
} else if (ELPlugin.JUEL_CONTEXT_CLASS != null) {
try {
return ELPlugin.JUEL_OPTIONAL.get().newInstance();
return ELPlugin.JUEL_CONTEXT_CLASS.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
throw new RuntimeException("Unable to instantiate JUEL SimpleContext", e);
}
Expand Down Expand Up @@ -76,12 +76,12 @@ public ELPropertyProvider withProperty(String name, Object object) {
@Override
public ELPropertyProvider withFunction(String prefix, String localName, Method method) {
checkArgument(!Strings.isNullOrEmpty(localName), "A function local name is required");
if (ELPlugin.EL3_OPTIONAL.isPresent()) {
if (ELPlugin.isLevel3()) {
elContext.getFunctionMapper().mapFunction(prefix, localName, method);
} else if (ELPlugin.JUEL_OPTIONAL.isPresent()) {
if (ELPlugin.JUEL_OPTIONAL.get().isAssignableFrom(elContext.getClass())) {
} else if (ELPlugin.JUEL_CONTEXT_CLASS != null) {
if (ELPlugin.JUEL_CONTEXT_CLASS.isAssignableFrom(elContext.getClass())) {
try {
ELPlugin.JUEL_OPTIONAL.get().getMethod("setFunction", String.class, String.class,
ELPlugin.JUEL_CONTEXT_CLASS.getMethod("setFunction", String.class, String.class,
Method.class).invoke(elContext, prefix, localName, method);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw SeedException.wrap(e, ExpressionLanguageErrorCode.UNEXPECTED_EXCEPTION);
Expand All @@ -92,7 +92,7 @@ public ELPropertyProvider withFunction(String prefix, String localName, Method m
}
} else {
throw new UnsupportedOperationException(
"Function mapping is not supported in this environment (EL level 3+ required)");
"Function mapping is not supported in this environment (EL level 3+ or JUEL required)");
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright © 2013-2018, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.seed.core.internal.el;

import org.seedstack.shed.exception.ErrorCode;

public enum ELErrorCode implements ErrorCode {
UNABLE_TO_INSTANTIATE_EXPRESSION_FACTORY
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
import org.seedstack.seed.el.spi.ELHandler;

class ELModule extends AbstractModule {
private static final TypeLiteral<Map<Class<? extends Annotation>, Class<ELHandler>>> MAP_TYPE_LITERAL = new
TypeLiteral<Map<Class<? extends Annotation>, Class<ELHandler>>>() {
};
private final ExpressionFactory expressionFactory;
private final Map<Class<? extends Annotation>, Class<ELHandler>> elMap;

ELModule(Map<Class<? extends Annotation>, Class<ELHandler>> elMap) {
ELModule(ExpressionFactory expressionFactory, Map<Class<? extends Annotation>, Class<ELHandler>> elMap) {
this.expressionFactory = expressionFactory;
this.elMap = elMap;
}

@Override
protected void configure() {
bind(ExpressionFactory.class).toInstance(ExpressionFactory.newInstance());
bind(ExpressionFactory.class).toInstance(expressionFactory);
bind(ELService.class).to(ELServiceInternal.class);
bind(ELContextBuilder.class).to(ELContextBuilderImpl.class);

Expand All @@ -39,6 +38,10 @@ protected void configure() {
}

// bind the map of annotation -> ELHandler
bind(MAP_TYPE_LITERAL).toInstance(ImmutableMap.copyOf(elMap));
bind(new AnnotationHandlersTypeLiteral()).toInstance(ImmutableMap.copyOf(elMap));
}

private static class AnnotationHandlersTypeLiteral
extends TypeLiteral<Map<Class<? extends Annotation>, Class<ELHandler>>> {
}
}
Loading