Search in sources :

Example 1 with ReflectionReflectFactory

use of org.terasology.reflection.reflect.ReflectionReflectFactory in project Terasology by MovingBlocks.

the class ReflectFactoryBenchmark method main.

public static void main(String[] args) {
    final List<Benchmark> benchmarks = Lists.newArrayList();
    benchmarks.add(new FieldAccessBenchmark(new ReflectionReflectFactory()));
    benchmarks.add(new FieldAccessBenchmark(new ByteCodeReflectFactory()));
    benchmarks.add(new GetterSetterAccessBenchmark(new ReflectionReflectFactory()));
    benchmarks.add(new GetterSetterAccessBenchmark(new ByteCodeReflectFactory()));
    benchmarks.add(new ConstructionBenchmark(new ReflectionReflectFactory()));
    benchmarks.add(new ConstructionBenchmark(new ByteCodeReflectFactory()));
    Benchmarks.execute(benchmarks, new PrintToConsoleCallback());
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ByteCodeReflectFactory(org.terasology.reflection.reflect.ByteCodeReflectFactory) PrintToConsoleCallback(org.terasology.benchmark.PrintToConsoleCallback) Benchmark(org.terasology.benchmark.Benchmark)

Example 2 with ReflectionReflectFactory

use of org.terasology.reflection.reflect.ReflectionReflectFactory in project Terasology by MovingBlocks.

the class EntitySystemSetupUtil method addReflectionBasedLibraries.

public static void addReflectionBasedLibraries(Context context) {
    ReflectionReflectFactory reflectFactory = new ReflectionReflectFactory();
    context.put(ReflectFactory.class, reflectFactory);
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    context.put(CopyStrategyLibrary.class, copyStrategyLibrary);
    TypeSerializationLibrary typeSerializationLibrary = TypeSerializationLibrary.createDefaultLibrary(reflectFactory, copyStrategyLibrary);
    context.put(TypeSerializationLibrary.class, typeSerializationLibrary);
    EntitySystemLibrary library = new EntitySystemLibrary(context, typeSerializationLibrary);
    context.put(EntitySystemLibrary.class, library);
    context.put(ComponentLibrary.class, library.getComponentLibrary());
    context.put(EventLibrary.class, library.getEventLibrary());
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) EntitySystemLibrary(org.terasology.entitySystem.metadata.EntitySystemLibrary) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary)

Example 3 with ReflectionReflectFactory

use of org.terasology.reflection.reflect.ReflectionReflectFactory in project Terasology by MovingBlocks.

the class PojoEventSystemTests method setup.

@Before
public void setup() {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
    TypeSerializationLibrary serializationLibrary = new TypeSerializationLibrary(reflectFactory, copyStrategies);
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, serializationLibrary);
    compLibrary = entitySystemLibrary.getComponentLibrary();
    entityManager = new PojoEntityManager();
    entityManager.setComponentLibrary(entitySystemLibrary.getComponentLibrary());
    entityManager.setPrefabManager(new PojoPrefabManager(context));
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    eventSystem = new EventSystemImpl(entitySystemLibrary.getEventLibrary(), networkSystem);
    entityManager.setEventSystem(eventSystem);
    entity = entityManager.create();
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) EntitySystemLibrary(org.terasology.entitySystem.metadata.EntitySystemLibrary) PojoEntityManager(org.terasology.entitySystem.entity.internal.PojoEntityManager) NetworkSystem(org.terasology.network.NetworkSystem) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) ContextImpl(org.terasology.context.internal.ContextImpl) EventSystemImpl(org.terasology.entitySystem.event.internal.EventSystemImpl) Before(org.junit.Before)

Example 4 with ReflectionReflectFactory

use of org.terasology.reflection.reflect.ReflectionReflectFactory in project Terasology by MovingBlocks.

the class TerasologyEngine method initManagers.

