A quick tutorial for middleware products

  • WeblogicArch

  • J2EEArch

  • FussionArch

Monday, April 8, 2019

On April 08, 2019 by Kamlesh   No comments
For traditional spring mvc architecture refer here, We were annotating spring mvc Controller Class with @Controller as shown below


@Controller
public class ViewsController {

@RequestMapping("/view1")
public String showView1(){
 return "register";
}

In the above code as we know,when the request is made to ApplicationContext/view1 the resource register file will be returned.

In addition to that,Spring boot supports rest controller as shown below


@RestController
@Produces("application/json")
public class BaseController {

@RequestMapping("/list")
private List getList(){
 return Arrays.asList("one","two","three");
}
}

As mentioned above the Annotation @RestController identifies that it needs to produce the content that is mentioned, Here the method getList() returns json as mentioned with annotaion @Produces("application/json").
On April 08, 2019 by Kamlesh   No comments
Since most of the spring boot configurations are done by annotations,it is better if we go through what annotations are first.

Annotation : provides information about the program that is annotated with and it is not part of the program itself.

These annotations can be run time or compile time annotations

Compile Time Annotations
Compile time annotations are checked by the compiler at compile time.

public interface Test {

 public void add(int a,int b);
}

class Tester implements Test{
 @Override
 public void add(int a, int b) { 
 }

}
In the above code Annotation @Override is compile time,if you try to add or remove any parameter it will show an error in IDE itself.

Run Time Annotations
As the Compile time annotation,run time annotation checks for run time information about the program that is annotated with.
On April 08, 2019 by Kamlesh   No comments
Setting up Spring Boot

Best way to set up a spring boot application is by Spring Intializer,Where you can add all the dependencies required ,download  and import it in IDE.
OR
Create a new maven or gradle project and all the dependencies manually.
OR
Start a spring starter project from spring tools suite IDE

To start an application,just run Generated MainApplication.java file which starts the embedded server.

import org.springframework.boot.SpringApplication;
@SpringBootApplication
public class MainApplication {
 public static void main(String[] args) {
 
  SpringApplication.run(MainApplication.class, args);
 }
 
}

Just run the MainApplication.java as classic java application, Once the server is up,you can request for resources.
Let's create some resources in coming chapters.
On April 08, 2019 by Kamlesh   No comments
Why spring boot was introduced when we had all the comforts of frameworks spring like mvc,hibernate etc


 One main reason to remove all the configurations that would take plenty of time to just setup the framework.

Setting up the traditional Spring MVC framework includes
Adding Internal View Resolvers
Setting up Hibernate Session Factory
Connection to Database etc

Sample Code of Component scan and internal view resolver in tradition mvc approach is as shown below

<context:component-scan base-package="com.example.spring.dao"></context:component-scan>
<context:component-scan base-package="com.example.spring.controllers"></context:component-scan>
<context:component-scan base-package="com.example.spring.services"></context:component-scan>
<mvc:annotation-driven/>
 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsps/" />
      <property name="suffix" value=".jsp" />
 </bean>

Above Code is replaced in just two lines in spring boot using Annotations.

Annotations are widely used in spring boot,All the configurations are replaced by single line annotations, so that the developer can concentrate on business logic rather than spending more time on configuring.

We will see how single line annotations can replace the traditional xml  in chapter "Annotations".
On April 08, 2019 by Kamlesh   No comments
Before staring with Spring Boot,You need to have basic knowledge of spring core to get better understanding of spring boot.


Lets start ...

What is spring boot?
Spring boot acts as a tool to build microservice.

What is microservice?
Microservice is a software architecture style that structures an application with collection of loosely coupled components.

Definition looks little complex?
Lets break it down!!

1.  Microservice is a software architecture
Architecture can be defined as set of certain rules to develop an application.

2.  It structures an application with collection of loosely coupled components
The Architecture structures an application  which may contain many components,It can be ORM's,Data Providers,JPA etc that are loosely coupled (does not depend on one other).

What exactly is microservice,In general way??
It is very difficult to explain what microservice is in just one shot,I will try my best here,

Just think microservice as a container which comes with no precise definition of architectural style,You can plug in whichever server you like to deploy the application, add your favorite ORM's, etc,it is a production ready system,it is as simple as running classic "java main class".

Here Spring boot basically aims in bootstrapping and deploying the spring packed project in a easy and quick way.

On April 08, 2019 by Kamlesh   No comments
This tutorials contains full end to end discussion on spring boot for beginners.The topics are well constructed, source code is available for each topic which can be downloaded and deployed in any IDE.

This "Spring Boot Tutorials" Contains
Spring Boot Introduction
                     What is Spring Boot?
                     Why Spring Boot?
                     Creating a Spring Boot Project
                     Annotations
                     Spring Boot Controllers
                     Spring Boot Configurations using YAML

 Spring Boot JPA
                    Introduction to Spring Boot JPA
                    CRUD Operations using Spring Boot JPA
                    Implementing own method using Spring Boot JPA

Spring Security
                  Introduction to Spring Security
                  Spring Security Implementation

Use navigation to go through the tutorials, I would suggest to go through all the topics without skipping any. If you have any doubts or any examples are not working,please let us know in the comment section or contact us.

Monday, September 4, 2017

On September 04, 2017 by Kamlesh   No comments

Creating My First Process Extension

while developing PX for Agile PLM, the most important part is project structure.
  1. Create a Java Project in Eclipse
  2. Under source folder add META-INF folder
  3. Create services folder under META-INF
  4. Create com.agile.px.ICustomAction file in services folder
So the project structure should be like :
Project
    =>src
         =>com.first.px
              =>HelloWorld.java
         =>META-INF
              =>services
                   =>com.agile.px.ICustomAction






What does com.agile.px.ICustomAction:

This file contains the full name of the PX class, when we say full name it means name of the class along with package. In our case this file will contain 
com.first.px.HelloWorld
Note: In this file we dont need to specify .class or .java extension

Why this structure:

This structure is important because when we deploy our jar in extensions folder, Agile PLM reads the structure and gets the PX class name from META-INF->services->com.agile.px.ICustomAction file. If we miss this structure PX framework will not be able to read it.

Code:

Every PX needs to implement ICustomAction Interface in order to recognized as PX in Agile PLM. The only method that needs to override/impelent is doAction. This method will provide our process extension following from PX framework.
  1. Session
  2. node
  3. IDataObject which is current business object like Part, Document, change etc
here is a demo code that can be used to create a hello world PX
package com.first.px;
import com.agile.api.APIException;
import com.agile.api.IAgileSession;
import com.agile.api.IDataObject;
import com.agile.api.INode;
import com.agile.px.ActionResult;
import com.agile.px.ICustomAction;
public class HelloWorld implements ICustomAction {
@Override
public ActionResult doAction(IAgileSession session, INode arg1,IDataObject object) {
String objectName="";
try {
objectName= object.getName();
} catch (APIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated method stub
return new ActionResult(ActionResult.STRING, objectName);
}
}

Note: Please add AgileAPI.jar in your project class path in order to compile your PX.