use of org.springframework.context.event.EventListener in project metacat by Netflix.
the class SNSNotificationServiceImpl method notifyOfPartitionDeletion.
/**
* {@inheritDoc}
*/
@Override
@EventListener
public void notifyOfPartitionDeletion(@NonNull final MetacatDeleteTablePartitionPostEvent event) {
log.debug("Received DeleteTablePartition event {}", event);
final String name = event.getName().toString();
final long timestamp = event.getRequestContext().getTimestamp();
final String requestId = event.getRequestContext().getId();
DeletePartitionMessage message = null;
try {
for (final String partitionId : event.getPartitionIds()) {
message = new DeletePartitionMessage(UUID.randomUUID().toString(), timestamp, requestId, name, partitionId);
this.publishNotification(this.partitionTopicArn, message);
this.registry.counter(this.registry.createId(Metrics.CounterSNSNotificationPartitionDelete.name()).withTags(Metrics.statusSuccessMap)).increment();
log.debug("Published delete partition message {} on {}", message, this.partitionTopicArn);
}
} catch (final Exception e) {
handleException(event.getName(), "Unable to publish partition deletion notification", Metrics.CounterSNSNotificationPartitionDelete.name(), message, e);
}
UpdateTablePartitionsMessage tableMessage = null;
try {
// Publish a global message stating how many partitions were updated for the table to the table topic
tableMessage = new UpdateTablePartitionsMessage(UUID.randomUUID().toString(), timestamp, requestId, name, new TablePartitionsUpdatePayload(0, event.getPartitionIds().size()));
this.publishNotification(this.tableTopicArn, tableMessage);
this.registry.counter(this.registry.createId(Metrics.CounterSNSNotificationTablePartitionDelete.name()).withTags(Metrics.statusSuccessMap)).increment();
} catch (final Exception e) {
this.handleException(event.getName(), "Unable to publish table partition delete notification", Metrics.CounterSNSNotificationTablePartitionDelete.name(), tableMessage, e);
}
}
use of org.springframework.context.event.EventListener in project metacat by Netflix.
the class SNSNotificationServiceImpl method notifyOfTableDeletion.
/**
* {@inheritDoc}
*/
@Override
@EventListener
public void notifyOfTableDeletion(@NonNull final MetacatDeleteTablePostEvent event) {
log.debug("Received DeleteTableEvent {}", event);
DeleteTableMessage message = null;
try {
message = new DeleteTableMessage(UUID.randomUUID().toString(), event.getRequestContext().getTimestamp(), event.getRequestContext().getId(), event.getName().toString(), event.getTable());
this.publishNotification(this.tableTopicArn, message);
this.registry.counter(this.registry.createId(Metrics.CounterSNSNotificationTableDelete.name()).withTags(Metrics.statusSuccessMap)).increment();
} catch (final Exception e) {
this.handleException(event.getName(), "Unable to publish delete table notification", Metrics.CounterSNSNotificationTableDelete.name(), message, e);
}
}
use of org.springframework.context.event.EventListener in project SpringStepByStep by JavaProgrammerLB.
the class UserServiceImpl method afterApplicationReady.
@Override
@EventListener
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void afterApplicationReady(ApplicationReadyEvent event) {
if (!userRepository.findByEmail(adminEmail).isPresent()) {
User user = new User();
user.setEmail(adminEmail);
user.setName(adminName);
user.setPassword(adminPassword);
user.setPassword(passwordEncoder.encode(adminPassword));
user.getRoles().add(Role.ADMIN);
userRepository.save(user);
}
}
use of org.springframework.context.event.EventListener in project dhis2-core by dhis2.
the class DefaultSchemaService method handleContextRefresh.
@EventListener
public void handleContextRefresh(ContextRefreshedEvent contextRefreshedEvent) {
I18n i18n = i18nManager.getI18n();
for (SchemaDescriptor descriptor : descriptors) {
Schema schema = descriptor.getSchema();
if (sessionFactory.getClassMetadata(schema.getKlass()) != null) {
schema.setPersisted(true);
}
schema.setDisplayName(i18n.getString("schema_class_" + schema.getKlass().getName()));
if (schema.getProperties().isEmpty()) {
schema.setPropertyMap(Maps.newHashMap(propertyIntrospectorService.getPropertiesMap(schema.getKlass())));
}
classSchemaMap.put(schema.getKlass(), schema);
singularSchemaMap.put(schema.getSingular(), schema);
pluralSchemaMap.put(schema.getPlural(), schema);
updateSelf(schema);
schema.getPersistedProperties();
schema.getNonPersistedProperties();
schema.getReadableProperties();
schema.getEmbeddedObjectProperties();
}
}
use of org.springframework.context.event.EventListener in project cas by apereo.
the class DefaultCasEventListener method handleCasAuthenticationPolicyFailureEvent.
/**
* Handle cas authentication policy failure event.
*
* @param event the event
*/
@EventListener
public void handleCasAuthenticationPolicyFailureEvent(final CasAuthenticationPolicyFailureEvent event) {
if (this.casEventRepository != null) {
final CasEvent dto = prepareCasEvent(event);
dto.setPrincipalId(event.getAuthentication().getPrincipal().getId());
dto.putId(CasAuthenticationPolicyFailureEvent.class.getSimpleName());
this.casEventRepository.save(dto);
}
}
Aggregations