Package org.hibernate.ejb.packaging

Examples of org.hibernate.ejb.packaging.Scanner


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

            //lazy load the scanner to avoid unnecessary IOExceptions
            Scanner scanner = null;
            URL jarURL = null;
            if ( metadata.getName() == null ) {
              scanner = buildScanner( metadata.getProps(), integration );
              jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
              metadata.setName( scanner.getUnqualifiedJarName(jarURL) );
            }
            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


    List<String> mappingFiles = metadata.getMappingFiles();
    addScannedEntries( scanningContext, classes, packages, hbmFiles, mappingFiles );
  }

  private static void addScannedEntries(ScanningContext scanningContext, List<String> classes, List<String> packages, List<NamedInputStream> hbmFiles, List<String> mappingFiles) throws IOException {
    Scanner scanner = scanningContext.scanner;
    if (scanningContext.detectClasses) {
      Set<Class<? extends Annotation>> annotationsToExclude = new HashSet<Class<? extends Annotation>>(3);
      annotationsToExclude.add( Entity.class );
      annotationsToExclude.add( MappedSuperclass.class );
      annotationsToExclude.add( Embeddable.class );
      Set<Class<?>> matchingClasses = scanner.getClassesInJar( scanningContext.url, annotationsToExclude );
      for (Class<?> clazz : matchingClasses) {
        classes.add( clazz.getName() );
      }

      Set<Package> matchingPackages = scanner.getPackagesInJar( scanningContext.url, new HashSet<Class<? extends Annotation>>(0) );
      for (Package pkg : matchingPackages) {
        packages.add( pkg.getName() );
      }
    }
    Set<String> patterns = new HashSet<String>();
    if (scanningContext.searchOrm) {
      patterns.add( META_INF_ORM_XML );
    }
    if (scanningContext.detectHbmFiles) {
      patterns.add( "**/*.hbm.xml" );
    }
    if ( mappingFiles != null) patterns.addAll( mappingFiles );
    if (patterns.size() !=0) {
      Set<NamedInputStream> files = scanner.getFilesInJar( scanningContext.url, patterns );
      for (NamedInputStream file : files) {
        hbmFiles.add( file );
        if (mappingFiles != null) mappingFiles.remove( file.getName() );
      }
    }
View Full Code Here

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

            //lazy load the scanner to avoid unnecessary IOExceptions
            Scanner scanner = null;
            URL jarURL = null;
            if ( metadata.getName() == null ) {
              scanner = buildScanner();
              jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
              metadata.setName( scanner.getUnqualifiedJarName(jarURL) );
            }
            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

    List<String> mappingFiles = metadata.getMappingFiles();
    addScannedEntries( scanningContext, classes, packages, hbmFiles, mappingFiles );
  }

  private static void addScannedEntries(ScanningContext scanningContext, List<String> classes, List<String> packages, List<NamedInputStream> hbmFiles, List<String> mappingFiles) throws IOException {
    Scanner scanner = scanningContext.scanner;
    if (scanningContext.detectClasses) {
      Set<Class<? extends Annotation>> annotationsToExclude = new HashSet<Class<? extends Annotation>>(3);
      annotationsToExclude.add( Entity.class );
      annotationsToExclude.add( MappedSuperclass.class );
      annotationsToExclude.add( Embeddable.class );
      Set<Class<?>> matchingClasses = scanner.getClassesInJar( scanningContext.url, annotationsToExclude );
      for (Class<?> clazz : matchingClasses) {
        classes.add( clazz.getName() );
      }

      Set<Package> matchingPackages = scanner.getPackagesInJar( scanningContext.url, new HashSet<Class<? extends Annotation>>(0) );
      for (Package pkg : matchingPackages) {
        packages.add( pkg.getName() );
      }
    }
    Set<String> patterns = new HashSet<String>();
    if (scanningContext.searchOrm) {
      patterns.add( META_INF_ORM_XML );
    }
    if (scanningContext.detectHbmFiles) {
      patterns.add( "**/*.hbm.xml" );
    }
    if ( mappingFiles != null) patterns.addAll( mappingFiles );
    if (patterns.size() !=0) {
      Set<NamedInputStream> files = scanner.getFilesInJar( scanningContext.url, patterns );
      for (NamedInputStream file : files) {
        hbmFiles.add( file );
        if (mappingFiles != null) mappingFiles.remove( file.getName() );
      }
    }
View Full Code Here

public class ScannerTest extends PackagingTestCase {
  public void testNativeScanner() throws Exception {
    File defaultPar = buildDefaultPar();
    addPackageToClasspath( defaultPar );

    Scanner scanner = new NativeScanner();
    assertEquals( "defaultpar", scanner.getUnqualifiedJarName( defaultPar.toURL() ) );

    Set<Class<? extends Annotation>> annotationsToLookFor = new HashSet<Class<? extends Annotation>>( 3 );
    annotationsToLookFor.add( Entity.class );
    annotationsToLookFor.add( MappedSuperclass.class );
    annotationsToLookFor.add( Embeddable.class );
    final Set<Class<?>> classes = scanner.getClassesInJar( defaultPar.toURL(), annotationsToLookFor );

    assertEquals( 3, classes.size() );
    assertTrue( classes.contains( ApplicationServer.class ) );
    assertTrue( classes.contains( org.hibernate.ejb.test.pack.defaultpar.Version.class ) );

    Set<String> filePatterns = new HashSet<String>( 2 );
    filePatterns.add( "**/*.hbm.xml" );
    filePatterns.add( "META-INF/orm.xml" );
    final Set<NamedInputStream> files = scanner.getFilesInJar( defaultPar.toURL(), filePatterns );

    assertEquals( 2, files.size() );
    for ( NamedInputStream file : files ) {
      assertNotNull( file.getStream() );
      file.getStream().close();
View Full Code Here

          if ( metadata.getProvider() == null || IMPLEMENTATION_NAME.equalsIgnoreCase(
              metadata.getProvider()
          ) ) {
            //correct provider
            //lazy load the scanner to avoid unnecessary IOExceptions
            Scanner scanner = null;
            URL jarURL = null;
            if ( metadata.getName() == null ) {
              scanner = buildScanner( metadata.getProps(), integration );
              jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
              metadata.setName( scanner.getUnqualifiedJarName( jarURL ) );
            }
            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

    List<String> mappingFiles = metadata.getMappingFiles();
    addScannedEntries( scanningContext, classes, packages, hbmFiles, mappingFiles );
  }

  private static void addScannedEntries(ScanningContext scanningContext, List<String> classes, List<String> packages, List<NamedInputStream> hbmFiles, List<String> mappingFiles) throws IOException {
    Scanner scanner = scanningContext.scanner;
    if (scanningContext.detectClasses) {
      Set<Class<? extends Annotation>> annotationsToExclude = new HashSet<Class<? extends Annotation>>(3);
      annotationsToExclude.add( Entity.class );
      annotationsToExclude.add( MappedSuperclass.class );
      annotationsToExclude.add( Embeddable.class );
      Set<Class<?>> matchingClasses = scanner.getClassesInJar( scanningContext.url, annotationsToExclude );
      for (Class<?> clazz : matchingClasses) {
        classes.add( clazz.getName() );
      }

      Set<Package> matchingPackages = scanner.getPackagesInJar( scanningContext.url, new HashSet<Class<? extends Annotation>>(0) );
      for (Package pkg : matchingPackages) {
        packages.add( pkg.getName() );
      }
    }
    Set<String> patterns = new HashSet<String>();
    if (scanningContext.searchOrm) {
      patterns.add( META_INF_ORM_XML );
    }
    if (scanningContext.detectHbmFiles) {
      patterns.add( "**/*.hbm.xml" );
    }
    if ( mappingFiles != null) patterns.addAll( mappingFiles );
    if (patterns.size() !=0) {
      Set<NamedInputStream> files = scanner.getFilesInJar( scanningContext.url, patterns );
      for (NamedInputStream file : files) {
        hbmFiles.add( file );
        if (mappingFiles != null) mappingFiles.remove( file.getName() );
      }
    }
View Full Code Here

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

            //lazy load the scanner to avoid unnecessary IOExceptions
            Scanner scanner = null;
            URL jarURL = null;
            if ( metadata.getName() == null ) {
              scanner = buildScanner( metadata.getProps(), integration );
              jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
              metadata.setName( scanner.getUnqualifiedJarName(jarURL) );
            }
            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

    List<String> mappingFiles = metadata.getMappingFiles();
    addScannedEntries( scanningContext, classes, packages, hbmFiles, mappingFiles );
  }

  private static void addScannedEntries(ScanningContext scanningContext, List<String> classes, List<String> packages, List<NamedInputStream> hbmFiles, List<String> mappingFiles) throws IOException {
    Scanner scanner = scanningContext.scanner;
    if (scanningContext.detectClasses) {
      Set<Class<? extends Annotation>> annotationsToExclude = new HashSet<Class<? extends Annotation>>(3);
      annotationsToExclude.add( Entity.class );
      annotationsToExclude.add( MappedSuperclass.class );
      annotationsToExclude.add( Embeddable.class );
      Set<Class<?>> matchingClasses = scanner.getClassesInJar( scanningContext.url, annotationsToExclude );
      for (Class<?> clazz : matchingClasses) {
        classes.add( clazz.getName() );
      }

      Set<Package> matchingPackages = scanner.getPackagesInJar( scanningContext.url, new HashSet<Class<? extends Annotation>>(0) );
      for (Package pkg : matchingPackages) {
        packages.add( pkg.getName() );
      }
    }
    Set<String> patterns = new HashSet<String>();
    if (scanningContext.searchOrm) {
      patterns.add( META_INF_ORM_XML );
    }
    if (scanningContext.detectHbmFiles) {
      patterns.add( "**/*.hbm.xml" );
    }
    if ( mappingFiles != null) patterns.addAll( mappingFiles );
    if (patterns.size() !=0) {
      Set<NamedInputStream> files = scanner.getFilesInJar( scanningContext.url, patterns );
      for (NamedInputStream file : files) {
        hbmFiles.add( file );
        if (mappingFiles != null) mappingFiles.remove( file.getName() );
      }
    }
View Full Code Here

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

            //lazy load the scanner to avoid unnecessary IOExceptions
            Scanner scanner = null;
            URL jarURL = null;
            if ( metadata.getName() == null ) {
              scanner = buildScanner( metadata.getProps(), integration );
              jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
              metadata.setName( scanner.getUnqualifiedJarName(jarURL) );
            }
            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

TOP

Related Classes of org.hibernate.ejb.packaging.Scanner

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.