Update the sample code and tool components (Java and C ++) for sorting out my blog articles)

Source: Internet
Author: User

 * ** Java ***

1. Java all-powerful and efficient MVC & rest development frameworkPortal-Basic
2. Java log cutting and cleaning toolLog-cutter

* ** C ++ ***
1. General high-performance Windows Socket ComponentsHP-socket
2. Windows C ++ applicationsProgramGeneral log componentVC-logger

I. Java

1,Java all-powerful and efficient MVC & rest development framework portal-Basic

Portal-Basic is a complete set of high-performance full-stack web application development frameworks, built-in and scalable MVC Web infrastructure and DAO Database Access Components (the hibernate, mybatis, and JDBC Dao components are provided internally ), integrates basic web application components such as Action interception, form/Dao/spring bean assembly, internationalization, file upload/download, and page static, to provide an efficient and flexible pure JSP/servlet API programming model, spring can be perfectly integrated, and Action convention is supported. Traditional style and restful style applications can be developed quickly. The documents and examples are complete and easy to learn.

Portal-Basic Project homepage:Http://www.oschina.net/p/portal-basic

Portal-Basic is designed with full focus on functions, performance, and user experience. Portal-basic features:

Comprehensive functions:Built-in stable and efficient MVC infrastructure and Dao framework, supporting action interception, form bean/Dao bean/spring bean assembly, and clear transactions, provides common Web components such as internationalization, file upload and download, cache, and page static, to meet the needs of most web applications.

Highly scalable:The plug-in mechanism used by portal-Basic can be flexibly expanded, the portal-Basic-ext-rest and portal-Basic-ext-spring in the portal-Basic release package are provided in the form of plug-ins. you can load or uninstall these plug-ins as needed. Application developers can also compile custom plug-ins to expand portal-Basic based on actual needs.

Powerful integration capabilities:Portal-Basic is a full-stack framework and an open framework. It can integrate third-party components in a very simple way. This document describes in detail how to integrate common frameworks and components such as freemarker, velocity, urlrewrite, ehcache-web, spring, hibernate, and mybaits in portal-Basic.

High performance:Performance requirements are hard indicators of portal-basic, from the design of each module to each lineCodeAnd strive to be concise and efficient. In addition, portal-Basic does not encapsulate JSP/Servet APIs too much. Developers still use JSP/Servet APIs to develop applications, so there are not too many detours and the performance is guaranteed.

Excellent user experience:One of the goals of portal-Basic is to provide a good development experience and minimize the work of application developers. The API design is simple, complete, and clear. At the same time, portal-Basic provides a large number of util tools for application development to deal with general problems that are common during application development, further reducing the workload of application developers.

Gentle learning curve:Gentle learning curve: to learn how to use portal-basic, you only need to master certain core Java and JSP/servlet knowledge. This development manual will explain each knowledge point step by step, each knowledge point is described based on a complete example. The knowledge points echo each other before and after each other to ensure that learners learn from each other and learn from each other.

Comprehensive Technical Support:In addition to providing complete development manuals and sample code, we also provide blogs and QQ groups to answer all the problems encountered during the use of portal-Basic.

 

*Portal-basic overall architecture

 

*Portal-basic application dependency

----------------------------------------------------------------

2,Java log cutting and cleanup tool log-cutter

Log-cutter is a simple and practical log cutting and cleaning tool. Log cleanup is very important for routine server maintenance. If too many logs are left, disk space is seriously wasted and service performance is affected. Manual cleanup may take too much time and is difficult to meet actual requirements. For example, how do I cut a log file larger than 2g at every Saturday to keep the latest 100 m log records? No log cutting tool can meet the requirements of this seat on the Internet, so I spent some time writing one by myself. Because it needs to be used on multiple platforms, Java is used for convenience. This tool is named log-cutter and has the following features:

      • Supports all common operating systems such as Linux, Mac, and windows.
      • Supports interactive command line running.
      • Supports non-interactive running in the background (daemon process implementation in Linux/Mac, and system service implementation in Windows)
      • Two log cleanup methods are supported (delete log files or cut log files)
      • Support for gb18030, UTF-8, UTF-16LE, UTF-16BE and other common log file types cut (not cut off half a character)
      • Highly configurable (program execution cycle, log file expiration time to be deleted, log file threshold to be cut, and retained size)

Log-cutter project homepage:Http://ldcsaa.googlecode.com

 II. C ++

1,Universal high-performance Windows Socket component HP-socket

