Example usage for java.util.concurrent ConcurrentHashMap ConcurrentHashMap

List of usage examples for java.util.concurrent ConcurrentHashMap ConcurrentHashMap

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentHashMap ConcurrentHashMap.

Prototype

public ConcurrentHashMap() 

Source Link

Document

Creates a new, empty map with the default initial table size (16).

Usage

From source file:cc.osint.graphd.processes.JavascriptProcess.java

public JavascriptProcess(String key, GScriptEngine scriptEngine) {
    this.key = key;
    this.scriptEngine = scriptEngine;
    stateMap = new ConcurrentHashMap<String, Object>();
}

From source file:com.github.aistomin.jenkins.real.UsernamePasswordCredentials.java

@Override
public Map<String, String> headers() throws Exception {
    final Map<String, String> map = new ConcurrentHashMap<>();
    map.put("Authorization", String.format("Basic %s",
            Base64.encodeBase64String(String.format("%s:%s", this.user, this.pass).getBytes("UTF-8"))));
    return Collections.unmodifiableMap(map);
}

From source file:com.wineaccess.winelicensedetail.WineLicenseDetailAdapterHelper.java

/**
 * This method is used to update the WineLicenseDetail in the database.
 * //from  www.  j  a  v  a 2 s .c  o m
 * @param wineLicenseDetailUpdatePO
 *            is used to take the input in this PO.
 * @return output map containing response
 */
public static Map<String, Object> updateWineLicenseDetail(
        final WineLicenseDetailUpdatePO wineLicenseDetailUpdatePO) {

    logger.info("start updateWineLicenseDetail method");

    String errorMsg = StringUtils.EMPTY;

    final Map<String, Object> output = new ConcurrentHashMap<String, Object>();

    Response response = null;

    try {

        MasterData caLicenseType = null;
        WineModel wine = null;
        WineLicenseDetailModel wineLicenseDetailModel = null;

        if (wineLicenseDetailUpdatePO.getCaLicenseTypeId() != null
                && !wineLicenseDetailUpdatePO.getCaLicenseTypeId().isEmpty()) {
            caLicenseType = MasterDataRepository
                    .getMasterDataById(Long.parseLong(wineLicenseDetailUpdatePO.getCaLicenseTypeId()));
            if (caLicenseType == null) {
                // caLicenseType not exist
                response = ApplicationUtils.errorMessageGenerate(

                        SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_CA_LICENSE_TYPE,
                        SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_CA_LICENSE_TYPE_TEXT, SUCCESS_CODE);

                logger.error("CA License Type not exist");
            }
        }

        ProductItemModel productModel = ProductItemRepository
                .getProductItemById(Long.parseLong(wineLicenseDetailUpdatePO.getProductId()));
        if (productModel == null) {
            response = ApplicationUtils.errorMessageGenerate(

                    SystemErrorCode.UPDATE_WINE_PRODUCT_NOT_EXISTS,
                    SystemErrorCode.UPDATE_WINE_PRODUCT_NOT_EXISTS_TEXT, SUCCESS_CODE);

            logger.error("productId not exist");
        }

        if (response == null) {
            wine = WineRepository.getWineById(productModel.getItemId());
            if (wine == null) {
                // wine not exist
                response = ApplicationUtils.errorMessageGenerate(

                        SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE,
                        SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE_TEXT, SUCCESS_CODE);

                logger.error("wine not exist");
            }
        }

        if (response == null) {

            wineLicenseDetailModel = WineLicenseDetailRepository.getWineLicenseDetailByWine(wine);

            if (wineLicenseDetailModel == null) {

                WineryLicenseDetailModel wineryLicenseDetailModel = WineryLicenseDetailRepository
                        .getWineryLicenseDetailByWinery(wine.getWineryId());

                if (wineryLicenseDetailModel == null) {
                    // WineLicenseDetail not exist
                    response = ApplicationUtils.errorMessageGenerate(

                            SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE_LICENSE_ID,
                            SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE_LICENSE_ID_TEXT, SUCCESS_CODE);

                    logger.error("Wine License detail not exist");
                } else {
                    wineLicenseDetailModel = new WineLicenseDetailModel();

                    wineLicenseDetailModel.setCaLicenseType(wineryLicenseDetailModel.getCaLicenseType());
                    wineLicenseDetailModel.setWine(wine);
                    wineLicenseDetailModel.setContractExecuted(wineryLicenseDetailModel.getContractExecuted());
                    wineLicenseDetailModel.setShipCompliant(wineryLicenseDetailModel.getShipCompliant());
                    wineLicenseDetailModel.setShipEscrowNo(wineryLicenseDetailModel.getShipEscrowNo());

                    WineLicenseDetailRepository.save(wineLicenseDetailModel);

                    WineLicenseDetailVO wineLicenseDetailVO = new WineLicenseDetailVO(
                            SystemErrorCode.UPDATE_WINE_LICENSE_SUCCESS_TEXT);

                    BeanUtils.copyProperties(wineLicenseDetailVO, wineLicenseDetailModel);

                    wineLicenseDetailVO.setProductId(productModel.getId());
                    wineLicenseDetailVO.setWineId(wineLicenseDetailModel.getWine().getId());

                    response = new com.wineaccess.response.SuccessResponse(wineLicenseDetailVO, SUCCESS_CODE);
                }
            }
        }

        if (response == null) {

            wineLicenseDetailModel.setCaLicenseType(caLicenseType);

            wineLicenseDetailModel.setWine(wine);

            if (wineLicenseDetailUpdatePO.getContractExecuted() != null) {
                wineLicenseDetailModel.setContractExecuted(
                        Boolean.parseBoolean(wineLicenseDetailUpdatePO.getContractExecuted()));
            }

            if (wineLicenseDetailUpdatePO.getShipCompliant() != null) {
                wineLicenseDetailModel
                        .setShipCompliant(Boolean.parseBoolean(wineLicenseDetailUpdatePO.getShipCompliant()));
            }

            if (wineLicenseDetailUpdatePO.getShipEscrowNo() != null) {
                wineLicenseDetailModel.setShipEscrowNo(wineLicenseDetailUpdatePO.getShipEscrowNo());
            }

            if (wineLicenseDetailUpdatePO.getShipCompliantProductKey() != null) {
                wineLicenseDetailModel
                        .setShipCompliantProductKey(wineLicenseDetailUpdatePO.getShipCompliantProductKey());
            }

            if (wineLicenseDetailUpdatePO.getPriceToRetailer() != null) {
                wineLicenseDetailModel
                        .setPriceToRetailer(Double.parseDouble(wineLicenseDetailUpdatePO.getPriceToRetailer()));
            }

            if (wineLicenseDetailUpdatePO.getColaNumber() != null) {
                wineLicenseDetailModel.setColaNumber(wineLicenseDetailUpdatePO.getColaNumber());
            }

            WineLicenseDetailRepository.update(wineLicenseDetailModel);

            WineLicenseDetailVO wineLicenseDetailVO = new WineLicenseDetailVO(
                    SystemErrorCode.UPDATE_WINE_LICENSE_SUCCESS_TEXT);

            BeanUtils.copyProperties(wineLicenseDetailVO, wineLicenseDetailModel);

            wineLicenseDetailVO.setProductId(productModel.getId());
            wineLicenseDetailVO.setWineId(wineLicenseDetailModel.getWine().getId());

            response = new com.wineaccess.response.SuccessResponse(wineLicenseDetailVO, SUCCESS_CODE);
        }

    } catch (Exception e) {

        errorMsg = e.getCause().getMessage();
    }

    if (errorMsg.contains("uk_wine_id")) {
        response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.UPDATE_WINE_LICENSE_ALREADY_EXISTS,
                SystemErrorCode.UPDATE_WINE_LICENSE_ALREADY_EXISTS_TEXT, SUCCESS_CODE);

        logger.error("wine license detail already exists");
    }

    output.put(OUPUT_PARAM_KEY, response);

    logger.info("exit updateWineLicenseDetail method");

    return output;
}

