Search in sources :

Example 1 with KeyedPluginStore

use of com.qlangtech.tis.plugin.KeyedPluginStore in project tis by qlangtech.

the class DataxReader method createDataXReaderKey.

private static TIS.DataXReaderAppKey createDataXReaderKey(IPluginContext pluginContext, boolean db, String appname) {
    return new TIS.DataXReaderAppKey(pluginContext, db, appname, new PluginStore.IPluginProcessCallback<DataxReader>() {

        @Override
        public void afterDeserialize(final DataxReader reader) {
            List<PluginFormProperties> subFieldFormPropertyTypes = reader.getDescriptor().getSubPluginFormPropertyTypes();
            if (subFieldFormPropertyTypes.size() > 0) {
                // 加载子字段
                subFieldFormPropertyTypes.forEach((pt) -> {
                    pt.accept(new PluginFormProperties.IVisitor() {

                        @Override
                        public Void visit(final SuFormProperties props) {
                            SubFieldFormAppKey<DataxReader> subFieldKey = new SubFieldFormAppKey<>(pluginContext, db, appname, props, DataxReader.class);
                            KeyedPluginStore<DataxReader> subFieldStore = KeyedPluginStore.getPluginStore(subFieldKey);
                            // 子表单中的内容更新了之后,要同步父表单中的状态
                            subFieldStore.addPluginsUpdateListener(new PluginStore.PluginsUpdateListener<DataxReader>(subFieldKey.getSerializeFileName(), reader) {

                                @Override
                                public void accept(PluginStore<DataxReader> pluginStore) {
                                    setReaderSubFormProp(props, pluginStore.getPlugin());
                                }
                            });
                            DataxReader subFieldReader = subFieldStore.getPlugin();
                            if (subFieldReader == null) {
                                return null;
                            }
                            setReaderSubFormProp(props, subFieldReader);
                            return null;
                        }

                        private void setReaderSubFormProp(SuFormProperties props, DataxReader subFieldReader) {
                            setReaderSubFormProp(props, reader, subFieldReader);
                        }

                        private void setReaderSubFormProp(SuFormProperties props, DataxReader reader, DataxReader subFieldReader) {
                            if (reader == null) {
                                return;
                            }
                            try {
                                props.subFormField.set(reader, props.subFormField.get(subFieldReader));
                            } catch (IllegalAccessException e) {
                                throw new RuntimeException("get subField:" + props.getSubFormFieldName(), e);
                            }
                        }
                    });
                });
            }
        }
    });
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) PluginStore(com.qlangtech.tis.plugin.PluginStore) TIS(com.qlangtech.tis.TIS) Descriptor(com.qlangtech.tis.extension.Descriptor) IPluginContext(com.qlangtech.tis.util.IPluginContext) Lists(com.google.common.collect.Lists) Public(com.qlangtech.tis.annotation.Public) IDataXPluginMeta(com.qlangtech.tis.datax.IDataXPluginMeta) IDataxReader(com.qlangtech.tis.datax.IDataxReader) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) KeyedPluginStore(com.qlangtech.tis.plugin.KeyedPluginStore) IPluginStore(com.qlangtech.tis.plugin.IPluginStore) Describable(com.qlangtech.tis.extension.Describable) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) IDataxReader(com.qlangtech.tis.datax.IDataxReader) PluginStore(com.qlangtech.tis.plugin.PluginStore) KeyedPluginStore(com.qlangtech.tis.plugin.KeyedPluginStore) IPluginStore(com.qlangtech.tis.plugin.IPluginStore) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties)

Example 2 with KeyedPluginStore

use of com.qlangtech.tis.plugin.KeyedPluginStore in project plugins by qlangtech.

the class TISFlinClassLoaderFactory method synchronizeIncrPluginsFromRemoteRepository.

public static void synchronizeIncrPluginsFromRemoteRepository(String appName) {
    if (CenterResource.notFetchFromCenterRepository()) {
        return;
    }
    TIS.permitInitialize = false;
    try {
        if (StringUtils.isBlank(appName)) {
            throw new IllegalArgumentException("param appName can not be null");
        }
        List<IRepositoryResource> keyedPluginStores = Lists.newArrayList();
        keyedPluginStores.add(new KeyedPluginStore(new KeyedPluginStore.AppKey(null, false, appName, MQListenerFactory.class)));
        keyedPluginStores.add(new KeyedPluginStore(new KeyedPluginStore.AppKey(null, false, appName, IncrStreamFactory.class)));
        keyedPluginStores.add(new KeyedPluginStore(new KeyedPluginStore.AppKey(null, false, appName, TISSinkFactory.class)));
        // keyedPluginStores.add(DataxWriter.getPluginStore(null, dataxName));
        ComponentMeta dataxComponentMeta = new ComponentMeta(keyedPluginStores);
        dataxComponentMeta.synchronizePluginsFromRemoteRepository();
    } finally {
        TIS.permitInitialize = true;
    }
}
Also used : ComponentMeta(com.qlangtech.tis.plugin.ComponentMeta) IRepositoryResource(com.qlangtech.tis.plugin.IRepositoryResource) KeyedPluginStore(com.qlangtech.tis.plugin.KeyedPluginStore)

Aggregations

KeyedPluginStore (com.qlangtech.tis.plugin.KeyedPluginStore)2 Lists (com.google.common.collect.Lists)1 TIS (com.qlangtech.tis.TIS)1 Public (com.qlangtech.tis.annotation.Public)1 IDataXPluginMeta (com.qlangtech.tis.datax.IDataXPluginMeta)1 IDataxReader (com.qlangtech.tis.datax.IDataxReader)1 Describable (com.qlangtech.tis.extension.Describable)1 Descriptor (com.qlangtech.tis.extension.Descriptor)1 PluginFormProperties (com.qlangtech.tis.extension.PluginFormProperties)1 SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)1 ComponentMeta (com.qlangtech.tis.plugin.ComponentMeta)1 IPluginStore (com.qlangtech.tis.plugin.IPluginStore)1 IRepositoryResource (com.qlangtech.tis.plugin.IRepositoryResource)1 PluginStore (com.qlangtech.tis.plugin.PluginStore)1 IPluginContext (com.qlangtech.tis.util.IPluginContext)1 java.util (java.util)1 StringUtils (org.apache.commons.lang.StringUtils)1