Example usage for org.springframework.oxm.jibx JibxMarshaller setTargetPackage

List of usage examples for org.springframework.oxm.jibx JibxMarshaller setTargetPackage

Introduction

In this page you can find the example usage for org.springframework.oxm.jibx JibxMarshaller setTargetPackage.

Prototype

public void setTargetPackage(String targetPackage) 

Source Link

Document

Set the target package for this instance.

Usage

From source file:eu.europeana.uim.sugarcrmclient.plugin.SugarCRMServiceImpl.java

/**
 * Constructor//from   w ww .  j av a 2 s .com
 */
public SugarCRMServiceImpl() {
    this.pollingListeners = new LinkedHashMap<String, PollingListener>();

    BlockingInitializer initializer = new BlockingInitializer() {
        @Override
        public void initializeInternal() {
            MessageFactory mf = null;
            try {
                mf = MessageFactory.newInstance();
            } catch (SOAPException e1) {
                e1.printStackTrace();
            }

            ExtendedSaajSoapMessageFactory mfactory = new ExtendedSaajSoapMessageFactory(mf);
            WebServiceTemplate webServiceTemplate = new WebServiceTemplate(mfactory);

            JibxMarshaller marshaller = new JibxMarshaller();

            marshaller.setStandalone(true);
            marshaller.setTargetClass(eu.europeana.uim.sugarcrmclient.jibxbindings.Login.class);
            marshaller.setTargetClass(eu.europeana.uim.sugarcrmclient.jibxbindings.GetEntries.class);
            marshaller.setEncoding("UTF-8");
            marshaller.setTargetPackage("eu.europeana.uim.sugarcrmclient.jibxbindings");

            try {
                marshaller.afterPropertiesSet();
            } catch (JiBXException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            System.out.println(
                    marshaller.supports(eu.europeana.uim.sugarcrmclient.jibxbindings.GetEntries.class));
            System.out.println(marshaller.supports(eu.europeana.uim.sugarcrmclient.jibxbindings.Login.class));

            webServiceTemplate.setMarshaller(marshaller);
            webServiceTemplate.setUnmarshaller(marshaller);

            sugarwsClient = new SugarWsClientImpl();
            String userName = PropertyReader.getProperty(UimConfigurationProperty.SUGARCRM_USERNAME);
            String password = PropertyReader.getProperty(UimConfigurationProperty.SUGARCRM_PASSWORD);
            String uri = PropertyReader.getProperty(UimConfigurationProperty.SUGARCRM_HOST);
            webServiceTemplate.setDefaultUri(uri);
            sugarwsClient.setUsername(userName);
            sugarwsClient.setPassword(password);
            sugarwsClient.setWebServiceTemplate(webServiceTemplate);

            try {
                sugarwsClient.setSessionID(
                        sugarwsClient.login(ClientUtils.createStandardLoginObject(userName, password)));
            } catch (JIXBLoginFailureException e) {
                sugarwsClient.setSessionID("-1");
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }

            System.out.println("Done");
        }

    };
    initializer.initialize(SugarWsClientImpl.class.getClassLoader());

}