<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Thejas Hm on Medium]]></title>
        <description><![CDATA[Stories by Thejas Hm on Medium]]></description>
        <link>https://medium.com/@thejas.hm?source=rss-13a745988f94------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T9NyP87jT4VCvTPnhZ2HxA.jpeg</url>
            <title>Stories by Thejas Hm on Medium</title>
            <link>https://medium.com/@thejas.hm?source=rss-13a745988f94------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:04:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thejas.hm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Standardized way of converting from XML to JSON by preserving the structure and the datatype]]></title>
            <link>https://medium.com/@thejas.hm/standardized-way-of-converting-from-xml-to-json-by-preserving-the-structure-and-the-datatype-04f9711b925e?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/04f9711b925e</guid>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 11:50:43 GMT</pubDate>
            <atom:updated>2025-10-19T11:50:43.465Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Y2oN5F4UeLvl_X3nynkIQ.png" /></figure><p><strong>Description</strong>: Most of the legacy systems uses XML as a defacto format and moving into the newer system often requires to come up with a JSON converter</p><p>Problem statement:</p><blockquote>Requirement is to convert any Complex XML into JSON preserving the datatype and data structure type (Object or Array ). We do not have equivalent XSD for each of the XML that are coming up</blockquote><blockquote>Jackson does provides tree traversal method to convert any XML to JSON but it does come up with its own drawback, it cannot explicitly preserve a certain tag as an Object or Array and it does depends on the repetition of tags to convert that as an array. It also doesn’t preserve the datatype</blockquote><blockquote>Another way is to have an intermediate class with the necessary types and Jackson annotation to handle the same</blockquote><blockquote>Writing down the classes for each of the XML is quite laborious and needs lot of effort, alternative is to come up with a master class that can be used for the conversion of any type of XML that flows in</blockquote><h3><strong>Solution </strong>:</h3><p>One of the possible solution for the above has been mentioned below</p><p>If the project doesn’t have a master XSD , then one has to formulate a master XML with all possible values that one can expect and these can be those that are required or mandatory which forms a link to the next system</p><p>Convert the XML to an XSD using an open source tool, feed this XSD into the XJC compiler to convert that into a master Java class.</p><p>The above generated class forms the basis for converting any incoming XML to JSON without worrying about the structure. Jackson does comes up with lot of annotation and needs some tweaking to the above mentioned created class</p><p>Below set of annotation does provide some flexibility to ensure that unknown fields are ignored, conversion of certain tags will happen as an array always regardless of the number of times the tag repeats</p><blockquote>@JsonIgnoreProperties(ignoreUnknown = true): To ignore any unknown fields</blockquote><blockquote>@JacksonXmlElementWrapper(use Wrapping = false)</blockquote><blockquote>@JacksonXmlProperty(localName=”&lt;&lt;repetitive tags&gt;&gt;”)</blockquote><h3>Demonstrating the code snippet</h3><p>Step 1: Is to convert from XSD to Java class</p><p>In the below pasted image , you can see the usage of XJC to convert the XSD to Java class, refer the configuration section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kISgCDNcjJdk5jOsI4qqDA.png" /><figcaption>Conversion of XSD to XML using XJC</figcaption></figure><p>Step 2:- To tweak the Master class generated with necessary Jackson annotation. For the purpose of demonstration , the conversion has been done using both manually created class by writing down each attributes and another one is an automated classes with few tweaking on the annotation as mentioned above</p><pre>package com.convertor.caller;<br><br>import java.io.File;<br>import java.io.IOException;<br><br>import org.apache.commons.io.FileUtils;<br><br>import com.fasterxml.jackson.databind.DeserializationFeature;<br>import com.fasterxml.jackson.databind.ObjectMapper;<br>import com.fasterxml.jackson.dataformat.xml.XmlMapper;<br>import com.manual.coded.ComplexXml;<br>import com.model.codeGenerator.ComplexXmlGenerated;<br>import com.model.codeGenerator.StandardClassForConversion;<br><br>public class XmlToJsonUsingClassInJackson {<br><br> public byte[] getFileBytes(String fileName) {<br>  try {<br><br>   return FileUtils.readFileToByteArray(new File(getClass().getClassLoader().getResource(fileName).getFile()));<br><br>  } catch (Exception e) {<br>   e.printStackTrace();<br>  }<br>  return null;<br><br> }<br><br> public static void main(String[] args) throws IOException {<br>  XmlToJsonUsingClassInJackson obj = new XmlToJsonUsingClassInJackson();<br>  XmlMapper xmlMapper = new XmlMapper();<br>  ObjectMapper mapper = new ObjectMapper();<br>  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);<br><br>  ComplexXml realestate = xmlMapper.readValue(obj.getFileBytes(&quot;Testing.xml&quot;), ComplexXml.class);<br><br>  String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(realestate);<br>  System.out.println(json);<br><br> <br>  <br>  StandardClassForConversion gen = xmlMapper.readValue(obj.getFileBytes(&quot;Testing.xml&quot;), StandardClassForConversion.class);<br>  String jsonRegen = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(gen);<br>  System.out.println(&quot;############ Regenerated JSON #################&quot;);<br>  System.out.println(jsonRegen);<br><br> }<br><br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*GzIqSVx4BbdDVE8VAYeQ9g.png" /><figcaption>Highlighted are the classes generated</figcaption></figure><p>Step 3:- Refer the below GitHub branch for the complete code snippet</p><p><strong>Branch name</strong>:- <a href="https://github.com/teju2017/JAVA_CONCEPTS/tree/XmlToJsonStandardConversion">XmlToJsonStandardConversion</a></p><p><a href="https://github.com/teju2017/JAVA_CONCEPTS.git">GitHub - teju2017/JAVA_CONCEPTS: This repository contains different concepts and frameworks surrounding the Java technology, this repository will be enhanced with more example depicting the working of each of the concepts</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04f9711b925e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programatic interaction with the LLM models]]></title>
            <link>https://medium.com/@thejas.hm/programatic-interaction-with-the-llm-models-4054f9a8d6d5?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/4054f9a8d6d5</guid>
            <category><![CDATA[llm-inegration]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Sun, 15 Jun 2025 10:31:02 GMT</pubDate>
            <atom:updated>2025-06-15T10:40:59.216Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1cWG3dmMjnWJyZXb7WpSyw.png" /><figcaption>Gemini AI generated image ( mid age software professional trying to understand AI and LLM :)</figcaption></figure><h4>Description:</h4><p>This page was created for someone jumping from traditional coding background into the world of AI and Large language model. Lets clear the air out of all the AI buzz and get into the basics of its working</p><p>Models that are pre-trained on a large dataset falls under the category of Large language models that uses neural network designed to mimic human like thinking. These LLM can perform various tasks based on the queries that are inputted.</p><h4>Basic questions</h4><p><strong>Question one</strong>:- How do you fed data to these models?</p><p>Data is fed to these models in the form of embedded token/vectors which are nothing but an array of numbers that determine the data, these are loaded into various vector databases (chroma DB )</p><p><strong>Question two</strong>:- What are the various ways of making use of these models for effective implementation of tasks?</p><p><strong>RAG</strong>:- Retrieval augmented Generation:- This picks a query and searches for that in the model and supplements the same with some external search, external search is facilitated by the data fed to the model using vector databases that is custom to the organization or topic</p><p><strong>Fine tuning</strong>:- You take a model and then start using a machine learning computational model to feed the data custom to the organization to achieve a specific task</p><p><strong>Prompt Engineering</strong>: This is to provide queries and accordingly get the response, this can be used for a wide variety of activities like Image generation, TTS, video generation etc</p><h4>Interacting with AI in a programmatic way</h4><p>There are multiple models available, for the ease of demonstration am interacting with the Gemini AI model and OpenAI model</p><p>You can use their SDK or a Rest API to interact with their services. Every model provider comes with a list of model variants with each capable of performing certain tasks.</p><p><em>gemini-2.0-flash</em> : generating the contents based on the user query</p><p><em>gemini-2.0-flash-preview-image-generation</em>:- Generate images based on the user input</p><h4>Integration with LLM:</h4><p>Below code snippet connects to the Open AI and Gemini AI model using the SDK to generate content equivalent of the Prompt engineering</p><p>I did try some image generation using Java and was getting the below error, so switched to python since this was clearly supported in the link provided below</p><p><a href="https://ai.google.dev/gemini-api/docs/image-generation">https://ai.google.dev/gemini-api/docs/image-generation</a></p><p><em>( 404 Not Found. models/gemini-2.0-flash-preview-image-generation is not found for API version v1beta, or is not supported for predict. Call ListModels to see the list of available models and their supported methods.)</em></p><pre>package com.tejas.sdk;<br><br>import java.io.BufferedReader;<br>import java.io.File;<br>import java.io.FileNotFoundException;<br>import java.io.FileOutputStream;<br>import java.io.IOException;<br>import java.io.InputStreamReader;<br>import java.util.Collections;<br>import java.util.List;<br>import java.util.Optional;<br>import java.util.Scanner;<br><br>import com.google.common.collect.ImmutableList;<br>import com.google.genai.Client;<br>import com.google.genai.types.GenerateContentConfig;<br>import com.google.genai.types.GenerateContentResponse;<br>import com.google.genai.types.GenerateImagesResponse;<br>import com.google.genai.types.GeneratedImage;<br>import com.google.genai.types.Part;<br>import com.openai.client.OpenAIClient;<br>import com.openai.client.okhttp.OpenAIOkHttpClient;<br>import com.openai.models.ChatCompletion;<br>import com.openai.models.ChatCompletionCreateParams;<br>import com.openai.models.ChatModel;<br>import com.openai.models.Image;<br><br>public class PromptsCalling {<br><br> public void callingOpenAi() {<br>  OpenAIClient client = OpenAIOkHttpClient.fromEnv();<br><br>  ChatCompletionCreateParams params = ChatCompletionCreateParams.builder().addUserMessage(&quot;Say this is a test&quot;)<br>    .model(&quot;gpt-4.1&quot;).build();<br>  ChatCompletion chatCompletion = client.chat().completions().create(params);<br> }<br><br> public void makeGeminiAiCall(BufferedReader buff) {<br>  try {<br>   Client client = new Client();<br><br>   String input;<br>   input = buff.readLine();<br><br>   GenerateContentResponse response = client.models.generateContent(&quot;gemini-2.0-flash&quot;, input, null);<br><br>   System.out.println(response.text());<br>  } catch (Exception ae) {<br>   System.out.println(&quot;Exception value = &quot; + ae.getMessage());<br>  }<br> }<br><br><br> public static void main(String[] args) {<br><br>  PromptsCalling prompts = new PromptsCalling();<br>  System.out.println(&quot;Enter your question here &quot;);<br>  BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));<br><br>  prompts.callingOpenAi();<br>  prompts.makeGeminiAiCall(buff);<br><br> }<br><br>}<br><br>#### Gemini AI #####<br>&lt;dependency&gt;<br>&lt;groupId&gt;com.google.genai&lt;/groupId&gt;<br>&lt;artifactId&gt;google-genai&lt;/artifactId&gt;<br>&lt;version&gt;1.0.0&lt;/version&gt;<br>&lt;/dependency&gt;<br><br>#### Open AI ####<br>&lt;dependency&gt;<br>    &lt;groupId&gt;com.openai&lt;/groupId&gt;<br>    &lt;artifactId&gt;openai-java&lt;/artifactId&gt;<br>    &lt;version&gt;0.31.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Generating the image based on the text using Python, below code snippet generated the code for the text prompt “Generate an image of a mid age software professional trying to understand AI and LLM” ,<em> the image generated by below code has been used as the cover page for this article</em> :)</p><pre>&#39;&#39;&#39;<br>Created on 15 Jun 2025<br><br>@author: Thejas<br>&#39;&#39;&#39;<br>from google import genai<br>from google.genai import types<br>from PIL import Image<br>from io import BytesIO<br>import base64<br><br>client = genai.Client()<br><br>contents = (&#39;Generate an image of a mid age software professional trying to understand AI and LLM &#39;)<br><br>response = client.models.generate_content(<br>    model=&quot;gemini-2.0-flash-preview-image-generation&quot;,<br>    contents=contents,<br>    config=types.GenerateContentConfig(<br>      response_modalities=[&#39;TEXT&#39;, &#39;IMAGE&#39;]<br>    )<br>)<br><br>for part in response.candidates[0].content.parts:<br>  if part.text is not None:<br>    print(part.text)<br>  elif part.inline_data is not None:<br>    image = Image.open(BytesIO((part.inline_data.data)))<br>    <br>    <br>    <br>    image.save(&#39;gemini-native-image.png&#39;)<br>    image.show()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4054f9a8d6d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Kafka broker in a docker desktop and interacting with it via the spring boot]]></title>
            <link>https://medium.com/@thejas.hm/spring-boot-and-kafka-running-on-a-windows-local-system-8b9d28a84586?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b9d28a84586</guid>
            <category><![CDATA[kafka-broke]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[docker-desktop]]></category>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 14:17:34 GMT</pubDate>
            <atom:updated>2025-02-15T14:18:40.346Z</atom:updated>
            <content:encoded><![CDATA[<p>This page has been created to provide information for someone looking forward to start a Kafka broker in a docker desktop on a windows system and understand the nuances of its working , also setting up a spring boot application to work as producer and consumer</p><p>The page doesn&#39;t focus much on going through the details of the Kafka working instead it explains what has been used as part of the below illustration. Integral part of Kafka is its broker, each broker has topics, topics in turn has partition. For this illustration we are looking at creating multiple topics in a broker</p><p>Step 1:- Install the docker desktop ( Pre-requisites are clearly mentioned in the below link)</p><p><a href="https://docs.docker.com/desktop/setup/install/windows-install/">https://docs.docker.com/desktop/setup/install/windows-install/</a></p><p>Step 2:- Start the docker desktop services in the my hub</p><p>Step 3:- Search for the below image from the docker hub search and pull the same</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*JZ77ws4o7vY1RwP-UodA_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*WFYGID-B6vNLztE1UwdemQ.png" /></figure><p>Step 4:- Click on the start button, it asks for the optional setting window, just provide a container name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*RgbRYeyzghLtQaOOPS6rsg.png" /></figure><p>Step 5:- Your container is started, 9092 is the external port for the application to connect</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HdaYRtyVWN-qgWdXFKI3BQ.png" /></figure><p>Step 6:- Follow the details mentioned in the below , refer the link for more details ( Refer this link for the details )</p><pre>1. Start a Kafka broker:<br><br>docker run -d --name broker apache/kafka:latest<br><br>2. Open a shell in the broker container:<br><br>docker exec --workdir /opt/kafka/bin/ -it broker sh<br><br>3. Create four different topics<br><br>./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic Tejas-Topic --group Tejas-Consumer-Group <br><br>./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic Tejas-SecondTopic --group Tejas-Consumer-Group<br><br>./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic Tejas-ThirdTopic --group Tejas-Consumer-Group<br><br>4. Use the below command to list all the topics<br><br>./kafka-topics.sh --bootstrap-server=localhost:9092 --list <br><br>5. Below command to list all the groups <br> <br>./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list // List all groups</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0WsNOTi9TwAJJmu2rfQi2A.png" /><figcaption>Details of a specific topic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*DOC4Rfbvux4pEGkqOv9GHw.png" /><figcaption>To display the consumer groups</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsR4W6iaMVCc4zOesCz6pQ.png" /></figure><p>Step 7:- Now create a spring boot application with the Kafka dependency, we assume that the person reading is familiar with the Spring boot and Java . You can add the necessary dependency from the spring starter boot page</p><p>Step 8:- The key part is the below details in the application. properties or application.yml file of the spring boot</p><blockquote>The consumer and producer are the key. group-id is mandatory and it indicates the consumer-group</blockquote><blockquote>client-id is an arbitary name. Every message sent will have a key and value</blockquote><blockquote>serializer and deserializer for the message type has to be extensively provided</blockquote><pre>server:<br>  port: 9001<br>spring:<br>   kafka:<br>     consumer:<br>        bootstrap-servers: localhost:9092<br>        group-id: Tejas-Consumer-Group,group_two<br>        auto-offset-reset: earliest<br>        key-deserializer: org.apache.kafka.common.serialization.StringDeserializer<br>        value-deserializer: org.apache.kafka.common.serialization.StringDeserializer<br>     producer:<br>        bootstrap-servers: localhost:9092<br>        key-serializer: org.apache.kafka.common.serialization.StringSerializer<br>        value-serializer: org.apache.kafka.common.serialization.StringSerializer</pre><p>Step 8:- The KafkaTemplate gets autoconfigured and we have a simple producer class that sends the message to a specific topic</p><pre>package com.apache.kafka;<br><br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.kafka.core.KafkaTemplate;<br>import org.springframework.stereotype.Component;<br><br>@Component<br>public class Producer {<br><br> Logger log = LoggerFactory.getLogger(Producer.class);<br><br> @Autowired<br> public KafkaTemplate&lt;String, String&gt; kafkaTemplate;<br><br> public void checkAndSend(String message) {<br>  String topic = &quot;Tejas-Topic&quot;;<br>  log.info(&quot;Message = &quot; + message);<br>  this.kafkaTemplate.send(topic, message);<br> }<br><br> public void checkTopicAndSendMessage(String topic, String message) {<br>  log.info(&quot;topic passed is :&quot; + topic);<br>  kafkaTemplate.send(topic, message);<br> }<br><br>}</pre><p>Step 9:- The below class is a consumer and Spring boot has a annotation called KafkaListener to specify the topic name and consumer group.</p><p>You can see multiple listeners, each looking for a specific topic created under a specific consumer group. Two groups are available, “Tejas_consumer_group” and “group_two”. Each method logs out the message that is read from the specific topic</p><pre>package com.apache.kafka;<br><br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br>import org.springframework.kafka.annotation.KafkaListener;<br>import org.springframework.stereotype.Component;<br><br>@Component<br>public class Consumer {<br><br> Logger logger = LoggerFactory.getLogger(Consumer.class);<br><br> <br> @KafkaListener(topics = &quot;test-topic&quot;, groupId = &quot;group_two&quot;)<br> public void checkOne(String message) <br> {<br>  logger.info(&quot;Consuming the message :::::&quot; + message);<br><br> }<br><br> @KafkaListener(topics = &quot;Tejas-Topic&quot;, groupId = &quot;Tejas-Consumer-Group&quot;)<br> public void consumerOne(String message) {<br>  logger.info(&quot;Consuming the message from Tejas-Topic:::::&quot; + message);<br><br> }<br><br> @KafkaListener(topics = &quot;Tejas-SecondTopic&quot;, groupId = &quot;Tejas-Consumer-Group&quot;)<br> public void consumerTwo(String message) {<br>  logger.info(&quot;Consuming the message from Tejas-SecondTopic :::::&quot; + message);<br><br> }<br><br> @KafkaListener(topics = &quot;Tejas-ThirdTopic&quot;, groupId = &quot;Tejas-Consumer-Group&quot;)<br> public void consumerThree(String message) {<br>  logger.info(&quot;Consuming the message Tejas-ThirdTopic :::::&quot; + message);<br><br> }<br><br>}</pre><p>Step 9:- Add a controller in the spring boot that takes the message sent to producer to publish in the Kafka topic. You can see endpoints</p><blockquote>a. /take == &gt;To publish a static message to a specific Topic</blockquote><blockquote>b. /take/{msg} ==&gt; To publish the message required to a specific topic</blockquote><blockquote>c. /take/{topic}/{message} ==&gt; To publish the required message to a topic that we want</blockquote><pre>package com.apache.kafka.controllers;<br><br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.PathVariable;<br>import org.springframework.web.bind.annotation.RestController;<br><br>import com.apache.kafka.Producer;<br><br>@RestController<br>public class ControllerMode {<br><br> Logger log = LoggerFactory.getLogger(ControllerMode.class);<br><br> @Autowired<br> Producer testObj;<br><br> @GetMapping(&quot;/take&quot;)<br> public String sendMessage() {<br>  testObj.checkAndSend(&quot;first simple message&quot;);<br>  return &quot;Simple message Check&quot;;<br> }<br><br> @GetMapping(&quot;/take/{msg}&quot;)<br> public String sendMessageVariant(@PathVariable String msg) {<br>  testObj.checkAndSend(msg);<br>  return &quot;message = &quot; + msg + &quot;Sent&quot;;<br> }<br><br> @GetMapping(&quot;/take/{topic}/{message}&quot;)<br> public String sendMessageToTopicProvided(@PathVariable String topic, @PathVariable String message) {<br>  log.info(&quot;Topic passed is &quot; + topic + &quot;  Message = &quot; + message);<br>  testObj.checkTopicAndSendMessage(topic, message);<br>  return &quot;message sent to &quot; + topic;<br> }<br><br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-nsyem4oPRfrRYpRccA1gw.png" /><figcaption>Showing the consumer ID and auto generated client id by the Kafka</figcaption></figure><p>Step 10:- Refer the below log to get a view, find the below link for the source code performing the task.</p><blockquote>Below screen shot show the log message of the Producer and Consumer class publishing and reading the message subsequently based on the web service endpoint call made as explained above</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wBQjqyQ7yg12mr9seqIWUw.png" /><figcaption>Log Message</figcaption></figure><pre>2025-02-15T21:57:54.199+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [nio-9001-exec-1] [0;39m[36mo.a.kafka.common.utils.AppInfoParser    [0;39m [2m:[0;39m Kafka commitId: 70d6ff42debf7e17<br>[2m2025-02-15T21:57:54.199+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [nio-9001-exec-1] [0;39m[36mo.a.kafka.common.utils.AppInfoParser    [0;39m [2m:[0;39m Kafka startTimeMs: 1739627874199<br>[2m2025-02-15T21:57:54.209+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [ad | producer-1] [0;39m[36morg.apache.kafka.clients.Metadata       [0;39m [2m:[0;39m [Producer clientId=producer-1] Cluster ID: 5L6g3nShT-eMCtK--X86sw<br>[2m2025-02-15T21:57:54.210+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [ad | producer-1] [0;39m[36mo.a.k.c.p.internals.TransactionManager  [0;39m [2m:[0;39m [Producer clientId=producer-1] ProducerId set to 6004 with epoch 0<br>[2m2025-02-15T21:57:54.257+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [ntainer#1-0-C-1] [0;39m[36mcom.apache.kafka.Consumer               [0;39m [2m:[0;39m Consuming the message from Tejas-Topic:::::first simple message<br>[2m2025-02-15T21:58:02.842+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [nio-9001-exec-7] [0;39m[36mc.a.kafka.controllers.ControllerMode    [0;39m [2m:[0;39m Topic passed is Tejas-SecondTopic  Message = WorkingWell<br>[2m2025-02-15T21:58:02.842+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [nio-9001-exec-7] [0;39m[36mcom.apache.kafka.Producer               [0;39m [2m:[0;39m topic passed is :Tejas-SecondTopic<br>[2m2025-02-15T21:58:02.856+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [ntainer#2-0-C-1] [0;39m[36mcom.apache.kafka.Consumer               [0;39m [2m:[0;39m Consuming the message from Tejas-SecondTopic :::::WorkingWell<br>[2m2025-02-15T21:58:10.298+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [nio-9001-exec-6] [0;39m[36mcom.apache.kafka.Producer               [0;39m [2m:[0;39m Message = SomeMessage<br>[2m2025-02-15T21:58:10.303+08:00[0;39m [32m INFO[0;39m [35m10384[0;39m [2m--- [ntainer#1-0-C-1] [0;39m[36mcom.apache.kafka.Consumer               [0;39m [2m:[0;39m Consuming the message from Tejas-Topic:::::SomeMessage</pre><p>Step 11:- Refer the below Gitlab link for the source code, please let me know your suggestion</p><p><a href="https://github.com/teju2017/kafka_springboot.git">https://github.com/teju2017/kafka_springboot.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b9d28a84586" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring security implementation — Preauthentication and authorization]]></title>
            <link>https://medium.com/@thejas.hm/spring-security-implementation-preauthentication-and-authorization-d98e08e546b5?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/d98e08e546b5</guid>
            <category><![CDATA[customuserdetails]]></category>
            <category><![CDATA[spring-security-6]]></category>
            <category><![CDATA[preauthentication]]></category>
            <category><![CDATA[in-memory]]></category>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Sun, 09 Apr 2023 14:45:03 GMT</pubDate>
            <atom:updated>2023-04-09T14:45:03.401Z</atom:updated>
            <content:encoded><![CDATA[<h3>Spring security implementation — Preauthentication and authorization</h3><h4><strong>Description</strong>:</h4><p>This page has been created to provide a clarity on using the spring security to integrate with pre -authentication and also using the file as a source of data for the authorization. The article provides information on the below two scenarios</p><h4><strong>Scenarios:</strong></h4><p>Spring security is built around the usage of pre and post filter that exists in any servlet session. Authentication is a process of validating the user and authorization determines what the user is allowed to view</p><p><em>Scenario one</em>:- Building a custom service to authorize a user based on the information available in an external file</p><p><em>Scenario two</em>:- Pre authentication of the user via an SSO and authorizing the user based on the information available in an external file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzaV-qZzS8caJlxd8drgtg.png" /><figcaption>Architecture and request flow</figcaption></figure><h4><strong>Implementation details for Scenario one :</strong></h4><p>The details are more specific around the implementation using the spring security thinking that the audience has some prior information on bring up a spring boot MVC application</p><ol><li>Add the spring security in the starter dependency of the spring boot application</li><li>Below is the maven dependency for the same, version is taken from the parent pom in this case am using the 3.0.0</li></ol><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;<br>  &lt;/dependency&gt;</pre><p>3. From Spring security 3.0.0 the antmatchers has been replaced with requestMatchers and one should create a SecurityFilterChain bean defining the URL path and its respective roles.</p><p>Please note that a bean should be created for the BCryptPasswordEncoder as the spring bean only compares the encoded password.</p><pre>@Configuration<br>@EnableWebSecurity<br>public class WebSecurityConfig {<br><br> @Bean<br> SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {<br><br>  return http<br>    .authorizeHttpRequests((request) -&gt; request.requestMatchers(&quot;/admin&quot;).hasRole(&quot;ADMIN&quot;)<br>      .requestMatchers(&quot;/extendedUser&quot;).hasAnyRole(&quot;EXTUSER&quot;, &quot;ADMIN&quot;).requestMatchers(&quot;/user&quot;)<br>      .hasAnyRole(&quot;USER&quot;, &quot;EXTUSER&quot;, &quot;ADMIN&quot;).anyRequest().authenticated())<br>    .formLogin().and().logout().and().csrf().disable().build();<br><br> }<br><br> @Bean<br> BCryptPasswordEncoder passwordEncoder() {<br>  return new BCryptPasswordEncoder();<br> }<br><br>}</pre><p>4. In the SecurityFilterChain we are setting up the rules that the user having the admin role will be able to view the page returned by the “/admin” controller etc</p><p>5. Spring security calls the loadUserByUsername method from the custom implementation that we provide for the UserDetailsService Interface. username is auto injected by the spring with the user value passed.</p><p>6. The most important thing here is to construct the UserDetails by making use of the User implementation provided by spring. As you can see that the constructor supports the below set of values. Most of them are self explained except the authorities which will be explained in the next section</p><pre>public User(String username, String password, boolean enabled, boolean accountNonExpired,<br>   boolean credentialsNonExpired, boolean accountNonLocked,<br>   Collection&lt;? extends GrantedAuthority&gt; authorities) {<br>  Assert.isTrue(username != null &amp;&amp; !&quot;&quot;.equals(username) &amp;&amp; password != null,<br>    &quot;Cannot pass null or empty values to constructor&quot;);<br>  this.username = username;<br>  this.password = password;<br>  this.enabled = enabled;<br>  this.accountNonExpired = accountNonExpired;<br>  this.credentialsNonExpired = credentialsNonExpired;<br>  this.accountNonLocked = accountNonLocked;<br>  this.authorities = Collections.unmodifiableSet(sortAuthorities(authorities));<br> }</pre><h4><strong>Authorities in Spring:</strong></h4><p>Authorities is the lowest level in the hierarchy of roles. A role can have multiple authorities assigned to it.</p><p>Role is a psuedo concept and let me explain with the below concept.</p><p>A role called admin can view pages admin, setting and Allusers. Here all the individual pages becomes authorities for the role admin. So in this way spring provides the flexibility of handling any authorities to the admin and can control the access of all those users having the role “ADMIN”</p><p>In the below implementation you can view that the user is constructed by passing the username and a new user is returned with the authorities and other details</p><pre><br>package com.tejas.springboot.security;<br><br>import java.util.Collection;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.security.core.GrantedAuthority;<br>import org.springframework.security.core.userdetails.User;<br>import org.springframework.security.core.userdetails.UserDetails;<br>import org.springframework.security.core.userdetails.UserDetailsService;<br>import org.springframework.security.core.userdetails.UsernameNotFoundException;<br>import org.springframework.stereotype.Component;<br><br>import com.tejas.springboot.services.ReadAccessFile;<br><br>@Component<br>public class UserDetailsServiceImpl implements UserDetailsService {<br><br> @Autowired<br> ReadAccessFile fileread;<br><br> @Override<br> public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {<br>  System.out.println(&quot;Username passed to loadUserByUsername method is  &quot; + username);<br>  UserDetails user = fileread.getUserDetails(username);<br>  if (user == null) {<br>   System.out.println(&quot;UserNameNotFound Exception&quot;);<br>  }<br>  Collection&lt;? extends GrantedAuthority&gt; authoritylist = user.getAuthorities();<br>  return new User(user.getUsername(), user.getPassword(), user.getAuthorities());<br><br> }<br><br>}</pre><h4>Implementation Details in Scenario two:-</h4><p>In scenario two there is no real need to validate the user since the same would have been done by an external agent configured in a webserver like Apache. An SSO related webagent will be configured in the webserver to read the information and check its validity in an LDAP server.</p><p>In this scenario we can extend the below classes to read the values coming in the header.</p><pre>protected abstract Object getPreAuthenticatedPrincipal(HttpServletRequest request);<br><br>protected abstract Object getPreAuthenticatedCredentials(HttpServletRequest request);</pre><p>Refer the below for the XML implementation, the header information coming in the SM_USER variable will be read along with an instance of authentication Manager</p><pre>&lt;bean id=&quot;siteminderFilter&quot; class=&quot;org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter&quot;&gt;<br>&lt;property name=&quot;principalRequestHeader&quot; value=&quot;SM_USER&quot;/&gt;<br>&lt;property name=&quot;authenticationManager&quot; ref=&quot;authenticationManager&quot; /&gt;<br>&lt;/bean&gt;<br><br>&lt;bean id=&quot;preauthAuthProvider&quot; class=&quot;org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider&quot;&gt;<br>&lt;property name=&quot;preAuthenticatedUserDetailsService&quot;&gt;<br> &lt;bean id=&quot;userDetailsServiceWrapper&quot;<br>  class=&quot;org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper&quot;&gt;<br> &lt;property name=&quot;userDetailsService&quot; ref=&quot;userDetailsService&quot;/&gt;<br> &lt;/bean&gt;<br>&lt;/property&gt;<br>&lt;/bean&gt;<br><br>&lt;security:authentication-manager alias=&quot;authenticationManager&quot;&gt;<br>&lt;security:authentication-provider ref=&quot;preauthAuthProvider&quot; /&gt;<br>&lt;/security:authentication-manager&gt;</pre><h4>Github link</h4><p>Refer the link below for the complete source code</p><p><a href="https://github.com/teju2017/SPRING_BOOT/tree/SpringSecurity_Custom">https://github.com/teju2017/SPRING_BOOT/tree/SpringSecurity_Custom</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d98e08e546b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Hateoas example]]></title>
            <link>https://medium.com/@thejas.hm/spring-hateoas-example-eb17684a640b?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb17684a640b</guid>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Mon, 26 Dec 2022 06:36:25 GMT</pubDate>
            <atom:updated>2022-12-26T08:35:29.822Z</atom:updated>
            <content:encoded><![CDATA[<p>This article illustrates the usage of Hateoas in a Springboot application. it provides information on the purpose and the steps to follow to implement the same. Focus is primarily on the implementation of the Hateoas and refer the GitLab link for the complete code</p><h3>What is Hateoas?</h3><p>HATEOAS (Hypermedia as the Engine of Application State) is a constraint of the REST application architecture. Rest Architectural style lets us use the hypermedia links in the API response contents. It allows the client to dynamically navigate to the appropriate resources by traversing the hypermedia links.</p><p><em>Navigating hypermedia links is conceptually the same as browsing through web pages by clicking the relevant hyperlinks to achieve a final goal.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*BlmQw7rbHn8TZwk8H3XhvQ.png" /></figure><p><strong>Description</strong>:- We are developing a spring boot application with end points to operate on a list of employees, integrate that with Hateaos and see the usage of the same.</p><p>I would recommend the usage of spring Tool suite 3 as the IDE for developing which will smoothen the process of adding the required dependencies.</p><ol><li>Select the spring boot starter project</li><li>Select the spring Hateoas as a dependency along with the other dependency</li><li>Below dependency will be added into the pom.xml when using the maven as the build tool</li></ol><pre>&lt;dependency&gt;<br>&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>&lt;artifactId&gt;spring-boot-starter-hateoas&lt;/artifactId&gt;<br>&lt;/dependency</pre><p>4. Create an Employee class with the id, name and salary as its attributes</p><p>5. Create a Controller class and define the endpoints to perform the below operations</p><p><em>a. GET: List of employees,</em></p><p><em>b. GET:- based on name</em></p><p><em>c. DELETE:- based on employee id</em></p><p><em>d. POST:- input the information</em></p><p>6. Now the hateoas is being used to get the response in a manner that all possible configured operations in the controller is made available as links</p><p>7. This simplifies the overall process of identifying the related operation for a single response</p><p><strong>Hateoas implementation</strong>:-</p><p>a. RepresentationAssembler:- This is an interface and it contains the default toCollectionModel method and toModel method</p><p>b. EmployeeAssembler class should implement the interface and provide an implementation to the “toModel method”</p><p>c. The representation model takes the Employee and EntityModel&lt;Employee&gt; as the reference</p><p>d. Refer the last three lines of the below code snippet</p><p><em>==&gt; withSelfRel(), we are adding the self link to the employee info that is returned. One with getName and other with the getEmpId.</em></p><p><em>==&gt;methodOn will take the controllerClassLoader as the parameter</em></p><p><em>==&gt;IanaLinkRelations.COLLECTION will provide the link to get the list of employees</em></p><pre>@Component<br>public class EmployeeAssembler implements RepresentationModelAssembler&lt;Employee,EntityModel&lt;Employee&gt;&gt; {<br>@Override<br>public EntityModel&lt;Employee&gt; toModel(Employee entity) {<br>EntityModel&lt;Employee&gt; employeemodel = EntityModel.of(entity);<br>employeemodel.add(linkTo(methodOn(SimpleController.class).getemployeevalue(entity.getName())).withSelfRel());<br>employeemodel.add(linkTo(methodOn(SimpleController.class).getemplist()).withRel(IanaLinkRelations.COLLECTION));<br>employeemodel.add(linkTo(methodOn(SimpleController.class).deleteemployee(entity.getEmpid())).withSelfRel());<br>return employeemodel;</pre><p>e. Refer below for the RepresentationModel class Hierarchy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*2ren43937a_05rYJ_WDtrw.png" /><figcaption>Class hierarchy</figcaption></figure><h4>Sample Response:-</h4><p>Below is the sample response that comes up when the below URL is fired from the postman</p><p><a href="http://localhost:8080/emplist/">http://localhost:8080/emplist/</a></p><ol><li>In the <strong><em>_links</em></strong> , you can see two href in the self array, One to get the list of employees and other to delete based on the employee id which were added in the code as mentioned above</li><li>You can see that for each employee record we have the corresponding the link to get the employee based on the employee name and delete based on the employee id</li><li>The collection object basically provides a link that gets the list of employees and it remains the same for all the different employee id’s</li></ol><pre>{<br>    &quot;_embedded&quot;: {<br>        &quot;employees&quot;: [<br>            {<br>                &quot;name&quot;: &quot;emp_name1&quot;,<br>                &quot;empid&quot;: &quot;emp1_id&quot;,<br>                &quot;salary&quot;: 123.45,<br>                &quot;_links&quot;: {<br>                    &quot;self&quot;: [<br>                        {<br>                            &quot;href&quot;: &quot;http://localhost:8080/emplist/emp_name1&quot;<br>                        },<br>                        {<br>                            &quot;href&quot;: &quot;http://localhost:8080/empdel/emp1_id&quot;<br>                        }<br>                    ],<br>                    &quot;collection&quot;: {<br>                        &quot;href&quot;: &quot;http://localhost:8080/emplist&quot;<br>                    }<br>                }<br>            },<br>            {<br>                &quot;name&quot;: &quot;emp_name2&quot;,<br>                &quot;empid&quot;: &quot;emp2_id&quot;,<br>                &quot;salary&quot;: 123456.45,<br>                &quot;_links&quot;: {<br>                    &quot;self&quot;: [<br>                        {<br>                            &quot;href&quot;: &quot;http://localhost:8080/emplist/emp_name2&quot;<br>                        },<br>                        {<br>                            &quot;href&quot;: &quot;http://localhost:8080/empdel/emp2_id&quot;<br>                        }<br>                    ],<br>                    &quot;collection&quot;: {<br>                        &quot;href&quot;: &quot;http://localhost:8080/emplist&quot;<br>                    }<br>                }<br>            },<br>            {<br>                &quot;name&quot;: &quot;emp_name3&quot;,<br>                &quot;empid&quot;: &quot;emp3_id&quot;,<br>                &quot;salary&quot;: 12334.45,<br>                &quot;_links&quot;: {<br>                    &quot;self&quot;: [<br>                        {<br>                            &quot;href&quot;: &quot;http://localhost:8080/emplist/emp_name3&quot;<br>                        },<br>                        {<br>                            &quot;href&quot;: &quot;http://localhost:8080/empdel/emp3_id&quot;<br>                        }<br>                    ],<br>                    &quot;collection&quot;: {<br>                        &quot;href&quot;: &quot;http://localhost:8080/emplist&quot;<br>                    }<br>                }<br>            }<br>        ]<br>    },<br>    &quot;_links&quot;: {<br>        &quot;self&quot;: {<br>            &quot;href&quot;: &quot;http://localhost:8080/emplist&quot;<br>        }<br>    }<br>}</pre><h4>GIT lab link:-</h4><p>Please refer the below link containing the code</p><p><a href="https://github.com/teju2017/Microservices-and-Springboot/tree/SpringHateoasExample">https://github.com/teju2017/Microservices-and-Springboot/tree/SpringHateoasExample</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb17684a640b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating SOAP client using eclipse and usage of the auto generated code to call the remote web…]]></title>
            <link>https://medium.com/@thejas.hm/generating-soap-client-using-eclipse-and-usage-of-the-auto-generated-code-to-call-the-remote-web-1d81667e9e4b?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d81667e9e4b</guid>
            <category><![CDATA[rpc]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[soap-webservices]]></category>
            <category><![CDATA[stub]]></category>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Sun, 23 Jan 2022 11:17:14 GMT</pubDate>
            <atom:updated>2022-01-23T11:17:14.197Z</atom:updated>
            <content:encoded><![CDATA[<h3>Generating SOAP client using eclipse and usage of the auto generated code to call the remote web service</h3><p>The purpose of this article is to give a clear understanding on the way the SOAP client can be generated using an IDE like eclipse and how to use the generated code to call the required webservice. I like to go about by answering some of the basic question to get a clarity for any new person jumping into the world of webservices. SOAP stands for simple object access protocol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*VHmlQrXV0l_QrZj3xTYTDA.png" /><figcaption>CLIENT SERVER INTERACTION VIA SOAP using stubs</figcaption></figure><p><strong>Question :- What is required to generate the SOAP client?</strong></p><p>WSDL is mandatory and it stands for web service description language which gives the complete information about the webservices that is running or deployed</p><p><strong>Question:- What are the important segments in a WSDL?</strong></p><p>a. Message :- This basically gives the information on the type of element that is being passed as request and response</p><p>b. Porttype:- This is an important segment that defines an interface which is called as service definition interface to access the required service</p><p>c. Binding:- A stub class implements the SDI, name is the binding name suffixed with stub</p><p>d. service:- Client program will not instantiate the stub directly and it would instantiate a service locator and call a get method which returns a stub</p><p><strong>Question:- How to generate using the IDE?</strong></p><h4>Steps on how to get into the below screens in eclipse are mentioned in the bottom of the image</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*5uMoJTo9K1nitaxKAzH7Ow.png" /><figcaption>Go to file new and select the webservice client</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*tMKQpSszUOL_tDbtJ4WApg.png" /><figcaption>Paste the WSDL in the service definition, for this article am using the below as an example <a href="http://localhost:8080/service/studentDetailsWsdl.wsdl">http://localhost:8080/service/studentDetailsWsdl.wsdl</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*br9X_914rSLH3Er9Svn6YA.png" /><figcaption>Above mentioned is the contents of the WSDL based on which the code will be generated</figcaption></figure><p>In the above image, the CLIENT_SOAPWS is the Java project under which the codes will be generated</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*2tcrQKMKFNh8UHv0B-zvUw.png" /><figcaption>Above mentioned are the codes that are generated based on the WSDL that is provided to the IDE</figcaption></figure><p>Question:- Can you explain what does the above generated code means?</p><ol><li>The webservice we are trying to consume is having one operation by name StudentDetails and Student.java is the POJO</li><li>StudentDetailsRequest.java and StudentDetailsResponse.java are the POJO’s indicating the request and response object</li><li>We have two interfaces in the list, StudentDetailsPort.java is having the StudentDetails method which takes the StudentRequest object and responds with the StudentResponse</li><li>StudentDetailsPortService is the interface through which we access the stub to call the method</li><li>StudentDetailsPortSoap11Stub.java is the class that needs to be used to call the service, the instance of the stub is accessed via the above mentioned step</li><li><strong><em>Stub basically helps to deal with the endpoint URL, namespace, or parameter arrays which are involved in dynamic invocation via the Service and Call objects. The stub hides all that work for you.</em></strong></li><li>StudentDetailsPortProxy.java is the class that is a proxy through which we can set the endpoint and get the StudentDetailsPort object to call the operation</li><li>StudentDetailsPortServiceLocator.java is the class that implements the StudentDetailsPortService interface and can be used to get the StudentDetailsPort object via the getStudentDetailsPortSoap11 method</li></ol><p><strong>Question:- How do you form a small stub using the above classes to call the webservice?</strong></p><ol><li>Below is the code that will call the service by passing the StudentDetailsRequest object.</li><li><strong>StudentDetailsPortServiceLocator is instantiated to get the StudentDetailsPort object by calling the getStudentDetailsPortSoap11() method</strong></li><li>The StudentDetailsPort object is used to call the Operation “StudentDetails” with the request object to get the response</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIKyMEqROjvgMj9dgvynnQ.png" /><figcaption>Client code calling the remote webservice</figcaption></figure><p><strong>GITHUB links</strong>:</p><p><em>Source code to the client stub</em></p><p><a href="https://github.com/teju2017/Microservices-and-Springboot/tree/SOAP_CLIENT_WS"><em>https://github.com/teju2017/Microservices-and-Springboot/tree/SOAP_CLIENT_WS</em></a></p><p><em>Link to the actual web services</em></p><p><a href="https://github.com/teju2017/Microservices-and-Springboot/tree/SOAP_WS_Spring"><em>https://github.com/teju2017/Microservices-and-Springboot/tree/SOAP_WS_Spring</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d81667e9e4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Usage of selenium framework in SRE role]]></title>
            <link>https://medium.com/@thejas.hm/usage-of-selenium-framework-in-sre-role-ddee154ba684?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddee154ba684</guid>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Wed, 29 Dec 2021 14:46:11 GMT</pubDate>
            <atom:updated>2021-12-29T14:59:44.011Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Selenium framework usage in an SRE role</strong></h3><p>One of the primary goal of the SRE role is to reduce the toll on the production team by focusing on areas that can be automated and at the same time ensuring the stability of the system. Any automation will help to bring down the human error and also saves the time from the monotonous tasks</p><p>This article tries to come up with few use cases where selenium can be used beyond testing and can be efficiently used to automate some of the tasks that comes up in a production environment</p><p><strong>Use case 1</strong>:- In any production support environment it is often expected to perform the health check of most of the critical UI application and this basically involves carrying out the routine process of opening the URL in a browser and clicking on certain elements and checking the output of the same and capturing the evidence of the work done</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*3w4RkVX8U6HUWjPjiPdfrg.png" /></figure><p>Selenium framework is very handy for the above kind of cases to automate and it supports multiple programming language like Java, Python, Scala with which the programs can be written and same can be scheduled in some scheduler/orchestration tool to trigger at a specific time.</p><p>Apart from the daily routine checks, the automation will greatly help to perform post release checks which can significantly identify for any gaps with the least manual intervention and time</p><p><strong>Use case 2</strong>:- In any production support environment people often end up in doing tasks that do not have any tracking in the form of an incident or a request that is captured in the ITSM tools like service now, Fresh service, HP service manager etc. This often gives an incorrect view on the effort and work involved on a daily basis.</p><p>In the above scenario the support person will be requested to raise an incident or a request and close the same after once the work is completed to get the work reflected in the ITSM tool</p><p><strong>Solution: </strong>Selenium framework comes up very handy in this situation to automate the whole work of raising and closing the incidents in the ITSM tool</p><p>The team can basically maintain a spreadsheet or any other MS tool to just track their work and feed the same to a program written using Selenium to create the tickets and provide the number for the tracking. Use a similar program to close the ticket by feeding the incident number to the same</p><p>In my next series of article you will get to view few sample programs written in Java using the selenium framework, refer the below github link</p><p><a href="https://github.com/teju2017">https://github.com/teju2017</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddee154ba684" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java web application development , Article 1: Spawning a basic web application]]></title>
            <link>https://medium.com/@thejas.hm/java-web-application-development-article-1-spawning-a-basic-web-application-8310b2f6d813?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/8310b2f6d813</guid>
            <category><![CDATA[ssi]]></category>
            <category><![CDATA[j2]]></category>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Wed, 01 Dec 2021 12:52:44 GMT</pubDate>
            <atom:updated>2021-12-01T12:58:32.580Z</atom:updated>
            <content:encoded><![CDATA[<h3>Java/J2EE web application development , Article 1: Spawning a basic web application</h3><h3>Overview</h3><p>This article is the first in the series of articles that will be published related to the development of web application using the basic J2EE technologies. The article focusses primarily on building web applications using the Servlet, JSP, JSTL, JDBC, MySQL and Tomcat web server. It doesn’t uses any of the popular MVC framework like Struts, Spring MVC etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*ID2r9KaORMADBoeME6yj9w.png" /><figcaption>Showing the flow of an HTTP request</figcaption></figure><h3>Description</h3><p>We start initially by setting up of a Java dynamic web project and deploying the same into the tomcat and accessing it via any web browser</p><h3>Steps</h3><ol><li>For this example am using the Eclipse IDE, you can use any of the preferred IDE’s</li><li>Go to the File=&gt; New =&gt;Maven project =&gt; ‘window opens”</li><li>Select catalog as “internal” and type web</li><li>Give the group id ,artifact id and version as the value mentioned in the below screen shot</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*Z9In1gNIYAi0TVslM_y0iw.png" /><figcaption>pom.xml contents</figcaption></figure><p>5. Install the Tomcat 4.0 server</p><p>6. Go to the windows and select server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*WOrCs5Y_Dfhy-9no2No1-Q.png" /><figcaption>Tomcat V9.0 server</figcaption></figure><p>7. Right click on the Tomcat v9.0 server and click on “Add or Remove”, below window opens up</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*Q7pYmVc6ssdE81oAI2ca_A.png" /></figure><p>9. Fire the below URL</p><p>http://localhost:&lt;&lt;port in which the tomcat is running&gt;&gt;/&lt;&lt;Context root&gt;&gt;</p><p>10. In the example the context root is “tejasApp” and tomcat is running on port 9020</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oWDrCyc7R-DTJ4Cp1l8rwQ.png" /><figcaption>http://localhost:9020/tejasApp</figcaption></figure><p>11. Below is the project structure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*RSSDdHhZSWK6RD-sUmVv0A.png" /><figcaption>project structure in eclipse</figcaption></figure><p>12. Below is the contents of the web.xml file and as you can see that it is pointing to the index.jsp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*4rwZQwSaDp2M8onJHvF3Ww.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8310b2f6d813" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototype application using Springboot and JPA,]]></title>
            <link>https://medium.com/@thejas.hm/prototype-application-using-springboot-and-jpa-726ed0e8bed1?source=rss-13a745988f94------2</link>
            <guid isPermaLink="false">https://medium.com/p/726ed0e8bed1</guid>
            <dc:creator><![CDATA[Thejas Hm]]></dc:creator>
            <pubDate>Fri, 19 Nov 2021 09:23:18 GMT</pubDate>
            <atom:updated>2021-11-19T09:23:18.341Z</atom:updated>
            <content:encoded><![CDATA[<h3>Developing a microservices based prototype application using Springboot and Spring Data JPA</h3><h4>This article is about building a prototype based on microservices architecture using the Springboot , Thymeleaf and Spring data JPA.</h4><h4>The application makes use of two separate Springboot services , one to accept the input from the user and the other to load the data to an RDBMS table. Spring security is used for the authentication</h4><h4>Information on the service</h4><ol><li>The first service is the controller service to accept the input from the user , named as “FrontEndservice”</li><li>The second service depends on the “FrontEndservice” to get the information to load the data to the table</li><li>The communication between the two services is via the http using the RestTemplate class</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*_gn1kGTAj2lNaj6UI8IZiA.png" /></figure><h4>SERVICE IMPLEMENTATION DETAILS</h4><h4><strong>FRONTENDSERIVCE</strong></h4><ol><li>The FrontEndservice is a Springboot application, please refer the below github link for the contents of the pom.xml</li><li>The service uses the Thymeleaf for the view purpose</li><li>Spring security comes up with an inbuild html page for the user authentication and it generates a random alpha numeric string when the service is started to be used as password and user name as “user”.</li><li>Below is the default page that gets displayed after firing the below URL ( <a href="http://localhost:8081/)">http://localhost:8081/)</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*AXnkxHdrPAK220aSFgvXqw.png" /><figcaption>Random generated password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*GB-V14nPjrXYZOkWpKPGtQ.png" /><figcaption>Default page generated by the spring security</figcaption></figure><p>5. Below is the controller class that has the @Controller annotation to takes the http request and invokes the getpage method in the below case</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*uyy8OoYwevlnm_vRksrQIg.png" /><figcaption>Controller annotation to handle the http request</figcaption></figure><p>6. “Pageone.html” will be shown up after successful authentication</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*JmVc_z8sjLpklVmT6DSwdg.png" /><figcaption>Pageone.html</figcaption></figure><p>7. Clicking on the post button will invoke the backend service and passes on the information, below is the code performing the same</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3AJxZ9StsVpN9tSdAH3XSw.png" /><figcaption>code calling the “Backend Service”</figcaption></figure><h4>BACKENDDATABASELOADING</h4><ol><li>Annotation PostMapping will handle the request from the “FrontEndService” and perform the dataloading action</li><li>For the dataloading, we use the SpringData JPA , refer the below section to understand the working in depth</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*LSwrcELOkQptxh3BRLbeBA.png" /></figure><h4>SPRINGDATA JPA WORKING</h4><ol><li>In this section am going to explain the working of Spring Data JPA specific to the implementation done for this application.</li><li>Create a POJO class called UserDetails and this should contain the fields that we need to load the data</li><li>You can see the annotation Entity indicating to the Spring that the class to be treated as a table</li><li>ID annotation indicating the primary key/unique identifier for the records, strategy=GenerationType.IDENTITY indicates that the values are picked from a sequence in the underlying table to which it is loaded</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*z7_yo10KE6j4SmPZjg6iwQ.png" /><figcaption>userDetails class</figcaption></figure><p>5. We need to define a Repository interface, in the below case you can see the UserDetailsRepository extends the JpaRepository which takes the Pojo class and the datatype of the unique id which is UserDetails and Integer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*I-lpByUiVv3WjMDS2cUixQ.png" /><figcaption>@Repository annotation</figcaption></figure><p>6. JpaRepository has few methods exposed which will do the required work of inserting, updating and deleting the records. In our example we are using the save method to insert to the record, refer the screen shot mentioned above</p><p>7. Autowired annotation is used to inject the dependency and call the save method</p><p>8. Database credentials are picked up from the “application.properties” file and one needs to provide the below three information</p><blockquote>spring.datasource.url</blockquote><blockquote>spring.datasource.username</blockquote><blockquote>spring.datasource.password</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*G2ftqoo2CJo1kKOE7AznZQ.png" /><figcaption>Autowired annotation injecting the dependency</figcaption></figure><h4>Github link</h4><p><strong>Repository</strong>:- <a href="https://github.com/teju2017/Microservices-and-Springboot.git">https://github.com/teju2017/Microservices-and-Springboot.git</a></p><p><em>FrontEndService</em>: <a href="https://github.com/teju2017/Microservices-and-Springboot/tree/FrontEndService">https://github.com/teju2017/Microservices-and-Springboot/tree/FrontEndService</a></p><p><em>Backenddatabaseloading</em>: <a href="https://github.com/teju2017/Microservices-and-Springboot/tree/Backenddatabaseloading">https://github.com/teju2017/Microservices-and-Springboot/tree/Backenddatabaseloading</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=726ed0e8bed1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>