/** * Clears the caches when Sirius is shutting down */ @Register public static class CacheManagerLifecycle implements Stoppable { @Override public void stopped() { caches.values().forEach(ManagedCache::clear); caches.clear(); } } }
/** * Automatically deletes old log files. */ @Register public class CleanLogsTask implements EveryDay { @Part private Tasks tasks; @ConfigValue("health.logFileRetention") private Duration logFileRetention; @Override public String getConfigKeyName() { return "logs-cleanup"; } @Override public void runTimer() throws Exception { tasks.defaultExecutor().start(() -> Sirius.getSetup().cleanOldLogFiles(logFileRetention.toMillis())); } }
/** * Provides access to {@link IndexAccess} as "index" in scripts. */ @Register public class SearchContextExtender implements GlobalContextExtender { @Part private IndexAccess index; @Override public void collectTemplate(BiConsumer<String, Object> globalParameterCollector) { // Nothing provided } @Override public void collectScripting(BiConsumer<String, Object> globalParameterCollector) { globalParameterCollector.accept("index", index); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return BigDecimal.class.equals(field.getType()); } @Override public Property create(Field field) { return new BigDecimalProperty(field); } }
/** * Invoked regularly to remove outdated entries from the system caches. */ @Register public class CacheEvictionTimer implements EveryTenMinutes { @Part private Tasks tasks; @Override public void runTimer() throws Exception { tasks.defaultExecutor().start(this::runEviction); } private void runEviction() { for (ManagedCache<?, ?> cache : CacheManager.getCaches()) { CacheManager.LOG.FINE("Running cache eviction for: %s", cache.getName()); cache.updateStatistics(); cache.runEviction(); } } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return EntityRef.class.equals(field.getType()) && field.isAnnotationPresent(RefType.class); } @Override public Property create(Field field) { return new EntityProperty(field); } }
/** * Provides metrics for Mongo DB (if configured). */ @Register public class MongoMetricsProvider implements MetricProvider { @Part private Mongo mongo; @Override public void gather(MetricsCollector collector) { if (mongo.isConfigured()) { collector.metric("mongo_calls","mongo-calls", "Mongo DB Calls", mongo.callDuration.getCount(), "/min"); collector.metric("mongo_call_duration","mongo-call-duration", "Mongo DB Call Duration", mongo.callDuration.getAndClear(), "ms"); collector.differentialMetric("mongo_slow_queries", "mongo-slow-queries", "MongoDB Slow Queries", mongo.numSlowQueries.getCount(), "/min"); } } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return LocalDate.class.equals(field.getType()); } @Override public Property create(Field field) { return new LocalDateProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return Long.class.equals(field.getType()) || long.class.equals(field.getType()); } @Override public Property create(Field field) { return new LongProperty(field); } }
/** * Factory for generating properties based on having a {@link NestedObject} annotation. */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return field.isAnnotationPresent(NestedObject.class) && !field.getType().equals(AutoCompletion.class); } @Override public Property create(Field field) { return new ObjectProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return Boolean.class.equals(field.getType()) || boolean.class.equals(field.getType()); } @Override public Property create(Field field) { return new BooleanProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return Double.class.equals(field.getType()) || double.class.equals(field.getType()); } @Override public Property create(Field field) { return new DoubleProperty(field); } }
/** * Factory for generating properties of type {@link AutoCompletion} . */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return field.getType().equals(AutoCompletion.class); } @Override public Property create(Field field) { return new CompleterProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return String.class.equals(field.getType()); } @Override public Property create(Field field) { return new StringProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return Integer.class.equals(field.getType()) || int.class.equals(field.getType()); } @Override public Property create(Field field) { return new IntProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return Map.class.equals(field.getType()) && field.isAnnotationPresent(MapType.class) && List.class.equals( field.getAnnotation(MapType.class).value()); } @Override public Property create(Field field) { return new StringListMapProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return EntityRefList.class.equals(field.getType()) && field.isAnnotationPresent(RefType.class); } @Override public Property create(Field field) { return new EntityListProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return Amount.class.equals(field.getType()); } @Override public Property create(Field field) { return new AmountProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return field.getType().isEnum(); } @Override public Property create(Field field) { return new EnumProperty(field); } }
/** * Factory for generating properties based on their field type */ @Register public static class Factory implements PropertyFactory { @Override public boolean accepts(Field field) { return LocalDateTime.class.equals(field.getType()); } @Override public Property create(Field field) { return new LocalDateTimeProperty(field); } }