public static String buildSafeClassName(String className, XMLContext.Default defaults) { return buildSafeClassName( className, defaults.getPackageName() ); }
JPAMetadataProvider(ClassLoaderAccess classLoaderAccess, boolean xmlMetadataEnabled) { this.classLoaderAccess = classLoaderAccess; this.xmlContext = new XMLContext( classLoaderAccess ); this.xmlMappingEnabled = xmlMetadataEnabled; }
private AttributeOverrides getMapKeyAttributeOverrides(Element tree, XMLContext.Default defaults) { List<AttributeOverride> attributes = buildAttributeOverrides( tree, "map-key-attribute-override" ); return mergeAttributeOverrides( defaults, attributes, false ); }
private boolean isProcessingId(XMLContext.Default defaults) { boolean isExplicit = defaults.getAccess() != null; boolean correctAccess = ( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) ) || ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD .equals( defaults.getAccess() ) ); boolean hasId = defaults.canUseJavaAnnotations() && ( isPhysicalAnnotationPresent( Id.class ) || isPhysicalAnnotationPresent( EmbeddedId.class ) ); //if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) { boolean mirrorAttributeIsId = defaults.canUseJavaAnnotations() && ( mirroredAttribute != null && ( mirroredAttribute.isAnnotationPresent( Id.class ) || mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) ); boolean propertyIsDefault = PropertyType.PROPERTY.equals( propertyType ) && !mirrorAttributeIsId; return correctAccess || ( !isExplicit && hasId ) || ( !isExplicit && propertyIsDefault ); }
private SequenceGenerator getSequenceGenerator(Element tree, XMLContext.Default defaults) { Element element = tree != null ? tree.element( annotationToXml.get( SequenceGenerator.class ) ) : null; if ( element != null ) { return buildSequenceGeneratorAnnotation( element ); } else if ( defaults.canUseJavaAnnotations() ) { return getPhysicalAnnotation( SequenceGenerator.class ); } else { return null; } }
protected XMLContext getContext(InputStream is) throws Exception { XMLContext xmlContext = new XMLContext( BootstrapContextImpl.INSTANCE ); Document doc = new SAXReader().read( is ); xmlContext.addDocument( doc ); return xmlContext; } }
@Override public AnnotationReader getAnnotationReader(AnnotatedElement annotatedElement) { AnnotationReader reader = cache.get( annotatedElement ); if (reader == null) { if ( xmlContext.hasContext() ) { reader = new JPAOverriddenAnnotationReader( annotatedElement, xmlContext, classLoaderAccess ); } else { reader = delegate.getAnnotationReader( annotatedElement ); } cache.put(annotatedElement, reader); } return reader; }
private void setAccess(Element unitElement, Default defaultType) { if ( unitElement != null ) { String access = unitElement.getTextTrim(); setAccess( access, defaultType ); } }
private void getJoinTable(List<Annotation> annotationList, Element tree, XMLContext.Default defaults) { addIfNotNull( annotationList, buildJoinTable( tree, defaults ) ); }
/** * Copy a string attribute from an XML element to an annotation descriptor. The name of the annotation attribute is * computed from the name of the XML attribute by {@link #getJavaAttributeNameFromXMLOne(String)}. * * @param annotation annotation descriptor where to copy to the attribute. * @param element XML element from where to copy the attribute. * @param attributeName name of the XML attribute to copy. * @param mandatory whether the attribute is mandatory. */ private static void copyStringAttribute( final AnnotationDescriptor annotation, final Element element, final String attributeName, final boolean mandatory) { copyStringAttribute( annotation, element, getJavaAttributeNameFromXMLOne( attributeName ), attributeName, mandatory ); }
public Annotation[] getAnnotations() { initAnnotations(); return annotations; }
protected JPAOverriddenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName) throws Exception { AnnotatedElement el = getAnnotatedElement( entityClass, fieldName ); XMLContext xmlContext = getContext( ormResourceName ); return new JPAOverriddenAnnotationReader( el, xmlContext, BootstrapContextImpl.INSTANCE ); }
private ExcludeSuperclassListeners getExcludeSuperclassListeners(Element tree, XMLContext.Default defaults) { return (ExcludeSuperclassListeners) getMarkerAnnotation( ExcludeSuperclassListeners.class, tree, defaults ); }
private List<AttributeOverride> buildAttributeOverrides(Element element, String nodeName) { List<Element> subelements = element == null ? null : element.elements( nodeName ); return buildAttributeOverrides( subelements, nodeName ); }
public void applyDiscoveredAttributeConverters(AttributeConverterDefinitionCollector collector) { for ( AttributeConverterInfo info : attributeConverterInfoList ) { collector.addAttributeConverter( info ); } attributeConverterInfoList.clear(); }
/** * @param mergeWithAnnotations Whether to use Java annotations for this * element, if present and not disabled by the XMLContext defaults. * In some contexts (such as an association mapping) merging with * annotations is never allowed. */ private AttributeOverrides getAttributeOverrides(Element tree, XMLContext.Default defaults, boolean mergeWithAnnotations) { List<AttributeOverride> attributes = buildAttributeOverrides( tree, "attribute-override" ); return mergeAttributeOverrides( defaults, attributes, mergeWithAnnotations ); }
public <T extends Annotation> T getAnnotation(Class<T> annotationType) { initAnnotations(); return (T) annotationsMap.get( annotationType ); }
private ExcludeDefaultListeners getExcludeDefaultListeners(Element tree, XMLContext.Default defaults) { return (ExcludeDefaultListeners) getMarkerAnnotation( ExcludeDefaultListeners.class, tree, defaults ); }
public <T extends Annotation> boolean isAnnotationPresent(Class<T> annotationType) { initAnnotations(); return annotationsMap.containsKey( annotationType ); }