org.springframework.integration.annotation.Transformer Java Examples

The following examples show how to use org.springframework.integration.annotation.Transformer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileWriterIntegrationConfig.java    From spring-in-action-5-samples with Apache License 2.0 6 votes vote down vote up
@Profile("javaconfig")
@Bean
@Transformer(inputChannel="textInChannel",
             outputChannel="fileWriterChannel")
public GenericTransformer<String, String> upperCaseTransformer() {
  return text -> text.toUpperCase();
}
 
Example #2
Source File: ScriptableTransformProcessorConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 6 votes vote down vote up
@Bean
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public MessageProcessor<?> transformer() {
	String language = this.properties.getLanguage();
	String script = this.properties.getScript();
	logger.info(String.format("Input script is '%s', language is '%s'", script, language));
	Resource scriptResource = new ByteArrayResource(decodeScript(script).getBytes()) {

		// TODO until INT-3976
		@Override
		public String getFilename() {
			// Only the groovy script processor enforces this requirement for a name
			return "StaticScript";
		}

	};
	return Scripts.script(scriptResource)
			.lang(language)
			.variableGenerator(this.scriptVariableGenerator)
			.get();
}
 
Example #3
Source File: TaskProcessor.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object setupRequest(String message) {
	Map<String, String> properties = new HashMap<>();
	if (StringUtils.hasText(this.processorProperties.getDataSourceUrl())) {
		properties
			.put("spring_datasource_url", this.processorProperties
				.getDataSourceUrl());
	}
	if (StringUtils
		.hasText(this.processorProperties.getDataSourceDriverClassName())) {
		properties.put("spring_datasource_driverClassName", this.processorProperties
			.getDataSourceDriverClassName());
	}
	if (StringUtils.hasText(this.processorProperties.getDataSourceUserName())) {
		properties.put("spring_datasource_username", this.processorProperties
			.getDataSourceUserName());
	}
	if (StringUtils.hasText(this.processorProperties.getDataSourcePassword())) {
		properties.put("spring_datasource_password", this.processorProperties
			.getDataSourcePassword());
	}
	properties.put("payload", message);

	TaskLaunchRequest request = new TaskLaunchRequest(
		this.processorProperties.getUri(), null, properties, null,
		this.processorProperties.getApplicationName());

	return new GenericMessage<>(request);
}
 
Example #4
Source File: CloseUserEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final User user) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(user.getEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(user);
	helper.setText(getText(model), true);
	return message;
}
 
Example #5
Source File: PublisherEarningReminderEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
  public MimeMessage transform(final User user) throws MessagingException, IOException {
MimeMessage message = getEmailSender().createMimeMessage();
  	MimeMessageHelper helper = new MimeMessageHelper(message);
  	helper.setTo(user.getEmail());
  	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
  	helper.setReplyTo(getDefaultFromAddress());
  	helper.setSubject(getSubject());
  	Map<String, Object> model = buildModel(user);
  	helper.setText(getText(model), true);
  	return message;
  }
 
Example #6
Source File: PaperightCreditTransactionPaymentReceivedEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
   public MimeMessage transform(final PaperightCreditTransaction transaction) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
   	MimeMessageHelper helper = new MimeMessageHelper(message);
   	helper.setTo(transaction.getUser().getEmail());
   	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
   	helper.setReplyTo(getDefaultFromAddress());
   	helper.setSubject(getSubject());
   	Map<String, Object> model = buildModel(transaction);
   	helper.setText(getText(model), true);
   	return message;
}
 
Example #7
Source File: ResetPasswordEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final ResetPassword resetPassword) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(resetPassword.getUser().getEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(resetPassword);
	helper.setText(getText(model), true);
	return message;
}
 
Example #8
Source File: UpdateEmailNewEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final UpdateEmail updateEmail) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(updateEmail.getUser().getEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(updateEmail);
	helper.setText(getText(model), true);
	return message;
}
 
Example #9
Source File: ActivateUserEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final User user) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(user.getEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(user);
	helper.setText(getText(model), true);
	return message;
}
 
Example #10
Source File: NewUserEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final User user) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(user.getEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(user);
	helper.setText(getText(model), true);
	return message;
}
 
