/*
 * Copyright 2013 NGDATA nv
 *
 * 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 com.ngdata.hbaseindexer.uniquekey;

import com.ngdata.hbaseindexer.conf.IndexerConf;

public class UniqueKeyFormatterFactory {
    private Class formatterClass;

    public UniqueKeyFormatterFactory (IndexerConf conf) {
        this.formatterClass = conf.getUniqueKeyFormatterClass();
    }

    public UniqueKeyFormatter newUniqueKeyFormatter(String tableName) {
        try {
            UniqueKeyFormatter uniqueKeyFormatter = (UniqueKeyFormatter)formatterClass.newInstance();
            if (uniqueKeyFormatter instanceof UniqueTableKeyFormatter) {
                ((UniqueTableKeyFormatter) uniqueKeyFormatter).setTable(tableName);
            }
            return uniqueKeyFormatter;
        } catch (Exception e) {
            throw new RuntimeException("Problem instantiating the UniqueKeyFormatter.", e);
        }
    }
}

@@ -665,24 +665,92 @@
 xer.
-conf.IndexerConf
+Configurable;%0Aimport com.ngdata.hbaseindexer.conf.IndexerConf;%0A%0Aimport java.util.Map
 ;%0A%0Ap
@@ -822,16 +822,61 @@
 erClass;
+%0A    private Map%3CString,String%3E globalParams;
 %0A%0A    pu
@@ -988,24 +988,76 @@
 terClass();%0A
+        this.globalParams = conf.getGlobalParams();%0A
     %7D%0A%0A    p
@@ -1308,24 +1308,24 @@
 ormatter) %7B%0A
-
             
@@ -1406,24 +1406,176 @@
           %7D%0A
+            if (uniqueKeyFormatter instanceof Configurable) %7B%0A                ((Configurable)uniqueKeyFormatter).configure(globalParams);%0A            %7D%0A
             

Support configurable params