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

com.microsoft.bingads.internal.CxfUtils Maven / Gradle / Ivy

Go to download

The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.

There is a newer version: 13.0.22.1
Show newest version
package com.microsoft.bingads.internal;

import java.util.function.Consumer;
import java.util.function.Supplier;

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.ext.logging.LoggingFeature;
import org.apache.cxf.feature.Feature;

public class CxfUtils {
    public static  T runOnNewBus(Supplier func, Consumer customizeLogging) {
        Bus newBus = BusFactory.newInstance().createBus();

        for (Feature feature : newBus.getFeatures()) {
            if (feature instanceof LoggingFeature) {
                LoggingFeature loggingFeature = (LoggingFeature)feature;
                
                customizeLogging.accept(loggingFeature);

                break;
            }
        }

        Bus oldBus = BusFactory.getAndSetThreadDefaultBus(newBus);

        try {
            return func.get();
        } finally {
            BusFactory.setThreadDefaultBus(oldBus);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy