Posts

Showing posts from February, 2017

OAuth 2 explained theory

What is OAuth2 This protocol allows third-party applications to grant limited access to an HTTP service, either on behalf of a resource owner or by allowing the third-party application to obtain access on its own behalf. Access is requested by a client, it can be a website or a mobile application for example. Roles The Third-Party Application: "Client" The client is the application that is attempting to get access to the user's account. It needs to get permission from the user before it can do so. The API: "Resource Server" The resource server is the API server used to access the user's information. The Authorization Server This is the server that presents the interface where the user approves or denies the request. In smaller implementations, this may be the same server as the API server, but larger scale deployments will often build this as a separate component. The User: "Resource Owner" The resource owne...

invoke vs invokeAll() in java executorservice

import java.util.ArrayList ; import java.util.List ; import java.util.concurrent.Callable ; import java.util.concurrent.ExecutionException ; import java.util.concurrent.ExecutorService ; import java.util.concurrent.Executors ; import java.util.concurrent.Future ; import java.util.concurrent.atomic.AtomicInteger ; public class ExecutorInvokeAll { public void runApp () throws InterruptedException , ExecutionException { // variable to store the sum AtomicInteger sum = new AtomicInteger (); // Use our friendly neighbourhood factory method of the Executors. ExecutorService executorService = Executors . newFixedThreadPool( 10 ); List< Callable< AtomicInteger > > callableList = new ArrayList< Callable< AtomicInteger > > (); for ( int count = 0 ; count <= 100 ;count ++ ) { callableList . add(getInstanceOfCallable(count,sum)); } // returns only ...

Spring Boot filter and interceptor

Image

Java8 Stream Api

Image
http://www.oracle.com/technetwork/articles/java/ma14-java-se-8-streams-2177646.html Streams are  Monads , thus playing a big part in bringing  functional programming  to Java: In functional programming, a monad is a structure that represents computations defined as sequences of steps. A type with a monad structure defines what it means to chain operations, or nest functions of that type together. Stream operations are either intermediate or terminal. Intermediate operations return a stream so we can chain multiple intermediate operations without using semicolons. Terminal operations are either void or return a non-stream result. In the above example  filter ,  map and  sorted  are intermediate operations whereas  forEach  is a terminal operation Use stream operations to express sophisticated data processing queries. What would you do without collections? Nearly every Java application  makes  and  processes  ...