I. Introduction
In the rainy season, the flood situation changes rapidly, and flood control management and decision-making have very high requirements for timeliness. If flood control personnel cannot grasp the latest flood control information in time, it will bring great difficulties to flood control work, and even disastrous consequences. Therefore, it is very necessary to establish a complete flood control information system. However, flood control work often covers a large area, involves a large number of people, and the working environment is complex, which will affect the timely and accurate transmission of information. Mobile communications have a wide coverage range and have the characteristics of three A (any time, any place, any way), which can just meet the needs of flood control work. There are two main ways to access the Internet on mobile phones: WAP and J2ME. WAP can only access web pages written in WML language, and its functions are subject to many restrictions; J2ME can be seamlessly combined with J2EE, and the J2ME program interface is friendly, input and output are convenient, and security is high. Therefore, this paper uses J2ME and J2EE technology to develop a flood control information system to improve the efficiency of flood control work.
2. J2ME
J2ME is a Java version provided by Sun specifically for developing applications for small resource-constrained consumer electronic devices. It is widely used in small resource-constrained devices such as mobile phones, PDAs, and TV set-top boxes. J2ME is actually a collection of specifications (JSR). Because the devices involved vary greatly in hardware configuration and performance, in order to facilitate the development of applications, the J2ME architecture adopts a modular and extensible design, which mainly includes 4 layers: host operating system, configuration, profile, and manufacturer optional package. Specifications at different levels work together to provide a complete mobile Java platform.
Figure 1 J2ME layered architecture diagram
The advantages of J2ME include:
(1) Write once, run anywhere. J2ME programs have good cross-platform and portability.
(2) Seamless integration with J2EE.
(3) Good security
J2EE is an architecture that uses the Java platform to simplify the development, deployment and management of enterprise solutions. It standardizes the application development of distributed systems. J2EE also adopts a layered structure. A typical J2EE application consists of four layers: client layer, presentation logic layer (Web layer), business logic layer and enterprise information system layer. Corresponding components and containers are defined on each layer. Each layer is independent of each other and calls and passes parameters through standard Java APIs. As a broad and universal standard, J2EE has greatly simplified the process of application development and migration.
3. Flood Control Information System
This system uses WebLogic as the application server and the database management system is MS Sqlserver 2000. The whole system mainly includes four modules: user login module, water condition query module, weather query module and user customization module.
(1) User login module
This module implements the user identity authentication function. Only legitimate users can log in to the system to obtain data information. The IP address of the mobile phone is dynamically allocated each time it goes online. When the user logs in, the IP address of this login will be written into the database, which is used by the server in the user customization module to actively send information to the client through Socket.
(2) Water situation update and query module
This module is the key to the flood control information system. Only by keeping the data of each hydrological station updated in real time and ensuring the accuracy and reliability of the data can the normal flood control work be guaranteed. After logging into the system through a mobile phone, each hydrological station can update the data, and other users can query the current and historical water conditions data of each hydrological station. Considering that it is difficult to input data on a mobile phone, the server should also provide the function of updating data online through the Web.
(3) Weather update and query module
Weather conditions are also an important factor to consider in flood prevention. Users can use their mobile phones to check weather forecasts for major cities and historical weather conditions for the same period, so as to make correct judgments on weather conditions. [page]
(4) User-customized modules
During the flood season, water conditions change rapidly. The flood control information system should have the function of actively notifying relevant responsible persons in case of emergency. The user customization module allows users to customize the required information according to their own situation. When the customized information appears, the system will automatically send a message to the user's mobile phone to remind the user to deal with it in time.
The connection between the client and the server is shown in Figure 2:
In this system, the client and server communicate mainly through the HTTP protocol, and the workflow is as follows:
(1) The user starts the MIDlet on the phone and enters the login interface, where he enters his username and password to log in. The MIDlet uses the open method of the Connector class to establish a connection to the server and casts the connection to an HttpConnection type.
(2) The client uses the openInputStream method and openOutputStream method of the HttpConnection class to return input and output streams and use them to send requests and receive response information.
(3) After receiving the connection request from the client, the server encapsulates it into an HttpServletRequest object, calls the corresponding Servlet, accesses the database through EJB or JavaBean, and returns the processing result to the client's MIDlet.
(4) The client MIDlet uses the input stream to receive the results returned by the server, and presents different interfaces on the screen depending on whether the returned result is "station" (station), "person" (ordinary user) or "none" (no such user).
(5) After successful login, MIDlet re-establishes HttpConnection to perform data update or query operations.
4. Technical Difficulties and Solutions
4.1 Receiving User Customized Information
There are two ways to send user-customized information:
(1) Scheduled delivery: Used to send user-customized daily information to users on a scheduled basis every day.
(2) Emergency sending: When an emergency flood situation occurs, the information will be sent immediately to the relevant responsible persons.
On the client side, the reception of relevant information is achieved through the PUSH registration function of J2ME. Push technology is a mechanism that enables Midlet applications to start running automatically without user operation. In a normal network connection, the client actively connects to the server, and the server accepts the request and returns the processing result to the client. Push technology is different. It does not require the application to obtain data through the network in a "pull" manner. The data required by the client will be actively "pushed" to the client's mobile device. When the mobile device receives the information, the relevant Midlet will be activated and start running to process the sent data.
The server can automatically send data to the client connected to it using Socket, which provides a guarantee for Push technology. The client's MIDlet first registers the service type, address, and port number. When the server detects an emergency or user-customized situation, it will send the corresponding message to the client through Socket, and the client will start the corresponding MIDlet to process the message accordingly.
J2ME platform has added support for Push registration since MIDP2.0. Push mechanism can activate Midlet in the following two ways: one is based on the connected network connection, when the client receives the information pushed from the network, it will automatically start the Midlet to run; the other is based on the timer warning notification. Push registration mechanism can make MIDlet run automatically, and there are two running modes: one is based on timing technology, when a specific time is reached, the program will run; the other is based on the network, when the device receives the information pushed by the network, it can start the program to run. This system adopts the first method to realize the sending of customized information.
To use Push technology on the client side, Push registration must be performed in advance. There are two methods for Push registration: static registration and dynamic registration. Static registration requires adding Push registration information to the JAD file and completing the registration when the Midlet Suite is installed. The disadvantage of static registration is that it must be implemented through the Midlet Suite installation process. Once installed, new registrations cannot be added. At the same time, if you want to cancel Push registration, you must also uninstall the Midlet Suite. Dynamic registration is implemented by MIDlet through the Push Registry interface API. Push registration can be added or canceled while the program is running, which increases flexibility. This article adopts the dynamic registration method.
During dynamic registration, the MIDlet needs to tell the AMS the IP address and port number of the server to which it is connected and the MIDlet class to be started. The implementation code is as follows:
…
String midletClassName = "com.water.PushInfo"; //This is the Midlet that automatically runs and processes data
String ConnectionURL =”socket://:6789”;
String AllowedSender = "*"; //* indicates that it is allowed to receive messages sent from any address
PushRegistry.registerConnection(midletClassName, ConnectionURL, AllowedSender);
…..
In this way, when AMS detects the data sent by the Socket server with port number 6789, it will start PushInfo under the com.water package to process the data.
Unregistering can be done using PushRegistry.unregisterConnection(ConnectionURL). [page]
4.2 Database Connection Pool Technology
This example uses database connection pool technology. Traditional Web applications generally go through three steps when performing database operations: (1) establishing a database connection; (2) performing database addition, deletion, modification, and query operations; and (3) disconnecting the database connection. This method has an important disadvantage: a database connection must be established and managed for each Web request, and these operations consume a lot of time and resources. The basic idea of a database connection pool is to establish some connections in advance and place them in memory objects for future use. When a database connection needs to be established in the program, just take one out of the memory instead of establishing a new connection. Similarly, after use, just put the connection back into the memory, and the establishment and disconnection of the connection are managed by the connection pool itself. WebLogic Server provides a graphical interface for establishing a database connection pool, which is relatively simple to set up. After establishing the database connection pool and data source, you can call it in the Servlet through JavaBean or EJB. The code is as follows:
…
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
try
{
Context ctx=new InitialContext(ht);
DataSource ds=(DataSource)ctx.lookup("WaterJNDI");
Connection con=ds.getConnection();
…
}catch(Exception e){
…
}
…
V. Conclusion
This system provides query services for flood control information (including historical and real-time water and rainfall conditions, work conditions, drought conditions, disaster conditions, etc.) for relevant personnel of flood control departments at all levels, and actively notifies relevant responsible persons in case of emergency, so that flood control personnel can obtain the latest flood control information anytime and anywhere, thereby improving the efficiency of flood control work.
With the development of mobile communication technology and the upcoming implementation of 3G technology, wireless networks have a good future, and using small devices such as mobile phones and PADs to communicate with the Internet will surely become one of the future development directions. With the continuous improvement of J2ME technology and the maturity of small device functions, applications supporting mobile commerce and mobile communications will surely be developed faster and more widely used.
6. Innovation
The innovation of this paper is to apply J2ME to flood control projects, and use Push registration in MIDP2.0 to actively send messages to the client. The database connection pool technology is used on the server side to improve the efficiency of accessing the database.
This system can effectively improve the efficiency of flood prevention work, so that emergency situations can be handled in a timely manner, thereby greatly reducing the mistakes in flood prevention work. The estimated economic benefits of this system are 500,000 yuan.
References
[1] Wu Min, Liu Ping. Design and implementation of mobile banking based on J2ME and J2EE[J]. Microcomputer Information, 2006.22:294-296.
[2] Wang Li, Pan Zhengyun, Liu Wei. A new design of mobile police application system based on J2ME[J]. Computer Engineering, 2006.7:283-285.
[3] Fang Anping, Li Shuxi. Research and application of MIDP2.0 in mobile email[J]. Journal of Wuhan University of Technology (Information and Management Engineering), 2006.6:52-55
[4] Zhang Pu, Wen Dengmin. Research on mobile e-commerce system based on J2ME and J2EE[J]. Chengdu University of Information Technology. 2006.8:505-507
[5] Hao Yulong, Li Xiangqian. J2ME Mobile Application Development[M]. Tsinghua University Press and Beijing Jiaotong University Press, 2006
Previous article:Implementation and function expansion of PXA272 bootloader
Next article:Research on real-time hierarchical scheduling algorithm based on μC/OS-Ⅱ
Recommended ReadingLatest update time:2024-11-16 15:23
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD World Trend Frontline——Development Board Water Group Welcomes You
- NSAT-1000 RF Passive Component Automatic Test System
- EFM32 BootLoader jump process
- 422 The receiving light is unstable, affected by the running time of the main function
- MSP430 MCU Development Record (3)
- Free draw! Tektronix will build your first oscilloscope in your life, and there are also speakers, wireless chargers, and telescopes waiting for you!
- 【K210 Series】1. Show off the K210 development board
- FPGA Practice (II) 8 LED Lights on and off and Flowing Lights
- Helping startups~21 Maxim evaluation boards are here! Free redemption in progress!
- Commonly used algorithms for drones - Kalman filter (XI)