<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' gd:etag='W/&quot;A0cDSXs9fCp7ImA9WhRbFkQ.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879</id><updated>2012-02-08T03:04:38.564-08:00</updated><category term='sessionfactory'/><category term='hibernate'/><title>cosinusc</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;A0cDSXs8eyp7ImA9WhRbFkQ.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-7925004789022395213</id><published>2012-02-08T02:54:00.000-08:00</published><updated>2012-02-08T03:04:38.573-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-08T03:04:38.573-08:00</app:edited><title>Lucene very good search engine</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;I- Hello Lucene Example:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;div class="code" style="background-color: white; border-bottom-color: black; border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: black; border-left-style: dashed; border-left-width: 1px; border-right-color: black; border-right-style: dashed; border-right-width: 1px; border-top-color: black; border-top-style: dashed; border-top-width: 1px; line-height: 12px; margin-bottom: 4px; margin-top: 4px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; text-align: -webkit-auto; white-space: pre; width: 568px;"&gt;
&lt;span style="color: #4c4c4c; font-family: courier, 'courier new', monospace; font-size: 12px;"&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;package com.ictelecom.lucene.search.test;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.analysis.standard.StandardAnalyzer;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.document.Document;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.document.Field;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.index.IndexWriter;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.index.IndexWriterConfig;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.queryParser.ParseException;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.queryParser.QueryParser;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.search.IndexSearcher;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.search.Query;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.search.ScoreDoc;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.search.TopScoreDocCollector;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.store.Directory;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.store.RAMDirectory;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import org.apache.lucene.util.Version;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;import java.io.IOException;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;public class HelloLucene&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;public static void main(String[] args) throws IOException, ParseException&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// 0. Specify the analyzer for tokenizing text.&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// &amp;nbsp; &amp;nbsp;The same analyzer should be used for indexing and searching&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// 1. create the index&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;Directory index = new RAMDirectory();&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_35, analyzer);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;IndexWriter w = new IndexWriter(index, config);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;addDoc(w, "Lucene in Action");&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;addDoc(w, "Lucene for Dummies");&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;addDoc(w, "Managing Gigabytes");&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;addDoc(w, "lucene test");&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;w.close();&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// 2. query&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;String querystr = args.length &amp;gt; 0 ? args[0] : "lucene test";&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// the "title" arg specifies the default field to use&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// when no field is explicitly specified in the query.&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;Query q = new QueryParser(Version.LUCENE_35, "title", analyzer).parse(querystr);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// 3. search&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;int hitsPerPage = 20;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;IndexSearcher searcher = new IndexSearcher(index, true);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage, true);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;searcher.search(q, collector);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;ScoreDoc[] hits = collector.topDocs().scoreDocs;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// 4. display results&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;System.out.println("Found " + hits.length + " hits.");&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;for(int i=0;i&lt;hits.length;++i)&amp;nbsp;&lt; p=""&gt;&lt;/hits.length;++i)&amp;nbsp;&lt;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;			&lt;/span&gt;int docId = hits[i].doc;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;			&lt;/span&gt;Document d = searcher.doc(docId);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;			&lt;/span&gt;System.out.println((i + 1) + ". " + d.get("title"));&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// searcher can only be closed when there&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;// is no need to access the documents any more.&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;searcher.close();&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;private static void addDoc(IndexWriter w, String value) throws IOException&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;Document doc = new Document();&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;doc.add(new Field("title", value, Field.Store.YES, Field.Index.ANALYZED));&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;w.addDocument(doc);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; text-align: left; white-space: normal;"&gt;
&lt;span style="color: #666666; font-family: Verdana, sans-serif; font-size: xx-small;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;span style="color: #4c4c4c;"&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;II- Sample Example (indexing):&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
This tutorial sketches a small Application. We want to index text Files and then search the files for words. This tutorial will give you an overview and is not intended to be a working application. The code given is not complete.&lt;/div&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
There are three classes:&lt;/div&gt;
&lt;ol style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;li&gt;One for indexing the files&lt;/li&gt;
&lt;li&gt;One for converting File objects to indexable documents&lt;/li&gt;
&lt;li&gt;One for searching the index&lt;/li&gt;
&lt;/ol&gt;
&lt;span style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;We will start with the Indexer Class. Lucene uses a IndexWriter for indexing documents. To index an object, the file must be converted to a document with fields, which can be indexable. The FileIndexer class has a index method which gets a File object for indexing.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class="code" style="background-color: white; border-bottom-color: black; border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: black; border-left-style: dashed; border-left-width: 1px; border-right-color: black; border-right-style: dashed; border-right-width: 1px; border-top-color: black; border-top-style: dashed; border-top-width: 1px; color: #4c4c4c; font-family: courier, 'courier new', monospace; font-size: 12px; line-height: 12px; margin-bottom: 4px; margin-top: 4px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; text-align: -webkit-auto; white-space: pre; width: 568px;"&gt;
&lt;pre&gt;&lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;public&lt;/span&gt; class FileIndexer {&lt;div class="paragraph"&gt;
&lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;static&lt;/span&gt; void index( File file ) {
    // 1. Convert indexed object to a document
    // 2. Write document to IndexWriter&lt;/div&gt;
&lt;div class="paragraph"&gt;
// directory, where to store the index
    // files
    &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;String&lt;/span&gt; indexFile = &lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"/tmp/fileindex"&lt;/span&gt;;&lt;/div&gt;
&lt;div class="paragraph"&gt;
// to index documents, they are 'written' or added to
    // an IndexWriter
    IndexWriter writer = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;null&lt;/span&gt;;
    &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;try&lt;/span&gt; {
      File f;
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;boolean&lt;/span&gt; create = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;true&lt;/span&gt;;
      // create index &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;if&lt;/span&gt; the directory does not exist
      &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;if&lt;/span&gt; ((f = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; File(indexFile)).exists() &amp;amp;&amp;amp; f.isDirectory()) {
        create = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;false&lt;/span&gt;;
      } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;else&lt;/span&gt; {
        create = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;true&lt;/span&gt;;
      }
      writer = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; IndexWriter(indexFile, &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; Analyzer(), create);&lt;/div&gt;
&lt;div class="paragraph"&gt;
writer.mergeFactor = 20;
      // now add &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;this&lt;/span&gt; document to the Index
      // we use an adapter class, which is given a
      // file and returns a document, which lucene
      // can index
      writer.addDocument(FileDocument.Document(file));
      writer.optimize();
    } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;catch&lt;/span&gt;(InterruptedException e) {
     &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;throw&lt;/span&gt; &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; IndexException(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"Unable to index document."&lt;/span&gt;, e);
   } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;catch&lt;/span&gt;(IOException e) {
     &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;throw&lt;/span&gt; &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; IndexException(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"Unable to index document."&lt;/span&gt;, e);
   } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;finally&lt;/span&gt; {
     close(writer);
   }
  }&lt;/div&gt;
&lt;div class="paragraph"&gt;
// close writer
  &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;static&lt;/span&gt; void close(IndexWriter writer) {
    &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;if&lt;/span&gt;(&lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;null&lt;/span&gt; != writer) {
      &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;try&lt;/span&gt; {
        writer.close();
      } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;catch&lt;/span&gt;(Exception e) {
      }
    }
  }
}&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
The convertion class used in FileIndexer is easy. It converts the File object to a Lucene document. Usually you use a Class with a static method Document as a factory method.&lt;/div&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;div class="code" style="border-bottom-color: black; border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: black; border-left-style: dashed; border-left-width: 1px; border-right-color: black; border-right-style: dashed; border-right-width: 1px; border-top-color: black; border-top-style: dashed; border-top-width: 1px; font-family: courier, 'courier new', monospace; font-size: 12px; line-height: 12px; margin-bottom: 4px; margin-top: 4px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; white-space: pre; width: 568px;"&gt;
&lt;pre&gt;&lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;public&lt;/span&gt; class FileDocument {
  // Lucene can only index objects of type
  // Document. So the to be indexed object
  // must be converted to &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;this&lt;/span&gt; document,
  // usually with a &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;static&lt;/span&gt; method&lt;div class="paragraph"&gt;
&lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;static&lt;/span&gt; Document Document(File file) {
    // load content of file, get name, path and date
    // and store them into content, name, date 
    ...&lt;/div&gt;
&lt;div class="paragraph"&gt;
Document doc = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; Document();&lt;/div&gt;
&lt;div class="paragraph"&gt;
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
      DateFormat.SHORT, Locale.GERMANY);&lt;/div&gt;
&lt;div class="paragraph"&gt;
// we want to index the fields content, name and date
    // we can then search &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;for&lt;/span&gt; &lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"house"&lt;/span&gt; everywhere or
    // &lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"content:house"&lt;/span&gt; in content.
    // fields can be added that are not indexed but
    // can be acessed at search time. This is e.g. useful
    // &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;for&lt;/span&gt; storing object primary keys etc.
    doc.add(Field.Text(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"content"&lt;/span&gt;, content));
    doc.add(Field.Text(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"path"&lt;/span&gt;, path);
    doc.add(Field.Text(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"name"&lt;/span&gt;, name);
    doc.add(Field.Text(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"date"&lt;/span&gt;, df.format(message.getSentDate())));
    &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;return&lt;/span&gt; doc;
  }
}&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;div class="paragraph"&gt;
&lt;/div&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
The FileSearcher class uses the index to find documents.&lt;/div&gt;
&lt;ol style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;li&gt;Get a QueryString&lt;/li&gt;
&lt;li&gt;Get an IndexSearcher&lt;/li&gt;
&lt;li&gt;Parse the Query&lt;/li&gt;
&lt;li&gt;Give the parsed Query to the IndexSearcher&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The IndexSearcher will return an Array with matching documents, sorted by hit quality&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="paragraph" style="background-color: white; color: #4c4c4c; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Geneva, Lucida, Helvetica, sans-serif; font-size: 11px; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;div class="snip-content" style="margin-top: 10px; width: 580px;"&gt;
&lt;div&gt;
&lt;div class="code" style="background-color: #fffced; border-bottom-color: black; border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: black; border-left-style: dashed; border-left-width: 1px; border-right-color: black; border-right-style: dashed; border-right-width: 1px; border-top-color: black; border-top-style: dashed; border-top-width: 1px; color: inherit; font-family: courier, 'courier new', monospace; font-size: 12px; line-height: 12px; margin-bottom: 4px; margin-top: 4px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; white-space: pre; width: 568px;"&gt;
&lt;pre&gt;// Get the query &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;String&lt;/span&gt; e.g. from the comand line
    ...&lt;div class="paragraph"&gt;
// Create a searcher from the index file
    &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;String&lt;/span&gt; indexFile = &lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"/tmp/fileindex"&lt;/span&gt;;
    Searcher searcher = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;null&lt;/span&gt;;
    &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;try&lt;/span&gt; {
      searcher = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; IndexSearcher(indexFile);
    } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;catch&lt;/span&gt;(IOException e) {
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.out.println(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"Unable to open index file: "&lt;/span&gt; + indexFile);
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.exit(1);
    }&lt;/div&gt;
&lt;div class="paragraph"&gt;
// parse the query &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;String&lt;/span&gt;.
    Query query = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;null&lt;/span&gt;;
    &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;try&lt;/span&gt; {
      // If no prefix &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;for&lt;/span&gt; a word is given, then search in 
      // content by &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;default&lt;/span&gt;
      query = QueryParser.parse(queryString, &lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"content"&lt;/span&gt;, &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; Analyzer());
    } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;catch&lt;/span&gt;(ParseException e) {
      close(searcher);
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.out.println(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"Unable to parse: "&lt;/span&gt; + queryString);
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.exit(1);
    }&lt;/div&gt;
&lt;div class="paragraph"&gt;
// get the hits from the searcher &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;for&lt;/span&gt;
    // the given query
    Hits hits = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;null&lt;/span&gt;;
    &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;try&lt;/span&gt; {
      hits = searcher.search(query);
    } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;catch&lt;/span&gt;(IOException e) {
      close(searcher);
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.out.println(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"IO Error."&lt;/span&gt;);
      e.printStackTrace();
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.exit(1);
    }&lt;/div&gt;
&lt;div class="paragraph"&gt;
// iterate over the results
    // the results are an array of document
    &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;try&lt;/span&gt; {
      // display the first 10 results
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;int&lt;/span&gt; start = 0;
      &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;final&lt;/span&gt; &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;int&lt;/span&gt; HITS_PER_PAGE = 10;
      &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;int&lt;/span&gt; end = &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;Math&lt;/span&gt;.min(HITS_PER_PAGE, hits.length());&lt;/div&gt;
&lt;div class="paragraph"&gt;
&lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;if&lt;/span&gt;(hits.length() &amp;gt; 0) {
        PrintfFormat pf = &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; PrintfFormat(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"%-20s %-30s %-30s"&lt;/span&gt;);
        &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.out.println(pf.sprintf(&lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;Object&lt;/span&gt;[]{&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"Date"&lt;/span&gt;,&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"Subject"&lt;/span&gt;,&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"To"&lt;/span&gt;}));
        &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;for&lt;/span&gt;(&lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;int&lt;/span&gt; i = start; i &amp;lt; end; i++) {
          &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.out.println(pf.sprintf(
            &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;Object&lt;/span&gt;[] { 
           // retrieve the indexed Fields from the result documents.
           // we could also get a persisten object key and load
           // the objects &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;for&lt;/span&gt; further attributes to display
           hits.doc(i).get(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"path"&lt;/span&gt;),
           hits.doc(i).get(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"name"&lt;/span&gt;),
           hits.doc(i).get(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"date"&lt;/span&gt;)}));
        }
      } &lt;span class="java-keyword" style="background-color: inherit; color: #0000aa; font-weight: bold;"&gt;else&lt;/span&gt; {
        &lt;span class="java-object" style="background-color: inherit; color: #000088;"&gt;System&lt;/span&gt;.out.println(&lt;span class="java-quote" style="background-color: inherit; color: #00aa00;"&gt;"No matching files found."&lt;/span&gt;);
      }&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br class="Apple-interchange-newline" /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-7925004789022395213?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/7925004789022395213/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=7925004789022395213' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/7925004789022395213?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/7925004789022395213?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2012/02/lucene-very-good-search-engine.html' title='Lucene very good search engine'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Dk4AQns-cCp7ImA9WhRUFko.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-7805650036672452152</id><published>2012-01-27T06:35:00.000-08:00</published><updated>2012-01-27T06:35:43.558-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-01-27T06:35:43.558-08:00</app:edited><title>Load balancing JK - apache2 - JBoss</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;div id="toctitle"&gt;
&lt;h2&gt;

Sommaire&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li class="toclevel-1"&gt;&lt;span class="tocnumber"&gt;1&lt;/span&gt; &lt;span class="toctext"&gt;Produits utilisés&lt;/span&gt;&lt;/li&gt;
&lt;li class="toclevel-1"&gt;&lt;span class="tocnumber"&gt;2&lt;/span&gt; &lt;span class="toctext"&gt;Schéma de déploiement du Load Balancer&lt;/span&gt;&lt;/li&gt;
&lt;li class="toclevel-1"&gt;&lt;span class="tocnumber"&gt;3&lt;/span&gt; &lt;span class="toctext"&gt;Installation du module apache2 JK&lt;/span&gt;&lt;/li&gt;
&lt;li class="toclevel-1"&gt;&lt;span class="tocnumber"&gt;4&lt;/span&gt; &lt;span class="toctext"&gt;Configuration du module JK&lt;/span&gt;&lt;/li&gt;
&lt;li class="toclevel-1"&gt;&lt;span class="tocnumber"&gt;5&lt;/span&gt; &lt;span class="toctext"&gt;Configuration des serveurs JBoss &amp;amp; activation du protocole AJP/1.3&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h2&gt;

&amp;nbsp;Produits utilisés  &lt;/h2&gt;
&lt;pre&gt;- JBoss 4.2.3 GA
- Apache2.2.x
- module apache2 JK 1.2.31
&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;h2&gt;

Schéma de déploiement du Load Balancer&lt;/h2&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/--V6-psTwbkk/TyK18riMYFI/AAAAAAAAAFY/2b38UpD0Ago/s1600/Deploiement_load_balancing_jboss.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/--V6-psTwbkk/TyK18riMYFI/AAAAAAAAAFY/2b38UpD0Ago/s320/Deploiement_load_balancing_jboss.gif" width="245" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;/div&gt;
&lt;h2&gt;

 Installation du module apache2 JK &lt;/h2&gt;
1- Télécharger le module apache2 suivant&amp;nbsp;: 


&lt;a class="external text" href="http://mirror.ibcp.fr/pub/apache//tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/i386/mod_jk-1.2.31-httpd-2.2.x.so" rel="nofollow" title="http://mirror.ibcp.fr/pub/apache//tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/i386/mod jk-1.2.31-httpd-2.2.x.so"&gt;mod_jk-1.2.31-httpd-2.2.x.so&lt;/a&gt;


ou 



&lt;pre&gt;wget http://mirror.ibcp.fr/pub/apache//tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/i386/mod_jk-1.2.31-httpd-2.2.x.so
&lt;/pre&gt;
2- Copier le fichier .so dans le répertoire module du server web apache



&lt;pre&gt;cp mod_jk-1.2.31-httpd-2.2.x.so /usr/lib/apache2/modules/mod_jk.so
&lt;/pre&gt;
&lt;h2&gt;

 Configuration du module JK &lt;/h2&gt;
1- Dans le fichier httpd.conf du server web apache2, ajouter les lignes suivantes&amp;nbsp;:


/etc/apache2/httpd.conf



&lt;pre&gt;LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile Workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile logs/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
#JkMount /* loadbalancer
#JkMount /index.php loadbalancer
#JkMount /jmx-console/* loadbalancer
#JkMount /jkstatus loadbalancer
JkMount /gsi_engine/* loadbalancer
&lt;ifmodule worker.c=""&gt;
        StartServers 5
        MaxClients 150
        MinSpareThreads 25
        MaxSpareThreads 75
        ThreadsPerChild 25
        MaxRequestsPerChild 0
&lt;/ifmodule&gt;
&lt;/pre&gt;
2- Créer le fichier Workers.properties dans /etc/apache2/



&lt;pre&gt;# Define 1 real worker using ajp13

worker.list=loadbalancer,status
# Set properties for worker1 (ajp13) JBoss 1
worker.worker1.type=ajp13
worker.worker1.host=10.0.3.61
worker.worker1.port=8109
worker.worker1.lbfactor=1
worker.worker1.connection_pool_size=10
worker.worker1.redirect=worker2
# Set properties for worker2 (ajp13) JBoss2
worker.worker2.type=ajp13
worker.worker2.host=10.0.3.58
worker.worker2.port=8109
worker.worker2.lbfactor=1
worker.worker2.connection_pool_size=10
#fonctionnement de l'equilibrage de charge
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1,worker2
worker.loadbalancer.sticky_session=True
worker.status.type=status
# Disable worker3 for all requests except failover
worker.worker2.activation=disabled
&lt;/pre&gt;
3- Créer le fichier uriworkermap.properties dans /etc/apache2/



&lt;pre&gt;/status=status
&lt;/pre&gt;
4- Créer le répertoire de log pour le module JK



&lt;pre&gt;mkdir /etc/apache2/logs
&lt;/pre&gt;
5- Redémarrer le server apache2



&lt;pre&gt;/etc/init.d/apache2 restart
&lt;/pre&gt;
&lt;h2&gt;

 Configuration des serveurs JBoss &amp;amp; activation du protocole AJP/1.3&lt;/h2&gt;
Pour chaque Serveur JBoss, il faut faire 


1- Dans le fichier de config 
$JBOSS_HOME/server/$SERVER_INSTANCE/deploy/jboss-web.deployer/META-INF/jboss-service.xml,
 modifier la balise suivante&amp;nbsp;:



&lt;pre&gt;&lt;attribute name="UseJK"&gt;false&lt;/attribute&gt;
&lt;/pre&gt;
&lt;pre&gt;&lt;attribute name="UseJK"&gt;true&lt;/attribute&gt;
&lt;/pre&gt;
2- Dans le fichier de config 
$JBOSS_HOME/server/$SERVER_INSTANCE/deploy/jboss-web.deployer/server.xml,
 décommenter le bloc suivant pour activer l'AJP/1.3&amp;nbsp;:



&lt;pre&gt;    &lt;connector address="${jboss.bind.address}" emptysessionpath="true" enablelookups="false" port="8009" protocol="AJP/1.3" redirectport="8443"&gt;

&lt;/connector&gt;&lt;/pre&gt;
3- Redémarrer le server JBoss



&lt;pre&gt;/etc/init.d/jboss restart
&lt;/pre&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-7805650036672452152?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/7805650036672452152/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=7805650036672452152' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/7805650036672452152?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/7805650036672452152?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2012/01/load-balancing-jk-apache2-jboss.html' title='Load balancing JK - apache2 - JBoss'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/--V6-psTwbkk/TyK18riMYFI/AAAAAAAAAFY/2b38UpD0Ago/s72-c/Deploiement_load_balancing_jboss.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DUcESHY5fip7ImA9WhRVE0U.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-7389777979717605288</id><published>2012-01-12T08:50:00.000-08:00</published><updated>2012-01-12T08:50:09.826-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-01-12T08:50:09.826-08:00</app:edited><title>Apache Thrift Example</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif; font-size: large;"&gt;&lt;b&gt;Thrift Example&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif; text-align: left;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif; text-align: left;"&gt;- Used tools&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Eclipse&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="text-align: left;"&gt;thrift-0.8.0&lt;/span&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="text-align: left;"&gt;JDK1.7&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;1- Download thrift-0.8.0.exe from the following url (http://www.apache.org/dyn/closer.cgi?path=/thrift/0.8.0/thrift-0.8.0.exe&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;2- &amp;nbsp;Create the thrift file:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;u&gt;&lt;b&gt;time.thrift&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;# time.thrift&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;namespace java tserver.gen&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;typedef i64 Timestamp&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;service TimeServer&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp;Timestamp time()&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;3 - Generate the java classes for server and client&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Command:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;gt; &lt;b&gt;thrift-0.8.0.exe&amp;nbsp;--gen java time.thrift&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;-&amp;gt; We will find all java generated classes in&amp;nbsp;gen-java directory&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;4- Implements Iface server class:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;package com.sample.thrift.server;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.TException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import tserver.gen.*;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;class TimeServerImpl implements TimeServer.Iface&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp;@Override&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp;public long time() throws TException&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; long time = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println("time() called: " + time);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return time;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;5- Create server class:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;&lt;span style="color: blue;"&gt;&lt;u&gt;Server.java&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;package com.sample.thrift.server;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import java.io.IOException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import java.net.InetAddress;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import java.net.UnknownHostException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.protocol.TBinaryProtocol;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.protocol.TBinaryProtocol.Factory;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.server.TServer;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.server.TThreadPoolServer;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TSSLTransportFactory;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TSSLTransportFactory.TSSLTransportParameters;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TServerSocket;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TTransportException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import tserver.gen.TimeServer;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;public class Server&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;private void startSampleServer()&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;try&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TServerSocket serverTransport = new TServerSocket(7911); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TimeServer.Processor processor = new TimeServer.Processor(new TimeServerImpl());&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;Factory protFactory = new TBinaryProtocol.Factory(true, true);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor).protocolFactory(protFactory));&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;System.out.println("Starting server on port 7911 ...");&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;server.serve();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;catch (TTransportException e)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;private void startSslServer()&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;try&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;params.setKeyStore("C:/Users/jamel/eclipse.helios.workspace/ThriftClientServer/certificat_ssl/saskeystore.jks", "sas001");&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TServerSocket serverTransport = TSSLTransportFactory.getServerSocket(7912, 10000, InetAddress.getByName("localhost"), params);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TimeServer.Processor processor = new TimeServer.Processor(new TimeServerImpl());&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;Factory protFactory = new TBinaryProtocol.Factory(true, true);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor).protocolFactory(protFactory));&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;System.out.println("Starting server on port 7912 ...");&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;server.serve();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;catch (TTransportException e)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;catch (UnknownHostException e)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;public static void main(String args[])&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;Server srv = new Server();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;//srv.startSampleServer();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;srv.startSslServer();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;6- Create Client Class:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;&lt;u&gt;&lt;span style="color: blue;"&gt;TimeClient.java&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;package com.sample.thrift.client;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.TException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.protocol.TBinaryProtocol;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.protocol.TProtocol;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TSSLTransportFactory;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TSocket;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TTransport;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import org.apache.thrift.transport.TTransportException;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;import tserver.gen.TimeServer.Client;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;public class TimeClient&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;private void startSampleClient()&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;TTransport transport;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;try&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;transport = new TSocket("localhost", 7911);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TProtocol protocol = new TBinaryProtocol(transport);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;Client client = new Client(protocol);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;transport.open();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;long time = client.time();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;System.out.println("Time from server:" + time);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;transport.close();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;catch (TTransportException e)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;catch (TException e)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;private void startSslClient()&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;TTransport transport;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;try&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;params.setTrustStore("C:/Users/jamel/eclipse.helios.workspace/ThriftClientServer/certificat_ssl/sastruststore.jks", "sas001");&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;transport = TSSLTransportFactory.getClientSocket("localhost", 7912, 10000, params);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;TProtocol protocol = new TBinaryProtocol(transport);&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;Client client = new Client(protocol);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;//transport.open();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;long time = client.time();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;System.out.println("Time from server:" + time);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;transport.close();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;catch (TTransportException e)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;catch (TException e)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;public static void main(String[] args)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;TimeClient c = new TimeClient();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;//c.startSampleClient();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;c.startSslClient();&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;7- Create keystore and trustore for SSL&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;u&gt;&lt;span style="color: blue;"&gt;&lt;b&gt;createSQSKeystoreandTruststore.bat&lt;/b&gt;&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;@echo off&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;if "%JAVA_HOME%" == "" (&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;set "JAVA_HOME=C:\Program Files\Java\jdk1.7.0\"&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;set "KEYTOOL_CMD="%JAVA_HOME%bin\keytool.exe""&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;rem créer le fichier de keystore&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;%KEYTOOL_CMD% -genkeypair -alias sascertificatekey -keyalg RSA -validity 7 -keystore saskeystore.jks -storepass sas001 -keypass sas001&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;echo saskeystore.jks crée&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;rem créer le fichier cert.cer&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;%KEYTOOL_CMD% -export -alias sascertificatekey -keystore saskeystore.jks -rfc -file cert.cer -storepass sas001 -keypass sas001&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;echo cert.cer crée&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;rem créer le fichier de sastruststore&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;%KEYTOOL_CMD% -import -alias certificatekey -file cert.cer -keystore sastruststore.jks -storepass sas001 -keypass sas001&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;echo Certificat importée avec succée&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;@pause&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-7389777979717605288?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/7389777979717605288/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=7389777979717605288' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/7389777979717605288?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/7389777979717605288?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2012/01/apache-thrift-example.html' title='Apache Thrift Example'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DUUNRHk6fip7ImA9WhZTEks.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-8759112762900623418</id><published>2011-03-15T09:12:00.001-07:00</published><updated>2011-03-16T02:21:35.716-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-16T02:21:35.716-07:00</app:edited><title>JMS Queue Producer</title><content type='html'>&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;package com.test;&lt;br /&gt;&lt;br /&gt;import java.util.Hashtable;&lt;br /&gt;import java.util.Properties;&lt;br /&gt;&lt;br /&gt;import javax.jms.Connection;&lt;br /&gt;import javax.jms.ConnectionFactory;&lt;br /&gt;import javax.jms.Destination;&lt;br /&gt;import javax.jms.JMSException;&lt;br /&gt;import javax.jms.Message;&lt;br /&gt;import javax.jms.MessageProducer;&lt;br /&gt;import javax.jms.Session;&lt;br /&gt;import javax.jms.TextMessage;&lt;br /&gt;import javax.naming.Context;&lt;br /&gt;import javax.naming.InitialContext;&lt;br /&gt;import javax.naming.NamingException;&lt;br /&gt;&lt;br /&gt;public class JmsQueueClient&lt;br /&gt;{&lt;br /&gt;   public static void main(String ...strings)&lt;br /&gt;   {&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           Context getMyContext = null;&lt;br /&gt;           try&lt;br /&gt;           {&lt;br /&gt;               Properties env = new Properties();&lt;br /&gt;               env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );&lt;br /&gt;               env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");&lt;br /&gt;               env.put(Context.PROVIDER_URL, "jnp://localhost:1199");&lt;br /&gt;               env.put(Context.SECURITY_PRINCIPAL, "guest");&lt;br /&gt;               env.put(Context.SECURITY_CREDENTIALS, "guest");&lt;br /&gt;&lt;br /&gt;               getMyContext = new InitialContext(env);&lt;br /&gt;             &lt;br /&gt;           }&lt;br /&gt;           catch (NamingException myNamingException)&lt;br /&gt;           {&lt;br /&gt;               System.out.println("Error establishing Connection" + ": " + myNamingException.toString());&lt;br /&gt;               System.exit(1);&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           ConnectionFactory myJMSFactory = null;&lt;br /&gt;           Destination myJMSDest = null;&lt;br /&gt;           try&lt;br /&gt;           {&lt;br /&gt;               myJMSFactory = (ConnectionFactory) getMyContext.lookup("ConnectionFactory");&lt;br /&gt;               myJMSDest = (Destination) getMyContext.lookup("queue/myAppQueue");&lt;br /&gt;           }&lt;br /&gt;           catch (Exception e)&lt;br /&gt;           {&lt;br /&gt;               System.out.println("Lookup failed: " +e);&lt;br /&gt;               System.exit(1);&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           Connection myJMSConnection = myJMSFactory.createConnection();&lt;br /&gt;&lt;br /&gt;           Session myJMSSession = myJMSConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);&lt;br /&gt;         &lt;br /&gt;           MessageProducer myJMSProducer = myJMSSession.createProducer(myJMSDest);&lt;br /&gt;           TextMessage message = myJMSSession.createTextMessage();&lt;br /&gt;           message.setText("Hello there from publisher");&lt;br /&gt;&lt;br /&gt;           myJMSProducer.send(message);&lt;br /&gt;       }&lt;br /&gt;       catch (JMSException e)&lt;br /&gt;       {&lt;br /&gt;           System.out.println(e);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-8759112762900623418?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/8759112762900623418/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=8759112762900623418' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/8759112762900623418?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/8759112762900623418?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2011/03/jms-queue-producer.html' title='JMS Queue Producer'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Dk4BRXs-fyp7ImA9WhZTEk0.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-5667415965959863439</id><published>2011-03-15T08:42:00.000-07:00</published><updated>2011-03-15T09:02:34.557-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-15T09:02:34.557-07:00</app:edited><title>Sécurisation du Serveur JBoss</title><content type='html'>&lt;ul&gt;&lt;li&gt;Sécuriser les Consoles JMX&lt;/li&gt;&lt;/ul&gt;Les consoles JMX (jmx-console) et Web (web-console) sont des applications Web traditionnelles, elles doivent donc être sécurisées en tant que tel. Les configurations fournies avec JBoss permettent d'activer l'authentification très rapidement puisque tout le paramétrage est présent dans les fichiers web.xml et jboss-web.xml, mais en commentaire.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!-- web.xml --&amp;gt;&lt;br /&gt;&amp;lt;security-constraint&amp;gt;&lt;br /&gt;&amp;lt;web-resource-collection&amp;gt;&lt;br /&gt;&amp;lt;web-resource-name&amp;gt;HtmlAdaptor&amp;lt;/web-resource-name&amp;gt;&lt;br /&gt;&amp;lt;description&amp;gt;An example security config that only allows users with the&lt;br /&gt;role JBossAdmin to access the HTML JMX console web application&lt;br /&gt;&amp;lt;/description&amp;gt;&lt;br /&gt;&amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;&amp;lt;http-method&amp;gt;GET&amp;lt;/http-method&amp;gt;&lt;br /&gt;&amp;lt;http-method&amp;gt;POST&amp;lt;/http-method&amp;gt;&lt;br /&gt;&amp;lt;/web-resource-collection&amp;gt;&lt;br /&gt;&amp;lt;auth-constraint&amp;gt;&lt;br /&gt;&amp;lt;role-name&amp;gt;JBossAdmin&amp;lt;/role-name&amp;gt;&lt;br /&gt;&amp;lt;/auth-constraint&amp;gt;&lt;br /&gt;&amp;lt;/security-constraint&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;login-config&amp;gt;&lt;br /&gt;&amp;lt;auth-method&amp;gt;BASIC&amp;lt;/auth-method&amp;gt;&lt;br /&gt;&amp;lt;realm-name&amp;gt;JBoss JMX Console&amp;lt;/realm-name&amp;gt;&lt;br /&gt;&amp;lt;/login-config&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;security-role&amp;gt;&lt;br /&gt;&amp;lt;role-name&amp;gt;JBossAdmin&amp;lt;/role-name&amp;gt;&lt;br /&gt;&amp;lt;/security-role&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Attention cependant, à utiliser le même "security-domain" pour les deux consoles, ce qui n'est pas le cas avec les exemples fournis. Il faut veiller aussi à changer les login et password par défaut dans les fichiers properties :&lt;br /&gt;&lt;br /&gt;JBOSS_HOME/server/ports-01/conf/props/jbossws-roles.properties&lt;br /&gt;JBOSS_HOME/server/ports-01/conf/props/jbossws-users.properties&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!-- jboss-web.xml --&amp;gt;&lt;br /&gt;&amp;lt;security-domain&amp;gt;java:/jaas/jmx-console&amp;lt;/security-domain&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Sécuriser le JMX Invoker&lt;/li&gt;&lt;/ul&gt;- Authentification:&lt;br /&gt;&lt;br /&gt;Les accès via RMI et twiddle passent par le jmx-invoker. Pour le sécuriser, il faut décommenter la partie proposée en fin du fichier jmx-invoker-service.xml :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!-- deploy/jmx-invoker-service.xml --&amp;gt;&lt;br /&gt;&amp;lt;descriptors&amp;gt;&lt;br /&gt; &amp;lt;interceptors&amp;gt;&lt;br /&gt;   &amp;lt;interceptor code="org.jboss.jmx.connector.invoker.AuthenticationInterceptor"&lt;br /&gt;                securityDomain="java:/jaas/jmx-console"/&amp;gt;&lt;br /&gt; &amp;lt;/interceptors&amp;gt;&lt;br /&gt;&amp;lt;/descriptors&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Un fois cette partie activée, les accès RMI nécessitent du authentification via un ClientLoginModule ou via la connexion à JNDI. Les accès par script (twiddle ou shutdown) nécessitent de renseigner les arguments -u et -p.&lt;br /&gt;&lt;br /&gt;- Restrictions réseau :&lt;br /&gt;&lt;br /&gt;La sécurité des accès distants peut encore être renforcée par un filtrage au niveau système.&lt;br /&gt;Le jmx-invoker utilise un protocole de communication RMI qui s'appuie sur un invoker jrmp, pooled, iiop ou http. En standard, c'est l'invoker jrmp qui est utilisé. Par conséquent, les accès twiddle ou RMI se font via le port 4444. Si on crée un nouvel invoker, sur un autre port, il est alors possible de faire passer uniquement les invocations JMX par ce nouvel invoker. Il reste alors à paramétrer le firewall système du serveur pour qu'il n'accepte que les adresses IP des postes d'administrateur sur ce port.&lt;br /&gt;Pour créer un nouvel invoker, on duplique l'invoker jrmp, du fichier conf/jboss-service.xml, en changeant le port et le nom du MBean ; puis on modifie le ProxyFactory du JmxInvoker.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!-- deploy/jmx-invoker-service.xml --&amp;gt;&lt;br /&gt;&amp;lt;mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"&lt;br /&gt;  name="jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFactory"&amp;gt;&lt;br /&gt;  &amp;lt;depends optional-attribute-name="InvokerName"&amp;gt;jboss:service=invoker,type=admin&amp;lt;/depends&amp;gt;&lt;br /&gt;&amp;lt;/mbean&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- RMI/JRMP invoker for Admin --&amp;gt;&lt;br /&gt;&amp;lt;mbean code="org.jboss.invocation.jrmp.server.JRMPInvoker"&lt;br /&gt;  name="jboss:service=invoker,type=admin"&amp;gt;&lt;br /&gt;  &amp;lt;attribute name="RMIObjectPort"&amp;gt;4449&amp;lt;/attribute&amp;gt;&lt;br /&gt;  &amp;lt;attribute name="ServerAddress"&amp;gt;${jboss.bind.address}&amp;lt;/attribute&amp;gt;&lt;br /&gt;  &amp;lt;depends&amp;gt;jboss:service=TransactionManager&amp;lt;/depends&amp;gt;&lt;br /&gt;&amp;lt;/mbean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-5667415965959863439?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/5667415965959863439/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=5667415965959863439' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/5667415965959863439?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/5667415965959863439?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2011/03/securisation-du-serveur-jboss.html' title='Sécurisation du Serveur JBoss'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;A04MSHk9fyp7ImA9Wx9aGEk.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-1328921659158543133</id><published>2011-03-11T05:13:00.000-08:00</published><updated>2011-03-11T05:26:29.767-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-11T05:26:29.767-08:00</app:edited><title>Comment créer des EJBs WebService</title><content type='html'>1- Création de l'interface EJB&lt;br /&gt;&lt;code&gt;&lt;br /&gt;package org.test&lt;br /&gt;&lt;br /&gt;import javax.jws.WebService;&lt;br /&gt;import javax.jws.soap.SOAPBinding;&lt;br /&gt;import javax.jws.soap.SOAPBinding.Style;&lt;br /&gt;import javax.xml.soap.SOAPException;&lt;br /&gt;&lt;br /&gt;@WebService&lt;br /&gt;@SOAPBinding(style = Style.RPC)&lt;br /&gt;public interface IUserManagerEJB&lt;br /&gt;{&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;public void createNewUser(User user) throws SOAPSession&lt;/div&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;2- Création de la classe EJB&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;package org.test&lt;br /&gt;&lt;br /&gt;import javax.annotation.Resource;&lt;br /&gt;import javax.ejb.Remote;&lt;br /&gt;import javax.ejb.Stateless;&lt;br /&gt;import javax.jws.HandlerChain;&lt;br /&gt;import javax.jws.WebService;&lt;br /&gt;import javax.xml.namespace.QName;&lt;br /&gt;import javax.xml.soap.SOAPException;&lt;br /&gt;import javax.xml.ws.WebServiceContext;&lt;br /&gt;import javax.xml.ws.handler.soap.SOAPMessageContext;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@Stateless&lt;br /&gt;@WebService(endpointInterface = "org.test.IUserManagerEJB")&lt;/code&gt;&lt;div&gt;&lt;code&gt;@Remote(IUserManagerEJB.class)&lt;br /&gt;@HandlerChain(file="aas_handler.xml")&lt;br /&gt;public class UserManagerEJB implements IUserManagerEJB&lt;br /&gt;{&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;@Resource&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;private WebServiceContext ctx;&lt;/div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;public void createNewUser(User user) throws SOAPSession&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;// Implementatation de la méthode&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Fichier aas_handler.xml&lt;br /&gt;&lt;br /&gt;&amp;lt;handler-chains xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee"&amp;gt;&lt;br /&gt; &amp;lt;handler-chain&amp;gt;&lt;br /&gt;   &amp;lt;handler&amp;gt;&lt;br /&gt;     &amp;lt;handler-name&amp;gt;AuthenticationHandler&amp;lt;/handler-name&amp;gt;&lt;br /&gt;     &amp;lt;handler-class&amp;gt;com.test.AASHandler&amp;lt;/handler-class&amp;gt;&lt;br /&gt;   &amp;lt;/handler&amp;gt;&lt;br /&gt; &amp;lt;/handler-chain&amp;gt;&lt;br /&gt;&amp;lt;/handler-chains&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;package com.test;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class AASHandler implements SOAPHandler&lt;soapmessagecontext&gt;&lt;br /&gt;{&lt;br /&gt;  // Complete Implemented méthode here&lt;br /&gt;}&lt;br /&gt;&lt;/soapmessagecontext&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-1328921659158543133?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/1328921659158543133/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=1328921659158543133' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/1328921659158543133?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/1328921659158543133?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2011/03/comment-creer-des-ejbs-webservice.html' title='Comment créer des EJBs WebService'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;A0YDRHwzeSp7ImA9Wx9aGEk.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-6711279847034190045</id><published>2011-03-11T02:41:00.000-08:00</published><updated>2011-03-11T05:12:55.281-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-11T05:12:55.281-08:00</app:edited><title>MBean Service Proxy</title><content type='html'>MBeanServerConnection server = (MBeanServerConnection) ic.lookup ("jmx/invoker/RMIAdaptor");&lt;br /&gt;&lt;br /&gt;ObjectName serviceName = new ObjectName("jboss:service=Gsi");&lt;br /&gt;&lt;br /&gt;SystemConfigurationServiceMBean myServiceProxy = JMX.newMBeanProxy(server, serviceName, SystemConfigurationServiceMBean.class, true);&lt;br /&gt;&lt;br /&gt;Et maintenant vous pouvez utiliser les méthodes de votre MBean (interface).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-6711279847034190045?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/6711279847034190045/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=6711279847034190045' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/6711279847034190045?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/6711279847034190045?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2011/03/mbean-service-proxy.html' title='MBean Service Proxy'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0YDSXoyfyp7ImA9Wx9aGE4.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-1523587484930507013</id><published>2011-03-10T08:42:00.000-08:00</published><updated>2011-03-11T01:19:38.497-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-11T01:19:38.497-08:00</app:edited><title>Creation des topic et des Queue JMS</title><content type='html'>Pour la création des Topic et des queue JMS pour le serveur JBOSS, il suffit de créer un fichier {toto-destination-service.xml} dans le répertoire ${JBOSS_HOME}/server/ports-01/deploy/&lt;br /&gt;&lt;br /&gt;&lt;CODE&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;server&amp;gt;&lt;br /&gt;        &amp;lt;!--My queue, named: myAppQueue --&amp;gt;&lt;br /&gt;        &amp;lt;mbean code=&amp;quot;org.jboss.mq.server.jmx.Queue&amp;quot; name=&amp;quot;jboss.mq.destination:service=Queue,name=myAppQueue&amp;quot;&amp;gt;&lt;br /&gt;                &amp;lt;depends optional-attribute-name=&amp;quot;DestinationManager&amp;quot;&amp;gt;jboss.mq:service=DestinationManager&amp;lt;/depends&amp;gt;&lt;br /&gt;        &amp;lt;/mbean&amp;gt;&lt;br /&gt;        &amp;lt;!-- My topic, named: myAppTopic --&amp;gt;&lt;br /&gt;        &amp;lt;mbean code=&amp;quot;org.jboss.mq.server.jmx.Topic&amp;quot; name=&amp;quot;jboss.mq.destination:service=Topic,name=myAppTopic&amp;quot;&amp;gt;&lt;br /&gt;                &amp;lt;depends optional-attribute-name=&amp;quot;DestinationManager&amp;quot;&amp;gt;jboss.mq:service=DestinationManager&amp;lt;/depends&amp;gt;&lt;br /&gt;        &amp;lt;/mbean&amp;gt;&lt;br /&gt;&amp;lt;/server&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/CODE&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-1523587484930507013?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/1523587484930507013/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=1523587484930507013' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/1523587484930507013?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/1523587484930507013?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2011/03/creation-des-topic-et-des-queue-jms.html' title='Creation des topic et des Queue JMS'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0QGSXc5eSp7ImA9Wx9aF0o.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-5904043125882644873</id><published>2010-05-25T07:50:00.000-07:00</published><updated>2011-03-10T08:42:08.921-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-10T08:42:08.921-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='sessionfactory'/><title>Create Hibernate Session Factory</title><content type='html'>&lt;div&gt;package com.ictelecom.portal.engine.utils;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;import org.hibernate.Session;&lt;/div&gt;&lt;div&gt;import org.hibernate.SessionFactory;&lt;/div&gt;&lt;div&gt;import org.hibernate.cfg.AnnotationConfiguration;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class HibernateSessionFactory &lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;/** The single instance of hibernate SessionFactory */&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;private static org.hibernate.SessionFactory sessionFactory;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;/**&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * disable contructor to guaranty a single instance&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; */&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;private HibernateSessionFactory() {}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;public static SessionFactory getInstance() &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;if (sessionFactory == null)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;			&lt;/span&gt;sessionFactory = sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;return sessionFactory;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;/**&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * Opens a session and will not bind it to a session context&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * @return the session&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; */&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;public Session openSession() &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;return sessionFactory.openSession();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;/**&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * Returns a session from the session context. If there is no session in the context it opens a session,&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * stores it in the context and returns it.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * This factory is intended to be used with a hibernate.cfg.xml&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * including the following property &lt;property&lt; div=""&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * name="current_session_context_class"&gt;thread This would return&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * the current open session or if this does not exist, will create a new&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * session&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * @return the session&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; */&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;public Session getCurrentSession() &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;return sessionFactory.getCurrentSession();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;/**&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; * closes the session factory&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt; */&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;public static void close()&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;if (sessionFactory != null)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;			&lt;/span&gt;sessionFactory.close();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;sessionFactory = null;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/property&lt;&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-5904043125882644873?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/5904043125882644873/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=5904043125882644873' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/5904043125882644873?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/5904043125882644873?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2010/05/create-hibernate-session-factory.html' title='Create Hibernate Session Factory'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEcER347cCp7ImA9Wx9aF0o.&quot;'><id>tag:blogger.com,1999:blog-8226915763650217879.post-2593549628363988359</id><published>2010-02-05T04:51:00.001-08:00</published><updated>2011-03-10T08:53:26.008-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-10T08:53:26.008-08:00</app:edited><title>BlackBery Developpement Envirronment</title><content type='html'>Pour le développement des applications pour Blackbery vous pouvez utiliser le BlackBery Developpement Envirronment JDE disponible à l'adresse suivante :&lt;br /&gt;(http://na.blackberry.com/eng/developers/javaappdev/javadevenv.jsp)&lt;br /&gt;&lt;br /&gt;Pour la validation et le test de vos applications vous pouvez utiliser le simulateur disponible aussi sur le site de BlackBery.&lt;br /&gt;&lt;br /&gt;Voiçi un Exemple Simple :&lt;br /&gt;&lt;br /&gt;&lt;CODE&gt;&lt;br /&gt;&lt;br /&gt;import net.rim.device.api.ui.*;&lt;br /&gt;import net.rim.device.api.ui.container.*;&lt;br /&gt;import net.rim.device.api.ui.component.*;&lt;br /&gt;&lt;br /&gt;public class HelloWorld extends UiApplication&lt;br /&gt;{&lt;br /&gt; private MainScreen _screen;&lt;br /&gt; private ButtonField _nextScreen;&lt;br /&gt;&lt;br /&gt; public static void main(String[] args)&lt;br /&gt; {&lt;br /&gt;     HelloWorld instance = new HelloWorld();&lt;br /&gt;     instance.enterEventDispatcher();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public HelloWorld()&lt;br /&gt; {&lt;br /&gt;     _screen = new MainScreen();&lt;br /&gt;     _nextScreen = new ButtonField("Go to Next Screen",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);&lt;br /&gt;     _nextScreen.setChangeListener(new FieldChangeListener()&lt;br /&gt;     {&lt;br /&gt;         public void fieldChanged(Field field,int context)&lt;br /&gt;         {&lt;br /&gt;             pushScreen(new NextScreen());&lt;br /&gt;         }&lt;br /&gt;         });&lt;br /&gt;         _screen.setTitle(new LabelField("Hello World Demo",LabelField.USE_ALL_WIDTH));&lt;br /&gt;         _screen.add(new RichTextField("Hello to the BlackBerry World!",Field.NON_FOCUSABLE));&lt;br /&gt;         _screen.add(_nextScreen);&lt;br /&gt;         pushScreen(_screen);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;class NextScreen extends MainScreen&lt;br /&gt;{&lt;br /&gt;   public NextScreen()&lt;br /&gt;   {&lt;br /&gt;         setTitle(new LabelField("Second Screen !",LabelField.USE_ALL_WIDTH));&lt;br /&gt;         add(new RichTextField("This is new screen",Field.NON_FOCUSABLE));&lt;br /&gt;         ButtonField _btnGoBack = new ButtonField("Go Back",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);&lt;br /&gt;         _btnGoBack.setChangeListener(new FieldChangeListener()&lt;br /&gt;         {&lt;br /&gt;               public void fieldChanged(Field field,int context)&lt;br /&gt;               {&lt;br /&gt;                     UiApplication.getUiApplication().popScreen();&lt;br /&gt;               }&lt;br /&gt;              });&lt;br /&gt;         add(_btnGoBack);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/CODE&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8226915763650217879-2593549628363988359?l=cosinusc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosinusc.blogspot.com/feeds/2593549628363988359/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8226915763650217879&amp;postID=2593549628363988359' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/2593549628363988359?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8226915763650217879/posts/default/2593549628363988359?v=2'/><link rel='alternate' type='text/html' href='http://cosinusc.blogspot.com/2010/02/title.html' title='BlackBery Developpement Envirronment'/><author><name>Jamel ESSOUSSI</name><uri>http://www.blogger.com/profile/07993710851367967827</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_9JJ6gVgnYW4/SY13swMiHgI/AAAAAAAAAAM/FRhgp4ZSlco/S220/n667139795_1268293_2134.jpg'/></author><thr:total>0</thr:total></entry></feed>