java - Periodically recreating an Object -
i'm trying integrate service service ( service b). in order create client service b, need token , utilize while create client. token expires every 72 hours. 1 time token expires, client expires. need recreate client.
right now, client object singleton, instantiated spring during start up. want recreate object every 72 hours.
i'm thinking of using singleton, synchronized getinstance. there improve way this?
singleton there best way this. when token, save static timestamp variable time when got token. then, in getinstance() function, check timestamp against current time see if more 72 hours old. if is, grab new token , recreate instance before homecoming it, if not, homecoming instance.
i've done similar using oauth authentication, , found simple , effective method.
java spring java-ee spring-mvc singleton
No comments:
Post a Comment