Search in sources :

Example 1 with DefaultMonetizationImpl

use of org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl in project carbon-apimgt by wso2.

the class APIAdminImpl method getMonetizationImplClass.

/**
 * These methods load the monetization implementation class
 *
 * @return monetization implementation class
 * @throws APIManagementException if failed to load monetization implementation class
 */
public Monetization getMonetizationImplClass() throws APIManagementException {
    APIManagerConfiguration configuration = org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
    Monetization monetizationImpl = null;
    if (configuration == null) {
        log.error("API Manager configuration is not initialized.");
    } else {
        String monetizationImplClass = configuration.getFirstProperty(APIConstants.Monetization.MONETIZATION_IMPL);
        if (monetizationImplClass == null) {
            monetizationImpl = new DefaultMonetizationImpl();
        } else {
            try {
                monetizationImpl = (Monetization) APIUtil.getClassInstance(monetizationImplClass);
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
                APIUtil.handleException("Failed to load monetization implementation class.", e);
            }
        }
    }
    return monetizationImpl;
}
Also used : Monetization(org.wso2.carbon.apimgt.api.model.Monetization) DefaultMonetizationImpl(org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl)

Example 2 with DefaultMonetizationImpl

use of org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl in project carbon-apimgt by wso2.

the class APIProviderImpl method getMonetizationImplClass.

/**
 * This methods loads the monetization implementation class
 *
 * @return monetization implementation class
 * @throws APIManagementException if failed to load monetization implementation class
 */
public Monetization getMonetizationImplClass() throws APIManagementException {
    APIManagerConfiguration configuration = org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
    Monetization monetizationImpl = null;
    if (configuration == null) {
        log.error("API Manager configuration is not initialized.");
    } else {
        String monetizationImplClass = configuration.getFirstProperty(APIConstants.Monetization.MONETIZATION_IMPL);
        if (monetizationImplClass == null) {
            monetizationImpl = new DefaultMonetizationImpl();
        } else {
            try {
                monetizationImpl = (Monetization) APIUtil.getClassInstance(monetizationImplClass);
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
                APIUtil.handleException("Failed to load monetization implementation class.", e);
            }
        }
    }
    return monetizationImpl;
}
Also used : Monetization(org.wso2.carbon.apimgt.api.model.Monetization) DefaultMonetizationImpl(org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl)

Example 3 with DefaultMonetizationImpl

use of org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl in project carbon-apimgt by wso2.

the class APIConsumerImpl method getMonetizationImplClass.

/**
 * This methods loads the monetization implementation class
 *
 * @return monetization implementation class
 * @throws APIManagementException if failed to load monetization implementation class
 */
public Monetization getMonetizationImplClass() throws APIManagementException {
    APIManagerConfiguration configuration = getAPIManagerConfiguration();
    Monetization monetizationImpl = null;
    if (configuration == null) {
        log.error("API Manager configuration is not initialized.");
    } else {
        String monetizationImplClass = configuration.getFirstProperty(APIConstants.Monetization.MONETIZATION_IMPL);
        if (monetizationImplClass == null) {
            monetizationImpl = new DefaultMonetizationImpl();
        } else {
            try {
                monetizationImpl = (Monetization) APIUtil.getClassInstance(monetizationImplClass);
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
                APIUtil.handleException("Failed to load monetization implementation class.", e);
            }
        }
    }
    return monetizationImpl;
}
Also used : Monetization(org.wso2.carbon.apimgt.api.model.Monetization) DefaultMonetizationImpl(org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl)

Aggregations

Monetization (org.wso2.carbon.apimgt.api.model.Monetization)3 DefaultMonetizationImpl (org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl)3