Example usage for java.util Collections synchronizedMap

List of usage examples for java.util Collections synchronizedMap

Introduction

In this page you can find the example usage for java.util Collections synchronizedMap.

Prototype

public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m) 

Source Link

Document

Returns a synchronized (thread-safe) map backed by the specified map.

Usage

From source file:edu.cuny.cat.stat.HistoricalReport.java

public HistoricalReport() {
    asks = new LinkedList<Shout>();
    bids = new LinkedList<Shout>();
    sortedShouts = new TreeBag<Shout>(new ShoutComparator());
    matchedShouts = Collections.synchronizedSet(new HashSet<Shout>());
    shoutMap = Collections.synchronizedMap(new HashMap<String, Shout>());

    observableProxy = new Observable() {
        @Override/*from   w  ww.  j a  v  a 2  s.co  m*/
        public void notifyObservers() {
            setChanged();
            super.notifyObservers();
        }
    };
}

From source file:org.opencds.service.drools.v55.DroolsAdapter.java

/** 
* big picture pseudo code for following method:
* 
*       for this requestedKmId { //from w w w .j  a  va2s . c  o m
*          getResponse:
*             create Drools session
*             load KM into session
 *           load globals into session
 *            load data from allFactLists into session 
 *           KBase.execute (calls Drools)
 *           unload result from KM to outputString
 *       } 
* 
* This means that we are considering the OMG-CDSS concept of KnowledgeModule equivalent to
* the Drools concept of KnowledgeBase.
*/

