コード例 #1
0
  public synchronized Collection<TariffPricePair> getTariffPricePairs(
      ProductTypeID productTypeID,
      CustomerGroupID customerGroupID,
      CurrencyID currencyID,
      ProgressMonitor monitor) {
    //		if (priceConfigID == null)
    //			throw new IllegalArgumentException("priceConfigID must not be null!");
    if (productTypeID == null)
      throw new IllegalArgumentException("productTypeID must not be null!");

    if (customerGroupID == null)
      throw new IllegalArgumentException("customerGroupID must not be null!");

    if (currencyID == null) throw new IllegalArgumentException("currencyID must not be null!");

    String key =
        productTypeID.toString() + "::" + customerGroupID.toString() + "::" + currencyID.toString();

    //		TariffPricePairsCarrier tppc = (TariffPricePairsCarrier) tariffPricePairsCarriers.get(key);

    TariffPricePairsCarrier tppc =
        (TariffPricePairsCarrier)
            cache.get(TariffPricePairDAO.class.getName(), key, (String[]) null, -1);
    if (tppc == null) { // || System.currentTimeMillis() - tppc.loadDT > EXPIRE_MSEC) {
      try {
        SimpleTradeManagerRemote stm = ejbProvider.getRemoteBean(SimpleTradeManagerRemote.class);
        Collection<TariffPricePair> tariffPricePairs =
            CollectionUtil.castCollection(
                stm.getTariffPricePairs(
                    productTypeID,
                    customerGroupID,
                    currencyID,
                    FETCH_GROUPS_TARIFF,
                    FETCH_GROUPS_PRICE));

        tppc =
            new TariffPricePairsCarrier(
                productTypeID, customerGroupID, currencyID, tariffPricePairs);
        //				tariffPricePairsCarriers.put(key, tppc);

        // TODO We have to somehow get notified when the appropriate TariffUserSet changes (and
        // evict the record from the cache). Needs some more thoughts. Marco.
        cache.put(TariffPricePairDAO.class.getName(), key, tppc, (String[]) null, -1);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tppc.tariffPricePairs;
  }