package Ġno . nav . pto . ve ilar b rem ot est ore Ċ Ċ import Ġcom . amazonaws . auth . AWS Static Credentials Provider Ċ import Ġcom . amazonaws . auth . Basic AWSC redentials Ċ import Ġcom . amazonaws . client . builder . Aws Client Builder Ċ import Ġcom . amazonaws . services . s 3 . Amazon S 3 Client Builder Ċ import Ġno . nav . pto . ve ilar b rem ot est ore . storage . Storage Service Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ private Ġval Ġlog Ġ= ĠLoggerFactory . getLogger (" ve ilar b rem ot est ore . Application ") Ċ Ċ data Ġclass ĠApplication State ( var Ġrunning : ĠBoolean Ġ= Ġtrue , Ġvar Ġinitialized : ĠBoolean Ġ= Ġfalse ) Ċ Ċ fun Ġmain () Ġ{ ĊĠĠĠ Ġval Ġconfiguration Ġ= ĠConfiguration () ĊĠĠĠ Ġval Ġcredentials Ġ= ĠBasic AWSC redentials ( configuration . s 3 AccessKey , Ġconfiguration . s 3 SecretKey ) ĊĠĠĠ Ġval Ġs 3 Ġ= ĠAmazon S 3 Client Builder . standard () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Endpoint Configuration ( Aws Client Builder . Endpoint Configuration ( configuration . s 3 Url , Ġconfiguration . s 3 Region )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. enable Path Style Access () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Credentials ( AWS Static Credentials Provider ( credentials )). build () ĊĊĠĠĠ Ġval Ġapplication State Ġ= ĠApplication State () ĊĠĠĠ Ġval Ġapplication Server Ġ= Ġcreate HttpServer ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication State Ġ= Ġapplication State , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprovider Ġ= ĠStorage Service ( s 3 , Ġconfiguration . namespace ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfiguration Ġ= Ġconfiguration ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠRuntime . get Runtime (). add Shutdown Hook ( Thread Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info (" Shutdown Ġhook Ġcalled , Ġshut ting Ġdown Ġgrace fully ") ĊĠĠĠĠĠĠĠ Ġapplication State . initialized Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġapplication Server . stop ( 5 0 0 0 , Ġ 5 0 0 0 ) ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġapplication Server . start ( wait Ġ= Ġtrue ) Ċ } Ċ