@Override protected void parseMemberMappingAnnotations(FieldMetaData fmd) { CassandraFieldMetaData cassField = (CassandraFieldMetaData) fmd; AnnotatedElement el = (AnnotatedElement) getRepository() .getMetaDataFactory().getDefaults().getBackingMember(fmd); ClassMapping mapped = null; for (Annotation annotation : el.getDeclaredAnnotations()) { mapped = mapping.get(annotation.annotationType()); if (mapped == null) { continue; } switch (mapped) { case EMBEDDED: handleEmbedded(cassField); break; case EMBEDDEDCOLLECTION: handleEmbeddedCollection(cassField); break; } } }
/** * The repository to use to hold metadata. */ public MetaDataRepository getRepository() { if (_repos == null) { _repos = newRepository(); _repos.setResolve(MODE_MAPPING, false); MetaDataFactory factory = _repos.getMetaDataFactory(); factory.getDefaults().setIgnoreNonPersistent(false); factory.setStoreMode(MetaDataFactory.STORE_VERBOSE); } return _repos; }
/** * Constructor. Supply broker attaching to. */ public AttachManager(BrokerImpl broker, boolean copyNew, OpCallbacks call) { _broker = broker; _proxy = broker.getConfiguration().getProxyManagerInstance(); _call = call; _copyNew = copyNew; _failFast = (broker.getConfiguration().getMetaDataRepositoryInstance(). getMetaDataFactory().getDefaults().getCallbackMode() & CallbackModes.CALLBACK_FAIL_FAST) != 0; }
/** * The access type used by this class. Either {@link #ACCESS_FIELD} * or {@link #ACCESS_PROPERTY}. */ public int getAccessType() { if (_accessType == ACCESS_UNKNOWN) { ClassMetaData sup = getPCSuperclassMetaData(); if (sup != null) return sup.getAccessType(); else { return getRepository().getMetaDataFactory(). getDefaults().getDefaultAccessType(); } } return _accessType; }
/** * Create a new metadata, populate it with default information, add it to * the repository, and return it. * * @param access the access type to use in populating metadata */ public ClassMetaData addMetaData(Class cls, int access) { if (cls == null || cls.isPrimitive()) return null; ClassMetaData meta = newClassMetaData(cls); _factory.getDefaults().populate(meta, access); // synchronize on this rather than the map, because all other methods // that access _metas are synchronized on this synchronized (this) { if (_pawares.containsKey(cls)) throw new MetaDataException(_loc.get("pc-and-aware", cls)); _metas.put(cls, meta); } return meta; }
/** * For a primary key field, return the type of the corresponding object id * class field. */ public int getObjectIdFieldTypeCode() { ClassMetaData relmeta = getDeclaredTypeMetaData(); if (relmeta == null) return getDeclaredTypeCode(); if (relmeta.getIdentityType() == ClassMetaData.ID_DATASTORE) { boolean unwrap = getRepository().getMetaDataFactory().getDefaults(). isDataStoreObjectIdFieldUnwrapped(); return (unwrap) ? JavaTypes.LONG : JavaTypes.OBJECT; } if (relmeta.isOpenJPAIdentity()) return relmeta.getPrimaryKeyFields()[0].getObjectIdFieldTypeCode(); return JavaTypes.OBJECT; }
/** * Update the list of implementations of base classes and interfaces. */ private void updateImpls(Class<?> cls, Class<?> leastDerived, Class<?> check) { // allow users to query on common non-pc superclasses Class<?> sup = check.getSuperclass(); if (leastDerived == cls && sup != null && sup != Object.class) { addToCollection(_impls, sup, cls, false); updateImpls(cls, leastDerived, sup); } // allow users to query on any implemented interfaces unless defaults // say the user must implement persistent interfaces explicitly in meta if (!_factory.getDefaults().isDeclaredInterfacePersistent()) return; Class<?>[] ints = check.getInterfaces(); for (int i = 0; i < ints.length; i++) { // don't map java-standard interfaces if (ints[i].getName().startsWith("java.")) continue; // only map least-derived interface implementors if (leastDerived == cls || isLeastDerivedImpl(ints[i], cls)) { addToCollection(_impls, ints[i], cls, false); updateImpls(cls, leastDerived, ints[i]); } } }
/** * Invalidate methods on the interface which are not managed. */ private void invalidateNonBeanMethods(BCClass bc, Class<?> iface, Set<Method> methods) { Method[] meths = (Method[]) AccessController.doPrivileged( J2DoPrivHelper.getDeclaredMethodsAction(iface)); BCMethod meth; Code code; Class<?> type = _repos.getMetaDataFactory().getDefaults(). getUnimplementedExceptionType(); for (int i = 0; i < meths.length; i++) { if (methods.contains(meths[i])) continue; meth = bc.declareMethod(meths[i].getName(), meths[i].getReturnType(), meths[i].getParameterTypes()); meth.makePublic(); code = meth.getCode(true); code.anew().setType(type); code.dup(); code.invokespecial().setMethod(type, "<init>", void.class, null); code.athrow(); code.calculateMaxLocals(); code.calculateMaxStack(); } }
/** * The type of identity being used. This will be one of: * <ul> * <li>{@link #ID_UNKNOWN}: unknown identity type</li> * <li>{@link #ID_DATASTORE}: identity managed by the data store and * independent of the fields of the instance</li> * <li>{@link #ID_APPLICATION}: identity managed by the application and * defined by one or more fields of the instance</li> * </ul> If unspecified, defaults to {@link #ID_DATASTORE} if there are no * primary key fields, and {@link #ID_APPLICATION} otherwise. */ public int getIdentityType() { if (_identity == ID_UNKNOWN) { ClassMetaData sup = getPCSuperclassMetaData(); if (sup != null && sup.getIdentityType() != ID_UNKNOWN) _identity = sup.getIdentityType(); else if (getPrimaryKeyFields().length > 0) _identity = ID_APPLICATION; else if (isMapped()) _identity = ID_DATASTORE; else _identity = _repos.getMetaDataFactory().getDefaults(). getDefaultIdentityType(); } return _identity; }
getDefaults(); boolean callbacks = def.getCallbacksBeforeListeners(type); if (callbacks) makeCallbacks(source, related, meta, type, exceptions);
/** * Set class attributes. * * @param access whether to write access */ private void addClassAttributes(ClassMetaData meta, boolean access) { if (!access) return; int def = getConfiguration().getMetaDataRepositoryInstance(). getMetaDataFactory().getDefaults().getDefaultAccessType(); if (meta.getAccessType() == ClassMetaData.ACCESS_FIELD && def == ClassMetaData.ACCESS_PROPERTY) addAttribute("access", "FIELD"); else if (meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY && def == ClassMetaData.ACCESS_FIELD) addAttribute("access", "PROPERTY"); }
/** * Create a new metadata, populate it with default information, add it to the repository, and * return it. * * @param access * the access type to use in populating metadata */ public ClassMetaData addMetaData(Class<?> cls, int access, boolean ignoreTransient) { if (cls == null || cls.isPrimitive()) return null; ClassMetaData meta = newClassMetaData(cls); _factory.getDefaults().populate(meta, access, ignoreTransient); // synchronize on this rather than the map, because all other methods // that access _metas are synchronized on this if (_locking) { synchronized(this){ return metasPutInternal(cls, meta); } } else { return metasPutInternal(cls, meta); } }
/** * For a primary key field, return the type of the corresponding object id * class field. */ public int getObjectIdFieldTypeCode() { ClassMetaData relmeta = getDeclaredTypeMetaData(); if (relmeta == null) return getDeclaredTypeCode(); if (relmeta.getIdentityType() == ClassMetaData.ID_DATASTORE) { boolean unwrap = getRepository().getMetaDataFactory().getDefaults(). isDataStoreObjectIdFieldUnwrapped(); return (unwrap) ? JavaTypes.LONG : JavaTypes.OBJECT; } if (relmeta.isOpenJPAIdentity()) return relmeta.getPrimaryKeyFields()[0].getObjectIdFieldTypeCode(); return JavaTypes.OBJECT; }
/** * Update the list of implementations of base classes and interfaces. */ private void updateImpls(Class<?> cls, Class<?> leastDerived, Class<?> check) { // allow users to query on common non-pc superclasses Class<?> sup = check.getSuperclass(); if (leastDerived == cls && sup != null && sup != Object.class) { addToCollection(_impls, sup, cls, false); updateImpls(cls, leastDerived, sup); } // allow users to query on any implemented interfaces unless defaults // say the user must implement persistent interfaces explicitly in meta if (!_factory.getDefaults().isDeclaredInterfacePersistent()) return; Class<?>[] ints = check.getInterfaces(); for (int i = 0; i < ints.length; i++) { // don't map java-standard interfaces if (ints[i].getName().startsWith("java.")) continue; // only map least-derived interface implementors if (leastDerived == cls || isLeastDerivedImpl(ints[i], cls)) { addToCollection(_impls, ints[i], cls, false); updateImpls(cls, leastDerived, ints[i]); } } }
/** * Invalidate methods on the interface which are not managed. */ private void invalidateNonBeanMethods(BCClass bc, Class<?> iface, Set<Method> methods) { Method[] meths = (Method[]) AccessController.doPrivileged( J2DoPrivHelper.getDeclaredMethodsAction(iface)); BCMethod meth; Code code; Class<?> type = _repos.getMetaDataFactory().getDefaults(). getUnimplementedExceptionType(); for (int i = 0; i < meths.length; i++) { if (methods.contains(meths[i])) continue; meth = bc.declareMethod(meths[i].getName(), meths[i].getReturnType(), meths[i].getParameterTypes()); meth.makePublic(); code = meth.getCode(true); code.anew().setType(type); code.dup(); code.invokespecial().setMethod(type, "<init>", void.class, null); code.athrow(); code.calculateMaxLocals(); code.calculateMaxStack(); } }
/** * The type of identity being used. This will be one of: * <ul> * <li>{@link #ID_UNKNOWN}: unknown identity type</li> * <li>{@link #ID_DATASTORE}: identity managed by the data store and * independent of the fields of the instance</li> * <li>{@link #ID_APPLICATION}: identity managed by the application and * defined by one or more fields of the instance</li> * </ul> If unspecified, defaults to {@link #ID_DATASTORE} if there are no * primary key fields, and {@link #ID_APPLICATION} otherwise. */ public int getIdentityType() { if (_identity != null) { return _identity; } else { ClassMetaData sup = getPCSuperclassMetaData(); if (sup != null && sup.getIdentityType() != ID_UNKNOWN) _identity = sup.getIdentityType(); else if (getPrimaryKeyFields().length > 0) _identity = ID_APPLICATION; else if (isMapped()) _identity = ID_DATASTORE; else if (isAbstract()) _identity = ID_UNKNOWN; else _identity = _repos.getMetaDataFactory().getDefaults(). getDefaultIdentityType(); } return _identity; }
getDefaults(); boolean callbacks = def.getCallbacksBeforeListeners(type); if (callbacks) makeCallbacks(source, related, meta, type, exceptions);
/** * Resolve superclass fields we've redefined. */ private void resolveDefinedSuperclassFields() { _defSupFields = true; if (_supFieldMap == null) return; FieldMetaData fmd; FieldMetaData sup; for (Iterator itr = _supFieldMap.values().iterator(); itr.hasNext();) { fmd = (FieldMetaData) itr.next(); sup = getSuperclassField(fmd); // jpa metadata doesn't qualify superclass field names, so we // might not know the declaring type until now if (fmd.getDeclaringType() == Object.class) { fmd.setDeclaringType(sup.getDeclaringType()); fmd.backingMember(getRepository().getMetaDataFactory(). getDefaults().getBackingMember(fmd)); } fmd.copy(sup); fmd.resolve(MODE_META); } }
/** * The repository to use to hold metadata. */ public MetaDataRepository getRepository() { if (_repos == null) { _repos = newRepository(); _repos.setResolve(MODE_MAPPING, false); MetaDataFactory factory = _repos.getMetaDataFactory(); factory.getDefaults().setIgnoreNonPersistent(false); factory.setStoreMode(MetaDataFactory.STORE_VERBOSE); } return _repos; }
/** * Constructor. Supply broker attaching to. */ public AttachManager(BrokerImpl broker, boolean copyNew, OpCallbacks call) { _broker = broker; _proxy = broker.getConfiguration().getProxyManagerInstance(); _call = call; _copyNew = copyNew; _failFast = (broker.getConfiguration().getMetaDataRepositoryInstance(). getMetaDataFactory().getDefaults().getCallbackMode() & CallbackModes.CALLBACK_FAIL_FAST) != 0; }