稍后补:php
一、稍后补;html
二、稍后补;java
<!-- - Resin 3.1 configuration file. - Resin 3.1 配置文件 --> <resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core"> <!-- adds all .jar files under the resin/lib directory --> <!-- 加载resin/lib下的全部.jar文件 --> <class-loader> <tree-loader path="${resin.home}/ext-lib"/> <tree-loader path="${resin.root}/ext-lib"/> <tree-loader path="${resin.home}/lib"/> <tree-loader path="${resin.root}/lib"/> </class-loader> <!-- - Management configuration - 管理配置 - - Remote management requires at least one enabled admin user. --> <management path="${resin.root}/admin"> <user name="admin" password="password" disable="true"/> <resin:if test="${resin.professional}"> <deploy-service/> <jmx-service/> <log-service/> <xa-log-service/> </resin:if> </management> <!-- - Logging configuration for the JDK logging API. - JDK日志接口的配置 --> <log name="" level="info" path="stdout:" timestamp="[%H:%M:%S.%s] {%{thread}} "/> <!-- - 'info' for production - 'fine' or 'finer' for development and troubleshooting - 日志信息的级别:'info' 生产环境 'fine' 开发环境 'finer' 调试环境 --> <logger name="com.caucho" level="info"/> <logger name="com.caucho.java" level="config"/> <logger name="com.caucho.loader" level="config"/> <!-- - For production sites, change dependency-check-interval to something - like 600s, so it only checks for updates every 10 minutes. - 环境上下文的检测时间,对于生产站点, 这个要设置长一点,例如600秒,10分钟 --> <dependency-check-interval>2s</dependency-check-interval> <!-- - SMTP server for sending mail notifications - 发送邮件通知的SMTP服务器 --> <system-property mail.smtp.host="127.0.0.1"/> <system-property mail.smtp.port="25"/> <!-- - Sets the default character encoding to utf-8 - - <character-encoding>utf-8</character-encoding> --> <!-- - You can change the compiler to "javac", "eclipse" or "internal". - 你能够把编译器改为 "javac", "eclipse" 或者 "internal" --> <javac compiler="internal" args="-source 1.5"/> <!-- Security providers. - <security-provider> - com.sun.net.ssl.internal.ssl.Provider - </security-provider> --> <!-- Uncomment to use Resin's XML implementations - 去掉注释,若是你使用resin提供的xml应用 - - <system-property javax.xml.parsers.DocumentBuilderFactory - ="com.caucho.xml.parsers.XmlDocumentBuilderFactory"/> - <system-property javax.xml.parsers.SAXParserFactory - ="com.caucho.xml.parsers.XmlSAXParserFactory"/> --> <cluster id="app-tier"> <!-- sets the content root for the cluster, relative to server.root --> <!-- 设置集群上下文的根, 相对于server.root --> <root-directory>.</root-directory> <server-default> <!-- The http port --> <!-- HTTP服务的端口 --> <http address="*" port="8080"/> <!-- - SSL port configuration: - SSL端口配置 - - <http address="*" port="8443"> - <openssl> - <certificate-file>keys/gryffindor.crt</certificate-file> - <certificate-key-file>keys/gryffindor.key</certificate-key-file> - <password>test123</password> - </openssl> - </http> --> <!-- - The JVM arguments - JVM参数设置 --> <jvm-arg>-Xmx256m</jvm-arg> <jvm-arg>-Xss1m</jvm-arg> <jvm-arg>-Xdebug</jvm-arg> <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg> <!-- - Uncomment to enable admin heap dumps - 去掉这个若是你想管理内存堆的倾倒 - <jvm-arg>-agentlib:resin</jvm-arg> --> <!-- - arguments for the watchdog process --> <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg> <watchdog-port>6600</watchdog-port> <!-- - Configures the minimum free memory allowed before Resin - will force a restart. - 强制resin强制重起时的最小空闲内存 --> <memory-free-min>1M</memory-free-min> <!-- Maximum number of threads. --> <!-- 最大线程数量 --> <thread-max>256</thread-max> <!-- Configures the socket timeout --> <!-- 套接字等待时间 --> <socket-timeout>65s</socket-timeout> <!-- Configures the keepalive --> <!-- 配置 keepalive --> <keepalive-max>128</keepalive-max> <keepalive-timeout>15s</keepalive-timeout> <!-- - If starting bin/resin as root on Unix, specify the user name - and group name for the web server user. - 若是使用的是UNIX,这里是启动的账号和用户组 - - <user-name>resin</user-name> - <group-name>resin</group-name> --> </server-default> <!-- define the servers in the cluster --> <!-- 定义群集服务器 --> <server id="" address="127.0.0.1" port="6800"/> <!-- - Configures the persistent store for single-server or clustered - in Resin professional. - 配置独立服务器或者群集的持久化存储,专业版的功能 --> <resin:if test="${resin.professional}"> <persistent-store type="cluster"> <init path="session"/> </persistent-store> </resin:if> <!-- - For security, use a different cookie for SSL sessions. - 为了安全, 你能够为SSL会话(SSL sessions)定义一个不一样的cookie - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie> --> <!-- - Enables the cache (available in Resin Professional) - 缓存启用 (专业版的功能) --> <resin:if test="${resin.professional}"> <cache path="cache" memory-size="64M"> <!-- Vary header rewriting for IE --> <rewrite-vary-as-private/> </cache> </resin:if> <!-- - Enables periodic checking of the server status and - check for deadlocks.. - - All servers can add <url>s to be checked. - 启用周期性的服务器状态检查和死锁检查,全部的服务器能够添加 <url> 来检查 --> <resin:if test="${resin.professional}"> <ping> <!-- <url>http://localhost:8080/test-ping.jsp</url> --> </ping> </resin:if> <!-- - Defaults applied to each web-app. - 每个web应用的默认参数 --> <web-app-default> <prologue> <!-- - Extension library for common jar files. The ext is safe - even for non-classloader aware jars. The loaded classes - will be loaded separately for each web-app, i.e. the class - itself will be distinct. - 扩展库的公共jar文件,扩展是安全的即便没有类装载器知道的jars,装载的类将为每一个应用分别装载,也就是这些类都是不一样的 --> <class-loader> <tree-loader path="${resin.root}/ext-webapp-lib"/> </class-loader> <!-- - Enable EL expressions in Servlet and Filter init-param - 启用EL表达式 --> <allow-servlet-el/> </prologue> <!-- - Sets timeout values for cacheable pages, e.g. static pages. - 设置缓存页、静态也的延时值 --> <cache-mapping url-pattern="/" expires="5s"/> <cache-mapping url-pattern="*.gif" expires="60s"/> <cache-mapping url-pattern="*.jpg" expires="60s"/> <cache-mapping url-pattern="*.png" expires="60s"/> <!-- - for security, disable session URLs by default. - 安全缘由, 默认禁用了会话的URLs --> <session-config> <enable-url-rewriting>false</enable-url-rewriting> </session-config> <!-- - For security, set the HttpOnly flag in cookies. - 安全缘由, 在cookies中设置HttpOnly标志 - <cookie-http-only/> --> <!-- - Some JSP packages have incorrect .tld files. It's possible to - set validate-taglib-schema to false to work around these packages. - 一些JSP包有不正确的 .tld文件。能够把validate-taglib-schema设置成false,可能继续正常工做 --> <jsp> <validate-taglib-schema>true</validate-taglib-schema> <fast-jstl>true</fast-jstl> </jsp> </web-app-default> <!-- includes the app-default for default web-app behavior --> <!-- 包含web应用的默认行为 --> <resin:import path="${resin.home}/conf/app-default.xml"/> <!-- - Sample database pool configuration - - The JDBC name is java:comp/env/jdbc/test - 简单的数据池配置 <database> <jndi-name>jdbc/mysql</jndi-name> <driver type="org.gjt.mm.mysql.Driver"> <url>jdbc:mysql://localhost:3306/test</url> <user></user> <password></password> </driver> <prepared-statement-cache-size>8</prepared-statement-cache-size> <max-connections>20</max-connections> <max-idle-time>30s</max-idle-time> </database> --> <!-- - Default host configuration applied to all virtual hosts. - 定义全部虚拟主机的默认配置 --> <host-default> <!-- - With another web server, like Apache, this can be commented out - because the web server will log this information. - 若是和别的web服务器整合,这个能够被去掉,由于web服务器也能够记录这些信息 --> <access-log path="logs/access.log" format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' rollover-period="1W"/> <!-- creates the webapps directory for .war expansion --> <!-- war 文件的布置目录 --> <web-app-deploy path="webapps"/> <!-- creates the deploy directory for .ear expansion --> <!-- ear文件的布置目录 --> <ear-deploy path="deploy"> <ear-default> <ejb-server> <config-directory>WEB-INF</config-directory> </ejb-server> </ear-default> </ear-deploy> <!-- creates the deploy directory for .rar expansion --> <!-- rar文件的布置目录 --> <resource-deploy path="deploy"/> </host-default> <!-- configures a deployment directory for virtual hosts --> <!-- 虚拟主机的布置目录 --> <host-deploy path="hosts"> <host-default> <resin:import path="host.xml" optional="true"/> </host-default> </host-deploy> <!-- configures the default host, matching any host name --> <!-- 默认的虚拟主机配置 --> <host id="" root-directory="."> <!-- - configures an explicit root web-app matching the - webapp's ROOT - 配置默认的应用 webapp's ROOT --> <web-app id="/" root-directory="webapps/ROOT"/> <web-app id="/resin-admin" root-directory="${resin.home}/php/admin"> <!-- - Administration application /resin-admin - 管理应用程序 /resin-admin --> <prologue> <resin:set var="resin_admin_external" value="false"/> <resin:set var="resin_admin_insecure" value="true"/> </prologue> </web-app> </host> </cluster> <!-- - Configuration for the web-tier/load-balancer --> <resin:if test="${resin.professional}"> <cluster id="web-tier"> <server-default> <!-- The http port --> <http address="*" port="9080"/> </server-default> <server id="web-a" address="127.0.0.1" port="6700"/> <cache path="cache" memory-size="64M"/> <host id=""> <web-app id="/"> <rewrite-dispatch> <load-balance regexp="" cluster="app-tier"/> </rewrite-dispatch> </web-app> </host> </cluster> </resin:if> </resin>
链接池的概念:mysql
在动态web站点设计中,数据库已成为必不可少的一部分,但数据库链接和释放开销很大,对于一个访问量少的网站可能没有什么影响,但同时有不少用户来网站查询资料时,就会致使服务器响应慢甚至死机。链接池就是针对这个问题提出的。
数据库链接池负责分配、管理和释放数据库链接,它容许应用程序重复使用一个现有的数据库链接,而再不是从新创建一个;释放空闲时间超过最大空闲时间的数据库链接来避免由于没有释放数据库链接而引发的数据库链接遗漏。这项技术能明显提升对数据库操做的性能。
数据库链接池在初始化时将建立必定数量的数据库链接放到链接池中,这些数据库链接的数量是由最小数据库链接数来设定的。不管这些数据库链接是否被使用,链接池都将一直保证至少拥有这么多的链接数量。链接池的最大数据库链接数量限定了这个链接池能占有的最大链接数,当应用程序向链接池请求的链接数超过最大链接数量时,这些请求将被加入到等待队列中。linux
resin中相关配置: web
Resin提供了一个良好的链接池来供开发人员来实现数据库链接,具体配置以下,在/conf/resin.conf中<resin></resin>标签中有如下内容:sql
<!-- - Sample database pool configuration - - The JDBC name is java:comp/env/jdbc/test <database> <jndi-name>jdbc/mysql</jndi-name> <driver type="org.gjt.mm.mysql.Driver"> <url>jdbc:mysql://localhost:3306/test</url> <user></user> <password></password> </driver> <prepared-statement-cache-size>8</prepared-statement-cache-size> <max-connections>20</max-connections> <max-idle-time>30s</max-idle-time> </database> -->
resin对具体参数的解析:数据库
结合案例分析上述参数,稍后补;express
一、移植性windows
tomcat是参照标准J2EE实现,移植性会更好(对于老手来讲tomcat和resin都同样,固然不把EJB那包括进来)
二、速度
resin的速度要比tomcat快3倍,官方的测试报告是针对resin-2.x与tomat4.x版本之前的比较了。
resin的 启动与关闭机制感受要比tomcat好不少,首先,tomcat在windows下启动,双击完startup.bat后总要等几秒钟才会启动服务,而且 关闭的时候也是同样的,有的时候甚至双击了shutdown.bat后startup.bat的窗口还老是在那好长时间,而且若是你哪一次不当心直接关闭 了dos窗口而没有运行shutdown,那下一次确定要出问题,在linux下启动速度仍是很不错的,但若是启动错误报错真是很郁闷。而相 反,resin的启动就十分人性化了,运行httpd后会出来个窗口,其中有start和stop,你能够随时方便的启动和关闭服务,而且速度也十分的 快,而且若是你的配置文件若是有改动的话,启动程序会自动监测并自动重启的,这样在配置环境的时候就不须要像tomcat那样须要反复人工关闭再启动,这 点tomcat真是差的很远。
三、报错机制
resin更好的支持中文,更好的报错机制。
resin对于中文的支持要比 tomcat好不少,各类编码和转码不少都是对tomcat设计的,由于在resin平台下根本就不须要,这点对于开发也是很重要的,特别要提的一点就 是,用tomcat写的面页不少时候若是只在面页加上contentType="text/html; charset=gb2312"仍是不能完成编码的还必需要加入一条看起来像是多此一举的一条语句 request.setCharacterEncoding("gb2312"),这一点真实让人不能忍受。
tomcat的报错机制,哪怕仅仅只是个小错误,tomcat都会用整页的篇幅来描述,若是时间长了还好,但新手确定会望而生畏的,相反,resin的报错是十分简洁 而明确的,可让你一眼就能够看出程序错误的类型和位置,这点对于刚开始学习的人来讲无疑是颇有帮助的。
四、方便性
resin支持自动编译 Servlet和Bean;
tomcat还不支持j2ee,至少在5之前仍是这样的;
五、成本
我的认为,对于企业来讲,效率高和成本低的开发,才符合创造最大经济消息的原则,用resin开发,通常的应用彻底能胜任。