From source file:service.ServerApplication.java

@Bean
UserRepository userRepository() {// w  w w .jav a2  s  . c o m
    Map<String, UserProtos.User> users = new ConcurrentHashMap<>();
    // populate with some dummy data
    // kalau sudah punya database, harusnya repo ini di-create dari database tsb
    Arrays.asList(
            //ini nanti harusnya diganti dengan methode private user di atas
            user("hayyuhanifah", "lalalala", "Hayyu Hanifah", "hayyuhanifah52@gmail.com", "085229167235",
                    "Jl Kebon Bibit Barat", "afteryearsofposting.blogspot.com"),
            user("kafifah", "lililili", "Khoirunnisa Afifah", "k_afis@gmail.com", "085229167236",
                    "Jl Siliwangi", "kafis.blogspot.com"),
            user("cfatima", "lulululu", "Choirunnisa Fatima", "choirunnisa.fatima@gmail.com", "085229167237",
                    "Jl Siliwangi", "ichakid.blogspot.com"))
            .forEach(c -> users.put(c.getUsername(), c));
    // our lambda just gets forwarded to Map#get(Integer)
    return users::get;
}

From source file:mecha.db.SolrManager.java

public SolrManager() throws Exception {
    cores = new ConcurrentHashMap<String, SolrCore>();
    partitionCoreRingList = new ArrayList<String>();
    for (int i = 0; i < PARTITION_CORE_COUNT; i++) {
        String s = "p" + i;
        partitionCoreRingList.add(s);/*from w w  w .ja  v a2s  . c  om*/
    }
    partitionCoreRing = new ConsistentHash<String>(1, partitionCoreRingList);
    partitionCoreCache = new HashMap<String, String>();
}

From source file:net.jmhertlein.mcanalytics.api.APISocket.java

public APISocket(PrintWriter out, BufferedReader in) {
    nextID = 0;//from   w ww  . j  a v a  2 s.com
    requests = new ConcurrentHashMap<>();
    this.out = out;
    this.in = in;
    workers = Executors.newCachedThreadPool();
}

From source file:com.justcloud.osgifier.SpringContextHolder.java

private SpringContextHolder() {
    contexts = new ConcurrentHashMap<String, OsgiBundleXmlApplicationContext>();
    regs = new ArrayList<ServiceRegistration>();
}

From source file:net.seedboxer.core.logic.DownloadsSessionManager.java

public DownloadsSessionManager() {
    sessionsPerUser = new ConcurrentHashMap<Long, DownloadSession>();
    filesPerUser = new ConcurrentHashMap<Long, String>();
}

From source file:com.aurel.track.lucene.util.InstancePool.java

private InstancePool() {
    _classPool = new ConcurrentHashMap();
}

From source file:com.cisco.oss.foundation.message.AbstractHornetQConcurrentMessageHandler.java

public AbstractHornetQConcurrentMessageHandler(String consumerName) {
    super(consumerName);
    onWorkIdentifierMap = new ConcurrentHashMap<String, Object>();
}