PHP组合JAVA的开发技术 LAJP
PHP结合JAVA的开发技术 LAJP
http://www.oschina.net/p/lajp
LAJP名称来源于著名的LAMP(Linux,Apache,Mysql,Php),LAMP是轻量级的开发 Web程序的环境,在Internet上有广泛的应用,但对于企业开发,如金融、电信领域,LAMP显得能力不足,这些领域通常是Java(J2EE)的 势力范围。LAJP是将LAMP的简便性和Java能力结合起来的一项技术,LAJP中的J指的是Java,由于数据库厂商对Java的广泛支持和 LAJP针对的领域,数据库不再特别限制为Mysql。
特点
优势互补: PHP是非常流行的WEB编程脚本语言,有易学、易用、开发部署效率高的特点,非常适合WEB开发;JAVA适合编写具有复杂的业务功能和数据的程序,二 者结合可发挥各自优势,适合开发B/S企业程序。
高效稳定:Apache+PHP 组合可带来优异的WEB服务稳定性,而JAVA可补充如连接池、事物管理、分布式、对象模型等高端特性。
创新的通信机制 PHP和Java间的通讯方式采用系统消息队列和Socket两种机制,同时兼顾通讯效率和平台兼容性。
数据类型自动转换机制 PHP数据和Java数据可准确、自动匹配和转换。
易用:LAJP安装配置简单,除了核心的几个Java类文件和Java JNI接口程序外,不需额外插件,PHP端和JAVA端编程符合各自的编程习惯。
轻 量级:LAJP架构非常轻量级,除了最基本的PHP和Java环境,不需要任何扩充的、第三方的组件。
LAMP和LAJP的简要对比 LAMP从传统技术架构上看属于2层结构,虽然在php5以后增强了面向对象的能力,有了形成业务逻辑层的语言基础,但对于复杂的企业级WEB应 用,php语言能力仍显不足。LAJP继承了LAMP在WEB领域编程的活力,并用java构建业务逻辑层,非常适合针对企业级WEB项目的开发。
php和java的互通
php和 java是两种不同的语言,在LAJP架构中二者之间的互通有两种机制。
一、 消息队列
以操作系统的消息队列为沟通媒介,在通讯 过程中php作为客户端调用java端服务。消息队列属于IPC技术(进程间通讯),php语言中内置了一组函数(msg_send、 msg_receive等)可以和System V消息队列通讯,而java中没有相似的方法,因此通过调用底层JNI接口使用C函数来实现。 使用消息队列有以下好处:
使php和java保持独立性
有极高的传输速度,大于socket
相 对于socket方式,Java服务端只向本机提供服务(没有对外侦听端口),相对安全,易于管理。
二、Socket
消息队列技术只能适用于Unix/Linux/BSD系统,因此LAJP提供基于TCP/IP的通讯机制,从而适 应各种平台。
数据类型转换
PHP和Java各有其语言内部定义的数据类 型,当PHP数据传送到Java,或Java数据传送到PHP时,LAJP在内部自动地、准确地对他们进行转换,程序员无需进行任何的解码工作。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.
