| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| LazyAgendaTree | 
  | 
  | 1.3333333333333333;1.333 | 
| 1 |  /* | |
| 2 |   * Copyright 2011 The Kuali Foundation | |
| 3 |   * | |
| 4 |   * Licensed under the Educational Community License, Version 1.0 (the "License"); | |
| 5 |   * you may not use this file except in compliance with the License. | |
| 6 |   * You may obtain a copy of the License at | |
| 7 |   * | |
| 8 |   * http://www.opensource.org/licenses/ecl1.php | |
| 9 |   * | |
| 10 |   * Unless required by applicable law or agreed to in writing, software | |
| 11 |   * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 |   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 |   * See the License for the specific language governing permissions and | |
| 14 |   * limitations under the License. | |
| 15 |   */ | |
| 16 |  package org.kuali.rice.krms.impl.provider.repository; | |
| 17 | ||
| 18 |  import org.kuali.rice.krms.api.engine.ExecutionEnvironment; | |
| 19 |  import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition; | |
| 20 |  import org.kuali.rice.krms.framework.engine.AgendaTree; | |
| 21 | ||
| 22 |  /** | |
| 23 |   * TODO...  | |
| 24 |   *  | |
| 25 |   * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 26 |   * | |
| 27 |   */ | |
| 28 | final class LazyAgendaTree implements AgendaTree {  | |
| 29 | ||
| 30 | 0 |          private final Object mutex = new Object(); | 
| 31 | private final AgendaDefinition agendaDefinition;  | |
| 32 | private final RepositoryToEngineTranslator translator;  | |
| 33 | ||
| 34 |          private AgendaTree agendaTree; | |
| 35 | ||
| 36 | 0 |          public LazyAgendaTree(AgendaDefinition agendaDefinition, RepositoryToEngineTranslator translator) { | 
| 37 | 0 |                  this.agendaDefinition = agendaDefinition; | 
| 38 | 0 |                  this.translator = translator; | 
| 39 | 0 |          } | 
| 40 | ||
| 41 | public void execute(ExecutionEnvironment environment) {  | |
| 42 | 0 |                  initialize(); | 
| 43 | 0 |                  agendaTree.execute(environment); | 
| 44 | 0 |          } | 
| 45 | ||
| 46 | public void initialize() {  | |
| 47 |                  // could use double-checked locking here for max efficiency | |
| 48 | 0 |                  synchronized (mutex) { | 
| 49 | 0 |                          if (agendaTree == null) { | 
| 50 | 0 |                                  agendaTree = translator.translateAgendaDefinitionToAgendaTree(agendaDefinition); | 
| 51 | }  | |
| 52 | 0 |                  } | 
| 53 | 0 |          } | 
| 54 | ||
| 55 | }  |