<?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/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8255098757764522281</id><updated>2024-09-22T16:09:42.453-07:00</updated><title type='text'>soumya&#39;s</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-7538343231610957496</id><published>2014-04-30T22:03:00.001-07:00</published><updated>2018-08-08T23:48:33.851-07:00</updated><title type='text'>Activiti BPMN integration with spring</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Activiti is a lightweight BPMN engine distributed under apache2 license. Spring is a popular framework to develop J2EE applications. In this tutorial we will explain the integration between spring and activiti.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;The code for this example can be downloaded from&amp;nbsp;&lt;a href=&quot;https://github.com/soumyajitswain/supernova/tree/master/sampleactiviti&quot;&gt;github&lt;/a&gt;&lt;/b&gt;.&lt;/h4&gt;
&lt;br /&gt;
The project is build using maven. Few maven dependecies needs to be added in pom.xml.&lt;br /&gt;
&amp;lt;dependency&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;artifactId&amp;gt;spring-beans&amp;lt;/artifactId&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;version&amp;gt;${spring.version}&amp;lt;/version&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;scope&amp;gt;compile&amp;lt;/scope&amp;gt;&lt;br /&gt;
&amp;lt;/dependency&amp;gt;&lt;br /&gt;
&amp;lt;dependency&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;groupId&amp;gt;org.activiti&amp;lt;/groupId&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;artifactId&amp;gt;activiti-engine&amp;lt;/artifactId&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;version&amp;gt;5.15&amp;lt;/version&amp;gt;&lt;br /&gt;
&amp;lt;/dependency&amp;gt;&lt;br /&gt;
&amp;lt;dependency&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;groupId&amp;gt;org.activiti&amp;lt;/groupId&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;artifactId&amp;gt;activiti-spring&amp;lt;/artifactId&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;version&amp;gt;5.15&amp;lt;/version&amp;gt;&lt;br /&gt;
&amp;lt;/dependency&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activiti processEngineConfiguration should be made in spring context.&lt;br /&gt;
&amp;lt;bean id=&quot;processEngineConfiguration&quot; class=&quot;org.activiti.spring.SpringProcessEngineConfiguration&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManager&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;databaseSchemaUpdate&quot; value=&quot;true&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;jobExecutorActivate&quot; value=&quot;false&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bean id=&quot;processEngine&quot; class=&quot;org.activiti.spring.ProcessEngineFactoryBean&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;processEngineConfiguration&quot; ref=&quot;processEngineConfiguration&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
RuntimeService should be&amp;nbsp;@Autowired in the Spring service.This will be used to deploy the process definition and start the process for activiti.&lt;br /&gt;
&lt;pre style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;line&quot; id=&quot;LC18&quot; style=&quot;box-sizing: border-box; height: 18px; padding-left: 10px;&quot;&gt;
&lt;pre style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;line&quot; id=&quot;LC188&quot; style=&quot;box-sizing: border-box; height: 18px; padding-left: 10px;&quot;&gt;
&lt;pre style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;line&quot; id=&quot;LC29&quot; style=&quot;box-sizing: border-box; height: 18px; padding-left: 10px;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC29&quot; style=&quot;box-sizing: border-box; height: 18px; padding-left: 10px;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC29&quot; style=&quot;box-sizing: border-box; height: 18px; padding-left: 10px;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC29&quot; style=&quot;box-sizing: border-box; height: 18px; padding-left: 10px;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC29&quot; style=&quot;box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; height: 18px; line-height: 18px; padding-left: 10px;&quot;&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: navy;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC188&quot; style=&quot;box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; height: 18px; line-height: 18px; padding-left: 10px;&quot;&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC18&quot; style=&quot;box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; height: 18px; line-height: 18px; padding-left: 10px;&quot;&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: navy;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC18&quot; style=&quot;box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; height: 18px; line-height: 18px; padding-left: 10px;&quot;&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: navy;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/7538343231610957496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2014/04/activiti-bpmn-integration-with-spring.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/7538343231610957496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/7538343231610957496'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2014/04/activiti-bpmn-integration-with-spring.html' title='Activiti BPMN integration with spring'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-461226816065843311</id><published>2014-01-09T07:26:00.001-08:00</published><updated>2014-04-21T01:23:52.384-07:00</updated><title type='text'>Cross domain URL access in javascript ajax call</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The Javascript blocks any other domain to provide security to the application. This restriction can be overcomed by providing appropriate privilege to the URL. Whenever a ajax call it sends two header parameter origin and referrer. &amp;nbsp;If the domain for origin and referrer is different than the request is blocked by javascript.&lt;br /&gt;
&lt;br /&gt;
The origin should be first be registered with the referrer web application. The make Javascript identify the origin, the domain of the origin should be added in the response header.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Response Header&lt;/b&gt;&lt;br /&gt;
Access-Control-Allow-Origin:http://172.16.1.100:8080&lt;br /&gt;
Content-Length:0&lt;br /&gt;
Date:Wed, 30 Nov 2013 02:13:21 GMT&lt;br /&gt;
&lt;br /&gt;
Server:Jetty(7.5.4.v20111024)&lt;br /&gt;
&lt;br /&gt;
The header can be explicitly added in the response or a filter can be used to do the same. The ajax function of JQuery first sends a option request. If the origin is identified by the referrer server than it sends the actual request.&lt;br /&gt;
&lt;br /&gt;
A crossdomain filter can be added to a java based web application. This will validate the request for origin and headers.It will also appends the required response header like &quot;Access-Control_Allow-Origin&quot; to the response. &lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;Sponsored links :&lt;a href=&quot;http://diagnodeals.com/&quot;&gt;http://diagnodeals.com/&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/461226816065843311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2014/01/cross-domain-url-access-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/461226816065843311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/461226816065843311'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2014/01/cross-domain-url-access-in-javascript.html' title='Cross domain URL access in javascript ajax call'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-8440255431007986901</id><published>2013-12-15T09:52:00.000-08:00</published><updated>2013-12-15T09:52:13.610-08:00</updated><title type='text'>Spring batch restarting a failed job</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Spring batch provides a robust interface to process large set of files.The major operations that it does is to read , write and process files. It persists the processing state in persistence system like database or memory. Spring batch provides a exception handling process, where the task will be stopped incase of a exception. It can be restarted again using the JobOperator restart method.&lt;br /&gt;
&lt;br /&gt;
The JobOperator restart method takes the transaction id as input and restarts the job. First the failed batch should be identified and retrieved using the JobExplorer bean. Both bean should be defined in the context file.&lt;br /&gt;
&lt;br /&gt;
batch-context.xml&lt;br /&gt;
..... &lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;lt;bean id=&quot;jobOperator&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;class=&quot;org.springframework.batch.core.launch.support.SimpleJobOperator&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;jobExplorer&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;bean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;class=&quot;org.springframework.batch.core.explore.support.JobExplorerFactoryBean&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;jobRepository&quot; ref=&quot;jobRepository&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;jobRegistry&quot; ref=&quot;jobRegistry&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;jobLauncher&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;bean parent=&quot;jobLauncher&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;taskExecutor&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;bean class=&quot;org.springframework.core.task.SimpleAsyncTaskExecutor&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean id=&quot;jobExplorer&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;class=&quot;org.springframework.batch.core.explore.support.JobExplorerFactoryBean&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
SampleBatch.java&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String[] configLocation&amp;nbsp; = &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;config/jobs/job-context.xml&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ApplicationContext context = new ClassPathXmlApplicationContext(configLocation);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; JobLauncher jobLauncher = (JobLauncher) context.getBean(&quot;jobLauncher&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Job job = (Job) context.getBean(&quot;samplejob1&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; JobExplorer explorer = (JobExplorer) context.getBean(&quot;jobExplorer&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; JobOperator operator = (JobOperator)context.getBean(&quot;jobOperator&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; JobRegistry registry = (JobRegistry)context.getBean(&quot;jobRegistry&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; JobParameters jobParameters = &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new JobParametersBuilder()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .addLong(&quot;time&quot;,System.currentTimeMillis())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; .addString(&quot;fail&quot;, &quot;true&quot;).toJobParameters();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; JobExecution execution = jobLauncher.run(job, jobParameters);&lt;br /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Exit Status : &quot; + execution.getStatus());&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;JobInstance&amp;gt; instances = explorer.getJobInstances(&quot;samplejob1&quot;, 0, 10);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Exploler Size : &quot; + instances.size());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(JobInstance instance:instances) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;JobExecution&amp;gt; executions = explorer.getJobExecutions(instance);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Executions size : &quot; + executions.size());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(executions.size() &amp;gt; 0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; JobExecution jobExecution = executions.get(executions.size() - 1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(jobExecution.getStatus().name().equals(&quot;FAILED&quot;)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; long a= operator.restart(instance.getId());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Exit Status : &quot; + a);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (Exception e) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/8440255431007986901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2013/12/spring-batch-restarting-failed-job.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/8440255431007986901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/8440255431007986901'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2013/12/spring-batch-restarting-failed-job.html' title='Spring batch restarting a failed job'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-3314336951994177732</id><published>2013-12-12T21:32:00.001-08:00</published><updated>2013-12-12T21:32:44.458-08:00</updated><title type='text'>Memcache server integration using spring and google SSM</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Google SSM project makes the integration of memcache server quite easy. The main benefit of using the google SSM client is, it support various memcache java clients, spymemcache, xmemcache. It also provides a rich set of annotation which makes the use of memcache server quite efficient.&lt;br /&gt;
&lt;br /&gt;
We use the maven to build the project. The google SSM project provides the dependecies which include the both spymemcache and xmemcache client. The google SSM project is a extension of spring cache project.&lt;br /&gt;
&lt;br /&gt;
Maven dependencies&lt;br /&gt;
&amp;lt;dependency&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;groupId&amp;gt;com.google.code.simple-spring-memcached&amp;lt;/groupId&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;artifactId&amp;gt;spymemcached-provider&amp;lt;/artifactId&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;3.2.0&amp;lt;/version&amp;gt;&lt;br /&gt;
&amp;lt;/dependency&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cache-context.xml&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;lt;cache:annotation-driven /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean name=&quot;cacheManager&quot; class=&quot;com.google.code.ssm.spring.SSMCacheManager&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;caches&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;set&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;bean class=&quot;com.google.code.ssm.spring.SSMCache&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;constructor-arg name=&quot;cache&quot; index=&quot;0&quot; ref=&quot;defaultCache&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;!-- 5 minutes --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;constructor-arg name=&quot;expiration&quot; index=&quot;1&quot; value=&quot;300&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;!-- @CacheEvict(..., &quot;allEntries&quot; = true) doesn&#39;t work --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;constructor-arg name=&quot;allowClear&quot; index=&quot;2&quot; value=&quot;false&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/set&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bean name=&quot;defaultCache&quot; class=&quot;com.google.code.ssm.CacheFactory&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;cacheName&quot; value=&quot;defaultCache&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;cacheClientFactory&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;bean name=&quot;cacheClientFactory&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;class=&quot;com.google.code.ssm.providers.spymemcached.MemcacheClientFactoryImpl&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;addressProvider&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;bean class=&quot;com.google.code.ssm.config.DefaultAddressProvider&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;address&quot; value=&quot;172.16.1.17:11211&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;configuration&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;bean class=&quot;com.google.code.ssm.providers.CacheConfiguration&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;consistentHashing&quot; value=&quot;true&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;The SSM project provides a set of annotation which can be used to integrate the dao and cache layer.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;SSM annotations&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white;&quot;&gt;@ReadThroughSingleCache&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white;&quot;&gt;@InvalidateMultiCache&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white;&quot;&gt;@UpdateAssignCache &amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;The simplest way to use the cache is to inject the Cache interface provided in the SSM project.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;It has apis to do operations like get,set,delete on memcache server.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;@Service &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;public class EmployeeService&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;@Autowire&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;Cache cache;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;public Employee getEmployee(String key) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; return cache.get(key); &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;public void saveEmployee(String key, Employee emp) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; cache.set(key,5000, emp);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;public void deleteEmployee(String key) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; cache.delete(key);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/3314336951994177732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2013/12/memcache-server-integration-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/3314336951994177732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/3314336951994177732'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2013/12/memcache-server-integration-using.html' title='Memcache server integration using spring and google SSM'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-4584491911775339732</id><published>2013-11-13T01:39:00.002-08:00</published><updated>2014-04-13T00:57:07.833-07:00</updated><title type='text'>Spring Security Configuration For SSO (Pre Authentication)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Spring Security provides a very robust framework for authentication and authorization mechanism. It can be easily customizable to be used in different environment.&amp;nbsp; For SSO service the request is already authenticated.&lt;br /&gt;
&lt;br /&gt;
Spring provides preautheticatedproviders to process already authenticated request. The spring configuration for a pre autheticated request will look as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;lt;http use-expressions=&quot;true&quot; entry-point-ref=&quot;http403EntryPoint&quot;&amp;gt;&lt;br /&gt; &amp;lt;intercept-url pattern=&quot;/&quot; access=&quot;permitAll&quot; /&amp;gt;&lt;br /&gt; &amp;lt;intercept-url pattern=&quot;/login/*&quot; access=&quot;permitAll&quot; /&amp;gt;&lt;br /&gt; &amp;lt;intercept-url pattern=&quot;/error/**&quot; access=&quot;permitAll&quot; /&amp;gt;&lt;br /&gt; &amp;lt;intercept-url pattern=&quot;/admin/**&quot; access=&quot;hasRole(&#39;ROLE_ADMIN&#39;)&quot; /&amp;gt;&lt;br /&gt; &amp;lt;intercept-url pattern=&quot;/**&quot; access=&quot;hasRole(&#39;ROLE_USER&#39;)&quot; /&amp;gt;&lt;br /&gt; &amp;lt;access-denied-handler error-page=&quot;/error&quot; /&amp;gt;&lt;br /&gt; &amp;lt;custom-filter position=&quot;PRE_AUTH_FILTER&quot; ref=&quot;preAuthFilter&quot; /&amp;gt;&lt;br /&gt; &amp;lt;/http&amp;gt;&lt;br /&gt; &amp;lt;authentication-manager alias=&quot;authenticationManager&quot;&amp;gt;&lt;br /&gt; &amp;lt;authentication-provider ref=&quot;preAuthProvider&quot; /&amp;gt;&lt;br /&gt; &amp;lt;/authentication-manager&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;bean:bean xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt; id=&quot;http403EntryPoint&quot;&lt;br /&gt; class=&quot;org.springframework.security.web.authentication.Http403ForbiddenEntryPoint&quot;&amp;gt;&lt;br /&gt; &amp;lt;/bean:bean&amp;gt;&lt;br /&gt; &amp;lt;bean:bean xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt; id=&quot;preAuthFilter&quot; class=&quot;org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter&quot;&amp;gt;&lt;br /&gt; &amp;lt;property name=&quot;principalRequestHeader&quot; value=&quot;SM_USER&quot; /&amp;gt;&lt;br /&gt; &amp;lt;property name=&quot;exceptionIfHeaderMissing&quot; value=&quot;false&quot; /&amp;gt;&lt;br /&gt; &amp;lt;property name=&quot;authenticationManager&quot; ref=&quot;authenticationManager&quot; /&amp;gt;&lt;br /&gt; &amp;lt;/bean:bean&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;bean:bean xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt; id=&quot;preAuthProvider&quot; class=&quot;org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider&quot;&amp;gt;&lt;br /&gt; &amp;lt;property name=&quot;preAuthenticatedUserDetailsService&quot; ref=&quot;preAuthenticatedUserDetailsService&quot; /&amp;gt;&lt;br /&gt; &amp;lt;/bean:bean&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The &lt;span style=&quot;font-family: inherit;&quot;&gt;RequestHeaderAuthenticationFilter filter&amp;nbsp; will read a header named SM_USER and it will get the authenticated token. Based on the token&amp;nbsp; the &lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;PreAuthenticatedAuthenticationProvider will identify the role and the request will be authorized.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Sample for code for this example can be downloaded &lt;a href=&quot;https://github.com/soumyajitswain/supernova/tree/ded83d807c1302ff2ce87341741613264d01f550/SpringSecurity&quot;&gt;here.&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/4584491911775339732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2013/11/spring-security-configuration-for-sso.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/4584491911775339732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/4584491911775339732'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2013/11/spring-security-configuration-for-sso.html' title='Spring Security Configuration For SSO (Pre Authentication)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-4271386189487097321</id><published>2013-11-08T11:54:00.002-08:00</published><updated>2013-11-08T12:08:31.461-08:00</updated><title type='text'>Spring JMX integration with Tomcat</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Spring&amp;nbsp; makes the MBean creation very simple. We can create&amp;nbsp; any number of MBean in spring. The spring takes care of registering them to MBeanServer. In this example we will use tomcat as a MBeanServer.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Tomcat Configuration for JMX&lt;/b&gt;&lt;br /&gt;
Tomcat server can be converted into a MBean server by modifying the CATALINA_OPTS variable&amp;nbsp; in the catalina.bat.&lt;br /&gt;
&lt;br /&gt;
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Spring JMX Configuration&lt;/b&gt;&lt;br /&gt;
Few configurations needs to be added in the applicationContext for spring to identify the Mbean and register them to MBeanServer.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;lt;bean id=&quot;mbeanServer&quot; class=&quot;java.lang.management.ManagementFactory&quot;&lt;br /&gt;
lazy-init=&quot;false&quot; factory-method=&quot;getPlatformMBeanServer&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;context:component-scan base-package=&quot;com.jmx&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;context:mbean-export server=&quot;mbeanServer&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above configuration will first locate the MBeanServer which in this case is Tomcat.Than it will scan the &lt;b&gt;com.jmx &lt;/b&gt;package for MBean.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;MBean creation&lt;/b&gt; &lt;br /&gt;
Spring provides various annotation which makes creation of MBean easy. The various annotations are &lt;b&gt;@ManageResource&lt;/b&gt;, &lt;b&gt;@ManageOperation&lt;/b&gt; and &lt;b&gt;@ManageAttribute.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;package com.jmx;&lt;br /&gt;&lt;br /&gt;import org.springframework.jmx.export.annotation.ManagedAttribute;&lt;br /&gt;import org.springframework.jmx.export.annotation.ManagedResource;&lt;br /&gt;import org.springframework.stereotype.Component;&lt;br /&gt;@Component&lt;br /&gt;@ManagedResource&lt;br /&gt;public class BatchProcessorImpl&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ManagedAttribute&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int getIt() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return 1010;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-color: white;&quot;&gt;MBean in Logging&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Deploy and restart the server. If the Mean is created successfully it will show up in DEBUG log.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;INFO: Located managed bean &#39;batchProcessorImpl&#39;: registering with JMX server as MBean [com.jmx:name=batchProcessorImpl,type=BatchProcessorImpl]&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt; &lt;/b&gt;&lt;b&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Check the MBean in JConsole&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Open JConsole and a new package com.jmx can be seen in the console. The BatchProcessImpl Mbean will be available under it.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;background-color: white;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/4271386189487097321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2013/11/spring-jmx-integration-with-tomcat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/4271386189487097321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/4271386189487097321'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2013/11/spring-jmx-integration-with-tomcat.html' title='Spring JMX integration with Tomcat'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-7521554499610985394</id><published>2013-10-15T08:55:00.003-07:00</published><updated>2013-10-15T08:55:59.827-07:00</updated><title type='text'>Memory and CPU monitoring using JMeter</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
JMeter&amp;nbsp; provides a perfmon listener which can be used to monitor the CPU and memory for any java process.&amp;nbsp; The steps to setup the JMeter perfmon plugin configuration are explained below.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;JMeter Installation&lt;/b&gt;&lt;br /&gt;
1. JMeter binary can be downloaded from the &lt;a href=&quot;https://jmeter.apache.org/download_jmeter.cgi&quot;&gt;JMeter download page&lt;/a&gt; &lt;b&gt;.&lt;/b&gt;Unzip the JMeter binary.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;JMeter Extra plugins&lt;/b&gt;&lt;br /&gt;
JMeter comes with some utility plugin which aren&#39;t available by default in original JMeter binaries. Download the &lt;a href=&quot;http://jmeter-plugins.org/downloads/all/&quot;&gt;JMeterExtra-Plugins&lt;/a&gt;&lt;b&gt;.&lt;/b&gt;Unzar the zip file and copy the files into ext folder.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ServerAgent-2.2.1.zip&lt;/b&gt;&lt;br /&gt;
Download the ServerAgent-2.2.1.zip from &lt;a href=&quot;http://jmeter-plugins.org/downloads/all/&quot;&gt;download&lt;/a&gt;&lt;b&gt; &lt;/b&gt;page.Unzip the file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;JMeter server agent configuration&lt;/b&gt;&lt;br /&gt;
1:Start the JMeter&lt;br /&gt;
2: Open the &lt;b&gt;Servers Performance Monitoring &lt;/b&gt;screen&lt;br /&gt;
3: Click on &lt;b&gt;Add one Server&lt;/b&gt;&lt;br /&gt;
4: Provide the host, port no, process id of application for which CPU and memory will be monitored.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Server Agent configuration&lt;/b&gt;&lt;br /&gt;
1:Start the&amp;nbsp;&lt;b&gt; &lt;/b&gt;server agent by clicking on &lt;b&gt;serverAgent.bat or serverAgent.sh&lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;&lt;b&gt;$ ./startAgent.sh --udp-port 0 --tcp-port 9000&lt;/b&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Now start the test and the CPU and Memory usage for the specified PID will be&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;displayed in Server Performance Monitoring screen.&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;
&lt;/b&gt;&lt;/pre&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt; &lt;b&gt;&amp;nbsp; &amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/7521554499610985394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2013/10/memory-and-cpu-monitoring-using-jmeter.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/7521554499610985394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/7521554499610985394'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2013/10/memory-and-cpu-monitoring-using-jmeter.html' title='Memory and CPU monitoring using JMeter'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-8238997160054563905</id><published>2013-08-26T04:15:00.001-07:00</published><updated>2013-08-26T04:15:31.545-07:00</updated><title type='text'>soumya&#39;s: Hadoop and Hbase installation steps</title><content type='html'>&lt;a href=&quot;http://soumyajitswain.blogspot.com/2013/08/hadoop-and-hbase-installation-steps.html?spref=bl&quot;&gt;soumya&#39;s: Hadoop and Hbase installation steps&lt;/a&gt;: The document explains the steps to set install HBase and dependent project in step by step manner. The&amp;nbsp;   HBase cluster is created using ...</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/8238997160054563905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2013/08/soumyas-hadoop-and-hbase-installation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/8238997160054563905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/8238997160054563905'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2013/08/soumyas-hadoop-and-hbase-installation.html' title='soumya&#39;s: Hadoop and Hbase installation steps'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-5568049468626413689</id><published>2013-08-26T04:13:00.000-07:00</published><updated>2013-08-26T04:13:03.697-07:00</updated><title type='text'>Hadoop and Hbase installation steps</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div&gt;
The document explains the steps to set install HBase and dependent project in step by step manner. The&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
HBase cluster is created using three linux machines. A fourth linux machine is used as client machine.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Hbase cluster is dependent on ZooKeeper and Hadoop cluster. Hbase manages the ZooKeeper cluster&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
by defult.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Hbase cluster involved following steps.&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Machine setup&amp;nbsp;&lt;/li&gt;
&lt;li&gt;ZoopKeeper installation&lt;/li&gt;
&lt;li&gt;Hadoop installation&lt;/li&gt;
&lt;li&gt;HBase installation&lt;/li&gt;
&lt;li&gt;Test Hbase&lt;/li&gt;
&lt;li&gt;Setup Client&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;1:Machine setup :&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; 1. Launch four micro instances with 100GB extended memory.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; 2. Open port 60000, 60020 and 2181 and assign the security group to aws instances.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; 3. The memory can be extended using the following commands.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
mkfs -t ext3 /dev/sdf&lt;/div&gt;
&lt;div&gt;
mkdir /mnt&lt;/div&gt;
&lt;div&gt;
chmod 7777 /mnt&lt;/div&gt;
&lt;div&gt;
mount /dev/sdf /mnt/&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;4. Host name configuration&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Open the hosts file and make the following entries. Replace the xxxxx with&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
system IP address.&lt;/div&gt;
&lt;div&gt;
xxxxxxx hadoop-namenode hbase-master&lt;/div&gt;
&lt;div&gt;
xxxxxxx hadoop-datanode1 hbase-regionserver1&lt;/div&gt;
&lt;div&gt;
xxxxxxx hadoop-datanode2 hbase-regionserver2&lt;/div&gt;
&lt;div&gt;
xxxxxxx hadoop-datanode4&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
5. SSH configuration.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ● Create a rsa key on hadoop-namenode using keygen command&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -P &#39;&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ● Copy the id_rsa and id_rsa.pub into all the node systems. Target location /root/.ssh● Provide appropriate access by using the below command&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; chmod 0600 $HOME/.ssh/authorized_keys&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; chmod 0600 $HOME/.ssh/id_rsa&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ● Run cat id_rsa.pub and copy the secure key.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cat /root/.ssh/id_rsa.pub on hadoop-namenode&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;vi authorization_keys and paste the secure key&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ● Open /etc/ssh/sshd_config in vi editor.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ● Add below two lines to the sshd_config file.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PermitRootLogin yes&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AllowUsers ec2-user root&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ● Comment the below two lines.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #PermitRootLogin forced-commands-only&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #PermitRootLogin yes&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ● Restart the sshd.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/init.d/sshd restart&lt;/div&gt;
&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;div&gt;
ZooKeeper Installation:&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;● Download ZooKeeper-3.3.3.tar. Untar the file.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;● Create a zoo.cfg by using zoo-sample.cfg file&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;● Change the path of dataDir directory path inside zoo.cfg&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dataDir = /hbase/zookeeper/server/data&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;● Start ./zkServer start&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Hadoop Installation&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Master installation&lt;/div&gt;
&lt;div&gt;
● Download hadoop-1.0.1.tar.gz. Untar it into a folder.&lt;/div&gt;
&lt;div&gt;
● Open core-site.xml from conf folder and add the following lines.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;!-- Defines the namenode and port number --&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;fs.default.name&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;hdfs://hadoop-namenode:9000&amp;lt;/value&amp;gt; &amp;lt;description&amp;gt;This is the namenode uri&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;hadoop.tmp.dir&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;$HADOOP_INSTALL_DIR/hadoop-1.0.1/&lt;/div&gt;
&lt;div&gt;
hadoop-datastore&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;description&amp;gt;A base for other temporary&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
directories.&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
● Open hdfs-site.xml and add the following properties.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;dfs.replication&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;Default block replication.The actual&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
number of replications can be specified when the file is created.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
The default is used if replication is not specified in create time.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
● Open mapred-site.xml and add the following properties.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;mapred.job.tracker&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;hadoop-namenode:9001&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;description&amp;gt;The host and port that the MapReduce job&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
tracker runs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;at. If &quot;local&quot;, then jobs are run in-process as a single&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
map and reduce&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;task.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
● Open conf/masters file in vi editor and add the machine name where the secondary&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
namenode will run.&lt;/div&gt;
&lt;div&gt;
Hadoop-namenode&lt;/div&gt;
&lt;div&gt;
● Open conf/slaves in vi editor and add the all the datanode machine name.&lt;/div&gt;
&lt;div&gt;
Hadoop-namenode&lt;/div&gt;
&lt;div&gt;
Hadoop-datanode1&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Hadoop-datanode2&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Slave Installation&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
● Download the hadoop-1.0.1.tar.gz and untar it into hbase folder.&lt;/div&gt;
&lt;div&gt;
● Open conf/core-site.xml in vi editor and add the following properties&lt;/div&gt;
&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;div&gt;
&lt;div&gt;
&amp;lt;!-- The uri&#39;s authority is used to determine the host, port, etc. for a&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
filesystem. --&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;fs.default.name&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;hdfs://hadoop-namenode:9000&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;This is the namenode uri&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;hadoop.tmp.dir&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;$HADOOP_INSTALL_DIR/hadoop-0.20.2/&lt;/div&gt;
&lt;div&gt;
hadoop-datastore&lt;/div&gt;
&lt;div&gt;
&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;A base for other temporary directories.&amp;lt;/&lt;/div&gt;
&lt;div&gt;
description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
● Open conf/hdfs-site.xml and add the following lines.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;dfs.replication&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;description&amp;gt;Default block replication.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;The actual number of replications can be specified when the file&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;is created. The default is used if replication is not specified in&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;create time.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
● Open /conf/mapred-site.xml and add the following properties&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;mapred.job.tracker&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;hadoop-namenode:9001&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;The host and port that the MapReduce job tracker&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
runs&lt;/div&gt;
&lt;div&gt;
at. If &quot;local&quot;, then jobs are run in-process as a single map and reduce&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;task.&lt;/div&gt;
&lt;div&gt;
&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
● Open /conf/masters and copy the machine name where the secondary namenode will&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
run.&lt;/div&gt;
&lt;div&gt;
Hadoop-namenode&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
● Open the slaves and add all datanodes.&lt;/div&gt;
&lt;div&gt;
Hadoop-namenode&lt;/div&gt;
&lt;div&gt;
Hadoop-datanode1&lt;/div&gt;
&lt;div&gt;
Hadoop-datanode2&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Start hadoop cluster&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
● Go to hadoop bin folder and execute the following command.&lt;/div&gt;
&lt;div&gt;
$HADOOP_INSTALL_DIR/bin/hadoop namenode –format&lt;/div&gt;
&lt;div&gt;
● Start the HDFS daemons:-&lt;/div&gt;
&lt;div&gt;
$HADOOP_INSTALL_DIR/bin/start-dfs.sh&lt;/div&gt;
&lt;div&gt;
● Start the MapReduce daemons:-&lt;/div&gt;
&lt;div&gt;
$HADOOP_INSTALL_DIR/bin/start-mapred.sh&lt;/div&gt;
&lt;div&gt;
● Check the java process, it should display :-&lt;/div&gt;
&lt;div&gt;
root@hadoop-namenode:ps –ef | grep java&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;6234 NameNode&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;8765 SecondaryNameNode&lt;/div&gt;
&lt;div&gt;
10032 JobTracker&lt;/div&gt;
&lt;div&gt;
15678 java&lt;/div&gt;
&lt;div&gt;
● Check the java process running on datanode machines :-&lt;/div&gt;
&lt;div&gt;
1135 DataNode&lt;/div&gt;
&lt;div&gt;
3423 TaskTracker&lt;/div&gt;
&lt;div&gt;
6745 java&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Stop hadoop cluster&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
● Stop MapReduce daemons :-&lt;/div&gt;
&lt;div&gt;
/bin/stop-mapred.sh&lt;/div&gt;
&lt;div&gt;
● Stop HDFS daemons :-Run the command /bin/stop-dfs.sh on the namenode machine.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Hbase Installation&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
● Download Hbase-0.94.0.tar.gz and untar it to /hbase folder.&lt;/div&gt;
&lt;div&gt;
● Open $HBASE_INSTALL_DIR/conf/hbase-site.xml and add the following lines.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;configuration.xsl&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;configuration&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;hbase.master&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;hbase-master:60000&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;description&amp;gt;The host and port that the HBase&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
master runs at.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;A value of &#39;local&#39; runs the master&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
and a regionserver&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;in a single process.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;hbase.rootdir&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;hdfs://hadoop-namenode:9000/hbase&amp;lt;/&lt;/div&gt;
&lt;div&gt;
value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;description&amp;gt;The directory shared by region&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
servers.&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;hbase.cluster.distributed&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;description&amp;gt;The mode the cluster will be in.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Possible values are&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;false: standalone and pseudo-distributed setups&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
with managed&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Zookeeper true: fully-distributed with unmanaged&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Zookeeper&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Quorum (see hbase-env.sh)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;hbase.zookeeper.property.clientPort&amp;lt;/&lt;/div&gt;
&lt;div&gt;
name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;value&amp;gt;2181&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;description&amp;gt;Property from ZooKeeper&#39;s&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
config zoo.cfg.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;The port at which the clients will connect.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;hbase.zookeeper.quorum&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;hbase-master&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;Comma separated list of servers in the ZooKeeper&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Quorum.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;For example,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&quot;host1.mydomain.com,host2.mydomain.com&quot;.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;By default this is set to localhost for local&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
and&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;pseudo-distributed modes of operation. For&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
a&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;fully-distributed setup, this should be set to&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
a full&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;list of ZooKeeper quorum servers. If&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;HBASE_MANAGES_ZK is set in hbaseenv.sh&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;this is the list of servers which we will start/&lt;/div&gt;
&lt;div&gt;
stop&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;ZooKeeper on.&lt;/div&gt;
&lt;div&gt;
&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/configuration&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
● Open file $HBASE_INSTALL_DIR/conf/hbase-env.sh and uncomment the following&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
lines :-&lt;/div&gt;
&lt;div&gt;
export HBASE_MANAGES_ZK=true&lt;/div&gt;
&lt;div&gt;
● Open the file $HBASE_INSTALL_DIR/conf/regionservers and add all regionserver&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
machines.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;hbase-regionserver1&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;hbase-regionserver2&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;hbase-master&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Installing HBase regoinservers&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
● Download Hbase-0.94.0 and untar it into hbase folder.&lt;/div&gt;
&lt;div&gt;
● Open /conf/hbase-site.xml and make the following changes :-&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
?xml version=&quot;1.0&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;configuration.xsl&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;configuration&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;hbase.master&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;hbase-master:60000&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;The host and port that the HBase master&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
runs at.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;A value of &#39;local&#39; runs the master and a&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
regionserver&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;in a single process.&lt;/div&gt;
&lt;div&gt;
&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;hbase.rootdir&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;hdfs://hadoop-namenode:9000/hbase&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;The directory shared by region servers.&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;hbase.cluster.distributed&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;The mode the cluster will be in. Possible&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
values are&lt;/div&gt;
&lt;div&gt;
false: standalone and pseudo-distributed setups with&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
managed&lt;/div&gt;
&lt;div&gt;
Zookeeper true: fully-distributed with unmanaged&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Zookeeper&lt;/div&gt;
&lt;div&gt;
Quorum (see hbase-env.sh)&lt;/div&gt;
&lt;div&gt;
&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;name&amp;gt;hbase.zookeeper.property.clientPort&amp;lt;/&lt;/div&gt;
&lt;div&gt;
name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;2181&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;Property from ZooKeeper&#39;s config zoo.cfg.&lt;/div&gt;
&lt;div&gt;
The port at which the clients will connect.&lt;/div&gt;
&lt;div&gt;
&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;name&amp;gt;hbase.zookeeper.quorum&amp;lt;/name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;value&amp;gt;hbase-master&amp;lt;/value&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;description&amp;gt;Comma separated list of&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
servers in the ZooKeeper Quorum. For&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
example, &quot;host1.mydomain.com,host2.mydomain.com&quot;.&lt;/div&gt;
&lt;div&gt;
By default this is set to localhost for local and pseudodistributed modes of operation. For a fully-distributed&lt;/div&gt;
&lt;div&gt;
setup, this should be set to a ful list of ZooKeeper&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
quorum&lt;/div&gt;
&lt;div&gt;
servers. If HBASE_MANAGES_ZK is set in hbaseenv.sh&lt;/div&gt;
&lt;div&gt;
this is the list of servers which we will start/stop&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
ZooKeeper on.&lt;/div&gt;
&lt;div&gt;
&amp;lt;/description&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/configuration&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
● Open the file /conf/hbase-env.sh and uncomment the following line.&lt;/div&gt;
&lt;div&gt;
export HBASE_MANAGES_ZK=true&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Start HBase cluster&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
● Starting the HBase cluster :-&lt;/div&gt;
&lt;div&gt;
$HBASE_INSTALL_DIR/bin/start-hbase.sh&lt;/div&gt;
&lt;div&gt;
● Run java process on hbase-master&lt;/div&gt;
&lt;div&gt;
root@hbase-master:ps –ef | grep java&lt;/div&gt;
&lt;div&gt;
4568 HMMaster&lt;/div&gt;
&lt;div&gt;
5609 HRegionServer&lt;/div&gt;
&lt;div&gt;
● Run java process on hbase-regionserver1&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
34098 HRegionServer&lt;/div&gt;
&lt;div&gt;
23458 java&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Stop Hbase cluster&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
● Stop Hbase cluster :-&lt;/div&gt;
&lt;div&gt;
$HBASE_INSTALL_DIR/bin/stop-hbase.sh&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Test HBase&lt;/div&gt;
&lt;div&gt;
● Go to $HBASE_HOME/bin folder and open hbase shell by executing the following&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
command.&lt;/div&gt;
&lt;div&gt;
root@hbase-master: ./hbase shell&lt;/div&gt;
&lt;div&gt;
● Create a table pageviewer using the following command&lt;/div&gt;
&lt;div&gt;
Create ‘pageviewer’, ‘gender’, ‘location’&lt;/div&gt;
&lt;div&gt;
● If the table gets created successfully than the setup is complete.&lt;/div&gt;
&lt;div&gt;
Setup Client&lt;/div&gt;
&lt;div&gt;
● Create a Hbase client using java API.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Configuration config = HBaseConfiguration.create();&lt;/div&gt;
&lt;div&gt;
config.set(&quot;hbase.zookeeper.quorum&quot;, &quot;hbase-master&quot;);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
config.set(&quot;hbase.master&quot;, &quot;hbase-master:60000&quot;);&lt;/div&gt;
&lt;div&gt;
HTable table = new HTable(config, &quot;pageviewer&quot;);&lt;/div&gt;
&lt;div&gt;
table.setAutoFlush(true);&lt;/div&gt;
&lt;div&gt;
for(int i=startIdx;i&amp;lt;endIdx;i++) {&lt;/div&gt;
&lt;div&gt;
String row_key = year+&quot;-retail&quot;+retailId+&quot;-site&quot;+i+&quot;-url&quot;+urlVal;&lt;/div&gt;
&lt;div&gt;
Put put = new Put(Bytes.toBytes(row_key));&lt;/div&gt;
&lt;div&gt;
put.add(Bytes.toBytes(&quot;gender&quot;), Bytes.toBytes(&quot;totalview&quot;),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Bytes.toBytes(101));&lt;/div&gt;
&lt;div&gt;
put.add(Bytes.toBytes(&quot;gender&quot;), Bytes.toBytes(&quot;maleview&quot;),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Bytes.toBytes(10));&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;put.add(Bytes.toBytes(&quot;gender&quot;), Bytes.toBytes(&quot;femaleview&quot;),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Bytes.toBytes(9));&lt;/div&gt;
&lt;div&gt;
put.add(Bytes.toBytes(&quot;location&quot;), Bytes.toBytes(&quot;country&quot;),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Bytes.toBytes(&quot;India&quot;));&lt;/div&gt;
&lt;div&gt;
put.add(Bytes.toBytes(&quot;location&quot;), Bytes.toBytes(&quot;state&quot;),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Bytes.toBytes(&quot;KA&quot;));&lt;/div&gt;
&lt;div&gt;
put.add(Bytes.toBytes(&quot;location&quot;), Bytes.toBytes(&quot;city&quot;),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Bytes.toBytes(&quot;bangalore&quot;));&lt;/div&gt;
&lt;div&gt;
table.put(put);&lt;/div&gt;
&lt;div&gt;
System.out.println(&quot;[&quot;+new Date()+&quot;]&lt;/div&gt;
&lt;div&gt;
&quot;+Thread.currentThread().getName()+&quot;: &quot;+row_key+&quot; inserted&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
successfully.&quot;);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
table.flushCommits();&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
● Create a executable jar file using the above API and run the jar file using jar&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
command.&lt;/div&gt;
&lt;div&gt;
Java –jar hbaseclient.jar&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/&quot;&gt;&lt;/a&gt;&lt;span id=&quot;goog_1256820515&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_1256820516&quot;&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/5568049468626413689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2013/08/hadoop-and-hbase-installation-steps.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/5568049468626413689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/5568049468626413689'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2013/08/hadoop-and-hbase-installation-steps.html' title='Hadoop and Hbase installation steps'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-7380061758203888187</id><published>2012-12-31T03:27:00.003-08:00</published><updated>2012-12-31T03:27:31.463-08:00</updated><title type='text'>Scripting in JAVA using apache JEXL2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
A decent level of scripting feature can be enabled for JAVA using apache JEXL library. This library is inspired by Velocity and JSTL. The JEXL archives can be downloaded from &lt;a href=&quot;http://commons.apache.org/jexl/download_jexl.cgi&quot;&gt;http://commons.apache.org/jexl/download_jexl.cgi&lt;/a&gt; link. Add the commons-jexl-2.1.1.jar to the classpath.&lt;br /&gt;
&lt;br /&gt;
public class JEXLExecuter {&lt;br /&gt;
public static final String str = &quot;ABCDEF&quot;;&lt;br /&gt;
&lt;br /&gt;
public String getValue() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return str;&lt;br /&gt;
}&lt;br /&gt;
public static void main(String args[]) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;String expression = &quot;jexlObject.getValue()&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Expression e = jexl.createExpression(expression);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;JexlContext context = new MapContext();&lt;br /&gt;
&amp;nbsp; &amp;nbsp;context.set(&quot;jexlObject&quot;, this);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Object o = e.evaluate(context);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;System.out.println(o.toString());&lt;br /&gt;
}&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
Output :&lt;br /&gt;
&lt;b&gt;ABCDEF&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/7380061758203888187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/12/scripting-in-java-using-apache-jexl2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/7380061758203888187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/7380061758203888187'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/12/scripting-in-java-using-apache-jexl2.html' title='Scripting in JAVA using apache JEXL2'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-4060803524078246693</id><published>2012-12-27T02:36:00.000-08:00</published><updated>2013-01-13T06:15:44.820-08:00</updated><title type='text'>Cross domain SSO with OpenAM</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
OpenAM provides a cross domain SSO based on cookie. To configure the CDSSO with OpenAM requires the following steps.&lt;br /&gt;
1: Install OpenAM&lt;br /&gt;
2: Create a J2ee Policy agent&lt;br /&gt;
3: Download J2ee policy agent.&lt;br /&gt;
4: Install J2ee policy agent.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1:&lt;b&gt;Install OpenAM&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;Download and configure OpenAM based on the instruction from the following link.&lt;br /&gt;
&lt;a href=&quot;https://wikis.forgerock.org/confluence/display/openam/3+OpenAM+Server+Configuration&quot;&gt;https://wikis.forgerock.org/confluence/display/openam/3+OpenAM+Server+Configuration&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
2: &lt;b&gt;Create J2ee policy agent&lt;/b&gt;&lt;br /&gt;
Login to OpenAM console and go t&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;o Access Control &amp;gt; Realm &amp;gt; Profiles &amp;gt; J2EE Profiles. Create a new profile.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;Refer Create the agent profile section :&amp;nbsp;&lt;a href=&quot;https://wikis.forgerock.org/confluence/display/openam/Installing+Tomcat+6.0+Policy+Agent&quot;&gt;https://wikis.forgerock.org/confluence/display/openam/Installing+Tomcat+6.0+Policy+Agent&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Go to&amp;nbsp;&lt;span style=&quot;font-family: sans-serif; font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;Access Control &amp;gt; Realm &amp;gt; Agents &amp;gt; J2EE &amp;gt; Agent Name &amp;gt; SSO. Configure the fields based on instruction from below site.&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://openam.forgerock.org/openam-documentation/openam-doc-source/doc/admin-guide/index/chap-cdsso.html&quot;&gt;&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;http://openam.forgerock.org/openam-documentation/openam-doc-source/doc/admin-guide/index/chap-cdsso.html&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;3: &lt;b&gt;Download J2ee policy agent&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;&amp;nbsp;Download the J2ee policy agent from&amp;nbsp;&lt;a href=&quot;http://forgerock.org/openam.html&quot;&gt;http://forgerock.org/openam.html&lt;/a&gt; site.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;4: &lt;b&gt;Install J2ee policy agent&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;Install the J2ee policy agent based on the instruction provided in&amp;nbsp;&lt;a href=&quot;https://wikis.forgerock.org/confluence/display/openam/Installing+Tomcat+6.0+Policy+Agent&quot;&gt;https://wikis.forgerock.org/confluence/display/openam/Installing+Tomcat+6.0+Policy+Agent&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 19.200000762939453px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/4060803524078246693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/12/cross-domain-sso-with-openam.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/4060803524078246693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/4060803524078246693'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/12/cross-domain-sso-with-openam.html' title='Cross domain SSO with OpenAM'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-3419403676112919512</id><published>2012-10-13T23:45:00.000-07:00</published><updated>2012-12-27T02:36:57.432-08:00</updated><title type='text'>HBase Low Latency OLAP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
HBase is a column oriented nosql database. It is useful to store large datasets. It can used&amp;nbsp;effectively as behind reporting tools. Low latency OLAP structure can be created in HBase.&lt;br /&gt;
&lt;br /&gt;
Here I will do&amp;nbsp;comparison between SQL and a preaggreated HBase table to explain the low latency feature.&lt;br /&gt;
&lt;br /&gt;
SQL :&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;font-family: Calibri, sans-serif; font-size: 11pt;&quot;&gt;select
logdate,country, city,manufacturer,device,count(*) from
DeviceInfo group by
logdate,&lt;/span&gt;&lt;span style=&quot;font-family: Calibri, sans-serif; font-size: 15px;&quot;&gt;country, city&lt;/span&gt;&lt;span style=&quot;font-family: Calibri, sans-serif; font-size: 11pt;&quot;&gt;,operator,manufacturer,device&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The SQL output can be used to create a preaggreated table in HBase. The HBase table structure should have the row is in combination of logdate, country, city, manufacturer, device.The column fields can be grouped into three column family. The two column family are region and devicedtl.country and city are column qualifier for country and city. manufacturer and device can be grouped under devicedtl. Once coulmn family metrics should be created which will&amp;nbsp; hold all measurement information.&lt;br /&gt;
&lt;br /&gt;
HBase table structure should look as below,&lt;br /&gt;
&lt;br /&gt;
rowId&amp;nbsp; | region:country&amp;nbsp; |&amp;nbsp; region:city | &amp;nbsp; devicedtl:manufacturer | devicedtl:device | metrics:count&lt;br /&gt;
&lt;br /&gt;
2012.01.05.india.bangalore.samsung.S3&amp;nbsp; India&amp;nbsp; Bangalore&amp;nbsp;&amp;nbsp; Samsung&amp;nbsp;&amp;nbsp;&amp;nbsp; S3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;br /&gt;
2012.01.05.india.bangalore.samsung.S2&amp;nbsp; India&amp;nbsp; Bangalore&amp;nbsp;&amp;nbsp; Samsung&amp;nbsp;&amp;nbsp;&amp;nbsp; S2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
2012.01.05.india.bangalore.Apple.IOS&amp;nbsp;&amp;nbsp;&amp;nbsp; India&amp;nbsp; Bangalore&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Apple&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IOS&amp;nbsp;&amp;nbsp; 10 &lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/3419403676112919512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/10/hbase-low-latency-olap.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/3419403676112919512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/3419403676112919512'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/10/hbase-low-latency-olap.html' title='HBase Low Latency OLAP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-2655240101612083373</id><published>2012-09-29T05:53:00.002-07:00</published><updated>2012-09-29T05:54:19.419-07:00</updated><title type='text'>Remove JasperServer4.5 inputcontrol Apply and Reset button </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/h3&gt;
Removing the Apply and Reset button from input control field is quite simple. Open &lt;b&gt;control.report.js&lt;/b&gt; file from &amp;nbsp; &lt;br /&gt;
script folder. Add the following lines.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JQuery(&quot;#Apply&quot;).hide();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JQuery(&quot;#Reset&quot;).hide();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JQuery(&quot;#Apply&quot;).click();&lt;br /&gt;
&lt;br /&gt;
Open &lt;b&gt;cascade.cascade.js&lt;/b&gt; from the same location and add the JQuery(&#39;#Apply&#39;).click() script inside findCascade(..) method. Now the reports will be loaded each time the input values changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/2655240101612083373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/09/remove-jasperserver45-inputcontrol.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/2655240101612083373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/2655240101612083373'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/09/remove-jasperserver45-inputcontrol.html' title='Remove JasperServer4.5 inputcontrol Apply and Reset button '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-8568808221293813004</id><published>2012-09-20T03:52:00.003-07:00</published><updated>2012-09-20T03:52:54.404-07:00</updated><title type='text'>Mondrian XMLA Provider</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Mondrian XMLA Provider&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Mondrian is a open source project to create cube and process MDX queries.&lt;br /&gt;
&lt;br /&gt;
MDX is a type of select queries which can create a result set from multidimension data that is return from the cube.&lt;br /&gt;
&lt;br /&gt;
CUBE is a structured data that can be represented in 0 or more dimension.&lt;br /&gt;
&lt;br /&gt;
XMLA stands form XML for analysis. This is a SOAP API that can be used to access OLAP database server on internet.&lt;br /&gt;
&lt;br /&gt;
Downlaod the mondrian.war from penaho site. Copy the war file to the local tomcat servre. Inside the tomcat/lib add the following jar files.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;eigenbase-properties.jar&lt;/li&gt;
&lt;li&gt;eigenbase-resgen.jar&lt;/li&gt;
&lt;li&gt;eigenbase-xom.jar&amp;nbsp;&lt;/li&gt;
&lt;li&gt;olap4j.jar&lt;/li&gt;
&lt;li&gt;mondrian.jar&lt;/li&gt;
&lt;li&gt;wcf.jar&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Create sample web application. Create two jsp files, xmla.jsp and chart.jsp.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;xmla.jsp&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%@ page session=&quot;true&quot; pageEncoding=&quot;UTF-8&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ taglib uri=&quot;http://www.tonbeller.com/jpivot&quot; prefix=&quot;jp&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http://java.sun.com/jstl/core&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&amp;nbsp; &amp;nbsp; * Change uri attribute to your deployment of this webapp.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; * The dataSource attribute is necessary for Mondrian&#39;s XMLA.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;jp:xmlaQuery id=&quot;query01&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; uri=&quot;http://localhost:8080/MyMondrain/xmla&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; dataSource=&quot;Provider=Mondrian;DataSource=Foodmart;&quot;&lt;br /&gt;
&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;catalog=&quot;schema&quot;&amp;gt;&lt;br /&gt;
select&lt;br /&gt;
&amp;nbsp; {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} on columns,&lt;br /&gt;
&amp;nbsp; {([Promotion Media].[All Media], [Product].[All Products])} ON rows&lt;br /&gt;
from Sales&lt;br /&gt;
where ([Time].[1997])&lt;br /&gt;
&amp;lt;/jp:xmlaQuery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c:set var=&quot;title01&quot; scope=&quot;session&quot;&amp;gt;Accessing Mondrian By XMLA&amp;lt;/c:set&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;XmlaServlet.java&lt;/b&gt;&lt;br /&gt;
This the servlet which exposes the mondrian XMLA api. This needs to be added to the web.xml.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/8568808221293813004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/09/mondrian-xmla-provider.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/8568808221293813004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/8568808221293813004'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/09/mondrian-xmla-provider.html' title='Mondrian XMLA Provider'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-6722369964774691716</id><published>2012-08-27T03:37:00.001-07:00</published><updated>2012-08-27T03:39:40.159-07:00</updated><title type='text'>OAuth1.0</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;O&lt;b&gt;Auth1.0 implementation for Rest API&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;After much of deliberation we decided to use OAuth1.0 specification to secure our RESTful API. Oauth1.0 works in way where two servers connect to each other on behalf of the client through the exchange of some tokens.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Steps to implement OAuth1.0 :-&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;ol&gt;&lt;ol&gt;&lt;ol&gt;&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Generate consumer key and secret key&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Generate Request Token&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Authorize the user&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Use Login&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Generate access token&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;1.Generate consumer key and secret key :-&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The target server should get a consumer and secret key from the source server. The consumer key and secret key can be a plain text or some encrypted string.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;2.Generate request token :-&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Create a servlet as RequestToken.java and it can receive a url with all oauth parameters.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;a href=&quot;https://serviceprovider.com/webservice/token_request&quot; rel=&quot;nofollow&quot; style=&quot;background-color: white; border: 0px; color: #0678be; line-height: 17.983333587646484px; margin: 0px; padding: 0px; vertical-align: baseline;&quot; title=&quot;https://serviceprovider.com/webservice/token_request&quot;&gt;https://localhost:8080/restservice/token_request&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;?&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;nbsp; &amp;nbsp; oauth_nonce=&lt;/span&gt;
&lt;span style=&quot;background-color: #f6f6f2; color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;bIZTBUrcSPa24nfpUeiTfjWNNVNxLqEf&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;nbsp; &amp;nbsp; oauth_timestamp=1202956957 &amp;amp;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;nbsp; &amp;nbsp; oauth_consumer_key=123456891011121314151617181920 &amp;amp;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;nbsp; &amp;nbsp; oauth_signature_method=plaintext &amp;amp;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;nbsp; &amp;nbsp; oauth_signature=abcdef &amp;amp;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;nbsp; &amp;nbsp; oauth_version=1.0&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;The server should validate the&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&amp;nbsp;request signature and it should validate the consumer key against the signature. Once the request is validated, it should send a response with request token key and token secret key.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;3:Authorize the user:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Create another servlet Authorize.java and it should also take two parameters oauth_token and callback. It supports two method GET and POST.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Sample URL :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f6f6f2; color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;http://&lt;/span&gt;&lt;a href=&quot;https://serviceprovider.com/webservice/token_request&quot; rel=&quot;nofollow&quot; style=&quot;background-color: white; border: 0px; color: #0678be; line-height: 17.983333587646484px; margin: 0px; padding: 0px; vertical-align: baseline;&quot; title=&quot;https://serviceprovider.com/webservice/token_request&quot;&gt;localhost&lt;/a&gt;:8080&lt;span style=&quot;background-color: #f6f6f2; color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;/restservice/authorize &lt;/span&gt;&lt;br style=&quot;color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: #f6f6f2; color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;?oauth_token=bIZTBUrcSPa24nfpUeiTfjWNNVNxLqEf&amp;amp;&lt;/span&gt;&lt;br style=&quot;color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: #f6f6f2; color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;oauth_callback=http://client/application.com/oauth-section&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;4: Login:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;If user authorization fails then the the Authorize.java should redirect to the callback url.The callback url should prompt the user to login.Once user logged in successfully, it should return back with &amp;nbsp;a 200 response code.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;5:Get Access Token:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;Once the user is authorized, the client server should request a access token from the source server. This should be handled through a AccessToken.java servlet file. It should take all oauth parameters.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;Sample URL :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;http://localhost:8080/restservice/access&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ?oauth_version=1.0&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; oauth_nonce=f5y9bb311de06fer8658c0531e337f65&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; oauth_timestamp=1224577277&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;      oauth_consumer_key=key&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;      oauth_token=requestkey&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;      oauth_signature_method=HMAC-SHA1&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;      oauth_signature=ivwrVYhKNpFMxgwJuc2h%2FAmfQdE%3D&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;      oauth_callback=http://localhost:8080&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;Response :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f6f6f2; color: #222222; line-height: 17.983333587646484px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;oauth_token=efht7645999uksedf3455&amp;amp;oauth_token_secret=sddff19344f55d&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;span style=&quot;line-height: 17.983333587646484px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-size: 13px; line-height: 17.983333587646484px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: &#39;Lucida Grande&#39;, &#39;DejaVu Sans&#39;, &#39;Bitstream Vera Sans&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 17.983333587646484px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/6722369964774691716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/08/oauth10.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/6722369964774691716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/6722369964774691716'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/08/oauth10.html' title='OAuth1.0'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-5520285082013906108</id><published>2012-04-02T02:51:00.001-07:00</published><updated>2012-04-02T02:51:43.680-07:00</updated><title type='text'>Freemarker configuration</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I will provide you a example of ftl configuration with StringTemplateLoader.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Configuration cfg = new Configuration();&lt;br /&gt;StringTemplateLoader templateLoader = new StringTemplateLoader();&lt;br /&gt;template = &quot;firstTemplate&quot;;&lt;br /&gt;templateLoader.putTemplate(template, &quot;${pet} does ${number} little hops :)&quot;);&lt;br /&gt;&lt;br /&gt;cfg.setTemplateLoader(templateLoader);&lt;br /&gt;freemarker.template.Template tpl = cfg.getTemplate(template);&lt;br /&gt;&lt;br /&gt;OutputStreamWriter output = new OutputStreamWriter(System.out);&lt;br /&gt;&lt;br /&gt;tpl.process(datamodel, output);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Without the template loader configuration, the Configuration will send a Template not Found exception.&lt;br /&gt;
&lt;br /&gt;
You can use different kinds of template loader, FileTemplateLoader, SpringTemplateLoader, ClassTemplateLoader.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/5520285082013906108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/04/freemarker-configuration.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/5520285082013906108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/5520285082013906108'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/04/freemarker-configuration.html' title='Freemarker configuration'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255098757764522281.post-5465057704336379212</id><published>2012-02-23T10:03:00.004-08:00</published><updated>2012-02-25T04:04:21.930-08:00</updated><title type='text'>JSONP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;font-size: large;&quot;&gt; JSONP and Jersey&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;
&lt;div&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Recently I was trying to call a restful service using Jquery ajax. But the script was giving exception and I had problem accessing the response. I googled a bit and found that Jquery ajax can&#39;t directly call the restful services due to &lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Access-Control-Allow-Origin policy. It provides a workaround using JSONP.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;JSONP&lt;/b&gt;: It is way in which the server will return the JSON response but it will be wrapped around the callback parameter specified in the request. JQuery will pass the response to the callback method.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Sample JSONP Code&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;function loadProducts() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;var id = &amp;nbsp;getURLParameter(&#39;id&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; var url =&amp;nbsp;&quot;http://localhost:8080/jersey/rest/1.0/store/getproducts?id=&quot;+id+&quot;&amp;amp;callback=product&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; $.jsonp({&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;url&quot;: url,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;data&quot;: {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;alt&quot;: &quot;json-in-script&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;success&quot;: function(data) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(data);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;function product(data) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; alert(data);
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;loadProducts()&amp;nbsp;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Jersey: &lt;/b&gt;It is a framework which can be used to create restful services. Jersey supports JSON MIMETYPE. &amp;nbsp;To JSON response into a JSONP format, the response has be intercepted using ContainerResponseFilter interface.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web.xml&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;init-param&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;param-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; com.sun.jersey.spi.container.ContainerResponseFilters&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;/param-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;param-value&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;com.myproject.services.rest.filters.JSONPResponseFilter,com.sun.jersey.api.container.filter.LoggingFilter&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;/param-value&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;/init-param&amp;gt; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;JSONPResponseFilter&lt;/b&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Create a new jersey filter as JSONPResponseFilter and implement the &amp;nbsp;ContainerResponseFilters. Inside the filter method get the value of the callback and set it to a variable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;JSONPResponseFilter#filter&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;logger.info(&quot;Response :&quot;+request.getQueryParameters().get(&quot;callback&quot;));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String temp = request.getQueryParameters().get(&quot;callback&quot;).toString();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;callback = temp.substring(1, temp.length()-1);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;setId();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response.setContainerResponseWriter(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new Adapter(response.getContainerResponseWriter()));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;Adapter&lt;/b&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Create a inner class as Adapter and implement the&amp;nbsp;ContainerResponseWriter.Implement the finish() method. Wrap the callback variable around the JSON response.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Adapter(ContainerResponseWriter crw) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.crw = crw;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.disableEntity = rc.getFeature(FEATURE_LOGGING_DISABLE_ENTITY);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;public void finish() throws IOException {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!disableEntity) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String &lt;b&gt;s&lt;/b&gt; = baos.toString();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;s =&lt;b&gt;callback&lt;/b&gt;+&quot;(&quot;+s+&quot;)&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;baos.write(s.getBytes());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; byte[] entity = baos.toByteArray();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printEntity(b, entity);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Output to log&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.info(s.toString());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Write out the headers and buffered entity&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OutputStream out = crw.writeStatusAndHeaders(contentLength, response);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.write(s.getBytes());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //crw.finish();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://soumyajitswain.blogspot.com/feeds/5465057704336379212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://soumyajitswain.blogspot.com/2012/02/jsonp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/5465057704336379212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255098757764522281/posts/default/5465057704336379212'/><link rel='alternate' type='text/html' href='http://soumyajitswain.blogspot.com/2012/02/jsonp.html' title='JSONP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17515467066397826093</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>