本文整理汇总了Java中org.jboss.shrinkwrap.api.Domain类的典型用法代码示例。如果您正苦于以下问题:Java Domain类的具体用法?Java Domain怎么用?Java Domain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Domain类属于org.jboss.shrinkwrap.api包,在下文中一共展示了Domain类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
@Override
public void init(SimulationParameters parameters, Map<String, Object> context) throws Exception {
Objects.requireNonNull(parameters, "parameters is null");
Objects.requireNonNull(context, "context is null");
this.parameters = parameters;
dictionary = getDictionary(context);
// read all contingencies
allContingencies.addAll(contingenciesProvider.getContingencies(network));
if (config.isUseBroadcast()) {
Domain domain = ShrinkWrap.createDomain();
try (OutputStream os = computationManager.newCommonFile(ALL_SCENARIOS_ZIP_FILE_NAME)) {
writeAllScenarios(domain, os);
}
try (OutputStream os = computationManager.newCommonFile(WP43_ALL_CONFIGS_ZIP_FILE_NAME)) {
writeAllWp43Configs(domain, os);
}
try (OutputStream os = computationManager.newCommonFile(LIMITS_ZIP_FILE_NAME)) {
writeLimits(domain, os);
}
}
}
示例2: writeFaultSeqArchive
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
public GenericArchive writeFaultSeqArchive(Domain domain, List<Contingency> contingencies, Network network, EurostagDictionary dictionary, Function<Integer, String> seqFileNameFct) throws IOException {
if ((contingencies == null) || (contingencies.isEmpty())) {
throw new RuntimeException("contingencies list is empty, cannot write .seq scenario files");
}
GenericArchive archive = domain.getArchiveFactory().create(GenericArchive.class);
try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
Path rootDir = fileSystem.getPath("/");
for (int i = 0; i < contingencies.size(); i++) {
Contingency contingency = contingencies.get(i);
Path seqFile = rootDir.resolve(seqFileNameFct.apply(i));
try (BufferedWriter writer = Files.newBufferedWriter(seqFile, StandardCharsets.UTF_8)) {
writeFaultSeq(writer, contingency, network, dictionary);
}
}
}
return archive;
}
示例3: createShrinkWrapDomain
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private void createShrinkWrapDomain() {
ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
try {
if (isFatJar()) {
Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
}
Domain domain = ShrinkWrap.getDefaultDomain();
domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
domain.getConfiguration().getExtensionLoader().addOverride(ZipImporter.class, ZipImporterImpl.class);
domain.getConfiguration().getExtensionLoader().addOverride(ExplodedExporter.class, ExplodedExporterImpl.class);
domain.getConfiguration().getExtensionLoader().addOverride(ExplodedImporter.class, ExplodedImporterImpl.class);
domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
} catch (Exception e) {
SwarmMessages.MESSAGES.shrinkwrapDomainSetupFailed(e);
} finally {
Thread.currentThread().setContextClassLoader(originalCl);
}
}
示例4: writeDtaAndControls
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private void writeDtaAndControls(Domain domain, OutputStream ddbOs, OutputStream dictGensOs) throws IOException {
GenericArchive archive = domain.getArchiveFactory().create(GenericArchive.class);
try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
Path rootDir = fileSystem.getPath("/");
ddbClient.dumpDtaFile(rootDir, DTA_FILE_NAME, network, parallelIndexes.toMap(), EurostagUtil.VERSION, dictionary.toMap());
}
archive.as(ZipExporter.class).exportTo(ddbOs);
//put just the generators dict csv file (extracted from the ddb files) in the common files set, to be used by wp43 transient stability index
if (archive.get(DDB_DICT_GENS_CSV) != null) {
ByteStreams.copy(archive.get(DDB_DICT_GENS_CSV).getAsset().openStream(), dictGensOs);
} else {
LOGGER.warn(DDB_DICT_GENS_CSV + " is missing in the dynamic data files set: some security indexers (e.g. transient stability) need this file");
}
}
示例5: init
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
@Override
public void init(SimulationParameters parameters, Map<String, Object> context) throws Exception {
Objects.requireNonNull(parameters, "parameters is null");
Objects.requireNonNull(context, "context is null");
this.parameters = parameters;
// exportConfig = new EurostagEchExportConfig(config.isLfNoGeneratorMinMaxQ());
// isLfNoGeneratorMinMaxQ must now be configured in eurostag-ech-export section
exportConfig = EurostagEchExportConfig.load();
fakeNodes = EurostagFakeNodes.build(network, exportConfig);
parallelIndexes = BranchParallelIndexes.build(network, exportConfig, fakeNodes);
// fill iTesla id to Esg id dictionary
dictionary = EurostagDictionary.create(network, parallelIndexes, exportConfig, fakeNodes);
if (config.isUseBroadcast()) {
Domain domain = ShrinkWrap.createDomain();
try (OutputStream ddbOs = computationManager.newCommonFile(DDB_ZIP_FILE_NAME);
OutputStream dictGensOs = computationManager.newCommonFile(DDB_DICT_GENS_CSV)) {
writeDtaAndControls(domain, ddbOs, dictGensOs);
}
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(computationManager.newCommonFile(PRE_FAULT_SEQ_FILE_NAME), StandardCharsets.UTF_8))) {
writePreFaultSeq(writer);
}
}
context.put("dictionary", dictionary);
}
示例6: before
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private EurostagContext before(Path workingDir) throws IOException {
if (config.isDebug()) {
// dump state info for debugging
Networks.dumpStateId(workingDir, network);
Exporter exporter = Exporters.getExporter("XIIDM");
if (exporter != null) {
Properties parameters = new Properties();
parameters.setProperty("iidm.export.xml.indent", "true");
parameters.setProperty("iidm.export.xml.with-branch-state-variables", "true");
parameters.setProperty("iidm.export.xml.with-breakers", "true");
try {
exporter.export(network, parameters, new FileDataSource(workingDir, "network"));
} catch (Exception e) {
LOGGER.error(e.toString(), e);
}
}
}
EurostagContext context = new EurostagContext();
if (!config.isUseBroadcast()) {
Domain domain = ShrinkWrap.createDomain();
try (OutputStream ddbOs = Files.newOutputStream(workingDir.resolve(DDB_ZIP_FILE_NAME));
ByteArrayOutputStream dictGensOs = new ByteArrayOutputStream()) {
writeDtaAndControls(domain, ddbOs, dictGensOs);
dictGensOs.flush();
context.dictGensCsv = dictGensOs.toByteArray();
}
try (BufferedWriter writer = Files.newBufferedWriter(workingDir.resolve(PRE_FAULT_SEQ_FILE_NAME), StandardCharsets.UTF_8)) {
writePreFaultSeq(writer);
}
}
writeEch(workingDir);
return context;
}
示例7: writeWp43Configs
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private void writeWp43Configs(Domain domain, List<Contingency> contingencies, OutputStream os) throws IOException, ConfigurationException {
// copy wp43 configuration files
GenericArchive archive = domain.getArchiveFactory().create(GenericArchive.class);
try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
Path rootDir = fileSystem.getPath("/");
writeWp43Configs(contingencies, rootDir);
}
archive.as(ZipExporter.class).exportTo(os);
}
示例8: writeLimits
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private static void writeLimits(Network network, EurostagDictionary dictionary, Domain domain, OutputStream os) throws IOException {
GenericArchive archive = domain.getArchiveFactory().create(GenericArchive.class);
try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
Path rootDir = fileSystem.getPath("/");
// dump first current limits for each of the branches
try (BufferedWriter writer = Files.newBufferedWriter(rootDir.resolve(CURRENT_LIMITS_CSV), StandardCharsets.UTF_8)) {
for (Line l : network.getLines()) {
dumpLimits(dictionary, writer, l);
}
for (TwoWindingsTransformer twt : network.getTwoWindingsTransformers()) {
dumpLimits(dictionary, writer, twt);
}
for (DanglingLine dl : network.getDanglingLines()) {
dumpLimits(dictionary, writer, dl.getId(),
dl.getCurrentLimits(),
null,
dl.getTerminal().getVoltageLevel().getNominalV(),
dl.getTerminal().getVoltageLevel().getNominalV());
}
}
try (BufferedWriter writer = Files.newBufferedWriter(rootDir.resolve(VOLTAGE_LIMITS_CSV), StandardCharsets.UTF_8)) {
for (Bus b : EchUtil.getBuses(network, dictionary.getConfig())) {
VoltageLevel vl = b.getVoltageLevel();
if (!Float.isNaN(vl.getLowVoltageLimit()) && !Float.isNaN(vl.getHighVoltageLimit())) {
writer.write(dictionary.getEsgId(b.getId()));
writer.write(";");
writer.write(Float.toString(vl.getLowVoltageLimit()));
writer.write(";");
writer.write(Float.toString(vl.getHighVoltageLimit()));
writer.write(";");
writer.write(Float.toString(vl.getNominalV()));
writer.newLine();
}
}
}
//dump lines dictionary, for WP43 integration
dumpLinesDictionary(network, dictionary, rootDir);
//dump buses dictionary, for WP43 integration
dumpBusesDictionary(network, dictionary, rootDir);
}
archive.as(ZipExporter.class).exportTo(os);
}
示例9: writeScenarios
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private void writeScenarios(Domain domain, List<Contingency> contingencies, OutputStream os) throws IOException {
GenericArchive archive = new EurostagScenario(parameters, config).writeFaultSeqArchive(domain, contingencies, network, dictionary,
faultNum -> FAULT_SEQ_FILE_NAME.replace(Command.EXECUTION_NUMBER_PATTERN, Integer.toString(faultNum)));
archive.as(ZipExporter.class).exportTo(os);
}
示例10: writeAllScenarios
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private void writeAllScenarios(Domain domain, OutputStream os) throws IOException {
writeScenarios(domain, allContingencies, os);
}
示例11: writeAllWp43Configs
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
private void writeAllWp43Configs(Domain domain, OutputStream os) throws IOException, ConfigurationException {
writeWp43Configs(domain, allContingencies, os);
}
示例12: getShrinkwrapDomain
import org.jboss.shrinkwrap.api.Domain; //导入依赖的package包/类
/**
* @return the shrinkwrapDomain
*/
protected final Domain getShrinkwrapDomain() {
return shrinkwrapDomain;
}