"How can I know at runtime what custom validators are being used on my entity objects?"
In JDeveloper 9.0.5, there is a new API called getValidators() thatwill return you an ArrayList of your validator beans at runtime for an entity definition or any one of its attribute definitions, but until then, you can adopt a trick that Shailesh on our team pointed out to me today. You can provide a custom entity definition class for any entity, over use a globally customized entity definition class as the base class for one or more entities in your application, in a way that overrides the framework's method called loadCustomDef(DefXmlElement xmlElement).
The overridden method might look something like this:
/* * This method will get called by entity definition * loading. The xmlElement passed in will be the * <Entity> element. */ protected void loadCustomDef(DefElementImpl xmlElement) throws PersistenceException { NodeList validatorTags = xmlElement.getChildrenByTagName("ValidationBean"); /* Here you would do something more interesting than this... */ System.out.println("Found " + validatorTags.getLength()+ " custom validators for Entity "+ getFullName()); }
If you do this in a global way, you would add this method in a class that extends oracle.jbo.server.EntityDefImpl, and then provide your customized class name as the name of the Entity Definition class to use for any entities that you want to have this behavior.
7:46:30 AM
|