HP-socket is a set of universal high-performance Windows Socket component packages, including the server component (iocp model) and the client component (event select model). It is widely used in Windows TCP communication systems. HP-socket fully encapsulates the communication layer, and upper-layer applications do not need to pay attention to any details of the communication layer. HP-socket provides an API Interface Based on The Event Notification model, it can be easily and efficiently integrated into various applications. In addition, in order to make it easier for everyone to learn HP-socket, we have carefully produced a function test example (test echo) with a test echo-PFM, you can use these two test examples to quickly master the design ideas and usage of components.

Versatility

    • The only responsibility of a communication component is to accept and send byte streams. It cannot participate in upper-layer protocol parsing;
    • Decoupled from upper-layer users and independent from each other, components interact with users through the operation interface and listener interface, and the component implementation operation interface provides the upper-layer operation method; the user registers himself as the listener of the component through the listener interface to receive notifications from the component. Therefore, any user can use components as long as the listener interface is implemented. On the other hand, you can even re-write a component implementation method that is completely different for the user to call, as long as the component complies with the operation interface of the component, this is also the embodiment of the dip design principles.

Availability

Availability is crucial to all common components. If it is too difficult to use, it is easier to rewrite it. Therefore, the Operation interfaces and listener interfaces of components are designed to be as simple as possible (in general, they are "dumbfounded"). There are no more than five main methods for these two interfaces. In addition, the component completely encapsulates all the underlying socket communication, and the upper-layer applications do not see any communication details and do not have to intervene in any communication operations. The socket connection is abstracted as the connection ID, this parameter is used as a connection identifier for upper-layer applications to identify different connections.

High Performance

As a general component at the underlying layer, performance issues must be considered and cannot be a bottleneck of the system. On the other hand, different Socket models are used according to the performance requirements of client components and server components. Components fully consider factors such as performance, actual use cases, availability, and implementation complexity to ensure that the performance requirements are not too complex. Make the following two design decisions:

    • Client: Implement socket communication interaction in a separate thread. This avoids interference with the main thread or other threads. Select the event select Communication Model for the I/O model.
    • Server: The iocp communication model with the highest efficiency on the Windows platform is adopted. The cache pool technology usually requires frequent application and release of the memory buffer during communication and a dynamic cache pool is established, A new object is created only when there are no available objects in the cache pool, and when there are too many cached objects, the cache pool is compressed. In addition, the dynamic memory of the component is allocated through the private heap mechanism, avoid competition with new/malloc and reduce memory holes.

Scalability

You can set the performance parameters of the component according to the actual usage environment requirements (for example: the number of working threads, the size of various cache pools, the size of the sending and receiving buffer, the size of the socket listening queue, the number of Accep distributions, and the interval of Heartbeat checks ).

HP-socket project homepage:Http://ldcsaa.googlecode.com

----------------------------------------------------------------

2,Windows C ++ General log component VC-logger

VC-logger is a simple and easy-to-use general log component for C ++ programs. The design focuses on three aspects:

Function:This log component is designed to meet the logging requirements of most applications. It outputs logs to files or sends them to applications, and does not provide complex but uncommon functions. The functions of this log component include:

    1. Output log information to a specified file
    2. Generate a log file every day
    3. For GUI programs, you can send log information to a specified window
    4. For the console application, you can send the log information to the standard output (STD: cout)
    5. Support for MBCS/Unicode and console/GUI programs
    6. Supports dynamic loading and static loading of the log component DLL
    7. Supports multiple log levels, such as debug, Trace, info, warn, error, and fatal.

Availability:This log component focuses on availability and makes it easy to use as much as possible:

    1. Simple and pure: independent from any library or framework
    2. Easy to use interfaces without complicated configuration or setup
    3. The cstaticlogger and cdynamiclogger packaging classes are provided for static or dynamic loading and operation log components. You do not need to pay attention to the loading details.
    4. If the program wants to record multiple log files, it only needs to create the corresponding cstaticlogger or cdynamiclogger object for each log file.
    5. You only need to call log ()/debug ()/Trace ()/info ()/warn ()/error ()/fatal () to record logs.
    6. Variable parameters are supported in the logging method.
    7. Log output format: <time> <thread ID> <log level> <log content>

Performance:Performance is a hard indicator of whether the component is worth using. The performance optimization should be considered in the process from design to coding:

    1. Supports simultaneous sending of log writing requests with multiple threads
    2. Using a separate thread to write logs in the background does not affect normal execution of the working thread
    3. Batch log recording

VC-logger projects home: http://ldcsaa.googlecode.com

Codeproject

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.