Skip to main content

Posts

Showing posts from February, 2017

Groovy : What is Groovy Truth and define Custom Groovy Truth

What is Groovy Truth Groovy has its own way of defining what is true and what is false, this is called the Groovy Truth . In Java, we have to write statements like if(obj ==null) , in groovy you can simply write if(obj) and you can define in what conditions this object will evaluate to true and when it will evaluate to false. Info To define your custom logic for groovy Truth you need to define method boolean asBoolean(){ // your logic here } What is True in Groovy Following evaluated to true in groovy boolean true Not null objects Non 0 numbers Not null and not empty Strings Not null and not empty lists, maps, collections What is False in Groovy Following things evaluates to false in groovy boolean false Numeric 0 number Null objects Null Strings Null or empty lists, maps, collections def groovyTruth = {val-> if (val) println "$val is true" else println "$val is false" } boolean b1 = true boolean b2 = false groovyTruth(b1) // true groovyTru

Browserify : How to use Node.js require dependencies in Browser as Javascipt

How to get Browserify Use the following to download browserify . npm install -g browserify Automate Browserify Dependency You can also create a package.json file by the following command. npm init This will create a basic package.json file. now run the command npm install --save browserify --save option will download the file and save its reference in package.json . Now on other machine you just need to run the command npm install and it will download the browserify plugin and save it on your machine. This will download the browserify in node_modules folder. Now we can use browserify to download our node dependencies. For this we will first create a .js file named require.js , you can name it anything you want. Let's see a sample file. angular = require ( 'angular' ); ngSanitize = require ( 'angular-sanitize' ); Now, to make browserify work you should have all these modules installed on your system under node_modules . npm install angular npm i

Gradle : How to use Gradle Cargo Plugin to Deploy war on Tomcat

This post is based on the Gradle Cargo Plugin by bmuschko Include the Plugin You need to include the plugin in your build.gradle . buildscript { repositories { jcenter() } dependencies { classpath 'com.bmuschko:gradle-cargo-plugin:2.2.3' } } apply plugin: 'com.bmuschko.cargo' buildscript block should be the first thing in the build.gradle file. Include the Gradle Cargo plugin dependencies Add the following in your gradle dependencies block dependencies { def cargoVersion = '1.4.5' cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion" , "org.codehaus.cargo:cargo-ant:$cargoVersion" } Define the Tomcat Container To deploy The war files to Tomcat you need to create a dsl by name cargo and define the mandatory containerId . Note ContainerId will define the version of tomcat you want to use. If your want to deploy to tomcat6 your containerId will tomcat6x . See t

Tomcat : How to start Tomcat as a service on Windows 7,8,10

Step 1 : Download and Extract tomcat Download tomcat from the link in .zip format. Once download is complete extract the tomcat in the location you want, preferably C:\Tomcat\ . Step 2 : Install Tomcat as a Service Go to the tomcat directory C:\Tomcat\bin . in the address bar write cmd . This will open the command prompt window. Now in the command prompt window type the command service.bat install <Service -Name> Here <Service-Name> can be any name that you want to assign to your Service. When you run this command you will see the following output. Check the installed Service Now, lets see if the service is created or not. For this open Services . It will give the following screen. Configure Service to Run at Startup We can make the service to run on windows startup, for this, open the Service setting by double click on the service. It will open the following screen From the dropdown Startup type select Automatic . This will start the service when Wi