/** * Represents a list of {@link MongoEntity entities} being referenced by id. * * @param <E> the type of entities being referenced */ public class MongoRefList<E extends MongoEntity> extends BaseEntityRefList<E, MongoRefList<E>> { @Part private static Mango mango; /** * Creates a new list for the given type and delete handler. * * @param type the type of entities to store in the list * @param deleteHandler the behaviour when one of the stored entities is deleted. Note that * {@link sirius.db.mixing.types.BaseEntityRef.OnDelete#SET_NULL} will remove the id from the * list instead of inserting a <tt>null</tt>. */ public MongoRefList(Class<E> type, BaseEntityRef.OnDelete deleteHandler) { super(type, deleteHandler); } @Override protected Optional<E> resolve(String id, ContextInfo... context) { return mango.find(type, id); } }
@Override public void handle(MutableGlobalContext ctx, Object object, Field field) throws Exception { Part annotation = field.getAnnotation(Part.class); if (Strings.isFilled(annotation.configPath())) { String value = Sirius.getSettings().getString(annotation.configPath()); if (Strings.isFilled(value)) { Object part = ctx.findPart(value, field.getType()); field.set(object, part); } } else { Object part = ctx.getPart(field.getType()); if (part != null) { field.set(object, part); } } } }
/** * Represents a list of {@link ElasticEntity entities} being referenced by id. * * @param <E> the type of entities being referenced */ public class ElasticRefList<E extends ElasticEntity> extends BaseEntityRefList<E, ElasticRefList<E>> { @Part private static Elastic elastic; /** * Creates a new list for the given type and delete handler. * * @param type the type of entities to store in the list * @param deleteHandler the behaviour when one of the stored entities is deleted. Note that * {@link sirius.db.mixing.types.BaseEntityRef.OnDelete#SET_NULL} will remove the id from the * list instead of inserting a <tt>null</tt>. */ public ElasticRefList(Class<E> type, BaseEntityRef.OnDelete deleteHandler) { super(type, deleteHandler); } @Override protected Optional<E> resolve(String id, ContextInfo... context) { return elastic.find(type, id, context); } }
@Part private static Mango mango;
@Part private static Elastic elastic;
@Part private static OMA oma;
implements SQLPropertyInfo, ESPropertyInfo { @Part private static Elastic elastic;
implements SQLPropertyInfo, ESPropertyInfo { @Part private static Mango mango;
private final BatchSQLQuery sqlQuery; @Part private static Databases dbs;
@Part private static Mixing mixing;
private Class<? extends SQLEntity> other; @Part private static Mixing mixing;
@Part private static Mixing mixing; private EntityDescriptor nestedDescriptor;
/** * Removes outdated traces used to discover optimistic lock errors */ @Register public class OptimisticLockTracer implements EveryTenSeconds { @Part private Tasks tasks; @Part private IndexAccess index; @Override public void runTimer() throws Exception { if (index.traceOptimisticLockErrors) { tasks.defaultExecutor().fork(this::cleanOldRecordings); } } private void cleanOldRecordings() { long limit = System.currentTimeMillis() - 10_000; index.traces.values().removeIf(indexTrace -> indexTrace.timestamp < limit); } }
private BulkRequestBuilder bulk; @Part private static IndexAccess index;
@Part private static Databases dbs;
implements SQLPropertyInfo, ESPropertyInfo { @Part private static OMA oma;
@Part protected static Databases dbs;
@Part private static Databases dbs;