List of usage examples for org.springframework.expression.spel.standard SpelExpressionParser SpelExpressionParser
public SpelExpressionParser(SpelParserConfiguration configuration)
From source file:com.fitbur.core.el.spring.internal.SpelExpressionParserProvider.java
@Rank(Integer.MIN_VALUE) @Singleton @Override public ExpressionParser provide() { return new SpelExpressionParser(config); }
From source file:org.springframework.cloud.function.deployer.ApplicationRunner.java
public Object evaluate(String expression, Object root, Object... attrs) { Expression parsed = new SpelExpressionParser(this.config).parseExpression(expression); StandardEvaluationContext context = new StandardEvaluationContext(root); context.setTypeLocator(this.typeLocator); if (attrs.length % 2 != 0) { throw new IllegalArgumentException("Context attributes must be name, value pairs"); }/*from ww w . j a va 2 s. c om*/ for (int i = 0; i < attrs.length / 2; i++) { String name = (String) attrs[2 * i]; Object value = attrs[2 * i + 1]; context.setVariable(name, value); } return parsed.getValue(context); }
From source file:org.springframework.integration.ftp.inbound.FtpInboundRemoteFileSystemSynchronizerTests.java
@Test public void testCopyFileToLocalDir() throws Exception { File localDirectoy = new File("test"); assertFalse(localDirectoy.exists()); TestFtpSessionFactory ftpSessionFactory = new TestFtpSessionFactory(); ftpSessionFactory.setUsername("kermit"); ftpSessionFactory.setPassword("frog"); ftpSessionFactory.setHost("foo.com"); FtpInboundFileSynchronizer synchronizer = spy(new FtpInboundFileSynchronizer(ftpSessionFactory)); synchronizer.setDeleteRemoteFiles(true); synchronizer.setRemoteDirectory("remote-test-dir"); synchronizer.setFilter(new FtpRegexPatternFileListFilter(".*\\.test$")); synchronizer.setIntegrationEvaluationContext(ExpressionUtils.createStandardEvaluationContext()); ExpressionParser expressionParser = new SpelExpressionParser(new SpelParserConfiguration(true, true)); Expression expression = expressionParser.parseExpression("#this.toUpperCase() + '.a'"); synchronizer.setLocalFilenameGeneratorExpression(expression); FtpInboundFileSynchronizingMessageSource ms = new FtpInboundFileSynchronizingMessageSource(synchronizer); ms.setAutoCreateLocalDirectory(true); ms.setLocalDirectory(localDirectoy); ms.afterPropertiesSet();//from w w w . ja v a 2 s .c o m Message<File> atestFile = ms.receive(); assertNotNull(atestFile); assertEquals("A.TEST.a", atestFile.getPayload().getName()); Message<File> btestFile = ms.receive(); assertNotNull(btestFile); assertEquals("B.TEST.a", btestFile.getPayload().getName()); Message<File> nothing = ms.receive(); assertNull(nothing); // two times because on the third receive (above) the internal queue will be empty, so it will attempt verify(synchronizer, times(2)).synchronizeToLocalDirectory(localDirectoy); assertTrue(new File("test/A.TEST.a").exists()); assertTrue(new File("test/B.TEST.a").exists()); }