Create spring beans using YAML

Spring highly adopted annotation based configuration and it is happily accepted by developer communities and why not, no one wants to struggle with XML tags but that’s not enough somewhere we still miss XML configuration or you can say external file configuration as powerful as XML configuration. especially when we write an application that has to alter behaviors without compilation.

But still writing an XML configuration is not readable and not easily understandable for beginners, so I’ve written experimental plugins for spring boot that convert YAML definition to Spring Beans.

here is an example of bean definition in XML and same in YAML.

Spring-beans.xml

Screen Shot 2017-11-04 at 6.45.07 PM

Spring-beans.yaml

Screen Shot 2017-11-04 at 6.44.14 PM

above code snippet, you can see a line of code and readability, let jump in a code example.

below code snippet, only need to add annotation “@ImportYamlResource” that will work same as “@ImportResource”

Screen Shot 2017-11-05 at 10.38.22 AM

below an example link, you can check out a project from git

yaml-beans-example

download library 

 

Note ->  YAML-spring-beans is a just experimental library, still there are lots of features not included

feedback will be much appreciated 🙂

Advertisements

Configure GitLab Runner with shell

Hi ,

I’ve found many examples where people configure with docker, in some cases if we need simple configuration for internal uses, we have also an alternative that can help to configure your GitLab CI runner easily.

In my case, i’m using Centos.

  1. added gitlab multi runner to yum repository

# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash

2.after added to repository install gitlab-multi runner
#sudo yum install gitlab-ci-multi-runner

once gitlab runner install, it will create “gitlab-runner” user in your machine

may find here “/home/gitlab-runner” , gitlab-runner user do not have permission you need to add it to user group or something else whatever you need.

you can also see multiple commands provided by gitlab runner

#gitlab-runner –help

now ,we need to configure it with our gitlab hosted repository

#sudo gitlab-ci-multi-runner register 

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
https://mygitlab.com/ci
Please enter the gitlab-ci token for this runner
xxx
Please enter the gitlab-ci description for this runner
my-runner
INFO[0034] fcf5c619 Registering runner… succeeded
Please enter the executor: shell, docker, docker-ssh, ssh?
shell
running already the config should be automatically reloaded!

————————————————-

after gitlab runner successfully configure you will see “admin area ->Runner” in gitlab

something similar to below images

Screen Shot 2016-10-08 at 5.29.43 PM.png

that is not completed yet you also need to configure Ci with include this file in your project root directory “”

added some configuration related to your project build and unit test running etc..

here is simple example i’ve added in “.gitlab-ci.yml” file

web_server_build:
script:
– cd spirng-mvc
– echo “making build”
– ./gradlew clean
– ./gradlew build

once configuration done, every commit we can run our build

Screen Shot 2016-10-08 at 5.55.33 PM.png

may I have skip few steps, let us know if needed will update.

Thank for reading 🙂

Strategy pattern in java

Hi Friends,

today i want to share strategy pattern, of course this is very well known and mostly used pattern. and their is lots of cases where we need to use strategic pattern.

#what is Strategy pattern?

The strategy pattern(also known as the policy pattern) is a software design pattern that enables an algorithm’s behavior to be selected at runtime. The strategy pattern. defines a family of algorithms, encapsulates each algorithm, and makes the algorithms interchangeable within that family. more

#When to use?

when we have multiple algorithm for a specific task and want to decides the actual implementation to be used at runtime

#Example

Suppose there is one software startup company and they have limited resource to done their work but all resource have multi-talent to do multiple roles,  like four resources (EmployeeA, EmployeeB, EmployeeC, EmployeeD) each one can able to done coding, testing,content writing etc. and any work can assign to anyone . its depend on availability.

Screen Shot 2015-10-22 at 3.10.43 AM

you can find example on Github link

Thanks

 

Chat application over xmpp protocol

Hi folk,

Today I’m going to share simple chat application that is based on xmpp protocol.

i know that they have lost of question in your mind about xmpp , so simply i’m start with some definition or basic question

# what is xmpp ?

xmpp is the extensible messaging and presence protocol, a set of open technologies for instant messaging,presence,multi-party chat, voice and video calls, collaboration, lightweight middleware, content syndication,and generalized routing of xml data.

XMPP was originally developed in the Jabber open-source community to provide an open, decentralized alternative to the closed instant messaging services at that time. click here for more detail

# Why xmpp?

#Open standard – its gives you the choice and control about how you access your data and service

#multi platform support – you can create chat application for the multiple platform over the xmpp protocol

# xmpp implementation :

For the xmpp chat application we have to implement chat client and  configure server. firstly we are talking about chat client then we going to implement server configuration.

#Prerequisites

The following assumes that you have already basic knowledge in Android development with android studio

1.Android studio

2.Smack 4.1 library (smack 4.1 supporting android for previous version we need to implement asmack  library)

#Example :

step 1 > Create a project in android studio(File -> New Project(add Application name,project location) -> check phone and teblet and select minimum sdk -> select activity type -> define activity name ->finish) for more detail how to manage a project in android studio click here

add library detail in build.gradle file as below

build_gradle_config

 

step 2 > after adding library into project , now connect to openfire server and login as user

Configuration_and_login

 

above this code example i have disable ssl and DIGEST-MD5 . According to your need you can enable it.

if you want to create user through your application then use AccountManager classto do it as for exp :

Account_manager step 3 > after successfully connected to chat server now create a chat with another user and receive there message

 doChat_createchatmessageListner

Above this code i’ve created doChat method where we need to pass userId(userId withwhome we want to chat) and implement ChatMessageListner to recive user message.

I hope a tutorial is helpful

Thanks for reading 🙂