Example #11
Source File: UserRegistrationEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final User user) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(toEmail);
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(user);
	helper.setText(getText(model), true);
	return message;
}
 
Example #12
Source File: LicencePurchaseEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final LicencePurchaseEmail licencePurchaseEmail) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(licencePurchaseEmail.getUser().getEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(licencePurchaseEmail);
	helper.setText(getText(model), true);
	return message;
}
 
Example #13
Source File: SuggestBookEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
  public MimeMessage transform(final SuggestBook suggestBook) throws MessagingException, IOException {
MimeMessage message = getEmailSender().createMimeMessage();
  	MimeMessageHelper helper = new MimeMessageHelper(message);
  	helper.setTo(getDefaultToAddress());
  	helper.setFrom(suggestBook.getEmail(), suggestBook.getName());
  	helper.setReplyTo(suggestBook.getEmail());
  	helper.setSubject(getSubject());
  	Map<String, Object> model = buildModel(suggestBook);
  	helper.setText(getText(model), true);
  	return message;
  }
 
Example #14
Source File: CancelPublisherPaymentRequestEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
  public MimeMessage transform(final PublisherPaymentRequest publisherPaymentRequest) throws MessagingException, IOException {
MimeMessage message = getEmailSender().createMimeMessage();
  	MimeMessageHelper helper = new MimeMessageHelper(message);
  	helper.setTo(getDefaultToAddress());
  	helper.setFrom(publisherPaymentRequest.getUser().getEmail(), publisherPaymentRequest.getUser().getCompany().getName());
  	helper.setReplyTo(publisherPaymentRequest.getUser().getEmail());
  	helper.setSubject(getSubject());
  	Map<String, Object> model = buildModel(publisherPaymentRequest);
  	helper.setText(getText(model), true);
  	return message;
  }
 
Example #15
Source File: UpdateEmailOldEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final UpdateEmail updateEmail) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(updateEmail.getOldEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(updateEmail);
	helper.setText(getText(model), true);
	return message;
}
 
Example #16
Source File: ReopenUserEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final User user) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(user.getEmail());
	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
	helper.setReplyTo(getDefaultFromAddress());
	helper.setSubject(getSubject());
	Map<String, Object> model = buildModel(user);
	helper.setText(getText(model), true);
	return message;
}
 
Example #17
Source File: PaidPublisherPaymentRequestEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
  public MimeMessage transform(final PublisherPaymentRequest publisherPaymentRequest) throws MessagingException, IOException {
MimeMessage message = getEmailSender().createMimeMessage();
  	MimeMessageHelper helper = new MimeMessageHelper(message);
  	helper.setTo(publisherPaymentRequest.getUser().getEmail());
  	helper.setFrom(getDefaultFromAddress(), getDefaultFromName());
  	helper.setReplyTo(getDefaultFromAddress());
  	helper.setSubject(getSubject());
  	Map<String, Object> model = buildModel(publisherPaymentRequest);
  	helper.setText(getText(model), true);
  	return message;
  }
 
Example #18
Source File: PublisherPaymentRequestEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
  public MimeMessage transform(final PublisherPaymentRequest publisherPaymentRequest) throws MessagingException, IOException {
MimeMessage message = getEmailSender().createMimeMessage();
  	MimeMessageHelper helper = new MimeMessageHelper(message);
  	helper.setTo(getDefaultToAddress());
  	helper.setFrom(publisherPaymentRequest.getUser().getEmail(), publisherPaymentRequest.getUser().getCompany().getName());
  	helper.setReplyTo(publisherPaymentRequest.getUser().getEmail());
  	helper.setSubject(getSubject());
  	Map<String, Object> model = buildModel(publisherPaymentRequest);
  	helper.setText(getText(model), true);
  	return message;
  }
 
Example #19
Source File: ContactUsEmailTransformer.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transformer
public MimeMessage transform(final ContactMessage contactMessage) throws MessagingException, IOException {
	MimeMessage message = getEmailSender().createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message);
	helper.setTo(getDefaultToAddress());
	helper.setFrom(contactMessage.getEmail(), contactMessage.getName());
	helper.setReplyTo(contactMessage.getEmail());
	helper.setSubject(contactMessage.getSubject());
	Map<String, Object> model = buildModel(contactMessage);
	helper.setText(getText(model), true);
	return message;
}
 
