Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.apache.marmotta.platform.core.services.statistics;
 
 
 import java.util.List;

StatisticsServiceImpl

Author(s):
Sebastian Schaffert
 
 @Named("kiwi.core.statisticsService")
 public class StatisticsServiceImpl implements StatisticsService {
 
 
     private boolean enabled = false;
 
     @Inject
     private Logger log;
 
     @Inject
     private ConfigurationService configurationService;

    
Initialise all statistics modules that are found in the system

Parameters:
modules
 
     @Inject
     protected void initModules(@Any Instance<StatisticsModulemodules) {
         .info("Apache Marmotta StatisticsService starting up ...");
 
         this. = new LinkedHashMap<String,StatisticsModule>();
 
         for(StatisticsModule module : modules) {
             registerModule(module.getName(),module);
         }
 
         if(.getBooleanConfiguration("statistics.enabled",false)) {
             enableAll();
         } else {
             disableAll();
         }
     }
 
         if (event.containsChangedKey("statistics.enabled")) {
             if(.getBooleanConfiguration("statistics.enabled",false)) {
                 enableAll();
             } else {
                 disableAll();
             }
         }
     }
 
 
 
     /* (non-Javadoc)
      * @see kiwi.api.statistics.StatisticsService#enableAll()
      */
     @Override
     public void enableAll() {
         for(StatisticsModule mod : .values()) {
             mod.enable();
         }
 
          = true;
     }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#disableAll()
     */
    @Override
    public void disableAll() {
        for(StatisticsModule mod : .values()) {
            mod.disable();
        }
         = false;
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#isEnabled()
     */
    @Override
    public boolean isEnabled() {
        return ;
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#enableModule(java.lang.String)
     */
    @Override
    public void enableModule(String modName) {
        if(.get(modName) != null) {
            .get(modName).enable();
        }
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#disableModule(java.lang.String)
     */
    @Override
    public void disableModule(String modName) {
        if(.get(modName) != null) {
            .get(modName).disable();
        }
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#registerModule(java.lang.String, kiwi.api.statistics.StatisticsModule)
     */
    @Override
    public void registerModule(String modNameStatisticsModule mod) {
        .info("registering statistics module \"{}\""modName);
        .put(modName,mod);
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#unregisterModule(kiwi.api.statistics.StatisticsModule)
     */
    @Override
    public void unregisterModule(StatisticsModule mod) {
        unregisterModule(mod.getName());
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#unregisterModule(java.lang.String)
     */
    @Override
    public void unregisterModule(String modName) {
        .info("unregistering statistics module \"{}\""modName);
        .remove(modName);
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#getModule(java.lang.String)
     */
    @Override
    public StatisticsModule getModule(String modName) {
        return .get(modName);
    }
    /* (non-Javadoc)
     * @see kiwi.api.statistics.StatisticsService#listModules()
     */
    @Override
    public List<StringlistModules() {
        return new LinkedList<String>(.keySet());
    }
New to GrepCode? Check out our FAQ X