Example usage for javax.xml.ws Service getClass

List of usage examples for javax.xml.ws Service getClass

Introduction

In this page you can find the example usage for javax.xml.ws Service getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

private static ServiceDelegate getServiceDelegateForService(Service service) {
    // Need to get to the private Service._delegate
    ServiceDelegate returnServiceDelegate = null;
    try {/*from   ww w  .  j  a  v a 2s.  c  o m*/
        try {
            Field serviceDelgateField = service.getClass().getDeclaredField("delegate");
            serviceDelgateField.setAccessible(true);
            returnServiceDelegate = (ServiceDelegate) serviceDelgateField.get(service);
        } catch (NoSuchFieldException e) {
            // This may be a generated service subclass, so get the delegate from the superclass
            Field serviceDelegateField = service.getClass().getSuperclass().getDeclaredField("delegate");
            serviceDelegateField.setAccessible(true);
            returnServiceDelegate = (ServiceDelegate) serviceDelegateField.get(service);
        }
    } catch (SecurityException e) {
        if (log.isDebugEnabled()) {
            log.debug("Attempt to get service delegate for service caught exception.", e);
        }
        throw ExceptionFactory.makeWebServiceException(e);
    } catch (IllegalAccessException e) {
        if (log.isDebugEnabled()) {
            log.debug("Attempt to get service delegate for service caught exception.", e);
        }
        throw ExceptionFactory.makeWebServiceException(e);
    } catch (NoSuchFieldException e) {
        if (log.isDebugEnabled()) {
            log.debug("Attempt to get service delegate for service caught exception.", e);
        }
        throw ExceptionFactory.makeWebServiceException(e);
    }
    return returnServiceDelegate;

}