Search in sources :

Example 1 with CacheLoaderArgument

use of org.killbill.billing.util.cache.CacheLoaderArgument in project killbill by killbill.

the class EhCacheOverriddenPlanCache method getOverriddenPlan.

@Override
public DefaultPlan getOverriddenPlan(final String planName, final StaticCatalog catalog, final InternalTenantContext context) {
    final ObjectType irrelevant = null;
    final Object[] args = new Object[2];
    args[0] = loaderCallback;
    args[1] = catalog;
    final CacheLoaderArgument argument = new CacheLoaderArgument(irrelevant, args, context);
    return (DefaultPlan) cacheController.get(planName, argument);
}
Also used : ObjectType(org.killbill.billing.ObjectType) DefaultPlan(org.killbill.billing.catalog.DefaultPlan) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument) PlanPhasePriceOverride(org.killbill.billing.catalog.api.PlanPhasePriceOverride) DefaultPriceOverride(org.killbill.billing.catalog.override.DefaultPriceOverride) DefaultPlanPhasePriceOverride(org.killbill.billing.catalog.DefaultPlanPhasePriceOverride)

Example 2 with CacheLoaderArgument

use of org.killbill.billing.util.cache.CacheLoaderArgument in project killbill by killbill.

the class EhCacheStateMachineConfigCache method createCacheLoaderArgument.

private CacheLoaderArgument createCacheLoaderArgument(final String pluginName) {
    final Object[] args = new Object[2];
    args[0] = loaderCallback;
    args[1] = pluginName;
    final ObjectType irrelevant = null;
    final InternalTenantContext notUsed = null;
    return new CacheLoaderArgument(irrelevant, args, notUsed);
}
Also used : ObjectType(org.killbill.billing.ObjectType) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument)

Example 3 with CacheLoaderArgument

use of org.killbill.billing.util.cache.CacheLoaderArgument in project killbill by killbill.

the class DefaultAccountInternalApi method getBCD.

@Override
public int getBCD(final UUID accountId, final InternalTenantContext context) throws AccountApiException {
    final CacheLoaderArgument arg = createBCDCacheLoaderArgument(context);
    final Integer result = (Integer) bcdCacheController.get(accountId, arg);
    return result != null ? result : DefaultMutableAccountData.DEFAULT_BILLING_CYCLE_DAY_LOCAL;
}
Also used : CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument)

Example 4 with CacheLoaderArgument

use of org.killbill.billing.util.cache.CacheLoaderArgument in project killbill by killbill.

the class DefaultAccountInternalApi method createBCDCacheLoaderArgument.

private CacheLoaderArgument createBCDCacheLoaderArgument(final InternalTenantContext context) {
    final AccountBCDCacheLoader.LoaderCallback loaderCallback = new AccountBCDCacheLoader.LoaderCallback() {

        @Override
        public Object loadAccountBCD(final UUID accountId, final InternalTenantContext context) {
            Object result = accountDao.getAccountBCD(accountId, context);
            if (result != null) {
                // If the value is 0, then account BCD was not set so we don't want to create a cache entry
                result = result.equals(DefaultMutableAccountData.DEFAULT_BILLING_CYCLE_DAY_LOCAL) ? null : result;
            }
            return result;
        }
    };
    final Object[] args = new Object[1];
    args[0] = loaderCallback;
    final ObjectType irrelevant = null;
    return new CacheLoaderArgument(irrelevant, args, context);
}
Also used : ObjectType(org.killbill.billing.ObjectType) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) AccountBCDCacheLoader(org.killbill.billing.util.cache.AccountBCDCacheLoader) UUID(java.util.UUID) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument)

Example 5 with CacheLoaderArgument

use of org.killbill.billing.util.cache.CacheLoaderArgument 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)

Aggregations

CacheLoaderArgument (org.killbill.billing.util.cache.CacheLoaderArgument)11 ObjectType (org.killbill.billing.ObjectType)7 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)7 Predicate (com.google.common.base.Predicate)1 ImmutableList (com.google.common.collect.ImmutableList)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Annotation (java.lang.annotation.Annotation)1 URI (java.net.URI)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 DefaultStateMachineConfig (org.killbill.automaton.DefaultStateMachineConfig)1 StateMachineConfig (org.killbill.automaton.StateMachineConfig)1 Account (org.killbill.billing.account.api.Account)1 DefaultAccount (org.killbill.billing.account.api.DefaultAccount)1 DefaultImmutableAccountData (org.killbill.billing.account.api.DefaultImmutableAccountData)1 DefaultPlan (org.killbill.billing.catalog.DefaultPlan)1 DefaultPlanPhasePriceOverride (org.killbill.billing.catalog.DefaultPlanPhasePriceOverride)1