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:com.vmware.identity.openidconnect.sample.SessionManager.java

public SessionManager() {
    this.map = new ConcurrentHashMap<SessionID, OIDCTokens>();
}

From source file:com.vmware.identity.openidconnect.sample.AuthenticationRequestTracker.java

public AuthenticationRequestTracker() {
    this.map = new ConcurrentHashMap<State, Nonce>();
}

From source file:com.github.lightdocs.model.ServiceDocumentation.java

public ServiceDocumentation() {
    resources = new ConcurrentHashMap<String, Resource>();
}

From source file:com.jayway.restassured.examples.springmvc.support.WithJetty.java

@BeforeClass
public static void startJetty() throws Exception {
    server = new Server(8080);
    Connector connector = new ServerConnector(server);
    server.addConnector(connector);// w  ww  .j a v a 2  s.  co m

    WebAppContext wac = new WebAppContext();
    wac.setContextPath("/");
    wac.setConfigurations(new Configuration[] { new WebXmlConfiguration(), new AnnotationConfiguration() {
        @Override
        public void preConfigure(WebAppContext context) throws Exception {
            ConcurrentHashMap<String, ConcurrentHashSet<String>> map = new ConcurrentHashMap<String, ConcurrentHashSet<String>>();
            ConcurrentHashSet<String> set = new ConcurrentHashSet<String>();
            set.add(WebApp.class.getName());
            map.put(WebApplicationInitializer.class.getName(), set);
            context.setAttribute(CLASS_INHERITANCE_MAP, map);
            _classInheritanceHandler = new ClassInheritanceHandler(map);
        }
    } });
    wac.setServer(server);

    server.setHandler(wac);
    server.start();
}

From source file:com.wineaccess.winerylicensedetail.WineryLicenseDetailAdapterHelper.java

/**
 * This method is used to update the WineryLicenseDetail in the database.
 * /*from w  w  w.  j a va2  s.c o  m*/
 * @param wineryLicenseDetailUpdatePO
 *            is used to take the input in this PO.
 * @return output map containing response
 */
