|
|
@ -1,20 +1,29 @@ |
|
|
|
package com.fr.start.module; |
|
|
|
package com.fr.start.module; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
import com.fr.base.ModifiedTable; |
|
|
|
import com.fr.base.ModifiedTable; |
|
|
|
import com.fr.base.Parameter; |
|
|
|
import com.fr.base.Parameter; |
|
|
|
import com.fr.base.StoreProcedureParameter; |
|
|
|
import com.fr.base.StoreProcedureParameter; |
|
|
|
import com.fr.base.TableData; |
|
|
|
import com.fr.base.TableData; |
|
|
|
import com.fr.base.env.serializer.OldSerializerAdapter; |
|
|
|
import com.fr.base.env.serializer.OldSerializerAdapter; |
|
|
|
import com.fr.base.env.serializer.ProcedureDataModelSerializer; |
|
|
|
import com.fr.base.env.serializer.ProcedureDataModelSerializer; |
|
|
|
import com.fr.base.env.user.RemoteUserCenter; |
|
|
|
import com.fr.core.env.EnvConfig; |
|
|
|
import com.fr.core.env.operator.user.UserCenter; |
|
|
|
import com.fr.core.env.EnvEvent; |
|
|
|
import com.fr.core.env.proxy.EnvProxy; |
|
|
|
import com.fr.core.env.proxy.EnvProxy; |
|
|
|
|
|
|
|
import com.fr.core.env.resource.EnvConfigUtils; |
|
|
|
|
|
|
|
import com.fr.core.env.resource.LocalEnvConfig; |
|
|
|
|
|
|
|
import com.fr.core.env.resource.RemoteEnvConfig; |
|
|
|
import com.fr.data.core.db.TableProcedure; |
|
|
|
import com.fr.data.core.db.TableProcedure; |
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
import com.fr.data.impl.storeproc.ProcedureDataModel; |
|
|
|
import com.fr.data.impl.storeproc.ProcedureDataModel; |
|
|
|
import com.fr.data.impl.storeproc.StoreProcedure; |
|
|
|
import com.fr.data.impl.storeproc.StoreProcedure; |
|
|
|
import com.fr.dav.DavXMLUtils; |
|
|
|
import com.fr.dav.DavXMLUtils; |
|
|
|
|
|
|
|
import com.fr.dav.LocalEnv; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
|
|
|
import com.fr.env.RemoteEnv; |
|
|
|
|
|
|
|
import com.fr.event.Event; |
|
|
|
|
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
|
|
|
|
import com.fr.event.Listener; |
|
|
|
import com.fr.file.filetree.FileNode; |
|
|
|
import com.fr.file.filetree.FileNode; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.module.Activator; |
|
|
|
import com.fr.module.Activator; |
|
|
@ -44,181 +53,190 @@ public class DesignerEnvProvider extends Activator { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
initDesignerEnv(); |
|
|
|
initDesignerEnv(); |
|
|
|
|
|
|
|
|
|
|
|
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher()); |
|
|
|
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher()); |
|
|
|
//设置好环境即可,具体跟环境有关的模块会自动调用
|
|
|
|
//设置好环境即可,具体跟环境有关的模块会自动调用
|
|
|
|
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); |
|
|
|
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initDesignerEnv() { |
|
|
|
private void initDesignerEnv() { |
|
|
|
|
|
|
|
|
|
|
|
addSerializers(); |
|
|
|
addSerializers(); |
|
|
|
EnvProxy.addRemoteService(UserCenter.class, new RemoteUserCenter()); |
|
|
|
EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener<EnvConfig>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void on(Event event, EnvConfig envConfig) { |
|
|
|
|
|
|
|
if (envConfig instanceof RemoteEnvConfig) { |
|
|
|
|
|
|
|
RemoteEnv remoteEnv = new RemoteEnv(envConfig.getPath(), EnvConfigUtils.getUsername(envConfig), EnvConfigUtils.getPassword(envConfig)); |
|
|
|
|
|
|
|
FRContext.setCurrentEnv(remoteEnv); |
|
|
|
|
|
|
|
} else if (envConfig instanceof LocalEnvConfig) { |
|
|
|
|
|
|
|
FRContext.setCurrentEnv(new LocalEnv()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void addSerializers() { |
|
|
|
private void addSerializers() { |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); |
|
|
|
EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter<ModifiedTable>( |
|
|
|
EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter<ModifiedTable>( |
|
|
|
new OldSerializerAdapter.OldSerializer<ModifiedTable>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<ModifiedTable>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(ModifiedTable obj, OutputStream out) throws Exception { |
|
|
|
public void serializer(ModifiedTable obj, OutputStream out) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLModifiedTables(obj, out); |
|
|
|
DavXMLUtils.writeXMLModifiedTables(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<ModifiedTable>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<ModifiedTable>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ModifiedTable deserializer(InputStream in) throws Exception { |
|
|
|
public ModifiedTable deserializer(InputStream in) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLModifiedTables(in); |
|
|
|
return DavXMLUtils.readXMLModifiedTables(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter<com.fr.data.impl.Connection>( |
|
|
|
EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter<com.fr.data.impl.Connection>( |
|
|
|
new OldSerializerAdapter.OldSerializer<Connection>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<Connection>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(Connection obj, OutputStream out) { |
|
|
|
public void serializer(Connection obj, OutputStream out) { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); |
|
|
|
DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<Connection>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<Connection>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Connection deserializer(InputStream in) throws Exception { |
|
|
|
public Connection deserializer(InputStream in) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLDatabaseConnection(in); |
|
|
|
return DavXMLUtils.readXMLDatabaseConnection(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter<FileNode[]>( |
|
|
|
EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter<FileNode[]>( |
|
|
|
new OldSerializerAdapter.OldSerializer<FileNode[]>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<FileNode[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(FileNode[] obj, OutputStream out) { |
|
|
|
public void serializer(FileNode[] obj, OutputStream out) { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLFileNodes(obj, out); |
|
|
|
DavXMLUtils.writeXMLFileNodes(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<FileNode[]>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<FileNode[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public FileNode[] deserializer(InputStream in) { |
|
|
|
public FileNode[] deserializer(InputStream in) { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLFileNodes(in); |
|
|
|
return DavXMLUtils.readXMLFileNodes(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter<TableProcedure[]>( |
|
|
|
EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter<TableProcedure[]>( |
|
|
|
new OldSerializerAdapter.OldSerializer<TableProcedure[]>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<TableProcedure[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(TableProcedure[] obj, OutputStream out) { |
|
|
|
public void serializer(TableProcedure[] obj, OutputStream out) { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLFileSQLTable(obj, out); |
|
|
|
DavXMLUtils.writeXMLFileSQLTable(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<TableProcedure[]>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<TableProcedure[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TableProcedure[] deserializer(InputStream in) throws Exception { |
|
|
|
public TableProcedure[] deserializer(InputStream in) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLSQLTables(in); |
|
|
|
return DavXMLUtils.readXMLSQLTables(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter<TableData>( |
|
|
|
EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter<TableData>( |
|
|
|
new OldSerializerAdapter.OldSerializer<TableData>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<TableData>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(TableData obj, OutputStream out) { |
|
|
|
public void serializer(TableData obj, OutputStream out) { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLFileTableData(obj, out); |
|
|
|
DavXMLUtils.writeXMLFileTableData(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<TableData>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<TableData>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TableData deserializer(InputStream in) throws Exception { |
|
|
|
public TableData deserializer(InputStream in) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLTableData(in); |
|
|
|
return DavXMLUtils.readXMLTableData(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter<Parameter[]>( |
|
|
|
EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter<Parameter[]>( |
|
|
|
new OldSerializerAdapter.OldSerializer<Parameter[]>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<Parameter[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(Parameter[] obj, OutputStream out) { |
|
|
|
public void serializer(Parameter[] obj, OutputStream out) { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLFileParameters(obj, out); |
|
|
|
DavXMLUtils.writeXMLFileParameters(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<Parameter[]>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<Parameter[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Parameter[] deserializer(InputStream in) throws Exception { |
|
|
|
public Parameter[] deserializer(InputStream in) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLParameters(in); |
|
|
|
return DavXMLUtils.readXMLParameters(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter<StoreProcedure>( |
|
|
|
EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter<StoreProcedure>( |
|
|
|
new OldSerializerAdapter.OldSerializer<StoreProcedure>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<StoreProcedure>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(StoreProcedure obj, OutputStream out) { |
|
|
|
public void serializer(StoreProcedure obj, OutputStream out) { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLFileStoreProcedure(obj, out); |
|
|
|
DavXMLUtils.writeXMLFileStoreProcedure(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<StoreProcedure>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<StoreProcedure>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public StoreProcedure deserializer(InputStream in) throws Exception { |
|
|
|
public StoreProcedure deserializer(InputStream in) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLStoreProcedure(in); |
|
|
|
return DavXMLUtils.readXMLStoreProcedure(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter<StoreProcedureParameter[]>( |
|
|
|
EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter<StoreProcedureParameter[]>( |
|
|
|
new OldSerializerAdapter.OldSerializer<StoreProcedureParameter[]>() { |
|
|
|
new OldSerializerAdapter.OldSerializer<StoreProcedureParameter[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void serializer(StoreProcedureParameter[] obj, OutputStream out) { |
|
|
|
public void serializer(StoreProcedureParameter[] obj, OutputStream out) { |
|
|
|
|
|
|
|
|
|
|
|
DavXMLUtils.writeXMLFileParameters(obj, out); |
|
|
|
DavXMLUtils.writeXMLFileParameters(obj, out); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
new OldSerializerAdapter.OldDeserializer<StoreProcedureParameter[]>() { |
|
|
|
new OldSerializerAdapter.OldDeserializer<StoreProcedureParameter[]>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { |
|
|
|
public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
return DavXMLUtils.readXMLStoreProcedureParameters(in); |
|
|
|
return DavXMLUtils.readXMLStoreProcedureParameters(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void stop() { |
|
|
|
public void stop() { |
|
|
|
//清空模块
|
|
|
|
//清空模块
|
|
|
|
getRoot().removeSingleton(EnvSwitcher.class); |
|
|
|
getRoot().removeSingleton(EnvSwitcher.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|