All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.atomikos.remoting.spring.httpinvoker.TransactionalHttpInvokerRequestExecutor Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
/**
 * Copyright (C) 2000-2020 Atomikos 
 *
 * LICENSE CONDITIONS
 *
 * See http://www.atomikos.com/Main/WhichLicenseApplies for details.
 */

package com.atomikos.remoting.spring.httpinvoker;

import java.io.IOException;
import java.net.HttpURLConnection;

import org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration;
import org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor;

import com.atomikos.logging.Logger;
import com.atomikos.logging.LoggerFactory;
import com.atomikos.remoting.support.ClientInterceptorTemplate;
import com.atomikos.remoting.support.HeaderNames;

public class TransactionalHttpInvokerRequestExecutor extends SimpleHttpInvokerRequestExecutor {

	private final Logger LOGGER = LoggerFactory.createLogger(TransactionalHttpInvokerRequestExecutor.class);

	
	private ClientInterceptorTemplate template = new ClientInterceptorTemplate();

	@Override
	protected void prepareConnection(HttpURLConnection con, int contentLength)
			throws IOException {
		LOGGER.logTrace("Filtering request...");
		String propagation = template.onOutgoingRequest();
		con.setRequestProperty(HeaderNames.PROPAGATION_HEADER_NAME, propagation);
		super.prepareConnection(con, contentLength);
	}

	@Override
	protected void validateResponse(HttpInvokerClientConfiguration config,
			HttpURLConnection con) throws IOException {
		super.validateResponse(config, con);
		LOGGER.logTrace("Filtering response...");
		String extent = con.getHeaderField(HeaderNames.EXTENT_HEADER_NAME);
		template.onIncomingResponse(extent);
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy