/** * PUBLIC: * Returns the InterfacePolicy. * The interface policy allows for a descriptor's public and variable interfaces to be defined. * Caution must be used in using this method as it lazy initializes an interface policy. * Calling this on a descriptor that does not use interfaces will cause problems, #hasInterfacePolicy() must always first be called. */ public InterfacePolicy getInterfacePolicy() { if (interfacePolicy == null) { // Lazy initialize to conserve space in non-inherited classes. setInterfacePolicy(new InterfacePolicy(this)); } return interfacePolicy; }
/** * INTERNAL: * Add child descriptor to the parent descriptor. */ public void addChildDescriptor(ClassDescriptor childDescriptor) { getChildDescriptors().add(childDescriptor); }
/** * INTERNAL: * Add parent descriptor. */ public void addParentDescriptor(ClassDescriptor parentDescriptor) { getParentDescriptors().add(parentDescriptor); }
/** * INTERNAL: * Select one object of any concrete subclass. */ public Object selectOneObjectUsingMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { Object object = null; for (Enumeration childDescriptors = getChildDescriptors().elements(); childDescriptors.hasMoreElements() && (object == null);) { ClassDescriptor descriptor = (ClassDescriptor)childDescriptors.nextElement(); object = descriptor.getInterfacePolicy().selectOneObject(query); } return object; }
protected void addInterfaceLines(NonreflectiveMethodDefinition method, InterfacePolicy policy) { method.addLine("// Interface Properties."); if (policy.isInterfaceChildDescriptor()) { for (Iterator<String> interfacesEnum = policy.getParentInterfaceNames().iterator(); interfacesEnum.hasNext();) { String parentInterfaceName = interfacesEnum.next(); method.addLine("descriptor.getInterfacePolicy().addParentInterface(" + parentInterfaceName + ".class);"); } } }
/** * INTERNAL: * Allow the descriptor to initialize any dependencies on this session. */ public void preInterfaceInitialization(AbstractSession session) throws DescriptorException { if (isInterfaceInitialized(PREINITIALIZED)) { return; } setInterfaceInitializationStage(PREINITIALIZED); assignDefaultValues(session); if (isInterfaceChildDescriptor()) { for (Iterator<Class> interfaces = getInterfacePolicy().getParentInterfaces().iterator(); interfaces.hasNext();) { Class parentInterface = interfaces.next(); ClassDescriptor parentDescriptor = session.getDescriptor(parentInterface); if ((parentDescriptor == null) || (parentDescriptor.getJavaClass() == getJavaClass()) || parentDescriptor.getInterfacePolicy().usesImplementorDescriptor()) { session.getProject().getDescriptors().put(parentInterface, this); session.clearLastDescriptorAccessed(); } else if (!parentDescriptor.isDescriptorForInterface()) { throw DescriptorException.descriptorForInterfaceIsMissing(parentInterface.getName()); } else { parentDescriptor.preInterfaceInitialization(session); parentDescriptor.getInterfacePolicy().addChildDescriptor(this); getInterfacePolicy().addParentDescriptor(parentDescriptor); } } } }
for (Iterator<Class> interfaces = getInterfacePolicy().getParentInterfaces().iterator(); interfaces.hasNext();) { Class parentInterface = interfaces.next(); getInterfacePolicy().initialize(session);
/** * This figures out the best name for each descriptor, * first using the local class name then the qualified one for duplicates. */ protected void computeDescriptorMethodNames() { Hashtable shortNames = new Hashtable(); Iterator descriptors = project.getOrderedDescriptors().iterator(); while (descriptors.hasNext()) { ClassDescriptor descriptor = (ClassDescriptor)descriptors.next(); // Singleton interface descriptors should not exist. if (!(descriptor.isDescriptorForInterface() && (descriptor.getInterfacePolicy().getImplementorDescriptor() != null))) { String shortName = Helper.getShortClassName(descriptor.getJavaClassName()); if (shortNames.containsKey(shortName)) { // Use the full package name. ClassDescriptor firstDescriptor = (ClassDescriptor)shortNames.get(shortName); getDescriptorMethodNames().put(firstDescriptor, removeDots(firstDescriptor.getJavaClassName())); getDescriptorMethodNames().put(descriptor, removeDots(descriptor.getJavaClassName())); } else { shortNames.put(shortName, descriptor); getDescriptorMethodNames().put(descriptor, shortName); } } } }
/** * INTERNAL: * Select all objects for an interface descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the objects. * * @return Vector containing all objects. * @exception DatabaseException - an error has occurred on the database. */ public Object selectAllObjectsUsingMultipleTableSubclassRead(ReadAllQuery query) throws DatabaseException { org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy = query.getContainerPolicy(); Object objects = containerPolicy.containerInstance(1); for (Enumeration childDescriptors = getChildDescriptors().elements(); childDescriptors.hasMoreElements();) { ClassDescriptor descriptor = (ClassDescriptor)childDescriptors.nextElement(); objects = containerPolicy.concatenateContainers(objects, descriptor.getInterfacePolicy().selectAllObjects(query)); } return objects; }
public void addParentInterfaceName(String parentInterfaceName) { getParentInterfaceNames().add(parentInterfaceName); }
/** * PUBLIC: * Add the parent Interface class. * * This method should be called once for each parent Interface of the Descriptor. */ public void addParentInterface(Class parentInterface) { getParentInterfaces().addElement(parentInterface); }
this.interfacePolicy.convertClassNamesToClasses(classLoader);
/** * INTERNAL: * Allow the descriptor to initialize any dependencies on this session. */ public void preInterfaceInitialization(AbstractSession session) throws DescriptorException { if (isInterfaceInitialized(PREINITIALIZED)) { return; } setInterfaceInitializationStage(PREINITIALIZED); assignDefaultValues(session); if (isInterfaceChildDescriptor()) { for (Enumeration interfaces = getInterfacePolicy().getParentInterfaces().elements(); interfaces.hasMoreElements();) { Class parentInterface = (Class)interfaces.nextElement(); ClassDescriptor parentDescriptor = session.getDescriptor(parentInterface); if ((parentDescriptor == null) || (parentDescriptor.getJavaClass() == getJavaClass()) || parentDescriptor.getInterfacePolicy().usesImplementorDescriptor()) { session.getProject().getDescriptors().put(parentInterface, this); session.clearLastDescriptorAccessed(); } else if (!parentDescriptor.isDescriptorForInterface()) { throw DescriptorException.descriptorForInterfaceIsMissing(parentInterface.getName()); } else { parentDescriptor.preInterfaceInitialization(session); parentDescriptor.getInterfacePolicy().addChildDescriptor(this); getInterfacePolicy().addParentDescriptor(parentDescriptor); } } } }
protected void addInterfaceLines(NonreflectiveMethodDefinition method, InterfacePolicy policy) { method.addLine("// Interface Properties."); if (policy.isInterfaceChildDescriptor()) { for (Iterator<String> interfacesEnum = policy.getParentInterfaceNames().iterator(); interfacesEnum.hasNext();) { String parentInterfaceName = interfacesEnum.next(); method.addLine("descriptor.getInterfacePolicy().addParentInterface(" + parentInterfaceName + ".class);"); } } }
for (Iterator<Class> interfaces = getInterfacePolicy().getParentInterfaces().iterator(); interfaces.hasNext();) { Class parentInterface = interfaces.next(); getInterfacePolicy().initialize(session);
/** * This figures out the best name for each descriptor, * first using the local class name then the qualified one for duplicates. */ protected void computeDescriptorMethodNames() { Hashtable shortNames = new Hashtable(); Iterator descriptors = project.getOrderedDescriptors().iterator(); while (descriptors.hasNext()) { ClassDescriptor descriptor = (ClassDescriptor)descriptors.next(); // Singleton interface descriptors should not exist. if (!(descriptor.isDescriptorForInterface() && (descriptor.getInterfacePolicy().getImplementorDescriptor() != null))) { String shortName = Helper.getShortClassName(descriptor.getJavaClassName()); if (shortNames.containsKey(shortName)) { // Use the full package name. ClassDescriptor firstDescriptor = (ClassDescriptor)shortNames.get(shortName); getDescriptorMethodNames().put(firstDescriptor, removeDots(firstDescriptor.getJavaClassName())); getDescriptorMethodNames().put(descriptor, removeDots(descriptor.getJavaClassName())); } else { shortNames.put(shortName, descriptor); getDescriptorMethodNames().put(descriptor, shortName); } } } }
public void addParentInterfaceName(String parentInterfaceName) { getParentInterfaceNames().addElement(parentInterfaceName); }
/** * PUBLIC: * Add the parent Interface class. * * This method should be called once for each parent Interface of the Descriptor. */ public void addParentInterface(Class parentInterface) { getParentInterfaces().add(parentInterface); }
this.interfacePolicy.convertClassNamesToClasses(classLoader);
/** * INTERNAL: * Allow the descriptor to initialize any dependencies on this session. */ public void preInterfaceInitialization(AbstractSession session) throws DescriptorException { if (isInterfaceInitialized(PREINITIALIZED)) { return; } setInterfaceInitializationStage(PREINITIALIZED); assignDefaultValues(session); if (isInterfaceChildDescriptor()) { for (Iterator<Class> interfaces = getInterfacePolicy().getParentInterfaces().iterator(); interfaces.hasNext();) { Class parentInterface = interfaces.next(); ClassDescriptor parentDescriptor = session.getDescriptor(parentInterface); if ((parentDescriptor == null) || (parentDescriptor.getJavaClass() == getJavaClass()) || parentDescriptor.getInterfacePolicy().usesImplementorDescriptor()) { session.getProject().getDescriptors().put(parentInterface, this); session.clearLastDescriptorAccessed(); } else if (!parentDescriptor.isDescriptorForInterface()) { throw DescriptorException.descriptorForInterfaceIsMissing(parentInterface.getName()); } else { parentDescriptor.preInterfaceInitialization(session); parentDescriptor.getInterfacePolicy().addChildDescriptor(this); getInterfacePolicy().addParentDescriptor(parentDescriptor); } } } }