/*
 *
 *  * Licensed to the Apache Software Foundation (ASF) under one or more
 *  *  contributor license agreements.  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.  For additional information regarding
 *  * copyright in this work, please see the NOTICE file in the top level
 *  * directory of this distribution.
 *
 */
package org.apache.usergrid.persistence.queue.impl;

import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.apache.usergrid.persistence.queue.*;

/**
 * manages whether we take in an external in memory override for queues.
 */
@Singleton
public class QueueManagerFactoryImpl implements QueueManagerFactory {


    private final QueueFig queueFig;
    private final QueueManagerInternalFactory queuemanagerInternalFactory;

    @Inject
    public QueueManagerFactoryImpl(final QueueFig queueFig, final QueueManagerInternalFactory queuemanagerInternalFactory){
        this.queueFig = queueFig;
        this.queuemanagerInternalFactory = queuemanagerInternalFactory;
    }
    @Override
    public QueueManager getQueueManager(QueueScope scope) {
        return queueFig.overrideQueueForDefault() ? new DefaultQueueManager() : queuemanagerInternalFactory.getQueueManager(scope);
    }
}

@@ -1120,16 +1120,65 @@
 eue.*;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * m
@@ -1444,16 +1444,75 @@
 Factory;
+%0A    private final Map%3CString,QueueManager%3E defaultManager;
 %0A%0A    @I
@@ -1743,24 +1743,73 @@
 nalFactory;%0A
+        this.defaultManager = new HashMap%3C%3E(10);%0A
     %7D%0A    @O
@@ -1888,15 +1888,11 @@
     
-return 
+if(
 queu
@@ -1925,38 +1925,303 @@
 lt()
- ? new DefaultQueueManager() :
+)%7B%0A            QueueManager manager = defaultManager.get(scope.getName());%0A            if(manager==null)%7B%0A                manager = new DefaultQueueManager();%0A                defaultManager.put(scope.getName(),manager);%0A            %7D%0A            return manager;%0A        %7Delse%7B%0A            return
  que
@@ -2269,16 +2269,26 @@
 scope);%0A
+        %7D%0A
     %7D%0A%7D%0A

fix default queue