public String getOneResponse(DSSRequestKMItem dssRequestKMItem)
        throws InvalidDriDataFormatExceptionFault, RequiredDataNotProvidedExceptionFault,
        EvaluationExceptionFault, InvalidTimeZoneOffsetExceptionFault, UnrecognizedScopedEntityExceptionFault,
        UnrecognizedLanguageExceptionFault, UnsupportedLanguageExceptionFault, DSSRuntimeExceptionFault {

    String requestedKmId = dssRequestKMItem.getRequestedKmId();
    String requestedKmPrimaryProcessName = SimpleKnowledgeRepository
            .getRequiredKMPrimaryProcessNameForKMId(requestedKmId);
    TimingDataKM timingDataKM = dssRequestKMItem.getKmTimingData();

    @SuppressWarnings("unchecked")
    JAXBElement<org.opencds.vmr.v1_0.schema.CDSInput> cdsInput = (JAXBElement<org.opencds.vmr.v1_0.schema.CDSInput>) dssRequestKMItem
            .getDssRequestDataItem().getCdsInput();

    DSSRequestDataItem dssRequestDataItem = dssRequestKMItem.getDssRequestDataItem();

    String externalFactModelSSId = dssRequestDataItem.getExternalFactModelSSId();
    Date evalTime = dssRequestDataItem.getEvalTime();
    String clientLanguage = dssRequestDataItem.getClientLanguage();
    String clientTimeZoneOffset = dssRequestDataItem.getClientTimeZoneOffset();
    String interactionId = dssRequestDataItem.getInteractionId();

    log.debug("II: " + interactionId + " KMId: " + requestedKmId + " (" + requestedKmPrimaryProcessName + ")"
            + ", SSId: " + externalFactModelSSId + ", evalTime: " + evalTime + ", clTimeZone: "
            + clientTimeZoneOffset + ", clLang: " + clientLanguage);

    /** 
     * Load fact map from specific externalFactModels, as specified in externalFactModel SSId...
     * 
     * Every separately identified SSId, by definition, specifies separate input and output mappings.
     * Input mappings are used here, and then output mappings are used following the session.execute.
     */

    Map<String, List<?>> allFactLists = Collections.synchronizedMap(new WeakHashMap<String, List<?>>());

    /** 
     * allFactLists are updated in place by the following call, including both facts and concepts...
     * ==================================================================
     */

    String focalPersonId = BuildCDSInputFactLists.buildFactLists(cdsInput, evalTime, allFactLists,
            timingDataKM);

    /** 
     * ==================================================================
     */
    dssRequestKMItem.setFocalPersonId(focalPersonId);

    log.debug("II: " + interactionId + " KMId: " + requestedKmId + " built fact/concept lists for "
            + focalPersonId);

    timingDataKM.setFinishBuildConceptListsTime(new AtomicLong(System.nanoTime()));

    /** 
     * Get the KMs and Load them into a stateless session
     * 
     * Currently, assumption is made that each requested knowledge module will be run separately
     *  (i.e., as part of a separate distinct knowledge base)
     * 
     */
    File drlFile = null;
    File bpmnFile = null;
    File pkgFile = null;

    KnowledgeBase knowledgeBase = (KnowledgeBase) SimpleKnowledgeRepository
            .getKnowledgeBaseCache(requestedKmId);

    if (knowledgeBase != null) {
        log.debug("II: " + interactionId + " KMId: " + requestedKmId + " knowledgeBase from cache");

    } else {
        knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
        KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

        drlFile = SimpleKnowledgeRepository.getResourceAsFileWithoutException("knowledgeModules",
                requestedKmId + ".drl");
        bpmnFile = SimpleKnowledgeRepository.getResourceAsFileWithoutException("knowledgeModules",
                requestedKmId + ".bpmn");
        pkgFile = SimpleKnowledgeRepository.getResourceAsFileWithoutException("knowledgeModules",
                requestedKmId + ".pkg");

        if (drlFile != null)
            knowledgeBuilder.add(ResourceFactory.newFileResource(drlFile), ResourceType.DRL);
        if (bpmnFile != null)
            knowledgeBuilder.add(ResourceFactory.newFileResource(bpmnFile), ResourceType.BPMN2);
        if (pkgFile != null)
            knowledgeBuilder.add(ResourceFactory.newFileResource(pkgFile), ResourceType.PKG);
        if (knowledgeBuilder.hasErrors()) {
            throw new DSSRuntimeExceptionFault("KnowledgeBuilder had errors on build of: '" + requestedKmId
                    + "', " + knowledgeBuilder.getErrors().toString());
        }
        if (knowledgeBuilder.getKnowledgePackages().size() == 0) {
            throw new DSSRuntimeExceptionFault(
                    "KnowledgeBuilder did not find any VALID '.drl', '.bpmn' or '.pkg' files for: '"
                            + requestedKmId + "', " + knowledgeBuilder.getErrors().toString());
        }

        knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
        SimpleKnowledgeRepository.putKnowledgeBaseCache(requestedKmId, knowledgeBase);
        log.debug("II: " + interactionId + " KMId: " + requestedKmId + " knowledgeBase built");
    }

    dssRequestKMItem.getKmTimingData().setFinishInsertKnowledgeTime(new AtomicLong(System.nanoTime()));

    StatelessKnowledgeSession statelessKnowledgeSession = knowledgeBase.newStatelessKnowledgeSession();

    /**
     *  to create a new Drools Working Memory Logger for in depth Drools debugging - Use either the InMemoryLogger
     *  to record logs on all input, or use the FileLogger for debugging of one input at a time in Drools and JBPM
     */

    //         WorkingMemoryInMemoryLogger memoryLogger   = new WorkingMemoryInMemoryLogger (statelessKnowledgeSession);
    //         WorkingMemoryFileLogger    fileLogger       = new WorkingMemoryFileLogger (statelessKnowledgeSession);   
    //         // If using the FileLogger, Set the log file that we will be using to log Working Memory (aka session)         
    //         fileLogger.setFileName("C:/opencds-logs/OpenCDS-Drools-event-log"); 
    //TODO:    make the above choice based on configuration settings

    dssRequestKMItem.getKmTimingData().setFinishStartKnowledgeSessionTime(new AtomicLong(System.nanoTime()));

    /**
     * Load the Globals and Fact lists:  evalTime, language, timezoneOffset
     * 
     */

    @SuppressWarnings("rawtypes")
    List<Command> cmds = Collections.synchronizedList(new ArrayList<Command>());

    /**
     * Load the Globals:  evalTime, language, timezoneOffset, focalPersonId, assertions, namedObjects
     * 
     */
    cmds.add(CommandFactory.newSetGlobal("evalTime", evalTime));
    cmds.add(CommandFactory.newSetGlobal("clientLanguage", clientLanguage));
    cmds.add(CommandFactory.newSetGlobal("clientTimeZoneOffset", clientTimeZoneOffset));
    cmds.add(CommandFactory.newSetGlobal("focalPersonId", dssRequestKMItem.getFocalPersonId()));

    //following global used to store flags for inter-task communication in a JBPM Process
    java.util.Set<String> assertions = new java.util.HashSet<String>();
    cmds.add(CommandFactory.newSetGlobal("assertions", assertions));

    //following global used to return facts added by rules, such as new observationResults
    java.util.Map<String, Object> namedObjects = new java.util.HashMap<String, Object>();
    cmds.add(CommandFactory.newSetGlobal("namedObjects", namedObjects));

    dssRequestKMItem.getKmTimingData().setFinishLoadGlobalsTime(new AtomicLong(System.nanoTime()));

    /**
     * Load the FactLists into Commands:  Only ones that are not empty...
     * 
     */

    //does this whole thing needs to be made concurrent safe ?? Will this do it??
    synchronized (allFactLists) {
        for (String oneName : allFactLists.keySet()) {
            @SuppressWarnings("unchecked")
            List<Object> oneFactList = (List<Object>) allFactLists.get(oneName);
            String oneTypeName = "";
            for (Object oneFact : (List<Object>) oneFactList) {
                oneTypeName = oneFact.getClass().getSimpleName();
            }
            if (oneFactList.size() > 0) {
                cmds.add(CommandFactory.newInsertElements((List<?>) oneFactList, oneTypeName, true, null));
            } else {
                allFactLists.remove(oneTypeName);
            }
        }
    }

    dssRequestKMItem.getKmTimingData().setFinishLoadFactListsTime(new AtomicLong(System.nanoTime()));

    /**   
     * If this is a PKG (for package with process, initiate the configured Primary Process for JBPM.
     * 
     */

    if ((requestedKmPrimaryProcessName != null) && (!"".equals(requestedKmPrimaryProcessName))) {
        if ("".equals(requestedKmPrimaryProcessName)) {
            throw new DSSRuntimeExceptionFault("DroolsAdapter found improperly configured KM: " + requestedKmId
                    + ".  This KM includes a BPMN file, but does not have a value "
                    + "for 'knowledgeModulePrimaryProcessName' in its configuration.");
        }
        cmds.add(CommandFactory.newStartProcess(requestedKmPrimaryProcessName));
        log.debug("II: " + interactionId + " KMId: " + requestedKmId + " knowledgeBase Primary Process: "
                + requestedKmPrimaryProcessName);
    }

    dssRequestKMItem.getKmTimingData().setStartInferenceEngine(new AtomicLong(System.nanoTime()));

    /**   
     * Use Drools to process everything   
     * Added try/catch around stateless session. because Drools has an unhandled exception
     * when a JBPM Process improperly re-declares a global that is constraining a gateway
     * and the resultant global is null - des 20120727      
     ********************************************************************************
     */
    ExecutionResults results = null;
    try {

        results = statelessKnowledgeSession.execute(CommandFactory.newBatchExecution((cmds)));

    } catch (Exception e) {
        String err = "OpenCDS call to Drools.execute failed with error: " + e.getMessage();
        log.error(err);
        StackTraceElement elements[] = e.getStackTrace();
        for (int i = 0, n = elements.length; i < n; i++) {
            String detail = elements[i].getClassName() + ":" + elements[i].getMethodName() + ":"
                    + elements[i].getLineNumber();
            log.error(detail);
            err += "\n" + elements[i].getMethodName();
        }
        throw new DSSRuntimeExceptionFault(err);
    }

    /**               
     ********************************************************************************
     *  END Drools
     *  
     */
    dssRequestKMItem.getKmTimingData().setFinishInferenceEngine(new AtomicLong(System.nanoTime()));
    //grab session logging of whichever type was started...
    //      log.trace(memoryLogger.getEvents());
    //      fileLogger.writeToDisk();

    //update original entries from allFactLists to capture any new or updated elements
    //** need to look for every possible fact list, because rules may have created new ones...
    //NOTE that results contains the original objects passed in via CMD structure, with any 
    //changes introduced by rules.

    Map<String, List<?>> resultFactLists = Collections.synchronizedMap(new WeakHashMap<String, List<?>>());

    synchronized (results) {
        Collection<String> allResultNames = results.getIdentifiers(); //includes concepts but not globals?
        for (String oneName : allResultNames) {
            if (!("evalTime".equals(oneName)) && !("clientLanguage".equals(oneName))
                    && !("clientTimeZoneOffset".equals(oneName))) {
                // ignore these submitted globals, they should not have been changed by rules, and look at everything else

                Object oneList = results.getValue(oneName);
                resultFactLists.put(oneName, (List<?>) oneList);
            }
        }
    }

    /**
     * now process the returned namedObjects and add them to the resultFactLists
     * 
     */
    synchronized (namedObjects) {
        for (String key : namedObjects.keySet()) {
            if (namedObjects.get(key) != null) {
                Object oneNamedObject = namedObjects.get(key);
                //            String className = oneNamedObject.getClass().getSimpleName();
                @SuppressWarnings("unchecked")
                List<Object> oneList = (List<Object>) resultFactLists
                        .get(oneNamedObject.getClass().getSimpleName());
                if (oneList == null) {
                    oneList = new ArrayList<Object>();
                    oneList.add(oneNamedObject);
                } else {
                    oneList.add(oneNamedObject);
                }
                resultFactLists.put(oneNamedObject.getClass().getSimpleName(), oneList);
            }
        }
    }

    /** 
     * Retrieve the Results for this requested KM and stack them in the DSS fkmResponse
     * NOTE: Each additional requested KM will have a separate output payload
     */

    dssRequestKMItem.getKmTimingData().setFinishInferenceEngineAdapterTime(new AtomicLong(System.nanoTime()));
    log.debug(
            "II: " + interactionId + " KMId: " + requestedKmId + " begin marshalling results to external VMR ");

    //FIXME probably need to create static final string to identify output SSID, probably always as VMR
    //        String                  payloadCreatorName   = SimpleKnowledgeRepository.getRequiredPayloadCreatorForSSID(externalFactModelSSId);
    IOutboundPayloadProcessor payloadCreator = (IOutboundPayloadProcessor) SimpleKnowledgeRepository
            .getPayloadCreatorInstanceForClassNameCache(
                    SimpleKnowledgeRepository.getRequiredPayloadCreatorForSSID(externalFactModelSSId));

    /**
     * following is normally instantiated as MarshalVMR2VMRSchemaPayload.getInstance().mappingOutbound( resultFactLists, dssRequestKMItem );
     * 
     */
    String outputString = payloadCreator.mappingOutbound(resultFactLists, dssRequestKMItem);

    log.trace("II: " + interactionId + " KMId: " + requestedKmId
            + " finished marshalling results to external VMR, " + outputString.length() + " chars.");

    /**
     * clear out maps and arrays    
     *    
     */
    //        BuildCDSInputFactLists.clearAllFactLists(allFactLists);
    //      synchronized (allFactLists) {
    log.debug("clearAllFactLists");

    //         for (String eachKey : ((Map<String, List<?>>)allFactLists).keySet()) {
    //            if (allFactLists.get(eachKey) != null) {
    //               List<?> eachList = allFactLists.get(eachKey);
    //               eachList.clear();
    //               allFactLists.remove(eachKey);
    //            }
    //         }
    //      }   

    //      long usedMemory4 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      // this is not needed, but it will make it easier to see the leak
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter before clear: " + usedMemory4 / 1000  + "KB");

    allFactLists.clear();
    //      long usedMemory5 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after allFactLists.clear(): " + usedMemory5 / 1000  + "KB, diff = " + (usedMemory5 - usedMemory4) / 1000 + "KB");

    allFactLists = null;
    //      long usedMemory6 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after allFactLists = null: " + usedMemory6 / 1000  + "KB, diff = " + (usedMemory6 - usedMemory5) / 1000 + "KB");

    cmds.clear();
    //      long usedMemory7 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after cmds.clear(): " + usedMemory7 / 1000  + "KB, diff = " + (usedMemory7 - usedMemory6) / 1000 + "KB");

    cmds = null;
    //      long usedMemory8 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after cmds = null: " + usedMemory8 / 1000  + "KB, diff = " + (usedMemory8 - usedMemory7) / 1000 + "KB");

    assertions.clear();
    //      long usedMemory9 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after assertions.clear(): " + usedMemory9 / 1000  + "KB, diff = " + (usedMemory9 - usedMemory8) / 1000 + "KB");

    assertions = null;
    //      long usedMemory10 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after assertions = null;: " + usedMemory10 / 1000  + "KB, diff = " + (usedMemory10 - usedMemory9) / 1000 + "KB");

    namedObjects.clear();
    //      long usedMemory11 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after namedObjects.clear(): " + usedMemory11 / 1000  + "KB, diff = " + (usedMemory11 - usedMemory10) / 1000 + "KB");

    namedObjects = null;
    //      long usedMemory12 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after namedObjects = null: " + usedMemory12 / 1000  + "KB, diff = " + (usedMemory12 - usedMemory11) / 1000 + "KB");

    for (String oneId : results.getIdentifiers()) {
        //results.getFactHandle(oneId)
        results.getIdentifiers().remove(results.getValue(oneId));
    }
    results = null;
    //      long usedMemory13 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after results = null: " + usedMemory13 / 1000  + "KB, diff = " + (usedMemory13 - usedMemory12) / 1000 + "KB");

    resultFactLists.values().clear();
    resultFactLists.clear();
    //      long usedMemory14 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after resultFactLists.clear(): " + usedMemory14 / 1000  + "KB, diff = " + (usedMemory14 - usedMemory13) / 1000 + "KB");

    resultFactLists = null;
    //      long usedMemory15 = Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory();
    //      System.gc(); 
    //      System.out.println("KMId: " + requestedKmId + " used memory at end of DroolsAdapter after resultFactLists = null: " + usedMemory15 / 1000  + "KB, diff = " + (usedMemory15 - usedMemory14) / 1000 + "KB");

    //        dssRequestKMItem = null;

    //        statelessKnowledgeSession = null;

    log.debug("II: " + interactionId + " KMId: " + requestedKmId + " completed Drools inferencing engine");

    return outputString;
}

