/** * Get the names of the properties that are supported for use with the * entity manager. These correspond to properties and hints that may be * passed to the methods of the EntityManager interface that take a * properties argument or used with the PersistenceContext annotation. These * properties include all standard entity manager hints and properties as * well as vendor-specific ones supported by the provider. These properties * may or may not currently be in effect. * * @return property names * * @since Java Persistence API 2.0 */ public Set<String> getSupportedProperties() { return EntityManagerProperties.getSupportedProperties(); }
/** * PUBLIC: * Return default value for whether descriptor should use isolated cache. * @deprecated see getDefaultCacheIsolation() */ @Deprecated public boolean getDefaultIsIsolated() { return this.defaultCacheIsolation.equals(CacheIsolationType.ISOLATED); }
private static void processKeyValue(Object instance, String propertyName, String kv) { String[] t = kv.split("="); if (t.length != 2) { // We must have a single key and a single value. throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } String methodName = "set" + t[0].trim(); // Stringified value to be set. Need to figure out it's type String value = t[1].trim(); List<Method> methods = getMethodsMatchingName(instance, methodName); MethodMatch match = null; try { match = getMethodMatchingParameter(methods, value); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } if (match != null) { Method method = match.getMethod(); Object parsedValue = match.getParsedValue(); try { invokeMethod(method, instance, parsedValue); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } } else { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } }
protected void processSessionCustomizer(Map m, ClassLoader loader) { String sessionCustomizerClassName = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.SESSION_CUSTOMIZER, m, session); if (sessionCustomizerClassName == null) { return; } Class sessionCustomizerClass = findClassForProperty(sessionCustomizerClassName, PersistenceUnitProperties.SESSION_CUSTOMIZER, loader); SessionCustomizer sessionCustomizer; try { sessionCustomizer = (SessionCustomizer)sessionCustomizerClass.newInstance(); sessionCustomizer.customize(session); } catch (Exception ex) { throw EntityManagerSetupException.failedWhileProcessingProperty(PersistenceUnitProperties.SESSION_CUSTOMIZER, sessionCustomizerClassName, ex); } }
protected static Object getConfigPropertyLogDebug(String propertyKey, Map overrides, AbstractSession session, boolean useSystemAsDefault){ Object value = null; if (overrides != null){ value = overrides.get(propertyKey); } if ((value == null) && useSystemAsDefault){ if (System.getSecurityManager() != null) { value = (String) AccessController.doPrivileged(new PrivilegedGetSystemProperty(propertyKey)); } else { value = System.getProperty(propertyKey); } } if ((value != null) && (session != null)) { if (session.shouldLog(SessionLog.FINEST, SessionLog.PROPERTIES)) { String overrideValue = PersistenceUnitProperties.getOverriddenLogStringForProperty(propertyKey);; Object logValue = (overrideValue == null) ? value : overrideValue; session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_specified", new Object[]{propertyKey, logValue}); } } return value; }
/** * Attempts to parse and then set the provided kvs String into the * appropriate set method on the provided instance. * * Note: Keys and values cannot contain '=' or ',' * * @param instance * An JavaBean instance * @param propertyName * The configuration name that is being set into instance. This * is only used for informational purposes. * @param kvs * A String of key=value comma delimited ie: k1=v1,k2=v2,... * @throws org.eclipse.persistence.exceptions.ConversionException * if unable to process the provided kvs */ public static void set(Object instance, String propertyName, String kvs) { if (instance == null || kvs == null || kvs.trim().isEmpty()) { return; } String[] keyValues = kvs.split(","); for (String kv : keyValues) { processKeyValue(instance, propertyName, kv); } }
private static List<Method> getMethodsMatchingName(Object instance, String methodName) { List<Method> methods = new ArrayList<>(); for (Method method : getMethods(instance.getClass())) { if (method.getName().equalsIgnoreCase(methodName)) { methods.add(method); } } return methods; }
/** * INTERNAL: * Process the customizer for those entities and embeddables that have one * defined. This must be the last thing called on this processor before * cleanup. */ public void processCustomizers() { for (ClassAccessor classAccessor: m_project.getAccessorsWithCustomizer()) { DescriptorCustomizer customizer = (DescriptorCustomizer) MetadataHelper.getClassInstance(classAccessor.getCustomizerClass().getName(), m_loader); try { customizer.customize(classAccessor.getDescriptor().getClassDescriptor()); } catch (Exception e) { getSessionLog().logThrowable(SessionLog.FINER, SessionLog.METADATA, e); } } }
private static void processKeyValue(Object instance, String propertyName, String kv) { String[] t = kv.split("="); if (t.length != 2) { // We must have a single key and a single value. throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } String methodName = "set" + t[0].trim(); // Stringified value to be set. Need to figure out it's type String value = t[1].trim(); List<Method> methods = getMethodsMatchingName(instance, methodName); MethodMatch match = null; try { match = getMethodMatchingParameter(methods, value); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } if (match != null) { Method method = match.getMethod(); Object parsedValue = match.getParsedValue(); try { invokeMethod(method, instance, parsedValue); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } } else { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } }
/** * INTERNAL: * Process the user inputed session customizer class. Will be run at the * end of the session build process */ protected void processSessionCustomizer(SessionConfig sessionConfig, AbstractSession session) { // Session customizer - MUST BE THE LAST THING TO PROCESS String sessionCustomizerClassName = sessionConfig.getSessionCustomizerClass(); if (sessionCustomizerClassName != null) { try { Class sessionCustomizerClass = m_classLoader.loadClass(sessionCustomizerClassName); if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ ((SessionCustomizer)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(sessionCustomizerClass))).customize(session); }else{ ((SessionCustomizer)PrivilegedAccessHelper.newInstanceFromClass(sessionCustomizerClass)).customize(session); } } catch (Exception exception) { throw SessionLoaderException.failedToLoadTag("session-customizer-class", sessionCustomizerClassName, exception); } } }
String logValue = PersistenceUnitProperties.getOverriddenLogStringForProperty(name); if (logValue != null){ log(session, logValue, logValue, suffix);
/** * PUBLIC: * Return default value for whether descriptor should use isolated cache. * @deprecated see getDefaultCacheIsolation() */ @Deprecated public boolean getDefaultIsIsolated() { return this.defaultCacheIsolation.equals(CacheIsolationType.ISOLATED); }
/** * Attempts to parse and then set the provided kvs String into the * appropriate set method on the provided instance. * * Note: Keys and values cannot contain '=' or ',' * * @param instance * An JavaBean instance * @param propertyName * The configuration name that is being set into instance. This * is only used for informational purposes. * @param kvs * A String of key=value comma delimited ie: k1=v1,k2=v2,... * @throws org.eclipse.persistence.exceptions.ConversionException * if unable to process the provided kvs */ public static void set(Object instance, String propertyName, String kvs) { if (instance == null || kvs == null || kvs.trim().isEmpty()) { return; } String[] keyValues = kvs.split(","); for (String kv : keyValues) { processKeyValue(instance, propertyName, kv); } }
private static List<Method> getMethodsMatchingName(Object instance, String methodName) { List<Method> methods = new ArrayList<>(); for (Method method : getMethods(instance.getClass())) { if (method.getName().equalsIgnoreCase(methodName)) { methods.add(method); } } return methods; }
/** * INTERNAL: * Process the user inputed session customizer class. Will be run at the * end of the session build process */ protected void processSessionCustomizer(SessionConfig sessionConfig, AbstractSession session) { // Session customizer - MUST BE THE LAST THING TO PROCESS String sessionCustomizerClassName = sessionConfig.getSessionCustomizerClass(); if (sessionCustomizerClassName != null) { try { Class sessionCustomizerClass = m_classLoader.loadClass(sessionCustomizerClassName); if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ ((SessionCustomizer)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(sessionCustomizerClass))).customize(session); }else{ ((SessionCustomizer)PrivilegedAccessHelper.newInstanceFromClass(sessionCustomizerClass)).customize(session); } } catch (Exception exception) { throw SessionLoaderException.failedToLoadTag("session-customizer-class", sessionCustomizerClassName, exception); } } }
String logValue = PersistenceUnitProperties.getOverriddenLogStringForProperty(name); if (logValue != null){ log(session, logValue, logValue, suffix);
/** * INTERNAL: * Process the user inputed session customizer class. Will be run at the * end of the session build process */ protected void processSessionCustomizer(SessionConfig sessionConfig, AbstractSession session) { // Session customizer - MUST BE THE LAST THING TO PROCESS String sessionCustomizerClassName = sessionConfig.getSessionCustomizerClass(); if (sessionCustomizerClassName != null) { try { Class sessionCustomizerClass = m_classLoader.loadClass(sessionCustomizerClassName); if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ ((SessionCustomizer)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(sessionCustomizerClass))).customize(session); }else{ ((SessionCustomizer)PrivilegedAccessHelper.newInstanceFromClass(sessionCustomizerClass)).customize(session); } } catch (Throwable exception) { throw SessionLoaderException.failedToLoadTag("session-customizer-class", sessionCustomizerClassName, exception); } } }
String logValue = PersistenceUnitProperties.getOverriddenLogStringForProperty(name); if (logValue != null){ log(session, logValue, logValue, suffix);