gpt4 book ai didi

org.overlord.sramp.atom.archive.expand.ZipToSrampArchive类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 07:55:31 28 4
gpt4 key购买 nike

本文整理了Java中org.overlord.sramp.atom.archive.expand.ZipToSrampArchive类的一些代码示例,展示了ZipToSrampArchive类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipToSrampArchive类的具体详情如下:
包路径:org.overlord.sramp.atom.archive.expand.ZipToSrampArchive
类名称:ZipToSrampArchive

ZipToSrampArchive介绍

[英]Class that converts a JAR into an S-RAMP archive. This class performs the following tasks:

  • Crack open the JAR (or EAR, WAR, etc)
  • Locate and index all S-RAMP artifacts
  • Generate meta-data for all located artifacts
  • Discover and record relationships between artifacts
  • Create a new S-RAMP archive that includes the located artifacts
    [中]类,该类将JAR转换为S-RAMP存档。该类执行以下任务:
    *打开罐子(或耳朵、战争等)
    *定位并索引所有S-RAMP瑕疵
    *为所有定位的工件生成元数据
    *发现并记录工件之间的关系
    *创建一个新的S-RAMP归档,其中包括定位的工件

代码示例

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

/**
 * @param j2sramp
 */
public static void closeQuietly(ZipToSrampArchive j2sramp) {
  try {
    if (j2sramp != null)
      j2sramp.close();
  } catch (IOException e) {
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

/**
 * Constructor from JAR input stream.  Note, this will consume and close the given {@link InputStream}.
 * @param jarStream
 * @throws ZipToSrampArchiveException
 */
public ZipToSrampArchive(InputStream jarStream) throws ZipToSrampArchiveException {
  this.originalJar = null;
  this.shouldDeleteOriginalJar = true;
  this.jarWorkDir = null;
  try {
    this.originalJar = File.createTempFile("j2sramp", ".jar"); //$NON-NLS-1$ //$NON-NLS-2$
    copyJarStream(jarStream, this.originalJar);
    jarWorkDir = createJarWorkDir();
    ArchiveUtils.unpackToWorkDir(this.originalJar, this.jarWorkDir);
    context = new ZipToSrampArchiveContext(this.jarWorkDir);
  } catch (IOException e) {
    if (this.jarWorkDir != null) {
      try { FileUtils.deleteDirectory(this.jarWorkDir); } catch (IOException e1) { }
    }
    if (this.originalJar != null && this.originalJar.exists()) {
      this.originalJar.delete();
    }
    throw new ZipToSrampArchiveException(e);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

} finally {
  FileUtils.deleteQuietly(tempFile);
  ZipToSrampArchive.closeQuietly(j2sramp);

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

/**
 * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#createSrampArchive()}.
 */
@Test
public void testCreateSrampArchive() throws Exception {
  InputStream resourceAsStream = ZipToSrampArchiveTest.class.getResourceAsStream("sample-webservice-0.0.1.jar"); //$NON-NLS-1$
  ZipToSrampArchive j2sramp = null;
  SrampArchive archive = null;
  try {
    j2sramp = new ZipToSrampArchive(resourceAsStream){};
    archive = j2sramp.createSrampArchive();
    Assert.assertNotNull(archive);
    Collection<SrampArchiveEntry> entries = archive.getEntries();
    Assert.assertEquals(2, entries.size());
    Set<String> paths = new HashSet<String>();
    for (SrampArchiveEntry entry : entries) {
      paths.add(entry.getPath());
    }
    Assert.assertEquals(2, entries.size());
    Assert.assertTrue(paths.contains("schema/teetime.xsd")); //$NON-NLS-1$
    Assert.assertTrue(paths.contains("wsdl/teetime.wsdl")); //$NON-NLS-1$
  } finally {
    ZipToSrampArchive.closeQuietly(j2sramp);
    SrampArchive.closeQuietly(archive);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

j2sramp.setArtifactFilter(new ArtifactFilter() {
    @Override
    public void setContext(ZipToSrampArchiveContext context) {
  archive = j2sramp.createSrampArchive();
  Assert.assertNotNull(archive);
  Collection<SrampArchiveEntry> entries = archive.getEntries();
  Assert.assertTrue(paths.contains("META-INF/maven/com.redhat.ewittman/sample-web-service/pom.properties")); //$NON-NLS-1$
} finally {
  ZipToSrampArchive.closeQuietly(j2sramp);
  SrampArchive.closeQuietly(archive);

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

j2sramp.setMetaDataFactory(new MetaDataFactory() {
    @Override
    public void setContext(ZipToSrampArchiveContext context) {
  archive = j2sramp.createSrampArchive();
  Assert.assertNotNull(archive);
  SrampArchiveEntry entry = archive.getEntry("schema/teetime.xsd"); //$NON-NLS-1$
  Assert.assertNotNull(md.getUuid());
} finally {
  ZipToSrampArchive.closeQuietly(j2sramp);
  SrampArchive.closeQuietly(archive);

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

/**
 * Creates an S-RAMP archive from this JAR.
 * @return an S-RAMP archive
 * @throws ZipToSrampArchiveException
 */
public SrampArchive createSrampArchive() throws ZipToSrampArchiveException {
  this.artifactFilter.setContext(this.context);
  this.metaDataFactory.setContext(this.context);
  DiscoveredArtifacts discoveredArtifacts = discoverArtifacts();
  discoveredArtifacts.index(jarWorkDir);
  generateMetaData(discoveredArtifacts);
  try {
    SrampArchive archive = new SrampArchive();
    for (DiscoveredArtifact artifact : discoveredArtifacts) {
      String path = artifact.getArchivePath();
      archive.addEntry(path, artifact.getMetaData(), artifact.getContent());
    }
    return archive;
  } catch (Exception e) {
    throw new ZipToSrampArchiveException(e);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

/**
 * Constructor.
 * @param jar
 * @throws ZipToSrampArchiveException
 */
public ZipToSrampArchive(File jar) throws ZipToSrampArchiveException {
  this.originalJar = jar;
  this.shouldDeleteOriginalJar = false;
  this.jarWorkDir = null;
  try {
    jarWorkDir = createJarWorkDir();
    ArchiveUtils.unpackToWorkDir(this.originalJar, this.jarWorkDir);
    context = new ZipToSrampArchiveContext(this.jarWorkDir);
  } catch (IOException e) {
    if (this.jarWorkDir != null) {
      try { FileUtils.deleteDirectory(this.jarWorkDir); } catch (IOException e1) { }
    }
    throw new ZipToSrampArchiveException(e);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-integration-kie

@Test
public void testKieIntegration() throws Exception {
  InputStream stream = getClass().getResourceAsStream("kie.jar"); //$NON-NLS-1$
  SrampArchive archive = null;
  KieJarToSrampArchive kie2archive = null;
  try {
    kie2archive = new KieJarToSrampArchive(stream);
    archive = kie2archive.createSrampArchive();
    Assert.assertNotNull(archive);
    doAllAssertions(archive);
  } finally {
    IOUtils.closeQuietly(stream);
    SrampArchive.closeQuietly(archive);
    ZipToSrampArchive.closeQuietly(kie2archive);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

/**
 * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#createSrampArchive()}.
 */
@Test
public void testMetaData() throws Exception {
  InputStream resourceAsStream = ZipToSrampArchiveTest.class.getResourceAsStream("sample-webservice-0.0.1.jar"); //$NON-NLS-1$
  ZipToSrampArchive j2sramp = null;
  SrampArchive archive = null;
  try {
    j2sramp = new ZipToSrampArchive(resourceAsStream){};
    archive = j2sramp.createSrampArchive();
    Assert.assertNotNull(archive);
    SrampArchiveEntry entry = archive.getEntry("schema/teetime.xsd"); //$NON-NLS-1$
    Assert.assertNotNull(entry);
    BaseArtifactType metaData = entry.getMetaData();
    Assert.assertNotNull(metaData);
    Assert.assertTrue(metaData instanceof XsdDocument);
    XsdDocument md = (XsdDocument) metaData;
    Assert.assertEquals("teetime.xsd", md.getName()); //$NON-NLS-1$
    Assert.assertNotNull(md.getUuid());
  } finally {
    ZipToSrampArchive.closeQuietly(j2sramp);
    SrampArchive.closeQuietly(archive);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-integration-switchyard

@Test
public void testSwitchYardIntegration() throws Exception {
  InputStream stream = getClass().getResourceAsStream("switchyard-quickstart-bean-service.jar"); //$NON-NLS-1$
  SrampArchive archive = null;
  SwitchYardAppToSrampArchive sy2archive = null;
  try {
    sy2archive = new SwitchYardAppToSrampArchive(stream);
    archive = sy2archive.createSrampArchive();
    Assert.assertNotNull(archive);
    doAllAssertions(archive);
  } finally {
    IOUtils.closeQuietly(stream);
    SrampArchive.closeQuietly(archive);
    ZipToSrampArchive.closeQuietly(sy2archive);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-atom

/**
 * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#JarToSrampArchive(java.io.InputStream)}.
 */
@Test
public void testJarToSrampArchiveInputStream() throws Exception {
  InputStream resourceAsStream = ZipToSrampArchiveTest.class.getResourceAsStream("sample-webservice-0.0.1.jar"); //$NON-NLS-1$
  ZipToSrampArchive j2sramp = null;
  try {
    j2sramp = new ZipToSrampArchive(resourceAsStream){};
    File jarWorkDir = getJarWorkDir(j2sramp);
    Assert.assertNotNull(jarWorkDir);
    Assert.assertTrue(jarWorkDir.isDirectory());
    Collection<File> files = FileUtils.listFiles(jarWorkDir, new String[] {"xsd", "wsdl"}, true); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals(2, files.size());
    Set<String> fnames = new HashSet<String>();
    for (File f : files) {
      fnames.add(f.getName());
    }
    Assert.assertTrue(fnames.contains("teetime.xsd")); //$NON-NLS-1$
    Assert.assertTrue(fnames.contains("teetime.wsdl")); //$NON-NLS-1$
  } finally {
    if (j2sramp != null)
      j2sramp.close();
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-client

} finally {
  IOUtils.closeQuietly(artifactsIS);
  ZipToSrampArchive.closeQuietly(sy2archive);
  SrampArchive.closeQuietly(archive);
} finally {
  IOUtils.closeQuietly(artifactsIS);
  ZipToSrampArchive.closeQuietly(sy2archive);
  SrampArchive.closeQuietly(archive);
} finally {
  IOUtils.closeQuietly(artifactsIS);
  ZipToSrampArchive.closeQuietly(sy2archive);
  SrampArchive.closeQuietly(archive);

代码示例来源:origin: org.overlord.sramp/s-ramp-integration-teiid

@Test
public void shouldExpandProductsVdb() throws Exception {
  final InputStream stream = getResourceAsStream("ProductsSS_VDB.vdb");
  VdbToSrampArchive vdbArchive = null;
  SrampArchive srampArchive = null;
  try {
    vdbArchive = new VdbToSrampArchive(stream);
    srampArchive = vdbArchive.createSrampArchive();
    assertThat(srampArchive, is(not(nullValue())));
    assertThat(srampArchive.getEntries().size(), is(2)); // manifest + 1 xmi models
    // check the manifest
    assertManifest(srampArchive);
    // check the model
    assertModel(srampArchive, "TestProducts/ProductsSS.xmi");
  } finally {
    IOUtils.closeQuietly(stream);
    SrampArchive.closeQuietly(srampArchive);
    ZipToSrampArchive.closeQuietly(vdbArchive);
  }
}

代码示例来源:origin: org.overlord.sramp/s-ramp-integration-teiid

@Test
public void shouldExpandBooksVdb() throws Exception {
  final InputStream stream = getResourceAsStream("BooksVdb.vdb");
  VdbToSrampArchive vdbArchive = null;
  SrampArchive srampArchive = null;
  try {
    vdbArchive = new VdbToSrampArchive(stream);
    srampArchive = vdbArchive.createSrampArchive();
    assertThat(srampArchive, is(not(nullValue())));
    assertThat(srampArchive.getEntries().size(), is(7)); // manifest + 6 xmi models
    // check the manifest
    assertManifest(srampArchive);
    // check the models
    assertModel(srampArchive, "BooksProject/Books_Oracle.xmi");
    assertModel(srampArchive, "BooksProject/BooksView_Output_View.xmi");
    assertModel(srampArchive, "BooksProject/BooksView_WS.xmi");
    assertModel(srampArchive, "BooksProject/BooksView.xmi");
    // check other files
    assertXsd(srampArchive, "BooksProject/BooksView_Input.xsd");
    assertXsd(srampArchive, "BooksProject/BooksView_Output.xsd");
  } finally {
    IOUtils.closeQuietly(stream);
    SrampArchive.closeQuietly(srampArchive);
    ZipToSrampArchive.closeQuietly(vdbArchive);
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com