本文整理汇总了Java中org.springframework.ws.transport.context.TransportContext类的典型用法代码示例。如果您正苦于以下问题:Java TransportContext类的具体用法?Java TransportContext怎么用?Java TransportContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransportContext类属于org.springframework.ws.transport.context包,在下文中一共展示了TransportContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleRequest
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Override
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
TransportContext transportContext = TransportContextHolder.getTransportContext();
WebServiceConnection webServiceConnection = transportContext.getConnection();
final String tenant = TenantContextHolder.getContext().getTenant();
if (webServiceConnection instanceof HeadersAwareSenderWebServiceConnection) {
if (StringUtils.hasText(tenant)) {
try {
((HeadersAwareSenderWebServiceConnection) webServiceConnection).addRequestHeader(getHeaderName(), tenant);
} catch (IOException e) {
throw new WebServiceIOException("Error setting header '" + getHeaderName() + "' on connection.", e);
}
}
}
return true;
}
开发者ID:mdeinum,项目名称:spring-multi-tenancy,代码行数:18,代码来源:TentantContextClientInterceptor.java
示例2: listFlights
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<BigInteger> listFlights() {
ObjectFactory factory = new ObjectFactory();
TListFlights tListFlights = factory.createTListFlights();
JAXBElement<TListFlights> request = factory.createListFlightsRequest(tListFlights);
JAXBElement<TFlightsResponse> response = (JAXBElement<TFlightsResponse>) webServiceTemplate
.marshalSendAndReceive(request, new WebServiceMessageCallback() {
public void doWithMessage(WebServiceMessage message) {
TransportContext context = TransportContextHolder.getTransportContext();
HttpUrlConnection connection = (HttpUrlConnection) context.getConnection();
connection.getConnection().addRequestProperty("Authorization",
BasicAuthenticationUtil.generateBasicAutenticationHeader(clientConfig.getUserName(),
clientConfig.getUserPassword()));
}
});
return response.getValue().getFlightNumber();
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:22,代码来源:TicketAgentClient.java
示例3: addSecurity
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
/**
* Agrega seguridad a una llamada a un servicio, para ello agrega dos header
* params, pertenecientes a Usuario y Password.
*
* @param user
* usuario de la llamada
* @param password
* contraseña del que invoca el servicio.
* @param message
* mensaje que actualmente se esta enviando
*/
public void addSecurity(String user, String password,
WebServiceMessage message) {
Charset cs = Charset.forName(CharEncoding.UTF_8);
TransportContext context = TransportContextHolder.getTransportContext();
HttpUrlConnection connection = (HttpUrlConnection) context
.getConnection();
HttpURLConnection uRLConnection = connection.getConnection();
String auth = CREDENTIALS_FORMAT.replace("USER", user).replace(
"PASSWORD", password);
byte[] encode = Base64.encode(auth.getBytes(cs));
uRLConnection.addRequestProperty(AUTHORIZATION_HEADER_PARAM,
HEADER_CREDENTIALS_FORMAT.replace("CREDENTIALS", new String(
encode, cs)));
}
开发者ID:fpuna-cia,项目名称:karaku,代码行数:27,代码来源:WSSecurityInterceptor.java
示例4: handleInvalidXmlException
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Override
protected void handleInvalidXmlException(HttpServletRequest req, HttpServletResponse res, Object handler,
InvalidXmlException ex) throws Exception {
WebServiceConnection connection = new MyHttpServletConnection(req, res);
TransportContext previousTransportContext = TransportContextHolder.getTransportContext();
TransportContextHolder.setTransportContext(new DefaultTransportContext(connection));
try {
MessageContext messageContext = new DefaultMessageContext(getMessageFactory().createWebServiceMessage(),
getMessageFactory());
SoapBody soapBody = ((SoapMessage) messageContext.getResponse()).getSoapBody();
soapBody.addServerOrReceiverFault(getFaultString(ex), Locale.ENGLISH);
connection.send(messageContext.getResponse());
} finally {
TransportUtils.closeConnection(connection);
TransportContextHolder.setTransportContext(previousTransportContext);
}
}
开发者ID:integram,项目名称:cleverbus,代码行数:22,代码来源:ErrorAwareWebServiceMessageReceiverHandlerAdapter.java
示例5: before
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void before(){
super.before();
handler = new RevokeSecurityGroupIngressHandler(){
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
List<NetworkRule> networkRules = new ArrayList<NetworkRule>();
NetworkRule networkRule = new NetworkRule();
networkRule.setDestinationSecurityGroupName("default");
networkRule.setNetworkProtocol(NetworkProtocol.TCP);
networkRule.setNetworkRuleType(NetworkRuleType.FIREWALL_OPEN);
networkRule.setPortRangeMax(80);
networkRule.setPortRangeMin(80);
networkRule.setSourceNetworks(new String[]{"0.0.0.0/0"});
networkRules.add(networkRule);
securityGroupService = mock(SecurityGroupService.class);
when(securityGroupService.revokeIngress("userid", "default", networkRules)).thenReturn(true);
handler.setSecurityGroupService(securityGroupService);
}
开发者ID:barnyard,项目名称:pi,代码行数:23,代码来源:RevokeSecurityGroupIngressHandlerTest.java
示例6: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.describeAddressesHandler = new DescribeAddressesHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
elasticIpAddressesService = mock(ElasticIpAddressesService.class);
List<String> addresses = new ArrayList<String>();
List<String> doubleUpAddresses = new ArrayList<String>();
doubleUpAddresses.add("1.1.1.1");
doubleUpAddresses.add("2.2.2.2");
SortedMap<String, InstanceRecord> addressesRecords = new TreeMap<String, InstanceRecord>();
addressesRecords.put("1.1.1.1", new InstanceRecord("i-001", "userid"));
addressesRecords.put("2.2.2.2", new InstanceRecord("i-002", "userid"));
when(elasticIpAddressesService.describeAddresses("userid", addresses)).thenReturn(addressesRecords);
when(elasticIpAddressesService.describeAddresses("userid", doubleUpAddresses)).thenReturn(addressesRecords);
describeAddressesHandler.setElasticIpAddressesService(elasticIpAddressesService);
}
开发者ID:barnyard,项目名称:pi,代码行数:22,代码来源:DescribeAddressesHandlerTest.java
示例7: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.describeImagesHandler = new DescribeImagesHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
imageService = mock(ManagementImageService.class);
List<String> imageIds = new ArrayList<String>();
imageIds.add("kmi-111");
imageIds.add("kmi-222");
images = new HashSet<Image>();
images.add(new Image("kmi-111", "k-111", "r-111", "manifest", "userid", "architecture", ImagePlatform.linux, true, MachineType.KERNEL));
images.add(new Image("kmi-111", "k-222", "r-111", "manifest", "userid", "architecture", ImagePlatform.linux, true, MachineType.RAMDISK));
when(imageService.describeImages("userid", imageIds)).thenReturn(images);
describeImagesHandler.setImageService(imageService);
}
开发者ID:barnyard,项目名称:pi,代码行数:20,代码来源:DescribeImagesHandlerTest.java
示例8: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.registerImageHandler = new RegisterImageHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
requestDocument = RegisterImageDocument.Factory.newInstance();
addNewRegisterImage = requestDocument.addNewRegisterImage();
addNewRegisterImage.setImageLocation("/tmp/imagefile");
imageService = mock(ManagementImageService.class);
when(imageService.registerImage("userid", "/tmp/imagefile")).thenReturn("kmi-123");
registerImageHandler.setImageService(imageService);
}
开发者ID:barnyard,项目名称:pi,代码行数:17,代码来源:RegisterImageHandlerTest.java
示例9: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.createSnapshotHandler = new CreateSnapshotHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
elasticBlockStorageService = mock(ElasticBlockStorageService.class);
Snapshot value = new Snapshot();
value.setVolumeId(volumeId);
value.setSnapshotId("snap-123");
value.setStatus(SnapshotState.PENDING);
value.setProgress(10.0);
value.setStartTime(System.currentTimeMillis());
when(elasticBlockStorageService.createSnapshot("userid", "v-123", null)).thenReturn(value);
createSnapshotHandler.setElasticBlockStorageService(elasticBlockStorageService);
ReflectionTestUtils.setField(createSnapshotHandler, "conversionUtils", new ConversionUtils());
}
开发者ID:barnyard,项目名称:pi,代码行数:21,代码来源:CreateSnapshotHandlerTest.java
示例10: before
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void before() {
elasticBlockStorage = mock(ElasticBlockStorageService.class);
List<Snapshot> listOfSnapshots = new ArrayList<Snapshot>();
listOfSnapshots.add(new Snapshot(snapshotId, volumeId, status, startTime, progress, description, ownerId));
when(elasticBlockStorage.describeSnapshots("userid", new ArrayList<String>())).thenReturn(listOfSnapshots);
this.connection = mock(HttpExchangeConnection.class);
this.transportContext = mock(TransportContext.class);
this.httpExchange = mock(HttpExchange.class);
when(this.transportContext.getConnection()).thenReturn(connection);
when(this.connection.getHttpExchange()).thenReturn(httpExchange);
when(this.httpExchange.getAttribute("koala.api.userid")).thenReturn(userid);
handler = new DescribeSnapshotsHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
handler.setElasticBlockStorage(elasticBlockStorage);
ReflectionTestUtils.setField(handler, "conversionUtils", new ConversionUtils());
}
开发者ID:barnyard,项目名称:pi,代码行数:22,代码来源:DescribeSnapshotsHandlerTest.java
示例11: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
super.before();
this.terminateInstancesHandler = new TerminateInstancesHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
requestDocument = TerminateInstancesDocument.Factory.newInstance();
addNewTerminateInstances = requestDocument.addNewTerminateInstances();
TerminateInstancesInfoType addNewInstancesSet = addNewTerminateInstances.addNewInstancesSet();
TerminateInstancesItemType addNewItem = addNewInstancesSet.addNewItem();
addNewItem.setInstanceId(INSTANCE_ID);
instancesService = mock(InstancesService.class);
List<String> instanceIds = new ArrayList<String>();
instanceIds.add(INSTANCE_ID);
Map<String, InstanceStateTransition> instanceTransistions = new HashMap<String, InstanceStateTransition>();
instanceTransistions.put(INSTANCE_ID, new InstanceStateTransition(InstanceState.RUNNING, InstanceState.SHUTTING_DOWN));
when(instancesService.terminateInstances(anyString(), (Collection<String>) anyObject())).thenReturn(instanceTransistions);
terminateInstancesHandler.setInstancesService(instancesService);
}
开发者ID:barnyard,项目名称:pi,代码行数:26,代码来源:TerminateInstancesHandlerTest.java
示例12: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.getConsoleOutputHandler = new GetConsoleOutputHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
requestDocument = GetConsoleOutputDocument.Factory.newInstance();
addNewGetConsoleOutput = requestDocument.addNewGetConsoleOutput();
instanceId = "i-123";
addNewGetConsoleOutput.setInstanceId(instanceId);
instancesService = mock(InstancesService.class);
ConsoleOutput value = new ConsoleOutput("Did you really mean to do rm -rf?", 1864445563437L, "bob", ImagePlatform.windows);
when(instancesService.getConsoleOutput("userid", "i-123")).thenReturn(value);
getConsoleOutputHandler.setInstancesService(instancesService);
}
开发者ID:barnyard,项目名称:pi,代码行数:19,代码来源:GetConsoleOutputHandlerTest.java
示例13: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.describeKeyPairsHandler = new DescribeKeyPairsHandler(){
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
keyPairsService = mock(KeyPairsService.class);
List<String> keyNames = new ArrayList<String>();
keyNames.add(keyName1);
keyNames.add(keyName2);
List<KeyPair> keyPairs = new ArrayList<KeyPair>();
keyPairs.add(new KeyPair("myKey1", "myKey1 fingerprint", ""));
keyPairs.add(new KeyPair("myKey2", "myKey2 fingerprint", ""));
when(keyPairsService.describeKeyPairs("userid", keyNames)).thenReturn(keyPairs);
describeKeyPairsHandler.setKeyPairsService(keyPairsService);
}
开发者ID:barnyard,项目名称:pi,代码行数:20,代码来源:DescribeKeyPairsHandlerTest.java
示例14: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.attachVolumeHandler = new AttachVolumeHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
requestDocument = AttachVolumeDocument.Factory.newInstance();
addNewAttachVolume = requestDocument.addNewAttachVolume();
addNewAttachVolume.setInstanceId("i-123");
device = "device";
addNewAttachVolume.setDevice(device);
volume = "volume";
addNewAttachVolume.setVolumeId(volume);
elasticBlockStorageService = mock(ElasticBlockStorageService.class);
Volume value = new Volume("userid", "volume", "i-123", "device", VolumeState.CREATING, now);
when(elasticBlockStorageService.attachVolume("userid", "volume", "i-123", "device")).thenReturn(value);
attachVolumeHandler.setElasticBlockStorageService(elasticBlockStorageService);
}
开发者ID:barnyard,项目名称:pi,代码行数:22,代码来源:AttachVolumeHandlerTest.java
示例15: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.deregisterImageHandler = new DeregisterImageHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
requestDocument = DeregisterImageDocument.Factory.newInstance();
addNewDederegisterImage = requestDocument.addNewDeregisterImage();
addNewDederegisterImage.setImageId("kmi-123");
imageService = mock(ManagementImageService.class);
when(imageService.deregisterImage("userid", "kmi-123")).thenReturn(true);
deregisterImageHandler.setImageService(imageService);
}
开发者ID:barnyard,项目名称:pi,代码行数:17,代码来源:DeregisterImageHandlerTest.java
示例16: setUp
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.before();
this.rebootInstancesHandler = new RebootInstancesHandler() {
@Override
protected TransportContext getTransportContext() {
return transportContext;
}
};
requestDocument = RebootInstancesDocument.Factory.newInstance();
addNewRebootInstances = requestDocument.addNewRebootInstances();
instanceId = "i-123";
addNewRebootInstances.addNewInstancesSet().addNewItem().setInstanceId(instanceId);
instancesService = mock(InstancesService.class);
List<String> instanceIds = new ArrayList<String>();
instanceIds.add("i-123");
when(instancesService.rebootInstances("userid", instanceIds)).thenReturn(true);
rebootInstancesHandler.setInstancesService(instancesService);
}
开发者ID:barnyard,项目名称:pi,代码行数:20,代码来源:RebootInstancesHandlerTest.java
示例17: setTenantContextAsHeader
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
private void setTenantContextAsHeader() throws IOException {
TransportContext transportContext = TransportContextHolder.getTransportContext();
WebServiceConnection connection = transportContext.getConnection();
String tenant = TenantContextHolder.getContext().getTenant();
if (tenant != null && connection instanceof HeadersAwareSenderWebServiceConnection) {
((HeadersAwareSenderWebServiceConnection) connection).addRequestHeader(headerName, tenant);
}
}
开发者ID:mdeinum,项目名称:spring-multi-tenancy,代码行数:9,代码来源:TenantContextEndpointInterceptor.java
示例18: handleRequest
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
TransportContext transportContext = TransportContextHolder.getTransportContext();
WebServiceConnection connection = transportContext.getConnection();
TenantContext context = getTenantContext(connection);
this.logger.debug("Using context: {}", context);
TenantContextHolder.setContext(context);
return true;
}
开发者ID:mdeinum,项目名称:spring-multi-tenancy,代码行数:11,代码来源:TenantContextEndpointInterceptor.java
示例19: getWeServiceConnection
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
private WebServiceConnection getWeServiceConnection() {
TransportContext transportContext = TransportContextHolder.getTransportContext();
if (transportContext != null) {
WebServiceConnection webServiceConnection = transportContext.getConnection();
if (webServiceConnection != null) {
return webServiceConnection;
}
}
return null;
}
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:CamelEndpointMapping.java
示例20: getUserId
import org.springframework.ws.transport.context.TransportContext; //导入依赖的package包/类
protected String getUserId() {
TransportContext context = getTransportContext();
HttpExchangeConnection connection = (HttpExchangeConnection) context.getConnection();
String userid = (String) connection.getHttpExchange().getAttribute("koala.api.userid");
LOG.debug(String.format("userid: %s", userid));
return userid;
}
开发者ID:barnyard,项目名称:pi,代码行数:8,代码来源:HandlerBase.java
注:本文中的org.springframework.ws.transport.context.TransportContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论