From source file:org.apache.hadoop.hbase.coprocessor.TestCoprocessorEndpoint.java

@Test
public void testCoprocessorService() throws Throwable {
    HTable table = new HTable(util.getConfiguration(), TEST_TABLE);
    NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();

    final TestProtos.EchoRequestProto request = TestProtos.EchoRequestProto.newBuilder().setMessage("hello")
            .build();// w  w w. j  ava 2s . c  o m
    final Map<byte[], String> results = Collections
            .synchronizedMap(new TreeMap<byte[], String>(Bytes.BYTES_COMPARATOR));
    try {
        // scan: for all regions
        final RpcController controller = new ServerRpcController();
        table.coprocessorService(TestRpcServiceProtos.TestProtobufRpcProto.class, ROWS[0],
                ROWS[ROWS.length - 1],
                new Batch.Call<TestRpcServiceProtos.TestProtobufRpcProto, TestProtos.EchoResponseProto>() {
                    public TestProtos.EchoResponseProto call(TestRpcServiceProtos.TestProtobufRpcProto instance)
                            throws IOException {
                        LOG.debug("Default response is " + TestProtos.EchoRequestProto.getDefaultInstance());
                        BlockingRpcCallback<TestProtos.EchoResponseProto> callback = new BlockingRpcCallback<TestProtos.EchoResponseProto>();
                        instance.echo(controller, request, callback);
                        TestProtos.EchoResponseProto response = callback.get();
                        LOG.debug("Batch.Call returning result " + response);
                        return response;
                    }
                }, new Batch.Callback<TestProtos.EchoResponseProto>() {
                    public void update(byte[] region, byte[] row, TestProtos.EchoResponseProto result) {
                        assertNotNull(result);
                        assertEquals("hello", result.getMessage());
                        results.put(region, result.getMessage());
                    }
                });
        for (Map.Entry<byte[], String> e : results.entrySet()) {
            LOG.info("Got value " + e.getValue() + " for region " + Bytes.toStringBinary(e.getKey()));
        }
        assertEquals(3, results.size());
        for (HRegionInfo info : regions.navigableKeySet()) {
            LOG.info("Region info is " + info.getRegionNameAsString());
            assertTrue(results.containsKey(info.getRegionName()));
        }
        results.clear();

        // scan: for region 2 and region 3
        table.coprocessorService(TestRpcServiceProtos.TestProtobufRpcProto.class, ROWS[rowSeperator1],
                ROWS[ROWS.length - 1],
                new Batch.Call<TestRpcServiceProtos.TestProtobufRpcProto, TestProtos.EchoResponseProto>() {
                    public TestProtos.EchoResponseProto call(TestRpcServiceProtos.TestProtobufRpcProto instance)
                            throws IOException {
                        LOG.debug("Default response is " + TestProtos.EchoRequestProto.getDefaultInstance());
                        BlockingRpcCallback<TestProtos.EchoResponseProto> callback = new BlockingRpcCallback<TestProtos.EchoResponseProto>();
                        instance.echo(controller, request, callback);
                        TestProtos.EchoResponseProto response = callback.get();
                        LOG.debug("Batch.Call returning result " + response);
                        return response;
                    }
                }, new Batch.Callback<TestProtos.EchoResponseProto>() {
                    public void update(byte[] region, byte[] row, TestProtos.EchoResponseProto result) {
                        assertNotNull(result);
                        assertEquals("hello", result.getMessage());
                        results.put(region, result.getMessage());
                    }
                });
        for (Map.Entry<byte[], String> e : results.entrySet()) {
            LOG.info("Got value " + e.getValue() + " for region " + Bytes.toStringBinary(e.getKey()));
        }
        assertEquals(2, results.size());
    } finally {
        table.close();
    }
}

