Package org.hibernate.ejb.packaging

Examples of org.hibernate.ejb.packaging.JarVisitor$ClassFilter


    }
    catch (IOException ie) {
      //fail silently
      return;
    }
    JarVisitor visitor = JarVisitor.getVisitor( url, getFilters() );
    assertEquals( 0, visitor.getMatchingEntries()[0].size() );
    assertEquals( 0, visitor.getMatchingEntries()[1].size() );
    assertEquals( 0, visitor.getMatchingEntries()[2].size() );
  }
View Full Code Here


  public void testInputStreamZippedJar() throws Exception {
    String jarFileName = "file:./build/testresources/defaultpar.par";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    JarVisitor.Filter[] filters = getFilters();
    JarVisitor jarVisitor = new InputStreamZippedJarVisitor( new URL( jarFileName ), filters );
    assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    JarVisitor.Entry entry = new JarVisitor.Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new JarVisitor.Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( (JarVisitor.Entry) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for (JarVisitor.Entry localEntry : (Set<JarVisitor.Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }

//    Set<String> classes = jarVisitor.getClassNames();
View Full Code Here

  public void testZippedJar() throws Exception {
    String jarFileName = "file:./build/testresources/defaultpar.par";
    //JarVisitor jarVisitor = new ZippedJarVisitor( jarFileName, true, true );
    JarVisitor.Filter[] filters = getFilters();
    JarVisitor jarVisitor = new FileZippedJarVisitor( new URL( jarFileName ), filters );
    assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    JarVisitor.Entry entry = new JarVisitor.Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new JarVisitor.Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( (JarVisitor.Entry) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for (JarVisitor.Entry localEntry : (Set<JarVisitor.Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
//    Set<String> classes = jarVisitor.getClassNames();
//    assertEquals( 3, classes.size() );
View Full Code Here

  public void testExplodedJar() throws Exception {
    String jarFileName = "./build/testresources/explodedpar.par";
    //JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, true, true );
    JarVisitor.Filter[] filters = getFilters();
    JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, filters );
    assertEquals( "explodedpar", jarVisitor.getUnqualifiedJarName() );
    Set[] entries = jarVisitor.getMatchingEntries();
    assertEquals( 1, entries[1].size() );
    assertEquals( 1, entries[0].size() );
    assertEquals( 1, entries[2].size() );

    JarVisitor.Entry entry = new JarVisitor.Entry( Carpet.class.getName(), null );
    assertTrue( entries[1].contains( entry ) );
    for (JarVisitor.Entry localEntry : (Set<JarVisitor.Entry>) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
//    Set<String> classes = jarVisitor.getClassNames();
//    assertEquals( 2, classes.size() );
View Full Code Here

    }
    filters = getFilters();
    for ( JarVisitor.Filter filter : filters ) {
      dupeFilters[index++] = filter;
    }
    JarVisitor jarVisitor = new ExplodedJarVisitor( jarFileName, dupeFilters );
    assertEquals( "explodedpar", jarVisitor.getUnqualifiedJarName() );
    Set[] entries = jarVisitor.getMatchingEntries();
    assertEquals( 1, entries[1].size() );
    assertEquals( 1, entries[0].size() );
    assertEquals( 1, entries[2].size() );
    for ( JarVisitor.Entry entry : (Set<JarVisitor.Entry>) entries[2] ) {
      InputStream is = entry.getInputStream();
View Full Code Here

              metadata.getProvider()
          ) ) {
            //correct provider
            URL jarURL = JarVisitor.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
            JarVisitor.Filter[] persistenceXmlFilter = getFilters( metadata, integration, metadata.getExcludeUnlistedClasses() );
            JarVisitor visitor = JarVisitor.getVisitor( jarURL, persistenceXmlFilter );
            if ( metadata.getName() == null ) {
              metadata.setName( visitor.getUnqualifiedJarName() );
            }
            if ( persistenceUnitName == null && xmls.hasMoreElements() ) {
              throw new PersistenceException( "No name provided and several persistence units found" );
            }
            else if ( persistenceUnitName == null || metadata.getName().equals( persistenceUnitName ) ) {
View Full Code Here

              metadata.getProvider()
          ) ) {
            //correct provider

            //lazy compute the visitor if possible to avoid useless exceptions if an unexpected state happens
            JarVisitor visitor = null;

            if ( metadata.getName() == null ) {
              visitor = getMainJarVisitor( url, metadata, integration );
              metadata.setName( visitor.getUnqualifiedJarName() );
            }
            if ( persistenceUnitName == null && xmls.hasMoreElements() ) {
              throw new PersistenceException( "No name provided and several persistence units found" );
            }
            else if ( persistenceUnitName == null || metadata.getName().equals( persistenceUnitName ) ) {
View Full Code Here

    if (jar == null) {
      log.error( "Container is providing a null PersistenceUnitRootUrl: discovery impossible");
      return;
    }
    try {
      JarVisitor visitor = JarVisitorFactory.getVisitor( jar, getFilters( detectedArtifacts, searchORM, null ) );
      addScannedEntries( visitor, entities, packages, hbmFiles, null );
    }
    catch (RuntimeException e) {
      throw new RuntimeException( "error trying to scan <jar-file>: " + jar.toString(), e );
    }
View Full Code Here

    }
    catch ( IOException ie ) {
      //fail silently
      return;
    }
    JarVisitor visitor = JarVisitorFactory.getVisitor( url, getFilters() );
    assertEquals( 0, visitor.getMatchingEntries()[0].size() );
    assertEquals( 0, visitor.getMatchingEntries()[1].size() );
    assertEquals( 0, visitor.getMatchingEntries()[2].size() );
  }
View Full Code Here

  public void testInputStreamZippedJar() throws Exception {
    File defaultPar = buildDefaultPar();
    addPackageToClasspath( defaultPar );

    Filter[] filters = getFilters();
    JarVisitor jarVisitor = new InputStreamZippedJarVisitor( defaultPar.toURL(), filters, "" );
    assertEquals( "defaultpar", jarVisitor.getUnqualifiedJarName() );
    Set entries = jarVisitor.getMatchingEntries()[1];
    assertEquals( 3, entries.size() );
    Entry entry = new Entry( ApplicationServer.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    entry = new Entry( org.hibernate.ejb.test.pack.defaultpar.Version.class.getName(), null );
    assertTrue( entries.contains( entry ) );
    assertNull( ( ( Entry ) entries.iterator().next() ).getInputStream() );
    assertEquals( 2, jarVisitor.getMatchingEntries()[2].size() );
    for ( Entry localEntry : ( Set<Entry> ) jarVisitor.getMatchingEntries()[2] ) {
      assertNotNull( localEntry.getInputStream() );
      localEntry.getInputStream().close();
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.ejb.packaging.JarVisitor$ClassFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.