Manual integration of koala Business Log System

Source: Internet
Author: User
4. Manual integration 1. Add dependency

Add Service Log interface module dependency at Application Layer

<Dependency>

<Groupid> org. openkoala. businesslog </groupid>

<Artifactid> koala-businesslog-API </artifactid>

<Version> 4.0.0 </version>

</Dependency>

Add Business Log implementation module dependency on the web layer

<Dependency>

<Groupid> org. openkoala. businesslog </groupid>

<Artifactid> koala-businesslog-impl </artifactid>

<Version> 4.0.0 </version>

</Dependency>

2. Create a logfilter class

For example, Com. xiaokaceng. Demo. Web. Controller. businesslog. logfilter. Java

Package COM. xiaokaceng. demo. web. controller. businesslog; import Org. openkoala. businesslog. utils. businesslogservletfilter; import javax. servlet. *; public class logfilter extends businesslogservletfilter {/*** put the required information into the log context * @ Param req * @ Param resp * @ Param chain */@ override public void beforefilter (servletrequest req, servletresponse resp, filterchain chain) {addipcontext (getip (req); // todo needs to obtain the username addusercontext ("XXX") by yourself;} public void Init (filterconfig) throws servletexception {// to change body of implemented methods use file | Settings | file templates .} public void destroy () {// to change body of implemented methods use file | Settings | file templates .}}

Note: The current user needs to obtain the information based on the system implementation.

3. Create the defaultbusinesslogcontroller class
package com.xiaokaceng.demo.web.controller.businesslog; import java.util.HashMap;import java.util.Map;import org.dayatang.domain.InstanceFactory;import org.dayatang.utils.Page;import org.openkoala.businesslog.application.BusinessLogApplication;import org.openkoala.businesslog.model.DefaultBusinessLogDTO;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody; @Controller@RequestMapping("/log")public class DefaultBusinessLogController {private BusinessLogApplication businessLogApplication; @ResponseBody@RequestMapping("/list")public Page pageJson(DefaultBusinessLogDTO defaultBusinessLogDTO,@RequestParam int page, @RequestParam int pagesize) {Page<DefaultBusinessLogDTO> all = getBusinessLogApplication().pageQueryDefaultBusinessLog(defaultBusinessLogDTO, page,pagesize);return all;} @ResponseBody@RequestMapping("/delete")public Map<String, Object> delete(@RequestParam String ids) {Map<String, Object> result = new HashMap<String, Object>();String[] value = ids.split(",");Long[] idArrs = new Long[value.length];for (int i = 0; i < value.length; i++) {idArrs[i] = Long.parseLong(value[i]);}getBusinessLogApplication().removeDefaultBusinessLogs(idArrs);result.put("result", "success");return result;} @ResponseBody@RequestMapping("/get/{id}")public Map<String, Object> get(@PathVariable Long id) {Map<String, Object> result = new HashMap<String, Object>();result.put("data", getBusinessLogApplication().getDefaultBusinessLog(id));return result;} public BusinessLogApplication getBusinessLogApplication() {if (null == businessLogApplication) {businessLogApplication = InstanceFactory.getInstance(BusinessLogApplication.class);}return businessLogApplication;}}

4. Configure web. xml
<filter>   <filter-name>LogFilter</filter-name>   <filter-class>com.xiaokaceng.demo.web.controller.businesslog.LogFilter</filter-class></filter><filter-mapping>   <filter-name>LogFilter</filter-name>   <url-pattern>/*</url-pattern></filter-mapping>


5. Create a koala-businesslog.properties under the class path

Pointcut = Execution (* org. openkoala. example. application. impl .*.*(..))

# Log Switch

Kaola. businesslog. Enable = true

# Log export tool

Businesslogexporter = org. openkoala. businesslog. utils. businesslogexporterimpl

# Database settings

Log. DB. JDBC. Driver =$ {dB. jdbcdriver}

Log. DB. JDBC. Connection. url =$ {dB. connectionurl}

Log. DB. JDBC. Username =$ {dB. Username}

Log. DB. JDBC. Password =$ {dB. Password}

Log. DB. JDBC. dialect =$ {hibernate. dialect}

Log. hibernate. hbm2ddl. Auto =$ {hibernate. hbm2ddl. Auto}

Log. hibernate. show_ SQL =$ {hibernate. show_ SQL}

Log. DB. Type =$ {dB. Type}

DB. generateddl =$ {generateddl}

Log. maximumconnectioncount = 3000

Log. minimumconnectioncount = 100

# Thread pool Configuration

# Number of core threads

Log. threadpool. corepoolsize = 100

# Maximum number of threads

Log. threadpool. maxpoolsize = 3000

# Maximum Queue Length

Log. threadpool. queuecapacity = 2000

# The idle time allowed by the thread pool maintenance thread

Log. threadpool. keepaliveseconds = 300

# Processing policy of the thread pool for rejecting tasks (available for wireless threads)

Log. threadpool. rejectedexecutionhandler = java. util. Concurrent. threadpoolexecutor $ callerrunspolicy

6. Add scan package path

Persistence-context.xml packagestoscan node Add:

<Value> org. openkoala. businesslog. Model </value>

7. Introduce spring Configuration

Db-context.xml add Configuration:

<Import resource = "classpath *: koala-businesslog-shared-persistence.xml"> </import>

Add configuration in root. xml:

<Import resource = "classpath *: koala-businesslog-aop.xml"> </import>

8. For the remaining integration, see the tutorial.

Note:

  • In the future, the plug-in will provide a one-click integration function without manual integration.
  • Third-party Project Integration is complex and has many technical constraints.

Manual integration of koala Business Log System

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.