From source file:com.apporiented.hermesftp.usermanager.impl.XmlFileUserManager.java

private Map<String, Long> getUserResourceConsumptions(String userAndDate) {
    Map<String, Long> userConsumption = resourceConsumption.get(userAndDate);
    if (userConsumption == null) {
        userConsumption = Collections.synchronizedMap(new HashMap<String, Long>());
        resourceConsumption.put(userAndDate, userConsumption);
    }/*from   w w w  . j a  v a  2 s . c  o m*/
    return userConsumption;
}

From source file:org.dbist.dml.impl.DmlJdbc.java

@SuppressWarnings("unchecked")
@Override/* w  ww  .ja v  a 2s. c o m*/
public void afterPropertiesSet() throws Exception {
    boolean debug = logger.isDebugEnabled();
    super.afterPropertiesSet();
    ValueUtils.assertNotEmpty("domain", getDomain());
    ValueUtils.assertNotEmpty("dataSource", getDataSource());
    ValueUtils.assertNotEmpty("jdbcOperations", getJdbcOperations());
    ValueUtils.assertNotEmpty("namedParameterJdbcOperations", getNamedParameterJdbcOperations());

    if (ValueUtils.isEmpty(getDbType())) {
        DatabaseMetaData metadata = dataSource.getConnection().getMetaData();
        setDbType(metadata.getDatabaseProductName().toLowerCase());
        if (getDbType().startsWith("microsoft sql server")) {
            setDbType("sqlserver");
        } else if (getDbType().startsWith("db2/")) {
            setDbType("db2");
        }
    }
    if (getQueryMapper() == null) {
        if (getDbType().equals("mysql"))
            setQueryMapper(new QueryMapperMysql());
        else if (getDbType().equals("postgresql"))
            setQueryMapper(new QueryMapperPostgresql());
        else if (getDbType().equals("oracle"))
            setQueryMapper(new QueryMapperOracle());
        else if (getDbType().equals("db2"))
            setQueryMapper(new QueryMapperDb2());
        else if (getDbType().equals("sqlserver"))
            setQueryMapper(new QueryMapperSqlserver());
    }
    if (!isSupported())
        throw new IllegalArgumentException("Unsupported dbType: " + getDbType());

    if ("sqlserver".equals(getDbType())) {
        List<String> domainList = new ArrayList<String>(this.domainList.size());
        for (String domain : this.domainList) {
            if (domain.indexOf('.') != -1)
                continue;
            domainList.add(domain + ".dbo");
        }
        this.domainList = domainList;
    }

    if (ValueUtils.isEmpty(columnAliasRuleForMapKey))
        columnAliasRuleForMapKey = COLUMNALIASRULE_DEFAULT;
    else if (!COLUMNALIASRULE_LIST.contains(columnAliasRuleForMapKey))
        throw new IllegalArgumentException("Unsupported columnAliasRule: ");
    columnAliasRule = COLUMNALIASRULE_LIST.indexOf(columnAliasRuleForMapKey);

    if (maxSqlByPathCacheSize > 0)
        sqlByPathCache = Collections.synchronizedMap(new LRUMap(maxSqlByPathCacheSize));
    if (debug)
        logger.debug("dml loaded (dbType: " + getDbType() + ")");
}