public static Map<String, Object> updateWineryLicenseDetail(
        final WineryLicenseDetailUpdatePO wineryLicenseDetailUpdatePO) {

    logger.info("start updateWineryLicenseDetail method");

    String errorMsg = StringUtils.EMPTY;

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

    Response response = null;

    try {

        MasterData caLicenseType = null;
        WineryModel winery = null;
        WineryLicenseDetailModel wineryLicenseDetailModel = null;

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

                        SystemErrorCode.UPDATE_WINERY_LICENSE_INVALID_CA_LICENSE_TYPE,
                        SystemErrorCode.UPDATE_WINERY_LICENSE_INVALID_CA_LICENSE_TYPE_TEXT, SUCCESS_CODE);

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

        if (response == null && wineryLicenseDetailUpdatePO.getWineryId() != null) {
            winery = WineryRepository.getWineryById(Long.parseLong(wineryLicenseDetailUpdatePO.getWineryId()));
            if (winery == null) {
                // winery not exist
                response = ApplicationUtils.errorMessageGenerate(

                        SystemErrorCode.UPDATE_WINERY_LICENSE_INVALID_WINERY,
                        SystemErrorCode.UPDATE_WINERY_LICENSE_INVALID_WINERY_TEXT, SUCCESS_CODE);

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

        if (response == null) {

            wineryLicenseDetailModel = WineryLicenseDetailRepository.getWineryLicenseDetailByWinery(winery);

            if (wineryLicenseDetailModel == null) {

                wineryLicenseDetailModel = new WineryLicenseDetailModel();

                wineryLicenseDetailModel.setCaLicenseType(caLicenseType);

                wineryLicenseDetailModel.setWinery(winery);

                if (wineryLicenseDetailUpdatePO.getContractExecuted() != null) {
                    wineryLicenseDetailModel.setContractExecuted(
                            Boolean.parseBoolean(wineryLicenseDetailUpdatePO.getContractExecuted()));
                } else {
                    wineryLicenseDetailModel.setContractExecuted(false);
                }

                if (wineryLicenseDetailUpdatePO.getShipCompliant() != null) {
                    wineryLicenseDetailModel.setShipCompliant(
                            Boolean.parseBoolean(wineryLicenseDetailUpdatePO.getShipCompliant()));
                } else {
                    wineryLicenseDetailModel.setShipCompliant(false);
                }

                if (wineryLicenseDetailUpdatePO.getShipEscrowNo() != null) {
                    wineryLicenseDetailModel.setShipEscrowNo(wineryLicenseDetailUpdatePO.getShipEscrowNo());
                }

                WineryLicenseDetailRepository.save(wineryLicenseDetailModel);

                WineryLicenseDetailVO wineryLicenseDetailVO = new WineryLicenseDetailVO(
                        SystemErrorCode.UPDATE_WINERY_LICENSE_SUCCESS_TEXT);

                BeanUtils.copyProperties(wineryLicenseDetailVO, wineryLicenseDetailModel);

                wineryLicenseDetailVO.setWineryId(wineryLicenseDetailModel.getWinery().getId());

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

        if (response == null) {

            //if (caLicenseType != null) {
            wineryLicenseDetailModel.setCaLicenseType(caLicenseType);
            //}

            wineryLicenseDetailModel.setWinery(winery);

            if (wineryLicenseDetailUpdatePO.getContractExecuted() != null) {
                wineryLicenseDetailModel.setContractExecuted(
                        Boolean.parseBoolean(wineryLicenseDetailUpdatePO.getContractExecuted()));
            }

            if (wineryLicenseDetailUpdatePO.getShipCompliant() != null) {
                wineryLicenseDetailModel
                        .setShipCompliant(Boolean.parseBoolean(wineryLicenseDetailUpdatePO.getShipCompliant()));
            }

            if (wineryLicenseDetailUpdatePO.getShipEscrowNo() != null) {
                wineryLicenseDetailModel.setShipEscrowNo(wineryLicenseDetailUpdatePO.getShipEscrowNo());
            }

            WineryLicenseDetailRepository.update(wineryLicenseDetailModel);

            WineryLicenseDetailVO wineryLicenseDetailVO = new WineryLicenseDetailVO(
                    SystemErrorCode.UPDATE_WINERY_LICENSE_SUCCESS_TEXT);

            BeanUtils.copyProperties(wineryLicenseDetailVO, wineryLicenseDetailModel);

            wineryLicenseDetailVO.setWineryId(wineryLicenseDetailModel.getWinery().getId());

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

    } catch (Exception e) {
        errorMsg = e.getCause().getMessage();
    }

    if (errorMsg.contains("uk_winery_id")) {
        response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.UPDATE_WINERY_LICENSE_ALREADY_EXISTS,
                SystemErrorCode.UPDATE_WINERY_LICENSE_ALREADY_EXISTS_TEXT, SUCCESS_CODE);

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

    output.put(OUPUT_PARAM_KEY, response);

    logger.info("exit updateWineryLicenseDetail method");

    return output;
}

From source file:Main.java

/**
 * Returns a newly created Map object./*from w  ww  . jav a 2s  . c  o m*/
 *
 * @param sorted                Whether the Map should maintain keys sorted in natural ascending order.
 * @param <K>                   The class of Map keys.
 * @param <V>                   The class of Map values.
 * @return                      A newly created Map object.
 */
public static <K, V> ConcurrentMap<K, V> create(boolean sorted) {
    ConcurrentMap<K, V> map;

    if (sorted) {
        map = new ConcurrentSkipListMap<K, V>();
    } else {
        map = new ConcurrentHashMap<K, V>();
    }

    return map;
}

From source file:model.DefaultDataManagerImpl.java

public void loadPaymentBase(String inputFileName) throws InputMismatchException, IOException {
    PaymentFileLoader paymentFileLoader = new PaymentFileLoader();
    paymentList = paymentFileLoader.getPaymentList(inputFileName);
    netAmounts = new ConcurrentHashMap<>();
    for (Money payment : paymentList) {
        updateNetAmounts(payment);/*from  www  .ja  v a2s  .c o m*/
    }
}

From source file:org.obp.remote.RemoteObpLocator.java

public RemoteObpLocator() {
    remotes = new CopyOnWriteArrayList<>();
    remoteInstances = new ConcurrentHashMap<>();
}

From source file:com.skcraft.launcher.swing.InstanceTableModel.java

public InstanceTableModel(InstanceList instances) {
    this.instances = instances;
    instanceIcons = new ConcurrentHashMap<Integer, InstanceIcon>();
    welcomeIcon = SwingHelper.createIcon(Launcher.class, "welcome_icon.png", 96, 64);

    // add an empty entry for "welcome" screen
    instanceIcons.put(0, new InstanceIcon());
}

From source file:com.weibo.api.motan.registry.support.command.CommandFailbackRegistry.java

public CommandFailbackRegistry(URL url) {
    super(url);/*w  w  w.j av  a  2s  . com*/
    commandManagerMap = new ConcurrentHashMap<URL, CommandServiceManager>();
    LoggerUtil.info("CommandFailbackRegistry init. url: " + url.toSimpleString());
}