Example #20
Source File: TasklaunchrequestTransformProcessorConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 5 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object setupRequest(String message) {
	Map<String, String> properties = new HashMap<String, String>();
	Map<String, String> deploymentProperties = null;
	List<String> commandLineArgs = null;

	if (StringUtils.hasText(processorProperties.getDataSourceUrl())) {
		properties.put("spring_datasource_url", processorProperties.getDataSourceUrl());
	}
	if (StringUtils.hasText(processorProperties.getDataSourceDriverClassName())) {
		properties.put("spring_datasource_driverClassName", processorProperties.getDataSourceDriverClassName());
	}
	if (StringUtils.hasText(processorProperties.getDataSourceUserName())) {
		properties.put("spring_datasource_username", processorProperties.getDataSourceUserName());
	}
	if (StringUtils.hasText(processorProperties.getDataSourcePassword())) {
		properties.put("spring_datasource_password", processorProperties.getDataSourcePassword());
	}
	if (StringUtils.hasLength(processorProperties.getDeploymentProperties())) {
		deploymentProperties = parse(processorProperties.getDeploymentProperties());
	}
	if (StringUtils.hasLength(processorProperties.getCommandLineArguments())) {
		commandLineArgs = parseParams(processorProperties.getCommandLineArguments());
	}

	TaskLaunchRequest request = new TaskLaunchRequest(
			processorProperties.getUri(), commandLineArgs, properties,
			deploymentProperties);

	return request;
}
 
Example #21
Source File: TimeProcessorApplication.java    From tutorials with MIT License 5 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object transform(Long timestamp) {

    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
    String date = dateFormat.format(timestamp);
    return date;
}
 
Example #22
Source File: KinesisBinderProcessorTests.java    From spring-cloud-stream-binder-aws-kinesis with Apache License 2.0 5 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public String transform(Message<String> message) {
	String payload = message.getPayload();
	if (!"junk".equals(payload)) {
		return payload.toUpperCase();
	}
	else {
		throw new IllegalStateException("Invalid payload: " + payload);
	}
}
 
Example #23
Source File: TxIntegrationConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
@Transformer(inputChannel = "inputChannel", outputChannel = "toServiceChannel")
public FileToStringTransformer fileToStringTransformer() {
    return new FileToStringTransformer();
}
 
Example #24
Source File: CustomerProcessorConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Customer convertToPojo(Customer payload) {

    return payload;
}
 
Example #25
Source File: ProcessorApp.java    From tutorials with MIT License 4 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public String processMessage(String payload) {
    log.info("Payload received!");
    return payload;
}
 
Example #26
Source File: AutoconfigurationDisabledTest.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public String transform(String in) {
	return in + " world";
}
 
Example #27
Source File: ExampleTest.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public String transform(String in) {
	return in + " world";
}
 
Example #28
Source File: TransformProcessorConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object transform(Message<?> message) {
	return properties.getExpression().getValue(message);
}
 
Example #29
Source File: GroovyTransformProcessorConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Bean
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public MessageProcessor<?> transformer() {
	return new GroovyScriptExecutingMessageProcessor(
			new ResourceScriptSource(properties.getScript()), scriptVariableGenerator);
}
 
Example #30
Source File: StockIntelligenceProcessorApplication.java    From Mastering-Spring-5.0 with MIT License 4 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object addOurInventory(StockPriceChangeEvent event) {

	logger.info("started processing event " + event);
	
	logger.info("received stock ticker " + event.getStockTicker());
	
	logger.info("received stock ticker and mapped to " + StockTicker.valueOf(event.getStockTicker()));

	Integer holding = holdings.get(StockTicker.valueOf(event.getStockTicker()));
	
	logger.info("holding value is  " + holding);
	
	StockPriceChangeEventWithHoldings eventWithHoldings = new StockPriceChangeEventWithHoldings(event, holding);

	logger.info("ended processing eventWithHoldings " + eventWithHoldings);
	return eventWithHoldings;
}