/** * INTERNAL: * Return all the classExtractionMethod */ protected Method getClassExtractionMethod() { if (classExtractor instanceof MethodClassExtractor) { return ((MethodClassExtractor)classExtractor).getClassExtractionMethod(); } else { return null; } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take a * Record as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used, then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be setup correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public String getClassExtractionMethodName() { if (classExtractor instanceof MethodClassExtractor) { return ((MethodClassExtractor)classExtractor).getClassExtractionMethodName(); } else { return null; } }
/** * INTERNAL: * Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid. */ public void initialize(ClassDescriptor descriptor, Session session) throws DescriptorException { setDescriptor(descriptor); Class[] declarationParameters = new Class[1]; declarationParameters[0] = ClassConstants.DatabaseRow_Class; try { setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters)); } catch (NoSuchMethodException ignore) { declarationParameters[0] = ClassConstants.Record_Class; try { setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters)); } catch (NoSuchMethodException exception) { throw DescriptorException.noSuchMethodWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } // CR#2818667 Ensure the method is static. if (!Modifier.isStatic(getClassExtractionMethod().getModifiers())) { throw DescriptorException.classExtractionMethodMustBeStatic(getClassExtractionMethodName(), descriptor); } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take Record * as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be set up correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public void setClassExtractionMethodName(String staticClassClassExtractionMethod) { if ((staticClassClassExtractionMethod == null) || (staticClassClassExtractionMethod.length() == 0)) { return; } if (!(getClassExtractor() instanceof MethodClassExtractor)) { setClassExtractor(new MethodClassExtractor()); } ((MethodClassExtractor)getClassExtractor()).setClassExtractionMethodName(staticClassClassExtractionMethod); }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { classForRow = (Class)AccessController.doPrivileged(new PrivilegedMethodInvoker(getClassExtractionMethod(), null, arguments)); } catch (PrivilegedActionException exception) { Exception throwableException = exception.getException(); if (throwableException instanceof IllegalAccessException) { throw DescriptorException.illegalAccessWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), throwableException); } else { throw DescriptorException.targetInvocationWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), throwableException); classForRow = (Class)PrivilegedAccessHelper.invokeMethod(getClassExtractionMethod(), null, arguments); throw DescriptorException.illegalAccessWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), exception); } catch (InvocationTargetException exception) { throw DescriptorException.targetInvocationWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), exception);
/** * INTERNAL: * Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid. */ public void initialize(ClassDescriptor descriptor, Session session) throws DescriptorException { setDescriptor(descriptor); Class[] declarationParameters = new Class[1]; declarationParameters[0] = ClassConstants.DatabaseRow_Class; try { setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters)); } catch (NoSuchMethodException ignore) { declarationParameters[0] = ClassConstants.Record_Class; try { setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters)); } catch (NoSuchMethodException exception) { throw DescriptorException.noSuchMethodWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } // CR#2818667 Ensure the method is static. if (!Modifier.isStatic(getClassExtractionMethod().getModifiers())) { throw DescriptorException.classExtractionMethodMustBeStatic(getClassExtractionMethodName(), descriptor); } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take Record * as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be set up correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public void setClassExtractionMethodName(String staticClassClassExtractionMethod) { if ((staticClassClassExtractionMethod == null) || (staticClassClassExtractionMethod.length() == 0)) { return; } if (!(getClassExtractor() instanceof MethodClassExtractor)) { setClassExtractor(new MethodClassExtractor()); } ((MethodClassExtractor)getClassExtractor()).setClassExtractionMethodName(staticClassClassExtractionMethod); }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { classForRow = (Class)AccessController.doPrivileged(new PrivilegedMethodInvoker(getClassExtractionMethod(), null, arguments)); } catch (PrivilegedActionException exception) { Exception throwableException = exception.getException(); if (throwableException instanceof IllegalAccessException) { throw DescriptorException.illegalAccessWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), throwableException); } else { throw DescriptorException.targetInvocationWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), throwableException); classForRow = (Class)PrivilegedAccessHelper.invokeMethod(getClassExtractionMethod(), null, arguments); throw DescriptorException.illegalAccessWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), exception); } catch (InvocationTargetException exception) { throw DescriptorException.targetInvocationWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), exception);
/** * INTERNAL: * Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid. */ public void initialize(ClassDescriptor descriptor, Session session) throws DescriptorException { setDescriptor(descriptor); Class[] declarationParameters = new Class[1]; declarationParameters[0] = ClassConstants.DatabaseRow_Class; try { setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters)); } catch (NoSuchMethodException ignore) { declarationParameters[0] = ClassConstants.Record_Class; try { setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters)); } catch (NoSuchMethodException exception) { throw DescriptorException.noSuchMethodWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception); } // CR#2818667 Ensure the method is static. if (!Modifier.isStatic(getClassExtractionMethod().getModifiers())) { throw DescriptorException.classExtractionMethodMustBeStatic(getClassExtractionMethodName(), descriptor); } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take Record * as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be set up correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public void setClassExtractionMethodName(String staticClassClassExtractionMethod) { if ((staticClassClassExtractionMethod == null) || (staticClassClassExtractionMethod.length() == 0)) { return; } if (!(getClassExtractor() instanceof MethodClassExtractor)) { setClassExtractor(new MethodClassExtractor()); } ((MethodClassExtractor)getClassExtractor()).setClassExtractionMethodName(staticClassClassExtractionMethod); }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { classForRow = (Class)AccessController.doPrivileged(new PrivilegedMethodInvoker(getClassExtractionMethod(), null, arguments)); } catch (PrivilegedActionException exception) { Exception throwableException = exception.getException(); if (throwableException instanceof IllegalAccessException) { throw DescriptorException.illegalAccessWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), throwableException); } else { throw DescriptorException.targetInvocationWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), throwableException); classForRow = (Class)PrivilegedAccessHelper.invokeMethod(getClassExtractionMethod(), null, arguments); throw DescriptorException.illegalAccessWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), exception); } catch (InvocationTargetException exception) { throw DescriptorException.targetInvocationWhileInvokingRowExtractionMethod((AbstractRecord)row, getClassExtractionMethod(), getDescriptor(), exception);
/** * INTERNAL: * Return all the classExtractionMethod */ protected Method getClassExtractionMethod() { if (classExtractor instanceof MethodClassExtractor) { return ((MethodClassExtractor)classExtractor).getClassExtractionMethod(); } else { return null; } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take a * Record as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used, then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be setup correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public String getClassExtractionMethodName() { if (classExtractor instanceof MethodClassExtractor) { return ((MethodClassExtractor)classExtractor).getClassExtractionMethodName(); } else { return null; } }
/** * INTERNAL: * Return all the classExtractionMethod */ protected Method getClassExtractionMethod() { if (classExtractor instanceof MethodClassExtractor) { return ((MethodClassExtractor)classExtractor).getClassExtractionMethod(); } else { return null; } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take a * Record as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used, then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be setup correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public String getClassExtractionMethodName() { if (classExtractor instanceof MethodClassExtractor) { return ((MethodClassExtractor)classExtractor).getClassExtractionMethodName(); } else { return null; } }