Search This Blog

Thursday, 31 October 2013

And They All Work Together

In the previous post we had a look at the invokeAny method that allowed us to get the result from the first thread to complete. ExecutorService also provides us with the invokeAll method that will execute all the tasks given. Consider the below code:

Wednesday, 30 October 2013

Anybody just give me the result !!

I came across the invokeAny method of ExecutorService and liked the idea a lot. There could always be the case that you have a set of input of which you care to see any one processed. Once we have an output the remaining results don't matter.
Accordingly I decided to implement such a case with the invokeAny method of  ExecutorService.

Saturday, 26 October 2013

Understanding volatile

Before I start - I have never used volatile nor can I claim to well versed at it. To be more accurate my understanding of the java volatile keyword is zilch. Part of the reason is that I never used it. Did not use hence did not bother learning.
So to understand the concept I searched the net. I found articles where explanations where given. These articles were then followed by comments claiming that the explanation was wrong/incomplete. Some of the posts only managed to confuse me further.
So when I found something that made sense, I decided to jot it down...........

Tuesday, 22 October 2013

Interrupting a Thread

I was asked to do a revision in threads a while back - so as to then start understanding the concurrency package. I decided to do it from the Sun's Concurrency tutorial. I liked the part of sleeping and interrupting threads. Consider the simple program below:

Saturday, 19 October 2013

Logout Settings in Spring Security

We have seen how to configure login behavior for our application. How to let Spring manage authentication, session creation, authorization etc.The logical end to the flow would be to logout. A normal logout would involve releasing any resources, destroying sessions etc - and a logout page.

Thursday, 17 October 2013

form-login Custom Options

In the previous post we saw how to set the login page as a custom one. There are other configuration options available too. For instance:
<form-login login-page="/login.jsp" authentication-failure-url="loginError.jsp"/>
If now login fails, then user will be redirected to the above failure URL. Consider the logs generated when I entered invalid credentials:

Wednesday, 16 October 2013

Spring Security - The Login Flow

In the last post we saw how Spring security can be used to secure web applications. I used both the form login and the basic login to get the user authentication done.
While basic login is pretty much client system dependent, the form login can be tweaked and customized. I decided to try out the options.

Tuesday, 15 October 2013

Saving an Enum in JPA

Consider the below entity:
@Table(name = "STUDENT")
public class Student {
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

Monday, 7 October 2013

SOAP Action Header

How does a simple WSDL file look?
There will be a portType element that is like an interface definition of the web-service. It would tell us :

Saturday, 5 October 2013

SOAP Header at Client

In the previous post we saw CXF endpoints could set a soap header in the response. But what if the server needs to process a soap header ? The CXF website recommends using interceptors for reading headers. As I still do not have a very clear idea about the concept I decided to look for a different solution.

Friday, 4 October 2013

Headers in SOAP

What is a soap header ?
From w3schools:
The optional SOAP Header element contains application-specific information (like 
authentication, payment, etc) about the SOAP message. If the Header element is 
present, it must be the first child element of the Envelope element. All immediate 
child elements of the Header element must be namespace-qualified.
So the soap message would be something like :