/**
 * Copyright 2010 David L. Whitehurst
 *
 * Licensed 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.dlw.ai.blackboard;

import java.util.concurrent.ConcurrentLinkedQueue;

import org.dlw.ai.blackboard.domain.Assumption;
import org.dlw.ai.blackboard.domain.BaseObject;

/**
 * <p>
 * This class is used as an attribute addition (extension) that defines the
 * implemented {@link org.dlw.ai.blackboard.knowledge.KnowledgeSource}(s) in
 * package {@link org.dlw.ai.blackboard.knowledge.primitive}.
 * </p>
 * 
 * <p>
 * This class cannot be extended and therefore not part of the API. Its use is
 * specific to the problem domain being solved by
 * {@link org.dlw.ai.blackboard.Main}.
 * </p>
 * 
 * @author <a href="mailto:dlwhitehurst@gmail.com">David L. Whitehurst</a>
 * @version 1.0.0-RC
 * 
 */
public class BlackboardContext extends BaseObject {

    /**
     * unique serial identifier
     */
    private static final long serialVersionUID = -545460787166534024L;

    /**
     * Attribute blackboard
     */
    private Blackboard blackboard;

    /**
     * Attribute controller
     */
    private Controller controller;

    /**
     * Attribute queue of assumptions made by KnowledgeSource
     */
    private ConcurrentLinkedQueue<Assumption> pastAssumptions = new ConcurrentLinkedQueue<Assumption>();

    /**
     * Default constructor
     */
    public BlackboardContext() {
    }

    /**
     * Loaded constructor
     * 
     * @param blackboard
     *              the {@link Blackboard} object needed
     * @param controller 
     *              the {@link Controller} object needed
     * @param pastAssumptions
     *              the {@link ConcurrentLinkedQueue} object data structure
     */
    public BlackboardContext(final Blackboard blackboard, final Controller controller,
            final ConcurrentLinkedQueue<Assumption> pastAssumptions) {
        this.blackboard = blackboard;
        this.controller = controller;
        this.pastAssumptions = pastAssumptions;
    }

    /**
     * @return the {@link Blackboard} object
     */
    public final Blackboard getBlackboard() {
        return blackboard;
    }

    /**
     * @param blackboard
     *            the {@link Blackboard} object to set
     */
    public final void setBlackboard(Blackboard blackboard) {
        this.blackboard = blackboard;
    }

    /**
     * @return the {@link Controller} object
     */
    public final Controller getController() {
        return controller;
    }

    /**
     * @param controller
     *            the {@link Controller} object to set
     */
    public final void setController(Controller controller) {
        this.controller = controller;
    }

    /**
     * @return the {@link ConcurrentLinkedQueue} object pastAssumptions
     */
    public final ConcurrentLinkedQueue<Assumption> getPastAssumptions() {
        return pastAssumptions;
    }

    /**
     * @param pastAssumptions
     *            the {@link ConcurrentLinkedQueue} pastAssumptions to set
     */
    public final void setPastAssumptions(
            ConcurrentLinkedQueue<Assumption> pastAssumptions) {
        this.pastAssumptions = pastAssumptions;
    }

    @Override
    public boolean equals(Object o) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public int hashCode() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return null;
    }

}

@@ -632,60 +632,8 @@
 d;%0A%0A
-import java.util.concurrent.ConcurrentLinkedQueue;%0A%0A
 impo
@@ -661,25 +661,28 @@
 ard.
-domain.Assumption
+util.SystemConstants
 ;%0Aim
@@ -712,24 +712,28 @@
 ard.
-domain.BaseObjec
+util.UniversalContex
 t;%0A%0A
@@ -755,213 +755,102 @@
 his 
-class is
+singleton class can be
  used 
-as an attribute addition (extension) that defines the%0A * implemented %7B@link org.dlw.ai.blackboard.knowledge.KnowledgeSource%7D(s) in%0A * package %7B@link org.dlw.ai.blackboard.knowledge.primitive%7D
+by any class to obtain the blackboard and %0A * controller instances
 .%0A *
@@ -1157,16 +1157,22 @@
 %0Apublic 
+final 
 class Bl
@@ -1191,149 +1191,114 @@
 ext 
-extends BaseObject %7B%0A%0A    /**%0A     * unique serial identifier%0A     */%0A    private static final long serialVersionUID = -545460787166534024L;%0A
+%7B%0A%0A    /**%0A     * Attribute singleton instance%0A     */%0A    private static BlackboardContext instance;%0A    
 %0A   
@@ -1473,259 +1473,285 @@
   * 
-Attribute queue of assumptions made by KnowledgeSource%0A     */%0A    private ConcurrentLinkedQueue%3CAssumption%3E pastAssumptions = new ConcurrentLinkedQueue%3CAssumption%3E(
+Hidden constructor%0A     */%0A    private BlackboardContext() %7B%0A        this.blackboard = (Blackboard) UniversalContext.getApplicationContext().getBean(%22blackboard%22
 );%0A
-%0A
     
-/**%0A     * Default 
+    this.
 con
-s
 tr
-uctor%0A     */%0A    public BlackboardContext() %7B
+oller = (Controller) UniversalContext.getApplicationContext().getBean(%22controller%22);
 %0A    %7D%0A
+    
 %0A   
@@ -1766,305 +1766,58 @@
   * 
-Loaded constructor%0A     * %0A     * @param blackboard%0A     *              the %7B@link Blackboard%7D object needed%0A     * @param controller %0A     *              the %7B@link Controller%7D object needed%0A     * @param pastAssumptions%0A     *              the %7B@link ConcurrentLinkedQueue%7D object data structure
+Method to return singleton instance%0A     * @return
 %0A   
@@ -1832,16 +1832,23 @@
  public 
+static 
 Blackboa
@@ -1860,260 +1860,138 @@
 text
-(final Blackboard blackboard, final Controller controller,%0A            final ConcurrentLinkedQueue%3CAssumption%3E pastAssumptions) %7B%0A        this.blackboard = blackboard;%0A        this.controller = controller;%0A        this.pastAssumptions = pastAssumptions
+ getInstance() %7B%0A        if (instance == null) %7B%0A            instance = new BlackboardContext();%0A        %7D%0A        return instance
 ;%0A  
@@ -2685,492 +2685,8 @@
  %7D%0A%0A
-    /**%0A     * @return the %7B@link ConcurrentLinkedQueue%7D object pastAssumptions%0A     */%0A    public final ConcurrentLinkedQueue%3CAssumption%3E getPastAssumptions() %7B%0A        return pastAssumptions;%0A    %7D%0A%0A    /**%0A     * @param pastAssumptions%0A     *            the %7B@link ConcurrentLinkedQueue%7D pastAssumptions to set%0A     */%0A    public final void setPastAssumptions(%0A            ConcurrentLinkedQueue%3CAssumption%3E pastAssumptions) %7B%0A        this.pastAssumptions = pastAssumptions;%0A    %7D%0A%0A
     
@@ -2972,62 +2972,49 @@
     
-// TODO Auto-generated method stub%0A        return null
+return SystemConstants.BLACKBOARD_CONTEXT
 ;%0A  

Refactor as singleton