Spring security: adding “On successful login event listener”

You need to define a Spring Bean which implements ApplicationListener. Then, in your code, do something like this: public void onApplicationEvent(ApplicationEvent appEvent) { if (appEvent instanceof AuthenticationSuccessEvent) { AuthenticationSuccessEvent event = (AuthenticationSuccessEvent) appEvent; UserDetails userDetails = (UserDetails) event.getAuthentication().getPrincipal(); // …. } } Then, in your applicationContext.xml file, just define that bean and it will automatically … Read more

Directory listener in Java

Since Java 1.7 you can use the Watch Service API to register for directory events. It is part of Java’s New I/O (NIO) library and does not require any additional resources. An example how to use the API can be found in the official documentation. After registering the WatchService you can retrieve events for the … Read more

jquery resize listener on a div

As the thread poelinca provided suggests, there are some nice plugins available for this functionality. If you don’t like the plugin idea, another simple solution would be to simply trigger a “resize” event on the div whenever the content is modified. Then you could monitor it with resize() as expected, utilizing an elegant observer pattern. … Read more

Android – How to achieve setOnClickListener in Kotlin?

There are six ways to use SetOnClickListener: First: button.setOnClickListener { // Do some work here } Second: button.setOnClickListener(object : View.OnClickListener { override fun onClick(view: View?) { // Do some work here } }) Third: button.setOnClickListener(View.OnClickListener { view -> // Do some work here }) Fourth: class MainActivity : AppCompatActivity(), View.OnClickListener{ lateinit var button : Button … Read more