<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michele Rizzi Web PageMichele Rizzi Web Page &#187; Programming languages (51)</title>
	<atom:link href="https://www.rizzimichele.it/arguments/pl/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rizzimichele.it</link>
	<description>Passion of IT</description>
	<lastBuildDate>Mon, 05 Dec 2016 20:53:30 +0000</lastBuildDate>
	<language>en-GB</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.8.41</generator>
	<item>
		<title>Water ripple javascript</title>
		<link>https://www.rizzimichele.it/water-ripple-javascript/</link>
		<comments>https://www.rizzimichele.it/water-ripple-javascript/#comments</comments>
		<pubDate>Mon, 05 Dec 2016 20:53:12 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1107</guid>
		<description><![CDATA[Here]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rizzimichele.it/javascriptHTML/waterEffect/Rippleexample.html">Here</a></p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fwater-ripple-javascript%2F&amp;linkname=Water%20ripple%20javascript" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fwater-ripple-javascript%2F&amp;linkname=Water%20ripple%20javascript" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fwater-ripple-javascript%2F&amp;linkname=Water%20ripple%20javascript" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fwater-ripple-javascript%2F&amp;title=Water%20ripple%20javascript" id="wpa2a_2"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/water-ripple-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AngularJS Dashboard</title>
		<link>https://www.rizzimichele.it/angularjs-dashboard/</link>
		<comments>https://www.rizzimichele.it/angularjs-dashboard/#comments</comments>
		<pubDate>Sun, 27 Nov 2016 11:07:34 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1099</guid>
		<description><![CDATA[I found this great Dashboard using AngularJS &#160; Enjoy]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rizzimichele.it/javascriptHTML/angularDashboard/#/sample/01">I found this great Dashboard using AngularJS</a></p>
<p>&nbsp;</p>
<p>Enjoy</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-dashboard%2F&amp;linkname=AngularJS%20Dashboard" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-dashboard%2F&amp;linkname=AngularJS%20Dashboard" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-dashboard%2F&amp;linkname=AngularJS%20Dashboard" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-dashboard%2F&amp;title=AngularJS%20Dashboard" id="wpa2a_4"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/angularjs-dashboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudoku With AngularJS</title>
		<link>https://www.rizzimichele.it/sudoku-with-angularjs/</link>
		<comments>https://www.rizzimichele.it/sudoku-with-angularjs/#comments</comments>
		<pubDate>Sun, 27 Nov 2016 09:50:58 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1096</guid>
		<description><![CDATA[Here is available a sudoku solver using AngularJS]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rizzimichele.it/javascriptHTML/sudoku-with-angularjs/">Here</a> is available a sudoku solver using AngularJS</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fsudoku-with-angularjs%2F&amp;linkname=Sudoku%20With%20AngularJS" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fsudoku-with-angularjs%2F&amp;linkname=Sudoku%20With%20AngularJS" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fsudoku-with-angularjs%2F&amp;linkname=Sudoku%20With%20AngularJS" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fsudoku-with-angularjs%2F&amp;title=Sudoku%20With%20AngularJS" id="wpa2a_6"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/sudoku-with-angularjs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Multitouch API</title>
		<link>https://www.rizzimichele.it/javascript-multitouch-api/</link>
		<comments>https://www.rizzimichele.it/javascript-multitouch-api/#comments</comments>
		<pubDate>Sun, 20 Nov 2016 10:05:04 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1086</guid>
		<description><![CDATA[here is one example on how to use the multi touch in a web application]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rizzimichele.it/wp-content/uploads/2016/11/multitouch.png"><img class="aligncenter size-full wp-image-1087" alt="multitouch" src="http://www.rizzimichele.it/wp-content/uploads/2016/11/multitouch.png" width="605" height="347" /></a><a href="http://www.rizzimichele.it/javascriptHTML/multitouch.html">here</a> is one example on how to use the multi touch in a web application</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fjavascript-multitouch-api%2F&amp;linkname=Javascript%20Multitouch%20API" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fjavascript-multitouch-api%2F&amp;linkname=Javascript%20Multitouch%20API" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fjavascript-multitouch-api%2F&amp;linkname=Javascript%20Multitouch%20API" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fjavascript-multitouch-api%2F&amp;title=Javascript%20Multitouch%20API" id="wpa2a_8"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/javascript-multitouch-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hadoop Big Data</title>
		<link>https://www.rizzimichele.it/hadoop-big-data/</link>
		<comments>https://www.rizzimichele.it/hadoop-big-data/#comments</comments>
		<pubDate>Sat, 19 Nov 2016 10:19:01 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>
		<category><![CDATA[Software engineering, architectures and distribuited systems (16)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1075</guid>
		<description><![CDATA[This week I got a chance of studying big data and Hadoop and I&#8217;ve written this short document What is big data? Big data is large amount of data to store and process on the server. They can be the user activities of big applications such as social media (facebook), search engines (google), Internet of [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This week I got a chance of studying big data and Hadoop and I&#8217;ve written this short document</p>
<p><strong>What is big data?</strong></p>
<p>Big data is large amount of data to store and process on the server.</p>
<p>They can be the user activities of big applications such as social media (facebook), search engines (google), Internet of things (sensors, machines, transports etc)</p>
<p>Today 1TB hard drive costs around 50 euro so it&#8217;s cheap storing large amount of data but processing it requires long time using SQL database and NoSQL databases are better way for storing these informations and also they are other frameworks for processing them such as Hadoop.</p>
<p><strong>Big Data technologies</strong></p>
<p>There are two classes of technologies to handle big data, they are complementary and usually used together:</p>
<ul>
<li><strong>Operational big data</strong>: technologies for storing and processing the big data: NoSQL databases</li>
<li><strong>Analytical Big Data</strong>: Systems for Massive Parallel Processing such as Hadoop</li>
</ul>
<p><strong>Google Hadoop</strong></p>
<p>in the usual client-server approach we have a client that gets the information from the database.</p>
<p>Hadoop splits the task in small parts assigning each one to a computer connected to the network and connects all the information afterward.This is the MapReduce algorithm.</p>
<p>This means that Hadoop has the below components:</p>
<ul>
<li>his own distributed file system called HDFS: it&#8217;s made of masters NameNode which manages many slaves nodes DataNodes. A file is divided into many blocks stored in set of DataNode. NameNode makes the mapping between the file and the block</li>
<li>his own common libraries</li>
<li>the framework called YARN</li>
<li>the map reduce algorithm: made by a Map task which converts the input in a map and a Reduce task which splits the map in a smaller set of tuple. The map reduce Algorithm has a single master called Job Tracker responsible for resource management and scheduling jobs, and a slave TaskTraker which executes the task</li>
</ul>
<p>Hadoop works as below:</p>
<ul>
<li>the user submits a job to Hadoop with a input/output elements, a MapReduce algorithm, the job configuration</li>
<li>the jobTraker takes the responsibility of the job submitting it to the slaves</li>
<li>the task traker executes its task</li>
</ul>
<p><a href="http://hadoop.apache.org/docs/r3.0.0-alpha1/hadoop-project-dist/hadoop-common/SingleCluster.html">Here is a guide on how to install Hadoop</a></p>
<p><a href="http://hadoop.apache.org/docs/r3.0.0-alpha1/hadoop-project-dist/hadoop-common/FileSystemShell.html">Here is a list of the hadoop file system commands</a></p>
<p>I tested a couple of commands: mkdir and ls, they work fine</p>
<p>Finally I&#8217;ve written a simple map reduce example:</p>
<p><a href="http://hadoop.apache.org/docs/r3.0.0-alpha1/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html">Here is an example of the MapReduce algorithm</a></p>
<pre>

package com.michele.rizzi.hadoop;
import java.io.IOException;
import java.util.StringTokenizer;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class WordCount {

public static class TokenizerMapper
extends Mapper&lt;Object, Text, Text, IntWritable&gt;{

private final static IntWritable one = new IntWritable(1);
private Text word = new Text();

public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
StringTokenizer itr = new StringTokenizer(value.toString());
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
}
}
}

public static class IntSumReducer
extends Reducer&lt;Text,IntWritable,Text,IntWritable&gt; {
private IntWritable result = new IntWritable();

public void reduce(Text key, Iterable&lt;IntWritable&gt; values,
Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
}

public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = Job.getInstance(conf, "word count");
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}

</pre>
<p>&nbsp;</p>
<p>The mapper sets all words in the context with key=word, value=1.</p>
<p>if the text file is like the one below</p>
<blockquote><p>Michele Michele Rizzi</p></blockquote>
<p>the context at the end of the mapper method will have</p>
<p>key:Michele, value:1</p>
<p>key:Michele value:1</p>
<p>key=Rizzi value:1</p>
<p>&nbsp;</p>
<p>The reducer automatically groups the items with the same key, the input parameters will be</p>
<p>key=&#8221;Michele&#8221; values={1,1}</p>
<p>key=&#8221;Rizzi&#8221; values={1}</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>Difference Flink Hadoop</strong></p>
<p>Map/Reduce is a protocol where one transformation takes most likely two phases: One map phase, one reduce phase. Between these phases, the results are spilled to disk. If you have more than one transformation, it stacks up.</p>
<p>One of the limitations of Hadoop MapReduce is that the framework can only batch process one job at a time.</p>
<p>MapReduce may be a legacy system for many companies who started their Big Data journey when Hadoop first came out. This framework has been the workhorse for large data projects. One of the significant challenges for systems developed with this framework is its high-latency, batch-mode response. Since MapReduce has evolved over the last 10 years some developers would complain that it’s difficult to maintain because of inherent inefficiencies in its design and code.<br />
Flink tries to combine all transformation into a job. If the job is started the transformations are done in this jobs, intermediate results are kept in memory. One of the highlights of Flink is its own memory management to prevent Garbage Collection and overflows.</p>
<p>Flink provides a true data streaming platform that uses high-performance dataflow architecture. It is also a strong tool for batch processing since Flink handles batch as a special case of streaming. Flink processes streaming data in real-time streams by pipelining data elements as soon as the elements arrive.</p>
<p>&nbsp;</p>
<p><a href="http://www.rizzimichele.it/aboutMePHP/MicheleRizzi.php?tech=hadoop">Here is available the source code of the application</a></p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fhadoop-big-data%2F&amp;linkname=Hadoop%20Big%20Data" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fhadoop-big-data%2F&amp;linkname=Hadoop%20Big%20Data" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fhadoop-big-data%2F&amp;linkname=Hadoop%20Big%20Data" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fhadoop-big-data%2F&amp;title=Hadoop%20Big%20Data" id="wpa2a_10"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/hadoop-big-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design Book object in Amazon Website</title>
		<link>https://www.rizzimichele.it/design-book-object-in-amazon-website/</link>
		<comments>https://www.rizzimichele.it/design-book-object-in-amazon-website/#comments</comments>
		<pubDate>Tue, 08 Nov 2016 07:34:00 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>
		<category><![CDATA[Software engineering, architectures and distribuited systems (16)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1056</guid>
		<description><![CDATA[How it should be designed a book object in the Amazon website? Should it have a logic? if I were the architect of the system I wouldn&#8217;t have put any logic in that book object so it should be just a container and below are my reasons The clean code says that one class should [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>How it should be designed a book object in the Amazon website?</p>
<p>Should it have a logic?</p>
<p><strong>if I were the architect of the system I wouldn&#8217;t have put any logic in that book object so it should be just a container</strong> and below are my reasons</p>
<ol>
<li>The clean code says that one class should be as short as possible with just one responsibility. the less methods and the less code is inside the better it is.</li>
<li>I imagine the Amazon web site made of the Model View Control pattern and SQL database using the DAO pattern. If that&#8217;s implemented using also Spring and the Dependency injenction pattern and Hibernate the system should be designed as below
<ol>
<li>View: normal HTML  Javascript page so when the user wants to see the list of the book it calls the REST endpoint in the Spring book controller called getBook</li>
<li>Controller: Spring Book controller with the initial business logic for verifying the input of the user, calling the model, populating a response object which contains a list of books and returns it to the view
<ol>
<li>All logic should be in the controller and its method getBooks, the book should contain just informations</li>
</ol>
</li>
<li>Model: Another REST endpoint which like the controller has the logic. The logic is inside the rest book service and the book object should be just a container.
<ol>
<li>That rest service can collect the information from the SQL database using hibernate and as usual the Hibernate book object is just a mapping of the book table, all logic should be inside the BookDAO using the DAO design pattern</li>
</ol>
</li>
</ol>
</li>
</ol>
<p>For me the book should be just a bean POJO with private variables, getters, setters and constructors</p>
<p>The more logic you put inside the less clean is the code</p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fdesign-book-object-in-amazon-website%2F&amp;linkname=Design%20Book%20object%20in%20Amazon%20Website" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fdesign-book-object-in-amazon-website%2F&amp;linkname=Design%20Book%20object%20in%20Amazon%20Website" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fdesign-book-object-in-amazon-website%2F&amp;linkname=Design%20Book%20object%20in%20Amazon%20Website" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fdesign-book-object-in-amazon-website%2F&amp;title=Design%20Book%20object%20in%20Amazon%20Website" id="wpa2a_12"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/design-book-object-in-amazon-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AngularJS 2 Mixed words</title>
		<link>https://www.rizzimichele.it/angularjs-mixed-words/</link>
		<comments>https://www.rizzimichele.it/angularjs-mixed-words/#comments</comments>
		<pubDate>Sat, 05 Nov 2016 14:59:08 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1041</guid>
		<description><![CDATA[Here is available an example about how to use AngularJS2 made by me]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rizzimichele.it/javascriptHTML/angular2mix/index.html">Here</a> is available an example about how to use AngularJS2 made by me</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-mixed-words%2F&amp;linkname=AngularJS%202%20Mixed%20words" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-mixed-words%2F&amp;linkname=AngularJS%202%20Mixed%20words" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-mixed-words%2F&amp;linkname=AngularJS%202%20Mixed%20words" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fangularjs-mixed-words%2F&amp;title=AngularJS%202%20Mixed%20words" id="wpa2a_14"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/angularjs-mixed-words/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReactJS encrypt text</title>
		<link>https://www.rizzimichele.it/reactjs-encrypt-text/</link>
		<comments>https://www.rizzimichele.it/reactjs-encrypt-text/#comments</comments>
		<pubDate>Mon, 31 Oct 2016 19:15:08 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1031</guid>
		<description><![CDATA[here you can find an utility for encrypting / decrypting the text made by me using ReactJS]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rizzimichele.it/javascriptHTML/enctext/reactJsEncryptBootstrap.html">here</a> you can find an utility for encrypting / decrypting the text made by me using ReactJS</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Freactjs-encrypt-text%2F&amp;linkname=ReactJS%20encrypt%20text" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Freactjs-encrypt-text%2F&amp;linkname=ReactJS%20encrypt%20text" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Freactjs-encrypt-text%2F&amp;linkname=ReactJS%20encrypt%20text" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Freactjs-encrypt-text%2F&amp;title=ReactJS%20encrypt%20text" id="wpa2a_16"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/reactjs-encrypt-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tomcat vs Websphere</title>
		<link>https://www.rizzimichele.it/tomcat-vs-websphere/</link>
		<comments>https://www.rizzimichele.it/tomcat-vs-websphere/#comments</comments>
		<pubDate>Thu, 20 Oct 2016 21:26:51 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>
		<category><![CDATA[Software engineering, architectures and distribuited systems (16)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1003</guid>
		<description><![CDATA[Firstly it&#8217;s necessary to understand which are Tomcat and Web Sphere Tomcat and IBM WebSphere are both HTTP Java servers Server: is a machine always on, which serves the client requests: the client asks for a request the server processes it and replies with a response. HTTP is the Hyper Text transfer protocol, it&#8217;s a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Firstly it&#8217;s necessary to understand which are Tomcat and Web Sphere</p>
<p>Tomcat and IBM WebSphere are both HTTP Java servers</p>
<p><a href="https://en.wikipedia.org/wiki/Server_(computing)">Server: </a>is a machine always on, which serves the client requests: the client asks for a request the server processes it and replies with a response.</p>
<p><a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a> is the Hyper Text transfer protocol, it&#8217;s a request- response protocol for exchanging web pages.<br />
A Java HTTP web server is a HTTP server which has a JVM (Java virtual machine) which allows to execute Java web applications.</p>
<p>A java web application can be stored in two archives: War and EAR.</p>
<ul>
<li><strong>WAR </strong>or web archive is an archive made of the below structure:
<ul>
<li><a href="http://www.rizzimichele.it/wp-content/uploads/2016/10/web-module.gif"><img class="aligncenter size-full wp-image-1016" alt="web-module" src="http://www.rizzimichele.it/wp-content/uploads/2016/10/web-module.gif" width="442" height="413" /></a></li>
<li>this archive is made of the below files
<ul>
<li><strong>web.xml</strong> is the application descriptors which contains the configuration information of the application</li>
<li><strong>lib</strong>: is a folder with all jar files necessary to make working our project</li>
<li>classes: all project byte codes</li>
<li><strong>JSP</strong>: the Java server Pages which contain html, css javascript code and Java code as well. After the user clicks on the button it may execute the java code inside the JSP or can call a class stored in the &#8220;classes folder&#8221; which can use a jar file contained in the lib folder.</li>
</ul>
</li>
<li>this archive can be made in many ways
<ul>
<li>using the eclipse export tool: export as-&gt;war</li>
<li>using the Java building tools such as Ant, Maven, Gradle</li>
</ul>
</li>
</ul>
</li>
<li><strong>EAR </strong>entreprise Archive is a more complex archive which can contain more war and the EJB JAR. The EJB or <a href="http://www.rizzimichele.it/enterprise-java-beans-and-all-j2ee/">Enterprise Java Beans</a> are necessary for implementing the session, the persistence of data and the message queue. EJB are used by Java front end framework such as JSF and Struts. If using Spring it has their own beans and it can make the above functions without needing EJB
<ul>
<li><a href="http://www.rizzimichele.it/wp-content/uploads/2016/10/7-packaging-and-deployment-16-728.jpg"><img class="aligncenter size-full wp-image-1017" alt="7-packaging-and-deployment-16-728" src="http://www.rizzimichele.it/wp-content/uploads/2016/10/7-packaging-and-deployment-16-728.jpg" width="728" height="546" /></a></li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p>After having clear the function about a Java web application and a java web server we can compare Tomcat and WebSphere</p>
<ul>
<li><strong>Tomcat: </strong>freeware open source server that is light and fast it doesn&#8217;t have a EJB container and it allows only to deploy EAR applications</li>
<li><strong>Web Sphere: </strong>Private IBM server very complex and expensive with the EJB container and the opportunity to install war and ear files. WebSphere allows to use JNDI, Queues and many other technologies.</li>
</ul>
<p>Both servers work with the java web applications (war) with JSP, Class files but being more widely supported Web Sphere is used for complex projects such as banks and insurances rather then Tomcat used for small projects such as web sites and small applications.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Ftomcat-vs-websphere%2F&amp;linkname=Tomcat%20vs%20Websphere" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Ftomcat-vs-websphere%2F&amp;linkname=Tomcat%20vs%20Websphere" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Ftomcat-vs-websphere%2F&amp;linkname=Tomcat%20vs%20Websphere" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Ftomcat-vs-websphere%2F&amp;title=Tomcat%20vs%20Websphere" id="wpa2a_18"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/tomcat-vs-websphere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA XML Processing</title>
		<link>https://www.rizzimichele.it/adding-node-to-an-xml-file/</link>
		<comments>https://www.rizzimichele.it/adding-node-to-an-xml-file/#comments</comments>
		<pubDate>Thu, 20 Oct 2016 16:17:10 +0000</pubDate>
		<dc:creator><![CDATA[Michele Rizzi]]></dc:creator>
				<category><![CDATA[All articles (75)]]></category>
		<category><![CDATA[Programming languages (51)]]></category>

		<guid isPermaLink="false">http://www.rizzimichele.it/?p=1000</guid>
		<description><![CDATA[Xml or extended markup language is a markup language made of many tag which are both readable by humans and machine, it has a tree structure with a root node, many branches and leaves. Xml can respect a set of rules defined in two ways: the old DTD (Document Type Definition) and the more recent [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Xml or extended markup language is a markup language made of many tag which are both readable by humans and machine, it has a tree structure with a root node, many branches and leaves.</p>
<p>Xml can respect a set of rules defined in two ways: the old <a href="https://en.wikipedia.org/wiki/Document_type_definition">DTD (Document Type Definition) </a>and the more recent <a href="https://en.wikipedia.org/wiki/XML_schema">XML schema</a>.</p>
<p>XML is useful for the below purposes</p>
<ul>
<li><a href="http://www.rizzimichele.it/jpa-rest-and-soap/">Web services SOAP use the XML for the communication</a> between the two involved endpoints and for their main configuration file (WSDL)</li>
<li><a href="http://www.rizzimichele.it/types-of-data-to-exchange-the-informations/">making the communication between different software, it&#8217;s much better than the CSV (Comma separated value) because being hierarchically an xml document can be easily converted in an object (that&#8217;s called &#8220;Marshalling&#8221;) and vice-versa (&#8220;Un-Marshalling&#8221;)</a></li>
<li>Storing configuration information: the application descriptor web.xml, the JSF configuration file faces-config.xml, the struts config file, the hibernate config file are just few examples about XML configurations file.</li>
</ul>
<p>&nbsp;</p>
<p>the only problem of the xml is that it&#8217;s redundant so every opened tag should be closed and the tag name is replicated two times</p>
<pre>

&lt;tag_name&gt;
tag value
&lt;tag_name&gt;

</pre>
<p>if the tag name is huge and it has not value so we transmit on line many characters with no value</p>
<p>A better format is the <a href="http://www.rizzimichele.it/types-of-data-to-exchange-the-informations/">JSON</a> which can be converted to an object but it replaces tags with parenthesis, so it&#8217;s not replicated any information.</p>
<p>How to process an XML file using Java?</p>
<p>We need to parse it using XPath and to add a node everywhere.</p>
<p>&nbsp;</p>
<h1>XPATH</h1>
<p>let&#8217;s try to inquire the below xml</p>
<pre>

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;Employees&gt;
&lt;Employee id="1"&gt;
&lt;age&gt;29&lt;/age&gt;
&lt;name&gt;Pankaj&lt;/name&gt;
&lt;gender&gt;Male&lt;/gender&gt;
&lt;role&gt;Java Developer&lt;/role&gt;
&lt;/Employee&gt;
&lt;Employee id="2"&gt;
&lt;age&gt;35&lt;/age&gt;
&lt;name&gt;Lisa&lt;/name&gt;
&lt;gender&gt;Female&lt;/gender&gt;
&lt;role&gt;CEO&lt;/role&gt;
&lt;/Employee&gt;
&lt;Employee id="3"&gt;
&lt;age&gt;40&lt;/age&gt;
&lt;name&gt;Tom&lt;/name&gt;
&lt;gender&gt;Male&lt;/gender&gt;
&lt;role&gt;Manager&lt;/role&gt;
&lt;/Employee&gt;
&lt;Employee id="4"&gt;
&lt;age&gt;25&lt;/age&gt;
&lt;name&gt;Meghna&lt;/name&gt;
&lt;gender&gt;Female&lt;/gender&gt;
&lt;role&gt;Manager&lt;/role&gt;
&lt;/Employee&gt;
&lt;/Employees&gt;

</pre>
<pre>

private static List&lt;String&gt; getFemaleEmployeesName(Document doc, XPath xpath) {
List&lt;String&gt; list = new ArrayList&lt;&gt;();
try {
//create XPathExpression object
XPathExpression expr =
xpath.compile("/Employees/Employee[gender='Female']/name/text()");
//evaluate expression result on XML document
NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i &lt; nodes.getLength(); i++)
list.add(nodes.item(i).getNodeValue());
} catch (XPathExpressionException e) {
e.printStackTrace();
}
return list;
}

private static List&lt;String&gt; getEmployeeNameWithAge(Document doc, XPath xpath, int age) {
List&lt;String&gt; list = new ArrayList&lt;&gt;();
try {
XPathExpression expr =
xpath.compile("/Employees/Employee[age&gt;" + age + "]/name/text()");

NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i &lt; nodes.getLength(); i++)
list.add(nodes.item(i).getNodeValue());
} catch (XPathExpressionException e) {
e.printStackTrace();
}
return list;
}

private static String getEmployeeNameById(Document doc, XPath xpath, int id) {
String name = null;
try {
XPathExpression expr =
xpath.compile("/Employees/Employee[@id='" + id + "']/name/text()");
name = (String) expr.evaluate(doc, XPathConstants.STRING);
} catch (XPathExpressionException e) {
e.printStackTrace();
}

return name;
}

&nbsp;

</pre>
<p>Below is the method to add a node in the name of a female employer</p>
<pre>

private static List&lt;String&gt; addNodesInsideFemaleEmployeesName(Document doc, XPath xpath) {
List&lt;String&gt; list = new ArrayList&lt;&gt;();
try {
//create XPathExpression object
XPathExpression expr =
xpath.compile("/Employees/Employee[gender='Female']/name/text()");
//evaluate expression result on XML document
NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i &lt; nodes.getLength(); i++){

Element node = doc.createElement("New_Node"+i);
Element nodeInside = doc.createElement("newnodeInside");

nodeInside.setTextContent("This is the content"); //adds content
nodeInside.setAttribute("attrib", "attrib_value"); //adds an attribute
node.appendChild(nodeInside);

nodes.item(i).getParentNode().insertBefore(node, nodes.item(i).getNextSibling());
}
} catch (XPathExpressionException e) {
e.printStackTrace();
}
return list;
}

&nbsp;

</pre>
<p>below is the result</p>
<pre>
&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
&lt;Employees&gt;
&lt;Employee id="1"&gt;
&lt;age&gt;29&lt;/age&gt;
&lt;name&gt;Pankaj&lt;/name&gt;
&lt;gender&gt;Male&lt;/gender&gt;
&lt;role&gt;Java Developer&lt;/role&gt;
&lt;/Employee&gt;
&lt;Employee id="2"&gt;
&lt;age&gt;35&lt;/age&gt;
&lt;name&gt;Lisa&lt;New_Node0&gt;
&lt;newnodeInside attrib="attrib_value"&gt;This is the content&lt;/newnodeInside&gt;
&lt;/New_Node0&gt;
&lt;/name&gt;
&lt;gender&gt;Female&lt;/gender&gt;
&lt;role&gt;CEO&lt;/role&gt;
&lt;/Employee&gt;
&lt;Employee id="3"&gt;
&lt;age&gt;40&lt;/age&gt;
&lt;name&gt;Tom&lt;/name&gt;
&lt;gender&gt;Male&lt;/gender&gt;
&lt;role&gt;Manager&lt;/role&gt;
&lt;/Employee&gt;
&lt;Employee id="4"&gt;
&lt;age&gt;25&lt;/age&gt;
&lt;name&gt;Meghna&lt;New_Node1&gt;
&lt;newnodeInside attrib="attrib_value"&gt;This is the content&lt;/newnodeInside&gt;
&lt;/New_Node1&gt;
&lt;/name&gt;
&lt;gender&gt;Female&lt;/gender&gt;
&lt;role&gt;Manager&lt;/role&gt;
&lt;/Employee&gt;
&lt;/Employees&gt;

</pre>
<p>if needed to insert the node outside the name it&#8217;s necessary just to modify the XPATH query that will be</p>
<p>/Employees/Employee[gender='Female']/name</p>
<p>the project is available <a href="http://www.rizzimichele.it/aboutMePHP/MicheleRizzi.php?tech=processing%20xml">here</a></p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fadding-node-to-an-xml-file%2F&amp;linkname=JAVA%20XML%20Processing" title="Facebook" rel="nofollow" target="_blank"></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fadding-node-to-an-xml-file%2F&amp;linkname=JAVA%20XML%20Processing" title="Twitter" rel="nofollow" target="_blank"></a><a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=https%3A%2F%2Fwww.rizzimichele.it%2Fadding-node-to-an-xml-file%2F&amp;linkname=JAVA%20XML%20Processing" title="Google+" rel="nofollow" target="_blank"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=https%3A%2F%2Fwww.rizzimichele.it%2Fadding-node-to-an-xml-file%2F&amp;title=JAVA%20XML%20Processing" id="wpa2a_20"></a></p>]]></content:encoded>
			<wfw:commentRss>https://www.rizzimichele.it/adding-node-to-an-xml-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
