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

com.sap.cloud.sdk.s4hana.connectivity.soap.Axis2CustomConverterListener Maven / Gradle / Ivy

There is a newer version: 2.28.0
Show newest version
/*
 * Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
 */

package com.sap.cloud.sdk.s4hana.connectivity.soap;

import javax.annotation.Nonnull;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.apache.axis2.databinding.utils.ConverterUtil;
import org.slf4j.Logger;

import com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory;

/**
 * Servlet listener that is responsible for registering a default custom converter class in the Axis2 framework.
 */
@WebListener
public class Axis2CustomConverterListener implements ServletContextListener
{
    private static final Logger logger = CloudLoggerFactory.getLogger(Axis2CustomConverterListener.class);

    @Override
    public void contextInitialized( @Nonnull final ServletContextEvent servletContextEvent )
    {
        registerCustomConverterForSoap(SoapCustomConverter.class);
    }

    @Override
    public void contextDestroyed( @Nonnull final ServletContextEvent servletContextEvent )
    {

    }

    private void registerCustomConverterForSoap( final Class converterClass )
    {
        try {
            SoapQuery.registerCustomConverter(converterClass);

            if( logger.isInfoEnabled() ) {
                logger.info(
                    "Axis2 Custom Converter Class " + converterClass.getSimpleName() + " registered during startup.");
            }
        }
        catch( final SoapException e ) {
            logger.error(
                "Error during registering Axis2 Custom Converter Class "
                    + converterClass.getSimpleName()
                    + ": "
                    + e.getMessage(),
                e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy