code: public synchronized Morphia mapPackage(final String packageName, final boolean ignoreInvalidClasses) {
          try {
              for (final Class clazz : ReflectionUtils.getClasses(getClass().getClassLoader(), packageName,
                  mapper.getOptions().isMapSubPackages())) {
                  try {
                      final Embedded embeddedAnn = ReflectionUtils.getClassEmbeddedAnnotation(clazz);
                      final Entity entityAnn = ReflectionUtils.getClassEntityAnnotation(clazz);
                      final boolean isAbstract = Modifier.isAbstract(clazz.getModifiers());
                      if ((entityAnn != null || embeddedAnn != null) && !isAbstract) {
                          map(clazz);
                      }
                  } catch (final MappingException ex) {
                      if (!ignoreInvalidClasses) {
                          throw ex;
                      }
                  }
              }
              return this;
          } catch (IOException e) {
              throw new MappingException("Could not get map classes from package " + packageName, e);
          } catch (ClassNotFoundException e) {
              throw new MappingException("Could not get map classes from package " + packageName, e);
          }
      }
docs: Tries to map all classes in the package specified.
  
  @param packageName          the name of the package to process
  @param ignoreInvalidClasses specifies whether to ignore classes in the package that cannot be mapped
  @return the Morphia instance