Exemple #1
0
def get_mapper_instance(env):
    global mapper_instance
    if not mapper_instance:
        fqcn = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_MAPPER_CLASS, DEFAULT_MAPPER_CLASS)
        env.log("Creating a new mapper instance of {}".format(fqcn))
        klass = find_class(fqcn)
        mapper_instance = klass(env)
    return mapper_instance
Exemple #2
0
def get_planner_instance(env):
    global planner_instance
    if not planner_instance:
        fqcn = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_PLANNER_CLASS, DEFAULT_PLANNER_CLASS)
        env.log("Creating a new planner instance of {}".format(fqcn))
        klass = find_class(fqcn)
        planner_instance = klass(env)
    return planner_instance
def get_mapper_instance(env):
    global mapper_instance
    if not mapper_instance:
        fqcn = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_MAPPER_CLASS,
                                DEFAULT_MAPPER_CLASS)
        env.log("Creating a new mapper instance of {}".format(fqcn))
        klass = find_class(fqcn)
        mapper_instance = klass(env)
    return mapper_instance
def get_planner_instance(env):
    global planner_instance
    if not planner_instance:
        fqcn = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_PLANNER_CLASS,
                                DEFAULT_PLANNER_CLASS)
        env.log("Creating a new planner instance of {}".format(fqcn))
        klass = find_class(fqcn)
        planner_instance = klass(env)
    return planner_instance
Exemple #5
0
def get_executor_instance(env, actionExecutor):
    global executor_instance
    if not executor_instance:
        fqcn = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_EXECUTOR_CLASS, DEFAULT_EXECUTOR_CLASS)
        env.log("Creating a new executor instance of {}".format(fqcn))
        klass = find_class(fqcn)
        executor_instance = klass(env, actionExecutor)
    # NOT THREAD SAFE
    # even if we already had an instance of an executor the choreographe object might have become
    # stale so we refresh it. We only have one executor instance at once so this should be OK
    executor_instance.actionExecutor = actionExecutor
    return executor_instance
def get_executor_instance(env, actionExecutor):
    global executor_instance
    if not executor_instance:
        fqcn = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_EXECUTOR_CLASS,
                                DEFAULT_EXECUTOR_CLASS)
        env.log("Creating a new executor instance of {}".format(fqcn))
        klass = find_class(fqcn)
        executor_instance = klass(env, actionExecutor)
    # NOT THREAD SAFE
    # even if we already had an instance of an executor the choreographe object might have become
    # stale so we refresh it. We only have one executor instance at once so this should be OK
    executor_instance.actionExecutor = actionExecutor
    return executor_instance
Exemple #7
0
def get_updaters(env):
    global updater_instances
    if not updater_instances:
        updater_instances = []
        fqcns = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_UPDATER_CLASSES)
        if fqcns:
            for fqcn in fqcns:
                env.log("Creating a new updater instance of {}".format(fqcn))
                klass = find_class(fqcn)
                updater = klass(env)
                if updater:
                    updater_instances.append(updater)
    
    return updater_instances
def get_updaters(env):
    global updater_instances
    if not updater_instances:
        updater_instances = []
        fqcns = env.get_property(DEFAULT_CONFIG_FILE, PROPERTY_UPDATER_CLASSES)
        if fqcns:
            for fqcn in fqcns:
                env.log("Creating a new updater instance of {}".format(fqcn))
                klass = find_class(fqcn)
                updater = klass(env)
                if updater:
                    updater_instances.append(updater)

    return updater_instances
Exemple #9
0
def get_translator(name=None):
    global translator_instances
    if not name:
        name = DEFAULT_TRANSLATOR_NAME

    # force the name to be a valid translator
    try:
        clazzname = TRANSLATORS[name]
    except KeyError:
        name = DEFAULT_TRANSLATOR_NAME
        clazzname = TRANSLATORS[DEFAULT_TRANSLATOR_NAME]

    # get an existing translator instance or make a new one
    try:
        translator = translator_instances[name]
    except KeyError:
        klass = find_class(clazzname)
        translator = klass()
        translator_instances[name] = translator
    return translator
Exemple #10
0
def get_translator(name=None):
    global default_translator
    if not default_translator:
        default_translator = find_class(DEFAULT_TRANSLATOR_NAME)
    return default_translator()