private void initManagers() {
    changeStatus(TerasologyEngineStatus.INITIALIZING_MODULE_MANAGER);
    TypeRegistry.WHITELISTED_CLASSES = ExternalApiWhitelist.CLASSES.stream().map(Class::getName).collect(Collectors.toSet());
    TypeRegistry.WHITELISTED_PACKAGES = ExternalApiWhitelist.PACKAGES;
    ModuleManager moduleManager = new ModuleManager(rootContext.get(Config.class), classesOnClasspathsToAddToEngine);
    ModuleTypeRegistry typeRegistry = new ModuleTypeRegistry(moduleManager.getEnvironment());
    rootContext.put(ModuleTypeRegistry.class, typeRegistry);
    rootContext.put(TypeRegistry.class, typeRegistry);
    rootContext.put(ModuleManager.class, moduleManager);
    changeStatus(TerasologyEngineStatus.INITIALIZING_LOWLEVEL_OBJECT_MANIPULATION);
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    rootContext.put(ReflectFactory.class, reflectFactory);
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    rootContext.put(CopyStrategyLibrary.class, copyStrategyLibrary);
    rootContext.put(TypeHandlerLibrary.class, TypeHandlerLibraryImpl.forModuleEnvironment(moduleManager, typeRegistry));
    changeStatus(TerasologyEngineStatus.INITIALIZING_ASSET_TYPES);
    assetTypeManager = new AutoReloadAssetTypeManager();
    rootContext.put(ModuleAwareAssetTypeManager.class, assetTypeManager);
    rootContext.put(AssetManager.class, assetTypeManager.getAssetManager());
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) ModuleTypeRegistry(org.terasology.reflection.ModuleTypeRegistry) Config(org.terasology.engine.config.Config) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) ModuleManager(org.terasology.engine.core.module.ModuleManager) AutoReloadAssetTypeManager(org.terasology.gestalt.assets.module.autoreload.AutoReloadAssetTypeManager)

Example 5 with ReflectionReflectFactory

use of org.terasology.reflection.reflect.ReflectionReflectFactory in project Terasology by MovingBlocks.

the class TerasologyEngine method initManagers.

private void initManagers() {
    changeStatus(TerasologyEngineStatus.INITIALIZING_MODULE_MANAGER);
    ModuleManager moduleManager = new ModuleManagerImpl(rootContext.get(Config.class));
    rootContext.put(ModuleManager.class, moduleManager);
    changeStatus(TerasologyEngineStatus.INITIALIZING_LOWLEVEL_OBJECT_MANIPULATION);
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    rootContext.put(ReflectFactory.class, reflectFactory);
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    rootContext.put(CopyStrategyLibrary.class, copyStrategyLibrary);
    rootContext.put(TypeSerializationLibrary.class, new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary));
    changeStatus(TerasologyEngineStatus.INITIALIZING_ASSET_TYPES);
    assetTypeManager = new ModuleAwareAssetTypeManager();
    rootContext.put(ModuleAwareAssetTypeManager.class, assetTypeManager);
    rootContext.put(AssetManager.class, assetTypeManager.getAssetManager());
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) ModuleManagerImpl(org.terasology.engine.module.ModuleManagerImpl) Config(org.terasology.config.Config) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) ModuleManager(org.terasology.engine.module.ModuleManager)

Aggregations

ReflectionReflectFactory (org.terasology.reflection.reflect.ReflectionReflectFactory)8 CopyStrategyLibrary (org.terasology.reflection.copy.CopyStrategyLibrary)7 ReflectFactory (org.terasology.reflection.reflect.ReflectFactory)5 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)4 EntitySystemLibrary (org.terasology.entitySystem.metadata.EntitySystemLibrary)3 Before (org.junit.Before)2 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)2 ContextImpl (org.terasology.context.internal.ContextImpl)2 ModuleManager (org.terasology.engine.core.module.ModuleManager)2 ModuleManager (org.terasology.engine.module.ModuleManager)2 PojoPrefabManager (org.terasology.entitySystem.prefab.internal.PojoPrefabManager)2 AutoReloadAssetTypeManager (org.terasology.gestalt.assets.module.autoreload.AutoReloadAssetTypeManager)2 Benchmark (org.terasology.benchmark.Benchmark)1 PrintToConsoleCallback (org.terasology.benchmark.PrintToConsoleCallback)1 Config (org.terasology.config.Config)1 Config (org.terasology.engine.config.Config)1 ContextImpl (org.terasology.engine.context.internal.ContextImpl)1 EnvironmentSwitchHandler (org.terasology.engine.core.bootstrap.EnvironmentSwitchHandler)1 EntitySystemLibrary (org.terasology.engine.entitySystem.metadata.EntitySystemLibrary)1 ModuleManagerImpl (org.terasology.engine.module.ModuleManagerImpl)1