跳至主要内容

博文

目前显示的是 四月, 2017的博文

Spring Config Checklist

Recently, when using spring aop in our project, we fail to intercept the targeted method, so we come up with a checklist for use, as following shows. CheckList Web.xml: Spring Starting Point Config File Location Component Scan and Annotations Enable AOP Aspect Register Public in Method Signature AOP with Arguments: Method Signature: long and Long Order Debug Misunderstanding Handler Interceptor vs Spring AOP Public in Execution Expression CGLIB vs Proxy Ref CheckList Web.xml : Spring Starting Point The first thing we need to check is the web.xml , this is where spring is initialized and loaded into your web application. By configure listener of application, spring custom log4j initialization ( Log4jConfigListener ) and init itself ( ContextLoaderListener ). By setting spring dispatch servlet, spring load the config file of spring mvc, beans, aop etc, then mapping all web application to dispatcher, which enable spring mvc works. < liste...

Office Format Conversion (2): Implementation

In the last blog of office format conversion , we discussed the design of format conversion function. Finally, we decided to convert office into html and implement two versions which respectively embed image and extract image out. In this blog, we discuss the detail of implementations and show the runnable code examples. Library Chosen Through some search, we find that the Apache POI has relative large number of questions on stackoverflow, which proves the user community is relative large and active. So we decided to use Apache POI to assistant conversion. Despite of it, we find xdocreport , which uses POI to add more utility class, support more convenient and powerful interfaces to do this job, so we include this lib also. Pitfalls One thing have to notice is that the poi version of 3.14 not compiled and we have to use the newer version of 3.15. maven dependency doc vs docx As we have previously stated, the doc and docx are in two different format, so the poi...

Interprocess Communication in Distributed System

We are familiar with the inter-process communications of OS: Named Pipe Anonymous Pipe Message Queue Soket File Signal …etc This lists can be longer, but all of this can be organized by two categories: File Type: simple file named pipe network Memory Type: share memory message queue signal But in a distributed system, memory and disk can’t be shared (at least can’t be shared without software assistant), the network become the single and more important way to achieve it. Today, we focus detail on how inter-process communication works in distributed system. Definition The definition of inter-process communication is message passing between a pair of process, either in the same host or not. In a distributed system, we can’t make sure the communication happen in same host, so we can hide the differences by using network. The following is some design considerations of inter-process communications : destinations: how to resolve another process? reliabilit...

Office Format Conversion (1): Design

Intuitives Our application support the upload and download office file to server. In order to support the preview of office format, which is a relative popular format, we decided to make some trials. The first things to do is of course searching. Via searching, we found a question show that we can preview office file through the website of Office365 viewer or Google Docs, in which case those website will interpret the url we feed and convert the document on the fly to show it. Considering the privacy and security problem, we decided not to do it. We know the there is no native support for render office in the front end, i.e. through browser, so we have to convert the format of office to others, like pdf and html. Challenges In order to perform conversion, we need to handle much challenges, the first thing to notice is that office format has two major versions. Version The early office format (‘doc’) is binary, which means if you open it by some other editor, the cont...