From source file:com.r1soft.backup.server.web.GlobalUpdater.java

private static synchronized void initEventQueues() {
    if (applicationEventQueues != null)
        return;/*from ww  w. j  a v  a  2  s  . c  om*/

    applicationEventQueues = Collections.synchronizedMap(new HashMap<String, EventQueue>());
    applicationEventQueues.put(EventConstants.NATIVE_DISK_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.NATIVE_DISK_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.VOLUME_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.VOLUME_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.DISK_SAFE_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.DISK_SAFE_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.TASK_HISTORY_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.TASK_HISTORY_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.SERVER_INFO_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.SERVER_INFO_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.TASK_SCHEDULER_INFO_EVENT_QUEUE_NAME, EventQueues
            .lookup(EventConstants.TASK_SCHEDULER_INFO_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.RECOVERY_POINT_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.RECOVERY_POINT_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.AGENT_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.AGENT_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.ARCHIVE_POINT_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.ARCHIVE_POINT_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.ARCHIVE_POINT_ACTION_EVENT_QUEUE_NAME, EventQueues
            .lookup(EventConstants.ARCHIVE_POINT_ACTION_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.LICENSING_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.LICENSING_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.USER_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.USER_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.GROUP_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.GROUP_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.POLICY_EVENT_QUEUE_NAME,
            EventQueues.lookup(EventConstants.POLICY_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.ZKOSS_IMAGE_CHART_EVENT_QUEUE_NAME, EventQueues
            .lookup(EventConstants.ZKOSS_IMAGE_CHART_EVENT_QUEUE_NAME, EventQueues.APPLICATION, true));
    applicationEventQueues.put(EventConstants.STATS_EVENT_QUEUE,
            EventQueues.lookup(EventConstants.STATS_EVENT_QUEUE, EventQueues.APPLICATION, true));

    // TODO: Simplify this shit by just using one EventConstants interface
    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.DISK_SAFE_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof DiskSafeCacheEvent))
                        return;

                    if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.DISK_SAFE_CACHE_ENTRY_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.DISK_SAFE_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.DISK_SAFE_UPDATE_EVENT_NAME, null,
                                        new SelectableDiskSafeCacheEntry(
                                                ((DiskSafeCacheEvent) event).getDiskSafeCacheEntry())));
                    } else if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.DISK_SAFE_CACHE_ENTRY_REMOVE_EVENT)) {
                        applicationEventQueues.get(EventConstants.DISK_SAFE_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.DISK_SAFE_DELETE_EVENT_NAME, null,
                                        new SelectableDiskSafeCacheEntry(
                                                ((DiskSafeCacheEvent) event).getDiskSafeCacheEntry())));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.VOLUME_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof VolumeEvent))
                        return;

                    if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.VOLUME_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.VOLUME_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.VOLUME_CREATE_EVENT_NAME, null,
                                        new SelectableVolume(((VolumeEvent) event).getVolume())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.VOLUME_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.VOLUME_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.VOLUME_UPDATE_EVENT_NAME, null,
                                        new SelectableVolume(((VolumeEvent) event).getVolume())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.VOLUME_DELETE_EVENT)) {
                        applicationEventQueues.get(EventConstants.VOLUME_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.VOLUME_DELETE_EVENT_NAME, null,
                                        new SelectableVolume(((VolumeEvent) event).getVolume())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.VOLUME_REMOVE_EVENT)) {
                        applicationEventQueues.get(EventConstants.VOLUME_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.VOLUME_DELETE_EVENT_NAME, null,
                                        new SelectableVolume(((VolumeEvent) event).getVolume())));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.VOLUME_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof VolumeCacheEvent))
                        return;

                    if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.VOLUME_CACHE_ENTRY_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.VOLUME_EVENT_QUEUE_NAME).publish(new Event(
                                EventConstants.VOLUME_UPDATE_EVENT_NAME, null,
                                new SelectableVolume(((VolumeCacheEvent) event).getVolumeCacheEntry())));
                    } else if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.VOLUME_CACHE_ENTRY_REMOVE_EVENT)) {
                        applicationEventQueues.get(EventConstants.VOLUME_EVENT_QUEUE_NAME).publish(new Event(
                                EventConstants.VOLUME_DELETE_EVENT_NAME, null,
                                new SelectableVolume(((VolumeCacheEvent) event).getVolumeCacheEntry())));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.RECOVERY_POINT_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof RecoveryPointEvent))
                        return;

                    if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.RECOVERY_POINT_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.RECOVERY_POINT_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.RECOVERY_POINT_CREATE_EVENT_NAME, null,
                                        ((RecoveryPointEvent) event).getRecoveryPointInfo()));
                    } else if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.RECOVERY_POINT_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.RECOVERY_POINT_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.RECOVERY_POINT_UPDATE_EVENT_NAME, null,
                                        ((RecoveryPointEvent) event).getRecoveryPointInfo()));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.AGENT_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof AgentEvent))
                        return;

                    if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.AGENT_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.AGENT_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.AGENT_CREATE_EVENT_NAME, null,
                                        new SelectableAgent(((AgentEvent) event).getAgent())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.AGENT_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.AGENT_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.AGENT_UPDATE_EVENT_NAME, null,
                                        new SelectableAgent(((AgentEvent) event).getAgent())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.AGENT_DELETE_EVENT)) {
                        applicationEventQueues.get(EventConstants.AGENT_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.AGENT_DELETE_EVENT_NAME, null,
                                        new SelectableAgent(((AgentEvent) event).getAgent())));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.ARCHIVE_POINT_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof ArchivePointEvent))
                        return;

                    if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.ARCHIVE_POINT_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.ARCHIVE_POINT_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.ARCHIVE_POINT_CREATE_EVENT_NAME, null,
                                        ((ArchivePointEvent) event).getArchivePointInfo()));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.ARCHIVE_POINT_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.ARCHIVE_POINT_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.ARCHIVE_POINT_UPDATE_EVENT_NAME, null,
                                        ((ArchivePointEvent) event).getArchivePointInfo()));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.ARCHIVE_POINT_ACTION_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof ArchivePointActionEvent))
                        return;

                    if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.ARCHIVE_POINT_ACTION_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.ARCHIVE_POINT_ACTION_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.ARCHIVE_POINT_ACTION_CREATE_EVENT_NAME, null,
                                        ((ArchivePointActionEvent) event).getArchivePointAction()));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.LICENSING_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof LicensingEvent))
                        return;

                    if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.LICENSING_INFO_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.LICENSING_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.LICENSING_INFO_UPDATE_EVENT_NAME, null,
                                        ((LicensingEvent) event).getLicenseInfoSpec()));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.TASK_HISTORY_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof TaskHistoryEvent))
                        return;

                    if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.TASK_HISTORY_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.TASK_HISTORY_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.TASK_HISTORY_CREATE_EVENT_NAME, null,
                                        new SelectableTaskExecutionContext(
                                                ((TaskHistoryEvent) event).getTaskExecutionContext())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.TASK_HISTORY_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.TASK_HISTORY_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.TASK_HISTORY_UPDATE_EVENT_NAME, null,
                                        new SelectableTaskExecutionContext(
                                                ((TaskHistoryEvent) event).getTaskExecutionContext())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.TASK_HISTORY_DELETE_EVENT)) {
                        applicationEventQueues.get(EventConstants.TASK_HISTORY_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.TASK_HISTORY_DELETE_EVENT_NAME, null,
                                        new SelectableTaskExecutionContext(
                                                ((TaskHistoryEvent) event).getTaskExecutionContext())));
                    }

                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.USER_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof UserEvent))
                        return;

                    if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.USER_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.USER_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.USER_CREATE_EVENT_NAME, null,
                                        new SelectableUser(((UserEvent) event).getUser())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.USER_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.USER_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.USER_UPDATE_EVENT_NAME, null,
                                        new SelectableUser(((UserEvent) event).getUser())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.USER_DELETE_EVENT)) {
                        applicationEventQueues.get(EventConstants.USER_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.USER_DELETE_EVENT_NAME, null,
                                        new SelectableUser(((UserEvent) event).getUser())));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.GROUP_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof GroupEvent))
                        return;

                    if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.GROUP_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.GROUP_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.GROUP_CREATE_EVENT_NAME, null,
                                        new SelectableGroup(((GroupEvent) event).getGroup())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.GROUP_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.GROUP_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.GROUP_UPDATE_EVENT_NAME, null,
                                        new SelectableGroup(((GroupEvent) event).getGroup())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.GROUP_DELETE_EVENT)) {
                        applicationEventQueues.get(EventConstants.GROUP_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.GROUP_DELETE_EVENT_NAME, null,
                                        new SelectableGroup(((GroupEvent) event).getGroup())));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.POLICY_EVENT_QUEUE, true)
            .subscribe(new EventListener() {
                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown)
                        return;
                    if (!(event instanceof PolicyEvent))
                        return;

                    if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.POLICY_CREATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.POLICY_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.POLICY_CREATE_EVENT_NAME, null,
                                        new SelectableDPPInfo(((PolicyEvent) event).getDPPInfo())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.POLICY_UPDATE_EVENT)) {
                        applicationEventQueues.get(EventConstants.POLICY_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.POLICY_UPDATE_EVENT_NAME, null,
                                        new SelectableDPPInfo(((PolicyEvent) event).getDPPInfo())));
                    } else if (event.getName()
                            .equals(com.r1soft.backup.server.event.EventConstants.POLICY_DELETE_EVENT)) {
                        applicationEventQueues.get(EventConstants.POLICY_EVENT_QUEUE_NAME)
                                .publish(new Event(EventConstants.POLICY_DELETE_EVENT_NAME, null,
                                        new SelectableDPPInfo(((PolicyEvent) event).getDPPInfo())));
                    }
                }
            });

    com.r1soft.backup.server.event.EventQueues
            .lookup(com.r1soft.backup.server.event.EventConstants.STATS_EVENT_QUEUE, true)
            .subscribe(new EventListener() {

                @Override
                public void onEvent(com.r1soft.backup.server.event.Event event) {

                    if (shutdown || !(event instanceof StatsEvent))
                        return;

                    if (event.getName().equals(
                            com.r1soft.backup.server.event.EventConstants.RESTORE_STATS_UPDATED_EVENT)) {
                        lookupEventQueue(EventConstants.STATS_EVENT_QUEUE).publish(
                                new Event(EventConstants.RESTORE_STATS_UPDATED_EVENT, null, event.getData()));
                    }

                }

            });

}

