    public static RuntimeDelegate getInstance() {
        if (delegate != null) {
            return delegate;
        }
        synchronized (RuntimeDelegate.class) {
            if (delegate != null) {
                return delegate;
            }
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            try {
                Object service = ProviderLocator.getService(RuntimeDelegate.class.getName(), RuntimeDelegate.class, classLoader);
                if (service != null) {
                    delegate = (RuntimeDelegate)service;
                    return delegate;
                }
            } catch (Exception ex) {
            } catch (Error ex) {
            }
            String className = null;
            try {
                className =  ProviderLocator.lookupByJREPropertyFile("lib" + File.separator + "jaxrpc.properties", RuntimeDelegate.class.getName());
                if (className != null) {
                    Class<?> delegateClass = ProviderLocator.loadClass(className,
                        RuntimeDelegate.class, classLoader);
                    delegate = (RuntimeDelegate)delegateClass.newInstance();
                    return delegate;
                }
            } catch (IOException e) {
            } catch (ClassNotFoundException e) {
            } catch (InstantiationException e) {
            } catch (IllegalAccessException e) {
            }
            try {
                className = System.getProperty("javax.ws.rs.ext.RuntimeDelegate");
            } catch (SecurityException e) {
            }
            if (className == null || "".equals(className)) {
                className = "org.apache.wink.common.internal.runtime.RuntimeDelegateImpl";
            }
            try {
                Class<?> delegateClass = ProviderLocator.loadClass(className,
                    RuntimeDelegate.class, classLoader);
                delegate = (RuntimeDelegate)delegateClass.newInstance();
                return delegate;
            } catch (ClassNotFoundException e1) {
            } catch (SecurityException e) {
            } catch (InstantiationException e) {
            } catch (IllegalAccessException e) {
            }
            return delegate;
        }
    }

    public static RuntimeDelegate getInstance() {
        if (delegate != null) {
            return delegate;
        }
        synchronized (RuntimeDelegate.class) {
            if (delegate != null) {
                return delegate;
            }
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            try {
                Object service = ProviderLocator.getService(RuntimeDelegate.class.getName(), RuntimeDelegate.class, classLoader);
                if (service != null) {
                    delegate = (RuntimeDelegate)service;
                    return delegate;
                }
            } catch (Exception ex) {
            } catch (Error ex) {
            }
            String className = null;
            try {
                className =  ProviderLocator.lookupByJREPropertyFile("lib" + File.separator + "jaxrpc.properties", RuntimeDelegate.class.getName());
                if (className != null) {
                    Class<?> delegateClass = ProviderLocator.loadClass(className,
                        RuntimeDelegate.class, classLoader);
                    delegate = (RuntimeDelegate)delegateClass.newInstance();
                    return delegate;
                }
            } catch (IOException e) {
            } catch (ClassNotFoundException e) {
            } catch (InstantiationException e) {
            } catch (IllegalAccessException e) {
            }
            try {
                className = System.getProperty("javax.ws.rs.ext.RuntimeDelegate");
            } catch (SecurityException e) {
            }
            if (className == null || "".equals(className)) {
                className = "org.apache.wink.common.internal.runtime.RuntimeDelegateImpl";
            }
            try {
                Class<?> delegateClass = ProviderLocator.loadClass(className,
                    RuntimeDelegate.class, classLoader);
                delegate = (RuntimeDelegate)delegateClass.newInstance();
                return delegate;
            } catch (ClassNotFoundException e1) {
            } catch (SecurityException e) {
            } catch (InstantiationException e) {
            } catch (IllegalAccessException e) {
            }
            throw new RuntimeException("Unable to create jax-rs RuntimeDelegate");
        }
    }
