/*
 * Copyright (c) 2013. Knowledge Media Institute - The Open University
 *
 * 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 uk.ac.open.kmi.iserve.sal.manager.impl;

import com.google.common.eventbus.EventBus;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.open.kmi.iserve.core.ConfiguredModule;
import uk.ac.open.kmi.iserve.sal.manager.DocumentManager;
import uk.ac.open.kmi.iserve.sal.manager.KnowledgeBaseManager;
import uk.ac.open.kmi.iserve.sal.manager.ServiceManager;
import uk.ac.open.kmi.iserve.sal.manager.SparqlGraphStoreManager;

/**
 * iServeModule is in charge of adequately initialising iServe by obtaining the configuration parameters
 * and binding each of the interfaces to the chosen implementation.
 *
 * @author <a href="mailto:carlos.pedrinaci@open.ac.uk">Carlos Pedrinaci</a> (KMi - The Open University)
 * @since 06/09/2013
 */
public class iServeManagementModule extends ConfiguredModule {

    private static final Logger log = LoggerFactory.getLogger(iServeManagementModule.class);

    @Override
    protected void configure() {
        // Ensure configuration is loaded
        super.configure();

        // Create the EventBus
        final EventBus eventBus = new EventBus("iServe");
        bind(EventBus.class).toInstance(eventBus);

        // Bind each of the managers
        bind(DocumentManager.class).to(DocumentManagerFileSystem.class);
        bind(ServiceManager.class).to(ServiceManagerSparql.class);
        bind(KnowledgeBaseManager.class).to(KnowledgeBaseManagerSparql.class);

        // Assisted Injection for the Graph Store Manager
        install(new FactoryModuleBuilder()
                .implement(SparqlGraphStoreManager.class, ConcurrentSparqlGraphStoreManager.class)
                .build(SparqlGraphStoreFactory.class));
    }
}

@@ -939,209 +939,9 @@
 ger.
-DocumentManager;%0Aimport uk.ac.open.kmi.iserve.sal.manager.KnowledgeBaseManager;%0Aimport uk.ac.open.kmi.iserve.sal.manager.ServiceManager;%0Aimport uk.ac.open.kmi.iserve.sal.manager.SparqlGraphStoreManager
+*
 ;%0A%0A/
@@ -1520,24 +1520,281 @@
 nfigure();%0A%0A
+        // Assisted Injection for the Graph Store Manager%0A        install(new FactoryModuleBuilder()%0A                .implement(SparqlGraphStoreManager.class, ConcurrentSparqlGraphStoreManager.class)%0A                .build(SparqlGraphStoreFactory.class));%0A%0A
         // C
@@ -1959,16 +1959,18 @@
 anagers%0A
+//
         
@@ -2028,26 +2028,48 @@
 ystem.class)
-;%0A
+.in(Singleton.class);%0A//
         bind
@@ -2100,38 +2100,60 @@
 o(ServiceManager
-Sparql
+IndexRdf.class).in(Singleton
 .class);%0A       
@@ -2145,16 +2145,18 @@
 class);%0A
+//
         
@@ -2228,68 +2228,90 @@
 ass)
-;%0A%0A        // Assisted Injection for the Graph Store Manager
+.in(Singleton.class);%0A//        bind(iServeManager.class).to(iServeFacade.class);%0A
 %0A   
@@ -2319,134 +2319,204 @@
     
+b
 in
-stall(new FactoryModuleBuilder()%0A                .implement(SparqlGraphStoreManager.class, ConcurrentSparqlGraphStor
+d(DocumentManager.class).to(DocumentManagerFileSystem.class);%0A        bind(ServiceManager.class).to(ServiceManagerSparql.class);%0A        bind(KnowledgeBaseManager.class).to(KnowledgeBas
 eManager
 .cla
@@ -2503,39 +2503,46 @@
 ledgeBaseManager
+Sparql
 .class)
+;
 %0A               
@@ -2538,54 +2538,56 @@
     
-        .build(SparqlGraphStoreFactory
+bind(iServeManager.class).to(iServeFacade
 .class)
-)
 ;%0A  

Rearrange module configuration. New interface and change in scopes.