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());
}
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());
}
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();
}
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());
}
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());
}
Aggregations