From source file:com.cognifide.cq.cqsm.core.scripts.ScriptManagerImpl.java

@Override
public Map<String, String> getPredefinedDefinitions() {
    if (predefinedDefinitions == null) {
        predefinedDefinitions = Collections.synchronizedMap(new TreeMap<String, String>());
        eventManager.trigger(Event.INIT_DEFINITIONS);
    }/*from  w  w w  .  j  a v a 2  s .c  o  m*/
    return predefinedDefinitions;
}

From source file:org.cloudata.core.tabletserver.UploaderCache.java

public void init() {
    if (columnCollections != null) {
        columnCollections.clear();/*  w  w w .j  a  v  a 2s . c  om*/
        columnCollections = null;
    }
    size = 0;
    columnCollections = Collections.synchronizedMap(new HashMap<String, ColumnCollection>(10));
    Runtime.getRuntime().gc();
}

From source file:org.opencms.frontend.templateone.CmsTemplateParts.java

/**
 * Initializes (also clears) the internal part cache map.<p>
 * //  w w  w.  j av  a 2s . c o m
 * @return the new created part cache map
 */
private synchronized Map initPartsMap() {

    Map cacheParts = CmsCollectionsGenericWrapper.createLRUMap(512);
    Map oldParts = m_parts;
    m_parts = Collections.synchronizedMap(cacheParts);
    if (oldParts != null) {
        oldParts.clear();
        oldParts = null;
    }
    return m_parts;
}

From source file:nl.nn.adapterframework.receivers.JavaListener.java

/**
 * Get all registered JavaListeners// ww w.  j av  a2 s.  co  m
 */
private synchronized static Map getListeners() {
    if (registeredListeners == null) {
        registeredListeners = Collections.synchronizedMap(new HashMap());
    }
    return registeredListeners;
}