tag:blogger.com,1999:blog-77481775006678313272018-02-24T16:45:55.104+05:30Programming Tutorials by SourceTricksSourceTrickshttp://www.blogger.com/profile/17421383822093860960noreply@blogger.comBlogger180125tag:blogger.com,1999:blog-7748177500667831327.post-7281766078530866702017-04-16T15:57:00.001+05:302017-04-16T16:03:17.938+05:30Spring Boot micro service as a Docker container inside Kubernetes on Windows – Containerize the micro service and deploy This section provides the steps needed to run the Spring Boot micro service as a Docker container inside Kubernetes. Copy the MyFirstApp-0.0.1-SNAPSHOT.jar built in the previous section to another folder say C:\MyFirstApp. Let us now create a Docker container using this standalone jar. We need to introduce the Docker file. Create a file with name Dockerfile in C:\MyFirstApp and add the SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com13tag:blogger.com,1999:blog-7748177500667831327.post-68640538242061793602017-04-16T15:29:00.001+05:302017-04-16T16:03:08.702+05:30Spring Boot micro service as a Docker container inside Kubernetes on Windows – Developing a simple Micro Service using Spring Boot This section provides a quick introduction on how to develop a simple micro service which exposes a REST API using Spring Boot. The intent is to do a simple “/sayhello” API which returns “Hello” as the output. Open the Spring Tool Suite (STS) and click on Spring Starter Project. Create a Spring Starter Project Fill in the application details. For this example we would use Java 8 and SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com3tag:blogger.com,1999:blog-7748177500667831327.post-68532644031116827042017-04-16T12:34:00.000+05:302017-04-16T16:02:46.145+05:30Spring Boot micro service as a Docker container inside Kubernetes on Windows – Installing tools This section lists the pre-requisite tools needed to run Spring Boot, Dockers and Kubernetes. Installation steps needed for each of the tools is summarized. Apache Maven  Maven is the build tool used for this article. Maven is based on the concept of a project object model (POM) Maven can manage build, reporting and documentation from a central piece of information. Download Maven from SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com1tag:blogger.com,1999:blog-7748177500667831327.post-59064400884793467572017-04-16T12:00:00.001+05:302017-04-16T16:02:59.161+05:30Spring Boot micro service as a Docker container inside Kubernetes on Windows - Introduction This page provides a quick reference on the steps needed to run a Spring Boot application as a Docker container inside Kubernetes on Windows. This would be ready reference for anyone wanting to experiment with micro services architecture. How to run a Spring Boot application as a Docker container inside Kubernetes on Windows - Introduction This section provides a quick introduction to SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com2tag:blogger.com,1999:blog-7748177500667831327.post-22409204260310420632015-02-04T21:33:00.000+05:302015-03-01T21:27:22.801+05:30Scala TraitsScala Traits defines object types by providing signature of the supported methods. This tutorial provides a quick introduction to Scala Traits. Some key points on Scala Traits.Scala Traits are like interfaces in Java.  Scala Traits can have default implementations for certain methods unlike Java interfaces.  Scala Traits don't have any constructor parameters. Scala class inherits only one super SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com10tag:blogger.com,1999:blog-7748177500667831327.post-60758984883274978032015-02-01T00:34:00.000+05:302015-03-01T21:47:14.502+05:30Scala Case ClassesScala supports an interesting construct called case classes with the intent of creating immutable objects that can be used in pattern matching. This article provides a quick introduction to Scala case classes with examples. A case class is created by adding the keyword case before the class definition. case class Employee Scala Case Classes can be used to automatically generate boilerplate SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com9tag:blogger.com,1999:blog-7748177500667831327.post-87167117434179019502015-01-17T10:03:00.004+05:302015-03-01T21:47:30.739+05:30Scala ClassesLike any object oriented programming language Scala allows to define classes which is the code template for creating objects. This article provides a quick introduction to work with Scala classes.Scala Classes, Fields and MethodsScala Class is the extensible static code template that can be initiated into objects at run time. Class definition in Scala can take parameters like constructor SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com2tag:blogger.com,1999:blog-7748177500667831327.post-75843237262846913872015-01-10T12:43:00.001+05:302015-03-02T05:41:50.799+05:30Scala Currying FunctionsCurrying converts a function with multiple arguments into a series of a functions with single argument. This article provides an introduction to Scala Currying Functions. Scala Currying Functions is often confused with Scala Partially Applied Functions. Both currying and partial application enables creation of derived functions with smaller number of arguments. Key difference is that in SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com6tag:blogger.com,1999:blog-7748177500667831327.post-44934677652243939122014-12-13T18:07:00.000+05:302015-03-02T05:34:51.724+05:30Scala Partially Applied FunctionsTo invoke functions requires us to specify all the function parameters. Scala provides a construct called Partially Applied Functions where a function invocation can be reused by retaining some of the parameters without the need to type them again. Partial application enables conversion of a function with multiple arguments into one with fewer arguments with some values provided in advance. Let SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com2tag:blogger.com,1999:blog-7748177500667831327.post-20123903566081787012014-12-07T07:25:00.000+05:302015-03-02T05:41:35.922+05:30Scala Anonymous FunctionsScala  supports a facility to avoid naming functions. This provides convenience when working with higher order functions where the need is to pass a function as a parameter to another function. These are referred to as anonymous functions or function literals.  A simple anonymous function. (x : Int) => x * x Here x : Int is the parameter and right side is the body of the function. An example SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-74578845450529781192014-12-06T08:19:00.002+05:302015-03-02T05:41:20.529+05:30Scala Higher Order FunctionsScala is also a functional programming language and allows the definition of higher order functions. Functions that take other functions as parameters or whose result is a function are called higher order functions (HOF). In Scala functions are treated as first class values which can be passed as parameters and returned as a result. Let us look at some simple examples to understand Scala higher SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-28278077776028815032014-12-03T15:05:00.000+05:302015-03-02T05:41:12.444+05:30Scala FunctionsScala is also a functional language and provides the flexibility to the programmer to use classes and methods as in a object oriented language along with pure functions. Functions in Scala are also objects. This article provides a brief introduction to using functions in Scala. def is keyword used to define functions in Scala. A Scala function definition is typically of the form, def SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-30246752203637394392014-11-29T12:42:00.000+05:302015-03-02T05:41:01.591+05:30Scala Companion ObjectThis article provides a brief introduction to an interesting concept the Scala Companion Object. Scala doesn't have static variables and methods. Scala Companion Object can be visualized as a place holder for all the static variable and method needs of a Scala class.  Scala Companion Object has the same name as an associated Scala class and needs to be specified in the same source file. Scala SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-57378171032948915282014-11-28T22:55:00.000+05:302015-03-02T05:39:55.035+05:30Scala ObjectsFor programmers already familiar with C++ or Java the concept of object in Scala looks interesting. In Scala object is a keyword and implicitly creates a singleton which is guaranteed to be unique. There is a anonymous class created for every object. It is important to note that Scala doesn't have static methods or fields and object serves the same purpose. A basic example of Scala object. SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com2tag:blogger.com,1999:blog-7748177500667831327.post-90413494517323640952014-11-28T07:44:00.002+05:302015-03-02T05:36:02.348+05:30Scala VariablesThis article provides a quick introduction on using variables in Scala. Mutable VariablesIn Scala var keyword is used to declare mutable variables whose value can be changed. var iInt : Int = 30 Scala supports type inference where the Scala compiler infers the type of the variable based on the value assigned. For example, the above variable declaration could be simply written as, var iInt = 30 SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com2tag:blogger.com,1999:blog-7748177500667831327.post-40700780786486694532014-11-23T08:34:00.000+05:302015-03-02T05:35:50.135+05:30Scala IntroductionThis article provides a quick introduction to Scala programming language.What is Scala?Scala is acronym for "Scalable Language". Scala integrates object-oriented and functional language concepts. Scala is often referred to as object-functional programming language. Scala source code gets compiled to Java byte-code and runs on the Java Virtual Machine (JVM). Java and Scala classes can be easily SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-52518068256132763372014-11-16T12:23:00.005+05:302015-03-02T05:35:04.845+05:30Quick start with ScalaThis article provides a quick start with Scala and to enables to write your first program with Scala. Scala InstallationScala Pre-requisitesTo install the Scala software distribution we need Java run-time version 1.6 or higher. You can check this using "java -version" from the command line. C:\Users\mad>java -version java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-29782038962316479272014-10-25T13:41:00.003+05:302015-03-02T05:46:36.753+05:30Java RMIJava RMI IntroductionJava Remote Method Invocation (RMI) enables remote communication between programs running across different Java Virtual Machines (JVM). RMI essentially allows an object running in one JVM to invoke a method on another object running in a different JVM. Java RMI provides the ability to write distributed objects in a simple and secure manner with the power of passing complete SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com1tag:blogger.com,1999:blog-7748177500667831327.post-82025186716168911932014-10-18T19:12:00.000+05:302015-03-02T05:46:48.144+05:30Java Messaging Service (JMS) using ActiveMQJava Messaging Service (JMS) IntroductionJava Messaging Service (JMS) provides a mechanism for applications to create, send and receive messages using reliable, asynchronous and loosely coupled communication. JMS is defined as part of the Java Enterprise Edition. JMS supports two messaging models, point-to-point model and the publish subscribe model. In the point to point messaging model we haveSourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-61417611923447608682014-09-25T09:26:00.001+05:302015-03-02T05:46:55.519+05:30Java ReentrantReadWriteLockReentrantReadWriteLock IntroductionA read-write lock provides greater level of concurrency than a mutual exclusion lock when working with shared data. Read-write locks allows simultaneous read only operations by multiple threads whereas a write operation can be performed by only one thread. Read-write locks provide increased level of concurrency and typically results in better performance if the SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-82152268944592425492014-09-22T20:59:00.000+05:302015-03-02T05:47:02.355+05:30Java ReentrantLockReentrantLock IntroductionLock provides a tool to control access to a shared resource in a multi-threaded environment. A lock provides access to only one thread at a time to the shared resource. Using synchronized methods and statements provides access to an implicit lock for an object. However in certain scenarios we might need access explicitly to the lock object for flexibility. ReentrantLock SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-24536432252553852112014-09-14T11:37:00.002+05:302015-03-02T05:47:10.605+05:30Java Atomic VariablesAtomic Operations IntroductionTraditional multi-threading approaches use locks to protect shared resources.  Synchronization objects like Semaphores provide mechanisms for the programmer to write code that doesn't modify a shared resource concurrently. The synchronization approaches block other threads when one of the thread is modifying a shared resource. Obviously blocked threads are not doing SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-63589570321627299602014-09-14T07:10:00.002+05:302015-03-02T05:47:27.760+05:30Java ExchangerExchanger Introduction Exchanger is a synchronization point in which threads can pair and exchange objects. Exchanger simplifies data exchange between two threads. Exchanger waits till two threads reach the synchronization point and then exchanges the data provided by the threads.Java Exchanger ClassJava support Exchanger synchronization object. Exchanger is a generic class and support the SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-73692626534484630772014-09-13T22:39:00.000+05:302015-03-02T05:47:34.764+05:30Java CyclicBarrierCyclicBarrier IntroductionCyclicBarrier is a synchronization object that will release when a given number of threads are waiting on it. CyclicBarrier is initialized with a count that indicates the number of threads that must wait on this barrier. CyclicBarrier is useful in applications where threads needs to wait for each other. Java CyclicBarrier Class Java supports CyclicBarrier synchronizationSourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0tag:blogger.com,1999:blog-7748177500667831327.post-9584745373450750092014-09-09T23:13:00.004+05:302015-03-02T05:49:51.646+05:30Java CountDownLatchCountDownLatch IntroductionCountDownLatch is a synchronization object that allows a thread to wait till certain events occur in other threads. We can make the current thread to wait until few dependent threads have completed their operation. CountDownLatch starts with a initial count. Thread that needs to wait, blocks until the count reaches to zero. Dependent threads on completing their task SourceTrickshttp://www.blogger.com/profile/18153422615549744777noreply@blogger.com0