cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1517548 - /cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
Date Mon, 26 Aug 2013 14:44:41 GMT
Author: dkulp
Date: Mon Aug 26 14:44:41 2013
New Revision: 1517548

URL: http://svn.apache.org/r1517548
Log:
Check the service itself and the binding for the various JMS spec extensors and adjust those
url's as well.

Modified:
    cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java

Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java?rev=1517548&r1=1517547&r2=1517548&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
(original)
+++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
Mon Aug 26 14:44:41 2013
@@ -94,42 +94,12 @@ public class EmbeddedJMSBrokerLauncher e
             for (Object o : map.values()) {
                 Service service = (Service)o;
                 Map<?, ?> ports = service.getPorts();
+                adjustExtensibilityElements(service.getExtensibilityElements(), url, encodedUrl);
+                
                 for (Object p : ports.values()) {
                     Port port = (Port)p;
-                    List<?> l = port.getExtensibilityElements();
-                    for (Object e : l) {
-                        if (e instanceof SOAPAddress) {
-                            String add = ((SOAPAddress)e).getLocationURI();
-                            int idx = add.indexOf("jndiURL=");
-                            if (idx != -1) {
-                                int idx2 = add.indexOf("&", idx);
-                                add = add.substring(0, idx)
-                                    + "jndiURL=" + encodedUrl
-                                    + (idx2 == -1 ? "" : add.substring(idx2));
-                                ((SOAPAddress)e).setLocationURI(add);
-                            }
-                        } else {
-                            try {
-                                Field f = e.getClass().getDeclaredField("jmsNamingProperty");
-                                ReflectionUtil.setAccessible(f);
-                                List<?> props = (List<?>)f.get(e);
-                                for (Object prop : props) {
-                                    f = prop.getClass().getDeclaredField("name");
-                                    ReflectionUtil.setAccessible(f);
-                                    if ("java.naming.provider.url".equals(f.get(prop))) {
-                                        f = prop.getClass().getDeclaredField("value");
-                                        ReflectionUtil.setAccessible(f);
-                                        String value = (String)f.get(prop);
-                                        if (value == null || !value.startsWith("classpath"))
{
-                                            f.set(prop, url);
-                                        }
-                                    }
-                                }
-                            } catch (Exception ex) {
-                                //ignore
-                            }
-                        }
-                    }                    
+                    adjustExtensibilityElements(port.getExtensibilityElements(), url, encodedUrl);
+                    adjustExtensibilityElements(port.getBinding().getExtensibilityElements(),
url, encodedUrl);
                 }
             }
         } catch (Exception e) {
@@ -137,6 +107,49 @@ public class EmbeddedJMSBrokerLauncher e
         }
     }
     
+    private static void adjustExtensibilityElements(List<?> l,
+                                                    String url,
+                                                    String encodedUrl) {
+        for (Object e : l) {
+            if (e instanceof SOAPAddress) {
+                String add = ((SOAPAddress)e).getLocationURI();
+                int idx = add.indexOf("jndiURL=");
+                if (idx != -1) {
+                    int idx2 = add.indexOf("&", idx);
+                    add = add.substring(0, idx)
+                        + "jndiURL=" + encodedUrl
+                        + (idx2 == -1 ? "" : add.substring(idx2));
+                    ((SOAPAddress)e).setLocationURI(add);
+                }
+            } else if (e.getClass().getSimpleName().startsWith("JndiURLType")) {
+                try {
+                    e.getClass().getMethod("setValue", String.class).invoke(e, url);
+                } catch (Exception ex) {
+                    //ignore
+                }                
+            } else {
+                try {
+                    Field f = e.getClass().getDeclaredField("jmsNamingProperty");
+                    ReflectionUtil.setAccessible(f);
+                    List<?> props = (List<?>)f.get(e);
+                    for (Object prop : props) {
+                        f = prop.getClass().getDeclaredField("name");
+                        ReflectionUtil.setAccessible(f);
+                        if ("java.naming.provider.url".equals(f.get(prop))) {
+                            f = prop.getClass().getDeclaredField("value");
+                            ReflectionUtil.setAccessible(f);
+                            String value = (String)f.get(prop);
+                            if (value == null || !value.startsWith("classpath")) {
+                                f.set(prop, url);
+                            }
+                        }
+                    }
+                } catch (Exception ex) {
+                    //ignore
+                }
+            }
+        }        
+    }
     public void stop() throws Exception {
         tearDown();
     }



Mime
View raw message