<?xml version="1.0" encoding="UTF-8"?> <Configuration status="INFO"> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> </Console> <File name="MyFile" fileName="all.log" immediateFlush="false" append="false"> <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </File> </Appenders> <Loggers> <Root level="debug"> <AppenderRef ref="Console" /> <AppenderRef ref="MyFile"/> </Root> </Loggers> </Configuration>
Techware
Friday, November 27, 2015
Very Simple Log4j2 xml Configuration Example
Thursday, November 26, 2015
Simulating Network TCP Delay Using Linux Commands
Keep in mind that this only works for outbound traffic, so choose your network interface accordingly.
sudo tc qdisc add dev eth0 root netem delay 100ms
To check status
sudo tc -s qdisc
sudo tc qdisc del dev eth0 root
To add 100ms to all outbound traffic on etho
sudo tc qdisc add dev eth0 root netem delay 100ms
To check status
sudo tc -s qdisc
To remove the delay from eth0
sudo tc qdisc del dev eth0 root
Tuesday, November 17, 2015
How to deploy a local jar to maven repository
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
Where: <path-to-file> the path to the file to load
<group-id> the group that the file should be registered under
<artifact-id> the artifact name for the file
<version> the version of the file
<packaging> the packaging of the file e.g. jar
Sunday, October 4, 2015
Working with hashCode and equals methods in java
In this post, I will point out my understanding about hashCode and equals methods in java. I will talk about how their default implementation and how to override them correctly.
hashCode()
and equals()
methods have been defined in Object
class which is parent class for java objects. For this reason, all java objects inherit a default implementation of these methods.Configuring a remote for a fork
To sync changes you make in a fork with the original repository, you must configure a remote that points to the upstream repository in Git.
- Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
- List the current configured remote repository for your fork.
git remote -v # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
- Specify a new remote upstream repository that will be synced with the fork.
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
- Verify the new upstream repository you've specified for your fork.
git remote -v # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
Saturday, October 18, 2014
Wild Card Paramters in Java
In this post I'm going to give you a small introduction about Wild card parameters used is java.
In java, Type parameters for generics have a limitation. Generic type parameters should match exactly for assignments. for example, If we use following statement in a java program, it will give a compilation error of incompatible types.
List<Number> intList = new ArrayList<Integer>();
If we slightly change the above statement to use wildcard parameter, it will compile without any errors.
List<?> wildCardList = new ArrayList<Integer>();
So, what does a wildcard mean? It's just like the wildcard, you use for substituting for a card in a card game. In java, you can use a wildcard parameter to indicate that it can match any type. With List<?>, you can mean that it is a List of any type. But when you want a type a indicating "any type", you may use the Object class, don't you? How about the statement, but using the Object type parameter?
List<Object> wildCardList = new ArrayList<Integer>();
No luck, you will get same compilation error you got when you used the first statement. In this case you are still trying to use subtyping for generic parameters. As you can see, List<Object> and List<?> are not same. In face List<?> is a super type of any List type. which means you can pass List<Integer>, or List<String>, or even List<Object> where List<?> is expected.
Thanks
In java, Type parameters for generics have a limitation. Generic type parameters should match exactly for assignments. for example, If we use following statement in a java program, it will give a compilation error of incompatible types.
List<Number> intList = new ArrayList<Integer>();
If we slightly change the above statement to use wildcard parameter, it will compile without any errors.
List<?> wildCardList = new ArrayList<Integer>();
So, what does a wildcard mean? It's just like the wildcard, you use for substituting for a card in a card game. In java, you can use a wildcard parameter to indicate that it can match any type. With List<?>, you can mean that it is a List of any type. But when you want a type a indicating "any type", you may use the Object class, don't you? How about the statement, but using the Object type parameter?
List<Object> wildCardList = new ArrayList<Integer>();
No luck, you will get same compilation error you got when you used the first statement. In this case you are still trying to use subtyping for generic parameters. As you can see, List<Object> and List<?> are not same. In face List<?> is a super type of any List type. which means you can pass List<Integer>, or List<String>, or even List<Object> where List<?> is expected.
Thanks
Wednesday, August 20, 2014
How to Configure Embedded Jetty Server with Maven
Hi Guys,
Through this post, I will show how to configure the embedded jetty server plugin with maven projects. First let's see what is Jetty. Jetty is a light weight web server. In it you can deploy your web application during the development phrase.
The Jetty Maven plugin is useful for rapid development and testing. You can add it to any webapp project that is structured according to the usual Maven defaults. The plugin can then periodically scan your project for changes and automatically redeploy the webapp if any are found. This makes the development cycle more productive by eliminating the build and deploy steps.
Lets see how to setup the jetty server into maven projects
First step, Create a maven web app project. use the following command in to create a new hello world project.
Once your project creation successful, a new web application project named “hello-webapp“, and the entire project directory structure is created automatically. Then go to that project root directory and open the pom.xml and then add the following code block within the build tag.
Through this post, I will show how to configure the embedded jetty server plugin with maven projects. First let's see what is Jetty. Jetty is a light weight web server. In it you can deploy your web application during the development phrase.
The Jetty Maven plugin is useful for rapid development and testing. You can add it to any webapp project that is structured according to the usual Maven defaults. The plugin can then periodically scan your project for changes and automatically redeploy the webapp if any are found. This makes the development cycle more productive by eliminating the build and deploy steps.
Lets see how to setup the jetty server into maven projects
First step, Create a maven web app project. use the following command in to create a new hello world project.
Once your project creation successful, a new web application project named “hello-webapp“, and the entire project directory structure is created automatically. Then go to that project root directory and open the pom.xml and then add the following code block within the build tag.
Once you add this plugin, you can deploy your hello-webapp application into jetty-server. To deploy the webapp in to jetty server, you the command as follows
then to view your web app in your browser localhost:8080/hello-webapp then try more complicated examples.
Subscribe to:
Posts (Atom)