Search in sources :

Example 1 with LoaderCallback

use of org.killbill.billing.util.cache.TenantOverdueConfigCacheLoader.LoaderCallback in project killbill by killbill.

the class EhCacheOverdueConfigCache method initializeCacheLoaderArgument.

private CacheLoaderArgument initializeCacheLoaderArgument() {
    final LoaderCallback loaderCallback = new LoaderCallback() {

        @Override
        public Object loadOverdueConfig(final String overdueConfigXML) throws OverdueApiException {
            final InputStream overdueConfigStream = new ByteArrayInputStream(overdueConfigXML.getBytes());
            final URI uri;
            try {
                uri = new URI("/overdueConfig");
                final DefaultOverdueConfig overdueConfig = XMLLoader.getObjectFromStream(uri, overdueConfigStream, DefaultOverdueConfig.class);
                return overdueConfig;
            } catch (final Exception e) {
                throw new OverdueApiException(ErrorCode.OVERDUE_INVALID_FOR_TENANT, "Problem encountered loading overdue config ", e);
            }
        }
    };
    final Object[] args = new Object[1];
    args[0] = loaderCallback;
    final ObjectType irrelevant = null;
    final InternalTenantContext notUsed = null;
    return new CacheLoaderArgument(irrelevant, args, notUsed);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) URI(java.net.URI) DefaultOverdueConfig(org.killbill.billing.overdue.config.DefaultOverdueConfig) LoaderCallback(org.killbill.billing.util.cache.TenantOverdueConfigCacheLoader.LoaderCallback) OverdueApiException(org.killbill.billing.overdue.api.OverdueApiException) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument) OverdueApiException(org.killbill.billing.overdue.api.OverdueApiException) ObjectType(org.killbill.billing.ObjectType) ByteArrayInputStream(java.io.ByteArrayInputStream) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext)

Example 2 with LoaderCallback

use of org.killbill.billing.util.cache.TenantOverdueConfigCacheLoader.LoaderCallback in project killbill by killbill.

the class DefaultOverdueConfigCache method initializeCacheLoaderArgument.

private CacheLoaderArgument initializeCacheLoaderArgument() {
    final LoaderCallback loaderCallback = new LoaderCallback() {

        @Override
        public OverdueConfig loadOverdueConfig(final String overdueConfigXML) throws OverdueApiException {
            final InputStream overdueConfigStream = new ByteArrayInputStream(overdueConfigXML.getBytes());
            try {
                return XMLLoader.getObjectFromStream(overdueConfigStream, DefaultOverdueConfig.class);
            } catch (final Exception e) {
                throw new OverdueApiException(ErrorCode.OVERDUE_INVALID_FOR_TENANT, "Problem encountered loading overdue config ", e);
            }
        }
    };
    final Object[] args = new Object[1];
    args[0] = loaderCallback;
    final ObjectType irrelevant = null;
    final InternalTenantContext notUsed = null;
    return new CacheLoaderArgument(irrelevant, args, notUsed);
}
Also used : ObjectType(org.killbill.billing.ObjectType) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) LoaderCallback(org.killbill.billing.util.cache.TenantOverdueConfigCacheLoader.LoaderCallback) OverdueApiException(org.killbill.billing.overdue.api.OverdueApiException) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument) OverdueApiException(org.killbill.billing.overdue.api.OverdueApiException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ObjectType (org.killbill.billing.ObjectType)2 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)2 OverdueApiException (org.killbill.billing.overdue.api.OverdueApiException)2 CacheLoaderArgument (org.killbill.billing.util.cache.CacheLoaderArgument)2 LoaderCallback (org.killbill.billing.util.cache.TenantOverdueConfigCacheLoader.LoaderCallback)2 URI (java.net.URI)1 DefaultOverdueConfig (org.killbill.billing.overdue.config.DefaultOverdueConfig)1