コード例 #1
0
  /** Load the given class name with the given class loader. */
  public static Class loadClass(
      String className,
      ClassLoader loader,
      boolean throwExceptionIfNotFound,
      MetadataProject project) {
    Class candidateClass = null;

    try {
      candidateClass = loader.loadClass(className);
    } catch (ClassNotFoundException exc) {
      if (throwExceptionIfNotFound) {
        throw PersistenceUnitLoadingException.exceptionLoadingClassWhileLookingForAnnotations(
            className, exc);
      } else {
        AbstractSessionLog.getLog()
            .log(
                AbstractSessionLog.WARNING,
                "persistence_unit_processor_error_loading_class",
                exc.getClass().getName(),
                exc.getLocalizedMessage(),
                className);
      }
    } catch (NullPointerException npe) {
      // Bug 227630: If any weavable class is not found in the temporary
      // classLoader - disable weaving
      AbstractSessionLog.getLog()
          .log(
              AbstractSessionLog.WARNING,
              AbstractSessionLog.WEAVER,
              "persistence_unit_processor_error_loading_class_weaving_disabled",
              loader,
              project.getPersistenceUnitInfo().getPersistenceUnitName(),
              className);
      // Disable weaving (for 1->1 and many->1)only if the classLoader
      // returns a NPE on loadClass()
      project.disableWeaving();
    } catch (Exception exception) {
      AbstractSessionLog.getLog()
          .log(
              AbstractSessionLog.WARNING,
              AbstractSessionLog.WEAVER,
              "persistence_unit_processor_error_loading_class",
              exception.getClass().getName(),
              exception.getLocalizedMessage(),
              className);
    } catch (Error error) {
      AbstractSessionLog.getLog()
          .log(
              AbstractSessionLog.WARNING,
              AbstractSessionLog.WEAVER,
              "persistence_unit_processor_error_loading_class",
              error.getClass().getName(),
              error.getLocalizedMessage(),
              className);
      throw error;
    }

    return candidateClass;
  }
コード例 #2
0
  /**
   * INTERNAL: Process a the XML defined type converters and check for a TypeConverter annotation.
   */
  protected void processTypeConverters() {
    // Check for XML defined type converters.
    for (TypeConverterMetadata typeConverter : m_typeConverters) {
      m_project.addConverter(typeConverter);
    }

    // Check for an TypeConverter annotation.
    MetadataAnnotation typeConverter = getAnnotation(TypeConverter.class);
    if (typeConverter != null) {
      m_project.addConverter(new TypeConverterMetadata(typeConverter, getAccessibleObject()));
    }
  }
コード例 #3
0
  /**
   * INTERNAL: Process the XML defined struct converters and check for a StructConverter annotation.
   */
  protected void processStructConverter() {
    // Check for XML defined struct converters.
    for (StructConverterMetadata structConverter : m_structConverters) {
      m_project.addConverter(structConverter);
    }

    // Check for a StructConverter annotation.
    MetadataAnnotation converter = getAnnotation(StructConverter.class);
    if (converter != null) {
      m_project.addConverter(new StructConverterMetadata(converter, getAccessibleObject()));
    }
  }
コード例 #4
0
  /** INTERNAL: Process the XML defined converters and check for a Converter annotation. */
  protected void processCustomConverters() {
    // Check for XML defined converters.
    for (ConverterMetadata converter : m_converters) {
      m_project.addConverter(converter);
    }

    // Check for a Converter annotation.
    MetadataAnnotation converter = getAnnotation(Converter.class);
    if (converter != null) {
      m_project.addConverter(new ConverterMetadata(converter, getAccessibleObject()));
    }
  }
コード例 #5
0
  /**
   * INTERNAL: Process the XML defined object type converters and check for an ObjectTypeConverter
   * annotation.
   */
  protected void processObjectTypeConverters() {
    // Check for XML defined object type converters.
    for (ObjectTypeConverterMetadata objectTypeConverter : m_objectTypeConverters) {
      m_project.addConverter(objectTypeConverter);
    }

    // Check for an ObjectTypeConverter annotation.
    MetadataAnnotation objectTypeConverter = getAnnotation(ObjectTypeConverter.class);
    if (objectTypeConverter != null) {
      m_project.addConverter(
          new ObjectTypeConverterMetadata(objectTypeConverter, getAccessibleObject()));
    }
  }
コード例 #6
0
 /** INTERNAL: */
 protected boolean useDelimitedIdentifier() {
   return m_project.useDelimitedIdentifier();
 }
コード例 #7
0
 /** INTERNAL: Return the upper cased attribute name for this accessor. Used when defaulting. */
 protected String getDefaultAttributeName() {
   return (m_project.useDelimitedIdentifier())
       ? getAttributeName()
       : getAttributeName().toUpperCase();
 }
コード例 #8
0
 /** INTERNAL: Return the metadata logger. */
 public MetadataLogger getLogger() {
   return m_project.getLogger();
 }