Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Java Topics Explanation

Factory Design Pattern:


step1: I created FileGen interface and it contains genFile abstarct method,
i was passed List of employee paramter.
step2: now i created textfile class and pdf,excel, word classes
step3: all file classes are implemted to FileGen interface
step4: and I overrid genFile method in all child classes,
like, textfile class, pdf file class, etc.,
step5: created Factory Design pattern class
step6: creted constructor for Factory design pattern class
and i split the fileTypes String(txt,pdf,xlsx,docx)
step7: created fileGenUtil class and
i Implemeted Swich case to create Object for all child
classes of FinGen interfce
step8: then in Factory design pattern class, i added file Objects
to one list
step9:then i executed all files

Deployement Process in Tomcat Server:


step1: tomcatserver-> configuraiton folder-> tomcat-users.xml file
we need change user roles and credentials
step2: we need to start a server,
in unde bin folder startup windows batch file
step3: we need login in browser with localhost and port number 8080
step4: then it display tomcat server home page
step5: we need click on manager Apps - and need to provide credentials
step6: then Tomcat Web Application Manager page will dipaly
step7: go to the WAR file to deploy column,
we need to upload our war file form application target folder
step8: then it will deploy.

Multiple Schema Configuration:


step1: I have taken two configuraiton files one is for Primary Db,
and another is Secondary DB configuraiton
step2: in both configuraiton classes, i changed, basepackages for
primay db base package and seconday DB configuraiton file
changed basepackage
step3: i wrote configuraitonproperties prefix values, for both configurations
step4: after that,in application.properties file
i changed prefix values in DB config details

Global Exception in SpringBoot?


step1: for example i'm taking exception, mailAlreadyExistsException
step2: need to create mailAlreadyExistsException class and
that should extends with Exception class
step3: need to create constructor to pass an exception message
step4: then use throw new mailAlreadyExistsException(message);
step5: and I cretad ErrorDetails class,and taken fields like
timestamp, error, message, statuscode
step6: then take GlobalExceptionHandler class,
that should annotate with @RestControllerAdvice annotation
step7: create exception handler method,
and that method annotate with @ExceptionHandler

How did you implemented filters?


step1: in my application we have to filter the data,
startsWith,EndsWith,contains,Equals,NotEquals conditions
step2: for that first I created FilterEnum and provided
AllFilters like startsWith,EndsWith,contains,Equals,NotEquals
step3: and taken swithcase in serviceImpl
and retrieve the data based on filter and return the data.

How did you Implemeted Excel?


step1: I added Apache-Poi dependency(means team lead added)
step2: created XSSFWorkbook,XSSFSheet Object
step3: by using XSSFWorkbook Object created excelsheet and cells
step4: using XSSFFont object, i was set font styles
step5: I retrive the data and write in Excel file

How did you Implemeted PDF?


step1: added Apche PDF dependency(team lead added)
step2: I have take Document Object
step3: I used PdfWriter.getInstance(); method to write retrival data
step4: used Paragraph Object to print the retrival content
How did you Implemented Word?
step1: I added Apache-Poi dependency(means team lead added)
step2: created XWPFDocument Object
step3: used XWPFTable object to create the cells
step4: to print the data in rows, used XWPFTableRow Object
step5: used XWPFRun Object to set the content in cells
step6: and print the retrieval data

How Did you Implemented Builder Design patter?


Step1: we used builder design pattern to build the API Response
Step2: the API response includes, http headers, message,
status code, data etc., fields
step3: for that I created one API response class, with fields of
http headers, message, status code, data
step4: in API response class, we have taken one more
API response Builder inner class, to build the response and
Initialize the data
Step5: and I have create one component class, i.e.,
Response Builder class to build the required response

Bean Life Cycle:


Spring Bean life Cycle steps are
Instantiation ➨ Populating Properties ➨ Pre-Initialization
➨AfterPropertiesSet ➨ Custom Initialization ➨Post-
Initialization➨ Pre-Destroy ➨Destroy ➨Custom Destruction
 In spring bean life cycle, first bean is instantiated
 After instantiating objects, Spring scans the beans
 Spring’s BeanPostProcessors, postProcessBeforeInitialization()
methods do their job.
 Spring executes the afterPropertiesSet() methods of the beans
 Spring triggers the initialization methods that we defined in of
our @Bean annotations.
 Spring’s BeanPostProcessors are in action for the second time. This
phase triggers the postProcessAfterInitialization() methods.
 Spring triggers @PreDestroy annotated methods in this phase.
 Spring executes the destroy() methods of DisposableBean
implementations
 We can define custom destruction hooks with
the destroyMethod attribute in the @Bean annotation and Spring runs
them in the last phase.

Profiles in SpringBoot:
 We have different environments in Project
Like Dev, UAT, QA, PROD etc.,
 By default we have environment profile application.properties
 Same as well we have different application.properties files
To different environments
 The all different environments may have different databases,
Different url’s or credentials etc.,
 If I want to trigger or I want to check any issue or bugs like UAT
environment
 In default profile application.properties,
I need to app property spring.profiles.active=UAT
(environment name)
 So that I can trigger to particular environment and I can check
the issue
How the Task Allocation will happen to you?
 The Task will allocate in JIRA
 Each user story or bug will contain TikcetID and title
 when team lead assign ticket, that I’ll receive mail to my
outlook
 when I’m staring work,
I’ll change status to inProgress
If I finished I’ll change status to done,
After that I’ll re-assign to my lead
 If I have any queries related to task, I’ll write in comment
section
SDLC(Software Devolopement Life Cycle):
We followed SDLC of AGILE Methodology
SDLC have different stages are,

 Planning Stage
 Requirements Analysis Stage
 Design Stage
 Development or Building Stage
 Testing Stage and
 Deployment
Maven lifecycle Phases:
Validate - validate the project is correct or not

Compile - compile the source code of the project

Test compile - compile test cases source code using a suitable unit
testing framework.

Package - take the compiled code and package as a JAR or War.

Verify - it will run and check the Integration testing code, either
Quality standards are met or not.

Install - it will generate the war or Jar file in target folder

Deploy - it will deploy the war file in location

Builder Design Pattern:


 I used Builder Design Pattern to Build the Response
 The Response we are expecting along with data, it need
headers, status code, messages data etc.,
 For that I have taken APIResponse class
 In APIResponse class I build a Response
 In APIResponse class, I have taken required fields for response
Like httpHeaders, httpStatusCode, message, Data etc.,
 And I have taken Static Inner class that is ApiResponseBuilder
 here we initialized the all response properties and build the
response
 after that we have taken One component class, i.e
ResponseBuilder
 component here we call the Response API Builder class, and
build the response with required fields.
Then we called in service class ResponseBuilder class build
response method.

LOMBOK:
 Lombok will use to reduce the Boilerplate code(repeatable
code)
 Boiler plate code in the scene like, setters, getters,
noArgConstructor, AllargConstructor, equals, hashcode etc.,
@Setter : to generate setter methods
@Getter: to generate getter methods
@AllargConstroctor: to generate zero argument constructor
@NoArgConstrcutor: to generate All arguments constructor
@ToString: to generate toString methods
@Equals: to generate equals method
@hashcode: to generate hashcode method
@Data: having
implicit @Getter, @Setter, @ToString, @EqualsAndHashCode , @RequiredArgs
Constructor

You might also like