BXM Standard
1. Common Rules for Using Service, Bean, and DBIO
1.1. Required Items
This section describes the common required items when using Service, Bean, and DBIO.
(1) @BxmCategory
The classes of Service and Bean and each method in the classes must include the @BxmCategory annotation (DBIO is generated from source, so it is not directly written by the developer).
-
@BxmCategory annotation defined in the class
@BxmService("SSMP1001A")
@BxmCategory(logicalName = "Single Processing")
public class SSMP1001A {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private MSmpEmpInfMng01 mSmpEmpInfMng01;
... ...
}
-
@BxmCategory annotation defined in the method
@BxmServiceOperation("ssmp1001a001")
@BxmCategory(logicalName = "Sample Employee Information Management Single Inquiry")
public SSMP1001A001OutDto ssmp1001a001(SSMP1001A001InDto input) throws DefaultApplicationException {
logger.debug("============== SERVICE START ==============");
logger.debug("input = {}", input);
... ...
}
(2) Application Exception
Service operations and Bean methods must throw bxm.dft.app.DefaultApplicationException.
@BxmServiceOperation("ssmp1001a001")
@BxmCategory(logicalName = "Sample Employee Information Management Single Inquiry")
public SSMP1001A001OutDto ssmp1001a001(SSMP1001A001InDto input) throws DefaultApplicationException /* Exception */ {
logger.debug("============== SERVICE START ==============");
logger.debug("input = {}", input);
... ...
}
1.2. Prohibited Items
This section describes the items that must not be used when using Service, Bean, and DBIO.
(1) Prohibition of Direct Object Creation
Service, Bean, and DBIO are objects managed by the framework, so developers must not create objects directly using new.
/* Must not create via direct new operator */
private MSmpEduCustomerMng mSmpEduCustomerMng = new MSmpEduCustomerMng();
Objects must be created using the getBean method in a service operation or Bean method.
/* Creation of Bean using getBean method */
if(mSmpEduCustomerMng == null){
mSmpEduCustomerMng = DefaultApplicationContext.getBean(MSmpEduCustomerMng.class);
}
(2) Prohibition of Including Data Objects as Member Variables
Service, Bean, and DBIO are singleton objects, and only one instance of each class is created within the framework. Therefore, if general objects (including primitive types) that store data as member variables and IO objects are held, the object data will be shared, so they must not be included as member variables (bug may occur).
(3) Prohibition of Including Its Own Type as a Member Variable
In the case of a Bean, a structure where it has itself as a member variable is not allowed.
@BxmBean
@BxmCategory(logicalName = "Sample Employee Information Management")
public class MSmpEmpInfMng {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/* The MSmpEmpInfMng Bean must not have itself (MSmpEmpInfMng) as a member variable */
private MSmpEmpInfMng mSmpEmpInfMng;
... ...
}
(4) Prohibition of Writing get/set Methods for Member Variables
@BxmService("SSMP1001A")
@BxmCategory(logicalName = "Single Processing")
public class SSMP1001A {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private MSmpEmpInfMng mSmpEmpInfMng; /* Sample Employee Information Management */
/* There must be no get method for the member variable */
public MSmpEmpInfMng getmSmpEmpInfMng() {
return mSmpEmpInfMng;
}
/* There must be no set method for the member variable */
public void setmSmpEmpInfMng(MSmpEmpInfMng mSmpEmpInfMng) {
this.mSmpEmpInfMng = mSmpEmpInfMng;
}
... ...
}
2. Service
2.1. Required Items
This section describes the items that must be written when creating a Service.
(1) A Service must include the @BxmService annotation in the class definition.
(2) @BxmService must include the Service name. The Service name and class name follow the naming standard.
2.2. Prohibited Items
This section describes the prohibited items when creating a Service.
(1) A Service cannot directly call the operations of another Service.
(2) A Service can have only Bean objects as member variables.
(3) Business logic must not be written in the Service. Business logic must be written in the Bean.
3. Bean
3.1. Required Items
This section describes the items that must be written when creating a Bean.
(1) @BxmBean
A Bean must include the @BxmBean annotation in the class definition.
/* Required annotation when creating a Bean */
@BxmBean
@BxmCategory(logicalName = "Sample Employee Information Management")
public class MSmpEmpInfMng {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
... ...
}
In the case of batch Beans (implemented with ItemReader, ItemProcessor, ItemWriter, Tasklet Interface), the Bean name must be specified.
/* Required annotation when creating a Bean */
@BxmBean("MSmpTaskletBtch")
@Scope("step")
@BxmCategory(logicalName = "Tasklet Sample")
public class MSmpTaskletBtch implements Tasklet{
private final Logger logger = LoggerFactory.getLogger(this.getClass());
... ...
}
3.2. Prohibited Items
This section describes the prohibited items when creating a Bean.
(1) Prohibition of Directly Calling Service Operations
A Bean cannot call the operations of a Service.
@BxmBean
@BxmCategory(logicalName = "Sample Employee Information Management")
public class MSmpEmpInfMng {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/* BxmService */
private SSMP1001A ssmp1001a;
@BxmCategory(logicalName = "Single Inquiry")
public DSmpEmpTst000Dto getEmpInf(DSmpEmpTst000Dto input) throws DefaultApplicationException {
if(ssmp1001a == null){
ssmp1001a = DefaultApplicationException.getBean(SSMP1001A.class);
}
/* A Bean must not call a Service operation */
ssmp1001a.getmSmpEmpInfMng();
return new DSmpEmpTst000Dto();
}
}
4. DBIO
4.1. Prohibited Items
The following describes precautions when using DBIO.
(1) Prohibition of Implementing DBIO Interface
Since the framework injects the implementation class through DI (Dependency Injection), developers must not directly write the implementation class that implements the DBIO interface.
(2) Prohibition of Directly Editing Interface Files
DBIO generates a pair of .dbio file and .java file (defined as an interface), and the developer must not directly write/edit the .java file.
(3) It is recommended that the number of SQL statements created in a DBIO be less than 10.
If there are too many SQL statements, the DBIO editor operation and commit operation may become slow.
6. @BxmCategory
The @BxmCategory annotation is required to generate flow diagrams. The following describes precautions on the use of the @BxmCategory annotation included in Service, service operations, Bean, Bean methods, DBIO, and DBIO methods.
6.1. Required Items
(1) @BxmCategory must include logicalName information.
(2) The logical name logicalName is the name exposed in the Package Explorer, so use an easily recognizable name.
6.2. Prohibited Items
(1) logicalName must be written as a string and must not use special characters (escape) such as \n, \t. Also, do not express strings with '+'.
@BxmBean
@BxmCategory(logicalName = "Sample Employee\nInformation\nManagement")
public class MSmpEmpInfMng {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
... ...
}
7. Annotation Summary
Annotations are a Java meta language that, by simply marking them in the source, allow certain functions to be performed at runtime or certain information to be extracted from classes.
| Category | Description | Location |
|---|---|---|
@BxmService |
Functions as a Service class |
Service class declaration |
@BxmServiceOperation |
Functions as a service operation |
Service class |
@BxmBean |
Functions as a Bean class |
Bean class declaration |
@BxmCategory |
Input logical name |
Service class declaration Service class public method declaration Bean class declaration Bean class public method declaration DBIO interface declaration (auto-generated) DBIO interface method declaration (auto-generated) |
@TransactionalOperation |
Used when processing transactions (Used when separating transactions) |
Method declaration that will process the transaction |