/** * Accessor for the main class represented. * @return The name of the class **/ public String getType() { return cmd.getFullClassName(); }
/** * Accessor for the type of the class being represented by this view. * @return The name of the class being represented here */ public String getType() { return cmd.getFullClassName(); }
/** * Constructor. * @param cmd MetaData for the class to be enhanced * @param clr ClassLoader resolver * @param mmgr MetaData manager */ public AbstractClassEnhancer(ClassMetaData cmd, ClassLoaderResolver clr, MetaDataManager mmgr) { this.clr = clr; this.cmd = cmd; this.className = cmd.getFullClassName(); this.metaDataMgr = mmgr; }
/** * Accessor for the implementation name for the specified "persistent-interface". * @param interfaceName The name of the persistent interface * @return The name of the implementation class */ public String getImplementationNameForPersistentInterface(String interfaceName) { ClassMetaData cmd = (ClassMetaData)classMetaDataByInterface.get(interfaceName); return (cmd != null ? cmd.getFullClassName() : null); }
/** * Convenience method to return if the passed class name is an implementation of the passed "persistent-interface". * @param interfaceName Name of the persistent interface * @param implName The implementation name * @return Whether it is a (generated) impl of the persistent interface */ public boolean isPersistentInterfaceImplementation(String interfaceName, String implName) { ClassMetaData cmd = (ClassMetaData)classMetaDataByInterface.get(interfaceName); return (cmd != null && cmd.getFullClassName().equals(implName)); }
/** * Constructor for an enhancer for the class. The class is assumed to be in the CLASSPATH. * @param cmd MetaData for the class to be enhanced * @param clr ClassLoader resolver * @param mmgr MetaData manager */ public ASMClassEnhancer(ClassMetaData cmd, ClassLoaderResolver clr, MetaDataManager mmgr) { super(cmd, clr, mmgr); cls = clr.classForName(cmd.getFullClassName()); asmClassName = cmd.getFullClassName().replace('.', '/'); classDescriptor = Type.getDescriptor(cls); inputResourceName = "/" + className.replace('.','/') + ".class"; }
/** * Constructor for an enhancer to enhance a class defined by the provided bytes. * @param cmd MetaData for the class to be enhanced * @param clr ClassLoader resolver * @param mmgr MetaData manager * @param classBytes Bytes of the class to enhance */ public ASMClassEnhancer(ClassMetaData cmd, ClassLoaderResolver clr, MetaDataManager mmgr, byte[] classBytes) { super(cmd, clr, mmgr); cls = clr.classForName(cmd.getFullClassName()); asmClassName = cmd.getFullClassName().replace('.', '/'); classDescriptor = Type.getDescriptor(cls); inputBytes = classBytes; }
public void onParameterMacro(MacroString.ParameterMacro pm) { throw new NucleusUserException(Localiser.msg("057033", cmd.getFullClassName(), pm)); } }, clr
public void onParameterMacro(MacroString.ParameterMacro pm) { throw new NucleusUserException(Localiser.msg("031009", cmd.getFullClassName(), pm)); } }, clr
/** * Utility to throw an exception if the object is not persistable. * @param op The ObjectProvider for the object */ void assertPCClass(ObjectProvider op) { Class c = op.getObject().getClass(); if (!op.getExecutionContext().getClassLoaderResolver().isAssignableFrom(cmd.getFullClassName(),c)) { throw new NucleusException(Localiser.msg("057013",cmd.getFullClassName(),c)).setFatal(); } }
/** * Constructor for an implementation of an abstract class. * @param cmd MetaData for the abstract class * @param implClassName Name of the implementation class to generate (omitting packages) * @param mmgr MetaData manager */ public ASMImplementationGenerator(ClassMetaData cmd, String implClassName, MetaDataManager mmgr) { super(cmd, implClassName, mmgr); asmClassName = fullClassName.replace('.', '/'); asmTypeDescriptor = "L" + asmClassName + ";"; fullSuperclassName = cmd.getFullClassName(); // Start the class writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); writer.visit(Opcodes.V1_3, Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, fullClassName.replace('.', '/'), null, fullSuperclassName.replace('.', '/'), null); // Create fields, default ctor, and methods createPropertyFields(); createDefaultConstructor(); createPropertyMethods(); // End the class writer.visitEnd(); bytes = writer.toByteArray(); String clsBytes = new String(bytes); NucleusLogger.GENERAL.info(">> ASMImplGen.ctr bytes=" + clsBytes); }
/** * Accessor for the mapping for the specified field/property. * @param mmd Metadata for the field/property * @return The Mapping for the field. */ public JavaTypeMapping getMemberMapping(AbstractMemberMetaData mmd) { assertIsInitialized(); JavaTypeMapping m = fieldMappings[mmd.getAbsoluteFieldNumber()]; if (m == null) { throw new NoSuchPersistentFieldException(cmd.getFullClassName(), mmd.getAbsoluteFieldNumber()); } return m; }
/** * Method to register the metadata for an implementation of a persistent abstract class. * @param cmd MetaData for the abstract class * @param implClass The implementation class * @param clr ClassLoader resolver */ public void registerImplementationOfAbstractClass(ClassMetaData cmd, Class implClass, ClassLoaderResolver clr) { ClassMetaData implCmd = new ClassMetaData(cmd, ClassUtils.getClassNameForClass(implClass)); // Register the ClassMetaData for the implementation registerMetaDataForClass(implCmd.getFullClassName(), implCmd); initialiseClassMetaData(implCmd, implClass, clr); // Deregister the metadata for the implementation from those "not found" if (NucleusLogger.METADATA.isDebugEnabled()) { NucleusLogger.METADATA.debug(Localiser.msg("044044", implClass.getName())); } classesWithoutPersistenceInfo.remove(implClass.getName()); } }
if (cmd.getPersistenceModifier() == ClassPersistenceModifier.PERSISTENCE_CAPABLE && !cmd.isEmbeddedOnly()) if (!storeDataMgr.managesClass(cmd.getFullClassName())) StoreData sd = storeDataMgr.get(cmd.getFullClassName()); if (sd == null) clsNameSet.add(cmd.getFullClassName());
/** * Accessor for the field mapping for the named field. * The field may exist in a parent table or a secondary table. * Throws a NoSuchPersistentFieldException if the field name is not found. * TODO Use of this is discouraged since the fieldName is not fully qualified * and if a superclass-table inheritance is used we could have 2 fields of that name here. * @param memberName Name of field/property * @return The mapping. * @throws NoSuchPersistentFieldException Thrown when the field/property is not found */ public JavaTypeMapping getMemberMapping(String memberName) { assertIsInitialized(); AbstractMemberMetaData mmd = getMetaDataForMember(memberName); JavaTypeMapping m = getMemberMapping(mmd); if (m == null) { throw new NoSuchPersistentFieldException(cmd.getFullClassName(), memberName); } return m; }
/** * Accessor for the field mapping for the specified field name. * @param fieldName Name of the field * @return The Java type mapping for the field */ public JavaTypeMapping getMemberMapping(String fieldName) { assertIsInitialized(); int rfn = cmd.getRelativePositionOfMember(fieldName); if (rfn < 0) { throw new NoSuchPersistentFieldException(cmd.getFullClassName(), fieldName); } return getMemberMapping(cmd.getMetaDataForManagedMemberAtRelativePosition(rfn)); }
/** * Method to register a persistent interface and its implementation with the MetaData system. * @param imd MetaData for the interface * @param implClass The implementation class * @param clr ClassLoader Resolver to use */ public void registerPersistentInterface(InterfaceMetaData imd, Class implClass, ClassLoaderResolver clr) { // Create ClassMetaData for the implementation ClassMetaData cmd = new ClassMetaData(imd, ClassUtils.getClassNameForClass(implClass), true); cmd.addImplements(new ImplementsMetaData(imd.getFullClassName())); // Register the ClassMetaData for the implementation registerMetaDataForClass(cmd.getFullClassName(), cmd); // Register the metadata for the implementation against this persistent interface classMetaDataByInterface.put(imd.getFullClassName(), cmd); initialiseClassMetaData(cmd, implClass, clr); // Deregister the metadata for the implementation from those "not found" if (NucleusLogger.METADATA.isDebugEnabled()) { NucleusLogger.METADATA.debug(Localiser.msg("044044",implClass.getName())); } classesWithoutPersistenceInfo.remove(implClass.getName()); }
if (cmd.getPersistenceModifier() == ClassPersistenceModifier.PERSISTENCE_CAPABLE && !cmd.isEmbeddedOnly()) if (!storeDataMgr.managesClass(cmd.getFullClassName())) StoreData sd = storeDataMgr.get(cmd.getFullClassName()); if (sd == null)
if (cmd.getPersistenceModifier() == ClassPersistenceModifier.PERSISTENCE_CAPABLE && !cmd.isAbstract() && !cmd.isEmbeddedOnly()) if (!storeDataMgr.managesClass(cmd.getFullClassName())) StoreData sd = storeDataMgr.get(cmd.getFullClassName()); if (sd == null)
/** * Accessor for the ID mapping for this table. * @return The ID mapping */ public JavaTypeMapping getIdMapping() { if (idMapping != null) { return idMapping; } PersistableMapping mapping = new PersistableMapping(); mapping.initialize(getStoreManager(), primaryTable.getClassMetaData().getFullClassName()); if (getIdentityType() == IdentityType.DATASTORE) { mapping.addJavaTypeMapping(datastoreIdMapping); } else if (getIdentityType() == IdentityType.APPLICATION) { for (int i = 0; i < pkMappings.length; i++) { mapping.addJavaTypeMapping(pkMappings[i]); } } idMapping = mapping; return mapping; }