예제 #1
0
 private EndpointReferenceType getReplyTo(Message message, EndpointReferenceType originalReplyTo) {
   Exchange exchange = message.getExchange();
   Endpoint info = exchange.getEndpoint();
   if (info == null) {
     return originalReplyTo;
   }
   synchronized (info) {
     EndpointInfo ei = info.getEndpointInfo();
     Destination dest = ei.getProperty(DECOUPLED_DESTINATION, Destination.class);
     if (dest == null) {
       dest = createDecoupledDestination(message);
       if (dest != null) {
         info.getEndpointInfo().setProperty(DECOUPLED_DESTINATION, dest);
       }
     }
     if (dest != null) {
       // if the decoupled endpoint context prop is set and the address is relative, return the
       // absolute url.
       final String replyTo = dest.getAddress().getAddress().getValue();
       if (replyTo.startsWith("/")) {
         String debase =
             (String)
                 message.getContextualProperty(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY);
         if (debase != null) {
           return EndpointReferenceUtils.getEndpointReference(debase + replyTo);
         }
       }
       return dest.getAddress();
     }
   }
   return originalReplyTo;
 }
예제 #2
0
  /**
   * This test verfies that the "getTarget() call returns the correct EndpointReferenceType for the
   * given endpoint address.
   */
  @Test
  public void testGetTarget() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.com/bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();

    EndpointReferenceType target =
        EndpointReferenceUtils.getEndpointReference("http://nowhere.com/bar/foo");

    // Test call
    EndpointReferenceType ref = conduit.getTarget();

    assertNotNull("unexpected null target", ref);
    assertEquals(
        "unexpected target",
        EndpointReferenceUtils.getAddress(ref),
        EndpointReferenceUtils.getAddress(target));

    assertEquals("unexpected address", conduit.getAddress(), "http://nowhere.com/bar/foo");
    assertEquals("unexpected on-demand URL", conduit.getURI().getPath(), "/bar/foo");
  }
예제 #3
0
 /** Set up the decoupled Destination if necessary. */
 private Destination setUpDecoupledDestination(Bus bus, String replyToAddress, Message message) {
   EndpointReferenceType reference = EndpointReferenceUtils.getEndpointReference(replyToAddress);
   if (reference != null) {
     String decoupledAddress = reference.getAddress().getValue();
     LOG.info("creating decoupled endpoint: " + decoupledAddress);
     try {
       Destination dest = getDestination(bus, replyToAddress, message);
       bus.getExtension(ClientLifeCycleManager.class).registerListener(DECOUPLED_DEST_CLEANER);
       return dest;
     } catch (Exception e) {
       // REVISIT move message to localizable Messages.properties
       LOG.log(Level.WARNING, "decoupled endpoint creation failed: ", e);
     }
   }
   return null;
 }