@Override @Nullable public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(context); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), expectedResultType); }
@Override @Nullable public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(context, rootObject); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), desiredResultType); }
@Override @Nullable public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), expectedResultType); }
@Override @Nullable public <T> T getValue(Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(rootObject); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), desiredResultType); }
@Override @Nullable public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), expectedResultType); }
@Override @Nullable public <T> T getValue(Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(rootObject); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), desiredResultType); }
@Override @Nullable public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(context, rootObject); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), desiredResultType); }
@Override @Nullable public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(context); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), expectedResultType); }
public static void displayDirectories(ApplicationContext context) { File inDir = (File) new DirectFieldAccessor(context.getBean(FileReadingMessageSource.class)).getPropertyValue("directory"); LiteralExpression expression = (LiteralExpression) new DirectFieldAccessor(context.getBean(FileWritingMessageHandler.class)).getPropertyValue("destinationDirectoryExpression"); File outDir = new File(expression.getValue()); System.out.println("Input directory is: " + inDir.getAbsolutePath()); System.out.println("Output directory is: " + outDir.getAbsolutePath()); System.out.println("==================================================="); }
@Test public void testGetValue() throws Exception { LiteralExpression lEx = new LiteralExpression("somevalue"); checkString("somevalue", lEx.getValue()); checkString("somevalue", lEx.getValue(String.class)); EvaluationContext ctx = new StandardEvaluationContext(); checkString("somevalue", lEx.getValue(ctx)); checkString("somevalue", lEx.getValue(ctx, String.class)); checkString("somevalue", lEx.getValue(new Rooty())); checkString("somevalue", lEx.getValue(new Rooty(), String.class)); checkString("somevalue", lEx.getValue(ctx, new Rooty())); checkString("somevalue", lEx.getValue(ctx, new Rooty(),String.class)); assertEquals("somevalue", lEx.getExpressionString()); assertFalse(lEx.isWritable(new StandardEvaluationContext())); assertFalse(lEx.isWritable(new Rooty())); assertFalse(lEx.isWritable(new StandardEvaluationContext(), new Rooty())); }
@Test public void testController() { DirectFieldAccessor accessor = new DirectFieldAccessor(inboundController); String errorCode = (String) accessor.getPropertyValue("errorCode"); assertEquals("oops", errorCode); LiteralExpression viewExpression = (LiteralExpression) accessor.getPropertyValue("viewExpression"); assertEquals("foo", viewExpression.getValue()); }
@Test @SuppressWarnings("rawtypes") public void testAnnotationGatewayProxyFactoryBean() { assertNotNull(this.gatewayByAnnotationGPFB); assertNull(this.notActivatedByProfileGateway); assertSame(this.exec, this.annotationGatewayProxyFactoryBean.getAsyncExecutor()); assertEquals(1111L, TestUtils.getPropertyValue(this.annotationGatewayProxyFactoryBean, "defaultRequestTimeout", Expression.class).getValue()); assertEquals(222L, TestUtils.getPropertyValue(this.annotationGatewayProxyFactoryBean, "defaultReplyTimeout", Expression.class).getValue()); Collection<MessagingGatewaySupport> messagingGateways = this.annotationGatewayProxyFactoryBean.getGateways().values(); assertEquals(1, messagingGateways.size()); MessagingGatewaySupport gateway = messagingGateways.iterator().next(); assertSame(this.gatewayChannel, gateway.getRequestChannel()); assertSame(this.gatewayChannel, gateway.getReplyChannel()); assertSame(this.errorChannel, gateway.getErrorChannel()); Object requestMapper = TestUtils.getPropertyValue(gateway, "requestMapper"); assertEquals("@foo", TestUtils.getPropertyValue(requestMapper, "payloadExpression.expression")); Map globalHeaderExpressions = TestUtils.getPropertyValue(requestMapper, "globalHeaderExpressions", Map.class); assertEquals(1, globalHeaderExpressions.size()); Object barHeaderExpression = globalHeaderExpressions.get("bar"); assertNotNull(barHeaderExpression); assertThat(barHeaderExpression, instanceOf(LiteralExpression.class)); assertEquals("baz", ((LiteralExpression) barHeaderExpression).getValue()); }
@Override @Nullable public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), expectedResultType); }
@Override @Nullable public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(context); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), expectedResultType); }
@Override @Nullable public <T> T getValue(Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(rootObject); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), desiredResultType); }
@Override @Nullable public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(context, rootObject); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), desiredResultType); }
@Test @MongoDbAvailable public void testWithCollectionNameExpressionSpecified() { Message<String> message = MessageBuilder.withPayload("").build(); MongoDbOutboundGateway gateway = createGateway(); gateway.setQueryExpression(new LiteralExpression("{name : 'Xavi'}")); gateway.setExpectSingleResult(true); gateway.setCollectionNameExpression(new LiteralExpression("anotherCollection")); gateway.afterPropertiesSet(); Object result = gateway.handleRequestMessage(message); assertNull(result); LiteralExpression collectionNameExpression = (LiteralExpression) TestUtils.getPropertyValue(gateway, "collectionNameExpression"); assertNotNull(collectionNameExpression); assertEquals("anotherCollection", collectionNameExpression.getValue()); }