Ensuring Technical Readiness For Copilot in Microsoft 365
Jlook open api platform-sysdevguide
1. OPEN API PLATFORM
SYSTEM DEVELOPMENT
GUIDE
METADATA DRIVEN
SERVICE PLATFORM HongSeong Jeon
jlooktech@gmail.com
jlook consulting
2. APPLICATION LOGICAL
ARCHITECTURE
Meta Driven Open API Service Platform
Interfaces Services Repositories
Security Controller Security Service Security Repository
Open API Service Interfaces
Metadata Management
Generic Controller Generic Service Generic Repository
Domain Controller Domain Service Domain Repository
Metadata Controller Metadata Service Metadata Repository
Infrastructures
Security Component Transaction OR Mapping
Management Management Management Management
Attachment Dynamic View Task & Batch JDBC Pool
Management Resolver Scheduler Management
3. APPLICATION TECHNICAL
SPECIFICATION
q Spring framework
q Spring IoC Container
q Spring Web MVC
q Spring Security
q JBoss – Hibernate, Javassist
q Google h2 Database
q Google gson
q MVEL 2.0
q Apache Velocity Template engine
q Java & Spring framework Annotation
q Qdox
4. PROJECT STRUCTURE
Project Directory Description
jlook Project name
src/main/java Java sources directory for platform
src/test/java Java sources directory for JUnit test
src/main/resource Resources directory for platform
domain Hibernate mapping configuration directory for domain
hibernate Hibernate configuration file
jdbc Hibernate jdbc properties file
properties Environment properties file
spring Spring configuration directory
template Hibernate configuration template file
velocity Velocity properties file
bin Ant build file
5. JAVA PACKAGE
STRUCTURE
Package Structure
jlook.framework
domain Domain object package
account User, group, domain objects
annotation jclass, jattr annotation class
batch Batch domain objects
common Common service domain objects – menu, announcement
docs Value object for API documentation
metadata Metadata domain objects – JClass, JAttribute, JType
management Management domain objects - JAccessLog
model UI value object for client application
security Security domain objects – JRole, JDataAccessRule, JMenuAccessRule
util Utility domain object – JArray, JAttachment
widget UI widget domain objects – JWidgetDefinition, JWidgetInstance
infrastructure Infrastructure components package for application
annotation Annotation – GsonExclude, Message
batch Batch task class
context Thread context for user information
gson Google gson utility
6. JAVA PACKAGE
STRUCTURE
Package Structure
jlook.framework
infrastructure hibernate Hibernate utility class
http http client component
jdbc Jdbc base class for repository component
junit Junit utility class
loader Metadata loading classes
security Security classes - JUserEntity
tools Generator classes – Hibernate config, API Documentation
task Multi threaded tasking classes
util Utility classes
web Web servlet and filter classes
interfaces Interfaces package
account Account interfaces – domain, user, group
common Common service interfaces – menu, announcement
metadata Metadata interfaces – JClass, JAttribute, JType
security Security interfaces – role, access rules
utility Utility interfaces – array, attachment
7. JAVA PACKAGE
STRUCTURE
Package Structure
jlook.framework
repository Repository interface package
impl Repository implementation class package
service Service interface package
action JClass Action classes
impl Service implementation class package
util Service utility classes
8. SYSTEM DOMAIN OBJECT
§ Table에 Entity value object를 정의한 것으로 모든 Domain object는 JObject로 부터 상속을 받
아 정의된다.
§ Member variables for JObject domain class
§ objectId : 한 Table내에서 entity를 식별하는 Id
§ classId : Table를 식별하는 Id
§ domainId : Domain을 식별하는 Id
§ createdBy : Enttiy를 등록한 JUser objectId
§ createdOn : Entity를 등록한 일시
§ updatedBy : Entity를 변경한 JUser objectId
§ updatedOn : Entity를 변경한 일시
§ Domain annotation : system domain object들의 metadata 를 등록하기 위해 domain object
의 metadata를 annotation으로 정의한다.
§ jclass : system domain object에 대한 JClass metadata 정보를 정의하는 annotation
§ jattr : system domain object의 Member Variable에 대한 JAttribute metadata 정보를 정의하
는 annotation
9. SYSTEM DOMAIN OBJECT
@jclass(cid=JMetaKeys.JOBJECT, did=JDomainDef.SYSTEM_ID, name=JObject.NAME,
type=JClassType.INTERFACE_TYPE, status=JMetaStatus.NONE_TYPE)
public class JObject implements Serializable, Comparable<JObject> {
public static final String NAME = "JObject”;
public static final String A_OID = "objectId";
public static final String A_CID = "classId";
public static final String A_DID = "domainId";
public static final String A_CREATED_BY = "createdBy";
public static final String A_CREATED_ON = "createdOn";
public static final String A_UPDATED_BY = "updatedBy";
public static final String A_UPDATED_ON = "updatedOn";
@jattr(name=A_OID, label="Object Id", type=JPrimitive.LONG_TYPE, length=15, description="Object Id",
required=true, unique=true, searchable=true, derived=true) protected Long objectId;
@jattr(name=A_CID, label="Class Id", type=JPrimitive.LONG_TYPE, length=15, description="Class Id",
required=true, unique=false, searchable=true, derived=true) protected Long classId;
@jattr(name=A_DID, label="Domain Id", type=JPrimitive.LONG_TYPE, length=15, description="Domain Id",
required=true, primary=true, unique=false, searchable=true, derived=true) protected Long domainId;
@jattr(name=A_CREATED_BY, label="CreatedBy", type=JPrimitive.LONG_TYPE, length=15, description="CreatedBy",
required=true, unique=false, searchable=true, derived=true) protected Long createdBy;
@jattr(name=A_CREATED_ON, label="CreatedOn", type=JPrimitive.TIMESTAMP_TYPE, description="CreatedOn",
required=true, unique=false, searchable=true, derived=true) protected Timestamp createdOn;
@jattr(name=A_UPDATED_BY, label="UpdatedBy", type=JPrimitive.LONG_TYPE, length=15, description="UpdatedBy",
required=false, unique=false, searchable=true, derived=true) protected Long updatedBy;
@jattr(name=A_UPDATED_ON, label="UpdatedOn", type=JPrimitive.TIMESTAMP_TYPE, description="UpdatedOn",
required=false, unique=false, searchable=true, derived=true) protected Timestamp updatedOn;
13. SERVICE LAYER
§ Service Component는 Repository를 이용해서 Business Logic을 구현하고, Transaction 처
리를 한다.
package jlook.framework.service.impl;
@Transactional(readOnly = true, rollbackForClassName={GlobalKeys.SERVICE_EXCEPTION,
"org.hibernate.exception.ConstraintViolationException", "org.springframework.dao.DataIntegrityViolationException"})
@Service(JGenericService.ID)
public class JGenericServiceImpl implements JGenericService {
@Override
@PreAuthorize("hasPermission(#jObject, 'create')")
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public JResultModel create(JObject jObject) throws JServiceException {
JUserEntity entity = security.getUserEntity();
if(jObject.getClassId()==null) {
throw new JServiceException("classId is not setted. - "+jObject);
}
14. SECURITY SERVICE
§ 로그인한 사용자 정보를 얻고, domainId 및 client type 정보를 얻는 API를 제공한다.
package jlook.framework.service.impl;
@Transactional(readOnly = true, rollbackForClassName={GlobalKeys.SERVICE_EXCEPTION})
@Service(JSecurityService.ID)
public class JSecurityServiceImpl implements JSecurityService, UserDetailsService {
package jlook.framework.service.impl;
@Transactional(readOnly = true, rollbackForClassName={GlobalKeys.SERVICE_EXCEPTION,
"org.hibernate.exception.ConstraintViolationException", "org.springframework.dao.DataIntegrityViolationException"})
@Service(JGenericService.ID)
public class JGenericServiceImpl implements JGenericService {
@Resource(name=JSecurityService.ID)
private JSecurityService security;
@Override
@PreAuthorize("hasPermission(#classId, {'read'})")
public JSummaryModel getSummaryData(JViewType jViewType, Long classId, PageUtil page,
Map<String, String[]> paramMap) throws JServiceException {
JUserEntity entity = security.getUserEntity();
15. INTERFACE LAYER
§ Client의 Request를 받아 Business Service를 실행하고 spring ModelAndView 객체를 생성하
여 반환하는 Logic을 정의한다.
@RequestMapping(value = "/generic/references", method = RequestMethod.GET)
public ModelAndView getReferences(
@RequestHeader(value=JHeader.JCONTENT_TYPE, required=false) String contentType,
@RequestParam(value=ParamKeys.CLASS_ID, required=true) Long classId)
throws JControllerException {
Map<Long, String> map;
try {
map = this.jClassService.getReferences(classId);
} catch (JServiceException e) {
throw new JControllerException("Fail to get references for JClass. - "+classId,e);
}
JContentType jContentType = JContentType.getJContentType(contentType);
ModelAndView mview = jContentType.create("generic/references");
mview.addObject(JResultModel.DATA_KEY, map);
return mview;
}
16. METADATA LOADER
§ Platform이 실행되기 위해 System Metadata를 초기에 Loading해야 하는 Component
§ Package : jlook.framework.infrastructure.loader
§ EnumLoader : System Metadata에서 사용하는 Enumeration Validation을 Loading함.
§ MetataLoader : Domain Object에 정의한 Annotation을 Metadata Table에 Loading함.
§ InitDataLoader : metadata package에 System Application을 구성하기 위한 Metadata를 정
의한 Enum으로 부터 Metadata를 Loading함.
§ ViewLoader : Loading된 JClass Metadata로 부터 각 JClass의 System default JView를 생
성함.
§ Metadata Reloading API – MainController : /metadata/load
@RequestMapping(value = "/metadata/load", method = RequestMethod.GET)
public String loadMetadata(HttpServletRequest request, HttpServletResponse response) throws JControllerException {
JSessionFactoryBean bean = (JSessionFactoryBean)ApplicationContextHolder.getBean("&mySessionFactory");
bean.dropDatabaseSchema();
bean.createDatabaseSchema();
ry {
this.enumLoader.setDataLoadEnabled(true);
this.enumLoader.doInit();
this.metadataLoader.setDataLoadEnabled(true);
this.metadataLoader.doInit();
this.dataLoader.setDataLoadEnabled(true);
this.dataLoader.doInit();
21. SERVLET FILTER
§ jlook.framework.infrastructure.web.filter package에 두 가지 종류의 System Servlet Filter를
제공함.
§ JGlobelFilter : 모든 Request에 대한 Servlet Filter로 로그인한 사용자 정보를 Thread
Context Variable에 Setting 하고, Access Log를 남긴다.
§ JServiceFilter : /service/*에 대한 요청에 대한 Servlet Filter
22. SPRING SECURITY
§ Spring security framework은 web.xml에 아래와 같이 정의된 Filter에 의해 모든 Request에 대
한 Web Resource의 권한 체크가 처리된다.
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
§ Spring security configuration file은 resource/spring/context-security.xml 이다.
§ Service Layer business method에서 아래와 같이 Authorization을 Annotation으로 정의할 수
있다.
@Override
@PreAuthorize("hasPermission(#classId, {'read'})")
public JSummaryModel getSummaryData(
JViewType jViewType, Long classId, PageUtil page, Map<String, String[]> paramMap)
throws JServiceException {
30. JCLASSLOADER
§ Application Home directory 밑에 classes 디렉토리에 있는 domain class들을 loading하는
ClassLoader로 Web Application ClassLoader를 parent ClassLoader로 갖는다.
CLASSPATH 경로의 Class System
들을 Loading하는 JVM ClassLoader
ClassLoader
Web Application Class들을 WebApplication
Loading하는 WAS ClassLoader
ClassLoader
Custom Domain Class들을
Loading하는 Application JClassLoader
ClassLoader
31. ENTITY META
MANAGEMENT
AbstractSession
FactoryBean
JConfigLoader Config.xml
Hibernate Session JSpringSession
Repository Factory FactoryBean
JClassLoader Domain
class
Configuration
Hibernate JavaClass
JGenericRepository
JGenericRepository Generator Generator
1. Create domain class
2. Create hibernate config JMetaService
3. Add config to hibernate Configuration
4. Build new SessionFactory by hibernate Configuration
5. Create JView
33. ENTITY MAP ACTION
q Mapping entity
q Make java class from metadata
q Make hibernate config from metadata
q Change entity
q Add and remove attribute
q Change attribute : name, type, primary, unique, virtual
q Cannot change : name and category for JClass (CREATED)
q Unmapping entity
q Change status from CREATED to UNMAPPED
q Remapping entity
q Change status from UNMAP to REMAPPED
q Build metadata
q Make java class from metadata for all entities.
q Make hibernate config from metadata for all entities.
q Create and initialize JClassLoader
q Create and initialize JSpringSessionFactoryBean
34. METADATA CHANGE
HISTORY
q Change history for JClass and Jattribute
q JClass
q Name, Category
q InheritanceClass, InheritanceType
q JAttribute
q JClass, Name, Type
q Primary, Unique, Virtual