This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JWTInterceptor implements HandlerInterceptor { | |
@Value("${jwt.key}") | |
private String jwtKey; | |
@Autowired | |
private BlackListingService blackListingService; | |
@Autowired | |
private UserRequestScopedBean userRequestScopedBean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Resurrected { | |
private static final Set<Resurrected> resurrected = new HashSet<>(); | |
@Override | |
protected void finalize() throws Throwable { | |
resurrected.add(this); // Resurrect the object by creating a new reference | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void finalize() throws Throwable { | |
// closing resources here.... | |
super.finalize(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileInputStream input = null; | |
try { | |
input = new FileInputStream(file1); | |
input.close(); input = null; | |
} finally { | |
if (input != null) input.close(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sessionStorage.setItem('pets', '{"pets":{"fido":{"species":"dog"}}}'); | |
const store = createStore(); | |
const persister = createSessionPersister(store, 'pets'); | |
await persister.load(); | |
console.log(store.getTables()); | |
// -> {pets: {fido: {species: 'dog'}}} | |
sessionStorage.clear(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const store = createStore().setTable('pets', { | |
fido: {species: 'dog'}, | |
felix: {species: 'cat'}, | |
cujo: {species: 'dog'}, | |
}); | |
const indexes = createIndexes(store); | |
indexes.setIndexDefinition( | |
'bySpecies', // indexId | |
'pets', // tableId to index | |
'species', // cellId to index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const store = createStore().setTables({pets: {fido: {sold: false}}}); | |
const checkpoints = createCheckpoints(store); | |
checkpoints.setSize(200); | |
store.setCell('pets', 'fido', 'sold', true); | |
checkpoints.addCheckpoint('sale'); | |
console.log(store.getCell('pets', 'fido', 'sold')); | |
// -> true | |
checkpoints.goBackward(); | |
console.log(store.getCell('pets', 'fido', 'sold')); | |
// -> false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const listenerId = store.addTableListener('pets', () => | |
console.log('changed'), | |
); | |
store.setCell('pets', 'fido', 'sold', false); | |
// -> 'changed' | |
store.delListener(listenerId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const store = createStore() | |
.setTables({pets: {fido: {species: 'dog'}}}) | |
.setSchema({ | |
pets: { | |
species: {type: 'string'}, | |
sold: {type: 'boolean', default: false}, | |
}, | |
}); | |
console.log(store.getTables()); | |
// -> {pets: {fido: {species: 'dog', sold: false}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// r2dbc | |
public Mono<OrderDTO> addOrder(@RequestParam("bookIsbn") String bookIsbn, @RequestParam("firstName") String firstName) { | |
return Mono.just(UUID.randomUUID()).flatMap(uuid -> { | |
log.info("addOrder() {} running", uuid); | |
Mono<User> user = userRepository.findByFirstName(firstName); | |
Mono<Book> book = bookRepository.findByIsbn(bookIsbn); | |
return Mono.zip(user, book).flatMap(zipFlux -> { | |
log.info("addOrder() {} I've got user and book", uuid); |