当前位置: 首页>>代码示例>>Java>>正文


Java EventSourcingRepository类代码示例

本文整理汇总了Java中org.axonframework.eventsourcing.EventSourcingRepository的典型用法代码示例。如果您正苦于以下问题:Java EventSourcingRepository类的具体用法?Java EventSourcingRepository怎么用?Java EventSourcingRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EventSourcingRepository类属于org.axonframework.eventsourcing包,在下文中一共展示了EventSourcingRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("sampleContext.xml");
    commandGateway = applicationContext.getBean(CommandGateway.class);
    repository = (EventSourcingRepository<ToDoItem>) applicationContext.getBean("toDoRepository");

    try {
      ToDoItemDemoRunner runner = new ToDoItemDemoRunner();
      runner.run();
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } finally {
      TimeUnit.SECONDS.sleep(1l);
      System.exit(0);
    }

  }
 
开发者ID:benwilcock,项目名称:axon-cqrs-sample,代码行数:18,代码来源:ToDoItemDemoRunner.java

示例2: registerAggregateFactories

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> void registerAggregateFactories(
		final RegistrableAggregateSnaphotter snapshotter) {
	Set<Annotation> qualifiers = ImmutableSet.copyOf(getQualifiers());
	for (AggregateRootInfo aggregateRoot : aggregateRootsInfo) {
		if (aggregateRoot.matchQualifiers(QualifierType.SNAPSHOTTER, qualifiers)) {
			Set<Annotation> factoryQualifiers = aggregateRoot
					.getQualifiers(QualifierType.REPOSITORY);
			Type type = TypeUtils.parameterize(EventSourcingRepository.class,
					aggregateRoot.getType());
			EventSourcingRepository<T> repository = (EventSourcingRepository<T>) CdiUtils
					.getReference(getBeanManager(), type, factoryQualifiers);
			if (repository != null) {
				snapshotter.registerAggregateFactory(repository.getAggregateFactory());
			}
			new EventCountSnapshotTriggerDefinition(snapshotter, 10);
		}
	}
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:20,代码来源:AutoConfiguringAggregateSnapshotterProducer.java

示例3: registerRepositories

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
protected <T> void registerRepositories(X commandBus) {
	final Set<Annotation> qualifiers = ImmutableSet.copyOf(getQualifiers());
	for (AggregateRootInfo aggregateRootInfo : aggregateRootsInfo) {
		if (aggregateRootInfo.matchQualifiers(QualifierType.COMMAND_BUS, qualifiers)) {
			Class<T> aggregateType = (Class<T>) aggregateRootInfo.getType();
			ParameterizedType repositoryType = TypeUtils.parameterize(EventSourcingRepository.class,
					aggregateType);
			EventSourcingRepository<T> repository = (EventSourcingRepository<T>) CdiUtils.getReference(
					getBeanManager(), repositoryType, aggregateRootInfo.getQualifiers(QualifierType.REPOSITORY));
			AggregateAnnotationCommandHandler<?> aggregateAnnotationCommandHandler = new AggregateAnnotationCommandHandler<>(aggregateType,
					repository);
			aggregateAnnotationCommandHandler.subscribe(commandBus);
			if (commandBus instanceof DisruptorCommandBus) {
				((DisruptorCommandBus) commandBus).createRepository(repository.getAggregateFactory());
			}
		}
	}
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:20,代码来源:AutoConfiguringCommandBusProducer.java

示例4: createInjector

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
private Injector createInjector() {
    return Guice.createInjector(new AbstractModule() {
        @Override
        protected void configure() {
            // Event store
            CommandBus commandBus = new SimpleCommandBus();
            CommandGateway commandGateway = new DefaultCommandGateway(commandBus);

            EventStore eventStore = new FileSystemEventStore(new SimpleEventFileResolver(eventStoreFolder));

            EventBus eventBus = new SimpleEventBus();

            EventSourcingRepository repository = new EventSourcingRepository(Rating.class, eventStore);
            repository.setEventBus(eventBus);

            // Event store handlers
            AggregateAnnotationCommandHandler.subscribe(Rating.class, repository, commandBus);
            AnnotationEventListenerAdapter.subscribe(new RatingEventHandler(), eventBus);

            // Load twist config
            TwistProvider twistProvider = new TwistProvider(twistsDataFile);

            // Twist rating
            TwistRating twistRating = new TwistRatingEventStore(commandGateway, twistProvider);


            // Bootstrap aggregates
            twistProvider.getTwists().stream().forEach(twist -> {
                commandGateway.send(new CreateTwistCommand(twist.id));
            });

            // Set up bindings
            bind(TwistRating.class).toInstance(twistRating);
            bind(TwistProvider.class).toInstance(twistProvider);

            Logger.info("Injector configured");
        }
    });
}
 
开发者ID:tipsy,项目名称:twistrating,代码行数:40,代码来源:Global.java

示例5: orderEventSourcingRepository

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@Bean
EventSourcingRepository<OrderAggregate> orderEventSourcingRepository() {
  EventSourcingRepository<OrderAggregate> repo = new EventSourcingRepository<OrderAggregate>(
      OrderAggregate.class, eventStore());
  repo.setEventBus(eventBus());
  return repo;
}
 
开发者ID:drm317,项目名称:cloud-native-reference,代码行数:8,代码来源:AxonConfiguration.java

示例6: repositoryFor

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
private <R extends EventSourcedAggregateRoot>
EventSourcingRepository<R> repositoryFor(
        final Class<R> beanType) {
    final EventSourcingRepository<R> repository
            = new EventSourcingRepository<>(beanType, eventStore);
    repository.setEventBus(eventBus);
    subscribe(beanType, repository, commandBus);
    return repository;
}
 
开发者ID:binkley,项目名称:axon-spring-boot-starter,代码行数:10,代码来源:EventSourcingRepositoryRegistrar.java

示例7: respository

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@Bean(name = "testAggregateEventsourcingRepository")
@Autowired
public EventSourcingRepository<MyTestAggregate> respository(final EventStore eventStore, final EventBus eventBus, final Cache cache) {
   final CachingEventSourcingRepository<MyTestAggregate> repository = new CachingEventSourcingRepository<>(new GenericAggregateFactory<>(MyTestAggregate.class), eventStore);
   repository.setCache(cache);
   repository.setEventBus(eventBus);
   return repository;
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:9,代码来源:TestConfiguration.java

示例8: respository

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@Bean(name = "testAggregateEventsourcingRepository")
@Autowired
public EventSourcingRepository<MyTestAggregate> respository(final EventStore eventStore, final EventBus eventBus) {
   final EventSourcingRepository<MyTestAggregate> repository = new EventSourcingRepository<>(MyTestAggregate.class, eventStore);
   repository.setEventBus(eventBus);
   return repository;
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:8,代码来源:TestConfiguration.java

示例9: productAggregateCommandHandler

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
/**
 * This method registers your Aggregate Root as a @CommandHandler
 *
 * @return
 */
@Bean
AggregateAnnotationCommandHandler<ProductAggregate> productAggregateCommandHandler(EventSourcingRepository<ProductAggregate> eventSourcingRepository, CommandBus commandBus) {
    AggregateAnnotationCommandHandler<ProductAggregate> handler = new AggregateAnnotationCommandHandler<ProductAggregate>(
            ProductAggregate.class,
            eventSourcingRepository,
            commandBus);
    return handler;
}
 
开发者ID:benwilcock,项目名称:cf-cqrs-microservice-sampler,代码行数:14,代码来源:AxonConfiguration.java

示例10: libraryRepository

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@Bean
public EventSourcingRepository<Library> libraryRepository() {

	DefaultMongoTemplate template = new DefaultMongoTemplate(axonconf.mongo);
	MongoEventStore eventStore = new MongoEventStore(template
			);
	EventSourcingRepository<Library> repository = new EventSourcingRepository<Library>(
			Library.class, eventStore);
	repository.setEventBus(axonconf.eventBus());
	return repository;
}
 
开发者ID:yizhuan,项目名称:library-saga,代码行数:12,代码来源:LibraryConfiguration.java

示例11: loadAggregate

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
private static void loadAggregate(EventSourcingRepository repository, String toDoItemId) {

    System.out.println("\n------------------- LOADING AGGREGATE -----------------------");
    System.out.println("Loading 'ToDoItem' with Id: " + toDoItemId);
    System.out.println("Events being re-applied...");
    UnitOfWork unitOfWork = new DefaultUnitOfWorkFactory().createUnitOfWork();
    ToDoItem item = (ToDoItem) repository.load(toDoItemId);
    unitOfWork.commit();
    System.out.println("Loaded...");
    System.out.println(
        "ToDoItem (" + item.getId() + ") " + "'" + item.getDescription() + "' " + "Complete?: "
            + item.isComplete());
    System.out.println("---------------------- AGGREGATE LOADED -----------------------\n");
  }
 
开发者ID:benwilcock,项目名称:axon-cqrs-sample,代码行数:15,代码来源:ToDoItemDemoRunner.java

示例12: postProcessAfterInitialization

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

    if (EventSourcedAggregateRoot.class.isAssignableFrom(bean.getClass())) {
        AggregateRoot aggregateRoot = (AggregateRoot) bean;
        EventSourcingRepository repository = new EventSourcingRepository(bean.getClass(), eventStore);
        repository.setEventBus(eventBus);
        beanFactory.registerSingleton(beanName + "Repository", repository);
        AggregateAnnotationCommandHandler.subscribe(aggregateRoot.getClass(), repository, commandBus);
    }

    return bean;
}
 
开发者ID:tomsoete,项目名称:spring-boot-starter-axon,代码行数:14,代码来源:AutoEventSourcingRepositoryCreator.java

示例13: autoEventSourcingRepositoryCreated

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@Test
public void autoEventSourcingRepositoryCreated(){
    this.context.register(AxonAutoConfiguration.class);
    this.context.register(DummyAggregateRoot.class);
    this.context.refresh();
    assertNotNull(this.context.getBean(EventSourcingRepository.class));
}
 
开发者ID:tomsoete,项目名称:spring-boot-starter-axon,代码行数:8,代码来源:AxonAutoConfigurationTest.java

示例14: createRepositoryBean

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> Bean<EventSourcingRepository<T>> createRepositoryBean(
		final BeanManager bm, final AggregateRootInfo aggregateRootInfo) {

	BeanBuilder<T> aggregateRootBean = new BeanBuilder<T>(bm)
			.readFromType((AnnotatedType<T>) aggregateRootInfo.getAnnotatedType(bm));

	ParameterizedType type = TypeUtils.parameterize(EventSourcingRepository.class,
			aggregateRootInfo.getType());

	BeanBuilder<EventSourcingRepository<T>> builder = new BeanBuilder<EventSourcingRepository<T>>(
			bm)
					.beanClass(EventSourcingRepository.class)
					.qualifiers(CdiUtils.normalizedQualifiers(
							aggregateRootInfo.getQualifiers(QualifierType.REPOSITORY)))
					.alternative(aggregateRootBean.isAlternative())
					.nullable(aggregateRootBean.isNullable())
					.types(CdiUtils.typeClosure(type))
					.scope(aggregateRootBean.getScope())
					.stereotypes(aggregateRootBean.getStereotypes())
					.beanLifecycle(
							new RepositoryContextualLifecycle<T, EventSourcingRepository<T>>(bm,
									aggregateRootInfo));

	if (!Strings.isNullOrEmpty(aggregateRootBean.getName())) {
		builder.name(aggregateRootBean.getName() + "Repository");
	}
	return builder.create();
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:30,代码来源:AxonCdiExtension.java

示例15: create

import org.axonframework.eventsourcing.EventSourcingRepository; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public R create(final Bean<R> bean, final CreationalContext<R> creationalContext) {
	R repository = (R) new EventSourcingRepository<T>(aggregateFactory(),
			eventStore(),
			snapshotTriggerDefinition());
	return repository;
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:9,代码来源:RepositoryContextualLifecycle.java


注:本文中的org.axonframework.eventsourcing.EventSourcingRepository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。