Package cz.o2.proxima.core.repository
Class Repository
- java.lang.Object
-
- cz.o2.proxima.core.repository.Repository
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
ConfigRepository
@Evolving public abstract class Repository extends java.lang.Object implements java.io.Serializable
Repository of all entities configured in the system.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRepository.ValidateVarious validation flags.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddedDataOperator(DataOperator op)Called when newDataOperatoris created.RepositoryFactoryasFactory()Convert this repository toSerializablefactory.abstract voiddrop()Drop theRepositoryand let it recreate from scratch using factory.abstract java.util.Optional<EntityDescriptor>findEntity(java.lang.String name)Find entity descriptor based on entity name.abstract java.util.Optional<AttributeFamilyDescriptor>findFamilyByName(java.lang.String name)Retrieve attribute family by name.abstract java.util.stream.Stream<EntityDescriptor>getAllEntities()Retrieve stream of all entities.java.util.stream.Stream<AttributeFamilyDescriptor>getAllFamilies()List all unique attribute families.abstract java.util.stream.Stream<AttributeFamilyDescriptor>getAllFamilies(boolean includeSystem)List all unique attribute families, possibly including system attribute families.EntityDescriptorgetEntity(java.lang.String name)Get entity descriptor based on entity name.abstract java.util.Set<AttributeFamilyDescriptor>getFamiliesForAttribute(AttributeDescriptor<?> attr)Retrieve list of attribute families for attribute.AttributeFamilyDescriptorgetFamilyByName(java.lang.String name)Retrieve attribute family by name.static java.lang.ClassLoadergetJpmsClassloader()<T extends DataOperator>
TgetOrCreateOperator(java.lang.Class<T> type, Consumer<T>... modifiers)Retrieve instance of data operator or create new instance with given settings.abstract java.util.Map<java.lang.String,TransformationDescriptor>getTransformations()Retrieve all transformers.abstract java.util.Optional<ValueSerializerFactory>getValueSerializerFactory(java.lang.String scheme)Retrieve value serializer for given scheme.booleanhasOperator(java.lang.String name)Check if given implementation of data operator is available on classpath andgetOrCreateOperator(Class, Consumer[])(java.lang.Class, Consumer...)} will return non-null object for class corresponding the given name.abstract booleanisEmpty()Check if this repository is empty.abstract booleanisShouldValidate(Repository.Validate what)Check if thisRepositoryshould eagerly validate various settings.static Repositoryof(cz.o2.proxima.typesafe.config.Config config)CreateRepositoryfrom givenConfig.static RepositoryofTest(cz.o2.proxima.typesafe.config.Config config, Repository.Validate... validate)CreateRepositoryfrom givenConfigfor testing purposes.
-
-
-
Method Detail
-
of
public static Repository of(cz.o2.proxima.typesafe.config.Config config)
CreateRepositoryfrom givenConfig.- Parameters:
config- the config- Returns:
- repository
-
ofTest
public static Repository ofTest(cz.o2.proxima.typesafe.config.Config config, Repository.Validate... validate)
CreateRepositoryfrom givenConfigfor testing purposes.- Parameters:
config- the configvalidate- validations that should be performed- Returns:
- repository
-
getJpmsClassloader
public static java.lang.ClassLoader getJpmsClassloader()
-
asFactory
public RepositoryFactory asFactory()
Convert this repository toSerializablefactory.- Returns:
- this repository as factory
-
findEntity
public abstract java.util.Optional<EntityDescriptor> findEntity(java.lang.String name)
Find entity descriptor based on entity name.- Parameters:
name- name of the entity to search for- Returns:
- optional
EntityDescriptorfound by name
-
getEntity
public EntityDescriptor getEntity(java.lang.String name)
Get entity descriptor based on entity name.- Parameters:
name- name of the entity to search for- Returns:
EntityDescriptorfound by name
-
getAllEntities
public abstract java.util.stream.Stream<EntityDescriptor> getAllEntities()
Retrieve stream of all entities.- Returns:
Streamof all entities specified in this repository
-
getTransformations
public abstract java.util.Map<java.lang.String,TransformationDescriptor> getTransformations()
Retrieve all transformers.- Returns:
- all transformations by name
-
isEmpty
public abstract boolean isEmpty()
Check if this repository is empty.- Returns:
trueif this repository is empty
-
getAllFamilies
public java.util.stream.Stream<AttributeFamilyDescriptor> getAllFamilies()
List all unique attribute families.- Returns:
- all families specified in this repository
-
getAllFamilies
public abstract java.util.stream.Stream<AttributeFamilyDescriptor> getAllFamilies(boolean includeSystem)
List all unique attribute families, possibly including system attribute families.- Parameters:
includeSystem-trueif system families should be included
-
findFamilyByName
public abstract java.util.Optional<AttributeFamilyDescriptor> findFamilyByName(java.lang.String name)
Retrieve attribute family by name.Note that this searched all families that were specified in configuration. It might include families not listed in
getAllFamilies(), because some families might be removed for various reasons (e.g. when proxying attributes).- Parameters:
name- name of the family- Returns:
OptionalAttributeFamilyDescriptorif family exists
-
getFamilyByName
public AttributeFamilyDescriptor getFamilyByName(java.lang.String name)
Retrieve attribute family by name.Note that this searched all families that were specified in configuration. It might include families not listed in
getAllFamilies(), because some families might be removed for various reasons (e.g. when proxying attributes).- Parameters:
name- name of the family- Returns:
AttributeFamilyDescriptorif family exists- Throws:
java.lang.IllegalArgumentException- when family doesn't exist
-
getFamiliesForAttribute
public abstract java.util.Set<AttributeFamilyDescriptor> getFamiliesForAttribute(AttributeDescriptor<?> attr)
Retrieve list of attribute families for attribute.- Parameters:
attr- attribute descriptor- Returns:
- all families of given attribute
-
getValueSerializerFactory
public abstract java.util.Optional<ValueSerializerFactory> getValueSerializerFactory(java.lang.String scheme)
Retrieve value serializer for given scheme.- Parameters:
scheme- scheme of theValueSerializerFactory- Returns:
- optional
ValueSerializerFactoryfor the scheme
-
getOrCreateOperator
@SafeVarargs public final <T extends DataOperator> T getOrCreateOperator(java.lang.Class<T> type, Consumer<T>... modifiers)
Retrieve instance of data operator or create new instance with given settings.- Type Parameters:
T- type of operator- Parameters:
type- the operator classmodifiers- modifiers of operator applied when the operator is created- Returns:
- the data operator of given type
-
hasOperator
public boolean hasOperator(java.lang.String name)
Check if given implementation of data operator is available on classpath andgetOrCreateOperator(Class, Consumer[])(java.lang.Class, Consumer...)} will return non-null object for class corresponding the given name.- Parameters:
name- name of the operator- Returns:
trueif the operator is available,falseotherwise
-
isShouldValidate
public abstract boolean isShouldValidate(Repository.Validate what)
Check if thisRepositoryshould eagerly validate various settings.- Parameters:
what- validation flag- Returns:
trueif this Repository should validate settings before usage (typically production settings, while test settings can be less strict).
-
drop
public abstract void drop()
Drop theRepositoryand let it recreate from scratch using factory. This is intended for use in tests mostly to prevent influence between two test cases.
-
addedDataOperator
protected void addedDataOperator(DataOperator op)
Called when newDataOperatoris created.- Parameters:
op- the operator that was created
-
-