View Javadoc

1   /*
2    *  
3    *  Fosstrak LLRP Commander (www.fosstrak.org)
4    * 
5    *  Copyright (C) 2008 ETH Zurich
6    *
7    *  This program is free software: you can redistribute it and/or modify
8    *  it under the terms of the GNU General Public License as published by
9    *  the Free Software Foundation, either version 3 of the License, or
10   *  (at your option) any later version.
11   *
12   *  This program is distributed in the hope that it will be useful,
13   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   *  GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License
18   *  along with this program.  If not, see <http://www.gnu.org/licenses/> 
19   *
20   */
21  
22  package org.fosstrak.capturingapp;
23  
24  import org.apache.log4j.Logger;
25  import org.drools.builder.ResourceType;
26  import org.drools.io.ResourceFactory;
27  
28  /**
29   * The default handler. This handler gets always loaded. if you invoke the 
30   * handler with a change-set file, the handler will use this change-set to 
31   * load the drools rule set.
32   * @author sawielan
33   *
34   */
35  public class DefaultECReportHandler extends ECReportsHandler {
36  
37  	// logger
38  	private static final Logger log = Logger.getLogger(DefaultECReportHandler.class);
39  	
40  	/**
41  	 * default constructor.
42  	 */
43  	public DefaultECReportHandler() {
44  		super();
45  	}
46  	
47  	/**
48  	 * create a new handler with a non default change set.
49  	 * @param changeSet
50  	 */
51  	public DefaultECReportHandler(String changeSet) {
52  		super(changeSet);
53  	}
54  	
55  	@Override
56  	public void loadRules() {
57  		// we only load the rules when the rule base is empty.
58  		if (null == kbase) {
59  			log.debug("loading rules from file.");
60  			kbuilder.add(
61  					ResourceFactory.newClassPathResource(
62  							changeSet,
63  							DefaultECReportHandler.class),
64  					ResourceType.CHANGE_SET);
65  		}
66  
67  	}
68  }