??xml version="1.0" encoding="utf-8" standalone="yes"?>
//允许输入字母、点、回退键、数?br /> if (((int)e.KeyChar >= (int)'a' && (int)e.KeyChar <= (int)'z') || (((int)e.KeyChar > 48 && (int)e.KeyChar < 57) || (int)e.KeyChar == 8 || (int)e.KeyChar == 46))
{
e.Handled = false;
}
else e.Handled = true;
//允许输入字母、回退键、数?br /> if (((int)e.KeyChar >= (int)'a' && (int)e.KeyChar <= (int)'z') || (((int)e.KeyChar > 48 && (int)e.KeyChar < 57) || (int)e.KeyChar == 8))
{
e.Handled = false;
}
else e.Handled = true;
// 只能输入字母数字以及中文?br /> if ((e.KeyChar != '\b') && (!Char.IsLetter(e.KeyChar)) && (!char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
//只输入数?br /> if (e.KeyChar != 8 && (!Char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
只能输入数字以及字母X
if (e.KeyChar != 88 && e.KeyChar != 8 && (!Char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
]]>
Install-Package NLog -Version 3.2.1
]]>only_full_group_by
的错误,可以在sql_mode中关闭他Q网上查扄?/span>
]]>
Path %MYSQL_HOME%\bin
先启动服务:
net start MySQL【或者是MySQL57?/code>
use mysql; GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; flush privileges;
REST API使用l一资源标识W(URIQ来d资源。在当今互联|上Q充斥着各种各样的URI设计规则Q既有像//api.example.com/louvre/leonardo-da-vinci/mona-lisaq样能够清楚的传达API资源模型的文章,也有很难理解的文章,例如Q?a style="box-sizing: border-box; background-color: transparent; color: #337ab7; text-decoration: none;">//api.example.com/68dd0-a9d3-11e0-9f1c-0800200c9a66 QTim Berners-Lee在他?#8220;Axioms of Web Architecture”一文中URI的不透明度ȝ成一句话Q?/p>
唯一可以使用标识W的是引用对象。在不取消引用时Q就不应该查看URI字符串的内容以获取其他信息?nbsp;
——蒂姆·伯纳?- ?/a>
客户端必遵循Web的链接范例,URI视ؓ不透明标识W?/p>
REST API设计人员应该在考虑REST API资源模型传达l潜在的客户端开发者的前提下,创造URI。在q篇文章中,我将试为REST API URI 引入一?a style="box-sizing: border-box; background-color: transparent; color: #337ab7; text-decoration: none;">设计规则?/p>
先蟩q规则,URI的通用语法也适用与本文中的URI?a style="box-sizing: border-box; background-color: transparent; color: #337ab7; text-decoration: none;">RFC 3986定义了通用URI语法Q如下所C:
URI = scheme “://” authority “/” path [ “?” query ][ “#” fragment ]
q是作ؓURI路径中处理中最重要的规则之一Q正斜杠Q?Q不会增加语义|且可能导致淆。REST API不允怸个尾部的斜杠Q不应该它们包含在提供l客L的链接的l尾处?/p>
许多Weblg和框架将q等对待以下两个URIQ?nbsp;
http://api.canvas.com/shapes/
http://api.canvas.com/shapes
但是Q实际上URI中的每个字符都会计入资源的唯一w䆾的识别中?/span>
两个不同的URI映射C个不同的资源。如果URI不同Q那么资源也是如此,反之亦然。因此,REST API必须生成和传递精的URIQ不能容忍Q何的客户端尝试不_的资源定位?/p>
有些API到q种情况Q可能设计ؓ让客L重定向到相应没有斜杠的URIQ也有可能会q回301 - 用来资源重定向)?/p>
URI的\径中的正斜杠Q?Q字W用于指C源之间的层次关系?/p>
例如Q?nbsp;
(http://api.canvas.com/shapes/polygons/quadrilaterals/squares Q?/p>
Z使您的URIҎ让h们理解,请用连字符Q?- Q字W来提高长\径中名称的可L。在路径中,应该使用q字W代I格q接两个单词 ?/p>
例如Q?nbsp;
http://api.example.com/blogs/guy-levin/posts/this-is-my-first-post
一些文本查看器Z区分URIQ常怼在URI下加上下划线。这样下划线Q_Q字W可能被文本查看器中默认的下划线部分地遮蔽或完全隐藏?/p>
为避免这U淆,请用连字符Q?- Q而不是下划线
方便ӞURI路径中首选小写字母,因ؓ大写字母有时会导致一些问题。RFC 3986URI定义为区分大写Q但scheme ?host components除外?/p>
例如Q?nbsp;
http://api.example.com/my-folder/my-doc
HTTP://API.EXAMPLE.COM/my-folder/my-doc
q个URI很好。URI格式规范QRFC 3986Q认URI与URIQ?相同?/p>
http://api.example.com/My-Folder/my-doc
而这个URI与URI 1?不同Q这可能会导致不必要的淆?/p>
在Web上,Q?Q字W通常用于分隔URI的文件名和扩展名?nbsp;
REST API不应在URI中包含h造文件扩展名Q来指示邮g实体的格式。相反,他们应该依赖通过Content-Type中的header传递media typeQ来定如何处理正文的内宏V?/p>
http://api.college.com/students/3248234/courses/2005/fall.json
http://api.college.com/students/3248234/courses/2005/fall
如上所C:不应使用文g扩展名来表示格式?/p>
应鼓励REST API客户端用HTTP提供的格式选择机制Accept request header?/p>
Z是链接和调试更简单,REST API应该支持通过查询参数来支持媒体类型的选择?/p>
keep-it-simple的原则在q里同样适用。虽然一?#8221;语法学家”会告诉你使用复数来描q资源的单个实例是错误的Q但实际上ؓ了保持URI格式的一致性徏议用复数Ş式?/p>
本着API提供商更Ҏ实施和API使用者更Ҏ操作的原则,可以不必U结一些奇怪的复数Qperson/peopleQgoose/geeseQ?/p>
但是应该怎么处理层关系呢?如果一个关pd能存在于另一个资源中QRESTful原则׃提供有用的指对{我们来看一下这个例子。学生有一些课E。这些课E在逻辑上映到学生l端Q如下所C:
http://api.college.com/students/3248234/courses - 索id?248234的学生学习的所有课E的清单?nbsp;
http://api.college.com/students/3248234/courses/physics -索该学生的物理课E?/p>
当你?a style="box-sizing: border-box; background-color: transparent; color: #337ab7; text-decoration: none;">设计REST API服务Ӟ您必L意这些由URI定义的资源?/p>
正在构徏的服务中的每个资源将臛_有一个URI标识它。这个URI最好是有意义的Q且能充分描q资源。URI应遵循可预测的层ơ结构,用来提高其可理解性,可用性:可预的意义在于它们是一致的Q它的层ơ结构在数据关系上是有意义的?/p>
RESTful API是ؓ使用者编写的。URI的名U和l构应该能够向用者传达更清晰的含义。通过遵@上述规则Q您创Z个更清晰的的REST API与更友好的客L。这些ƈ不是REST的规则或U束Q仅仅是API的增强和补充?/p>
我也你来看看http://blog.restcase.com/5-basic-rest-api-design-guidelines/q篇文章?/p>
最后,望大家牢讎ͼ你在Z的客L设计API URIQ而不仅仅是ؓ你的数据?/p>
?/span>classpath根目录下加蝲指定名称的文?/span>
* this.getClass().getResourceAsStream("testVariables.bpmn")
从当前包下加载指定名U的文g
* this.getClass().getResourceAsStream("/testVariables.bpmn")
?/span>classpath根目录下加蝲指定名称的文?/span>
activitipȝ一共有23个表Q包括流E定义表、一般数据信息表、流E运行实例表、流E历史记录表、用LL表?/p>
程定义表,程定义表也可以叫做是静态资源库Q静态资源包括图片、定义规则等。它有部|信息表、流E模型表、流E定义表
1、ACT_RE_DEPLOYMENTQ部|信息表Q?/p>
包括Q部|流E名U、类型、部|时?/p>
2、ACT_RE_MODELQ模型表Q?/p>
名称,key、类型、创建时间、最后修Ҏ间、版本、数据源信息、部|ID、编辑源值ID、编辑源额外值IDQ外键ACT_GE_BYTEARRAY Q?/p>
3、ACT_RE_PROCDEFQ流E定义表Q?nbsp;
包括程定义、类型、流E名U、流Ekey、版本号、部|ID、资源名U、图片资源名U、描qC息、是否从key启动、暂停状态?/p>
q行实例表记录流E流转过E中产生的数据,一般数据分Z个部分流E数据、业务数据。流E数据是指activiti程引擎{q程中的数据Q包括流E执行实例数据接、Q务数据、执行Q务h员信息、变量信息。业务数据则是流E过E中保存的表单数据,例如Q如请假的请假单数据、报销单数据、审Ҏ见信息等Q此部分数据一般需要自己徏数据表进行保存,在之前的jbpm4中没有保存业务数据?/p>
1、ACT_RU_EVENT_SUBSCRQ事件子脚本Q作用未?/p>
事g名称QEVENT_NAME_Q、事件类?EVENT_TYPE_)、流E执行ID(EXECUTION_ID_)、流E实例ID(PROC_INST_ID_)、活动ID(ACTIVITY_ID_)、配|信?CONFIGURATION_)、创建时_CREATED_Q?/p>
2、ACT_RU_EXECUTIONQ执行中程执行Q核心我的代办Q务查询表
程实例IDQPROC_INST_ID_Q,业务keyQBUSINESS_KEY_Q、父执行程QPARENT_ID_Q、流E定义IdQ外键PROC_DEF_ID_Q、实例idQACT_ID_Q、激zȝ态(IS_ACTIVE_Q、ƈ发状态(is_concurrentQ、is_scope、is_evnet_scope、暂停状态(suspension_stateQ、缓存结束状态(cached_end_stateQ?/p>
3、ACT_RU_IDENTITYLINKQn份联p)
用户lテQ(GROUP_ID_Q、用Lcd(TYPE_)、用户ID(USER_ID_)、Q务IdQ外键:TASK_ID_Q、流E实例IDQ外键:PROC_INST_ID_Q、流E定义IdQ外?PROC_DEF_ID_Q?/p>
4、ACT_RU_JOB(q行中的d)
5、ACT_RU_TASKQ执行中实时dQ代办Q务查询表
实例idQ外键EXECUTION_ID_Q、流E实例IDQ外键PROC_INST_ID_Q、流E定义IDQPROC_DEF_ID_Q、Q务名UͼNAME_Q、父节Q务IDQPARENT_TASK_ID_Q?/p>
、Q务描qͼDESCRIPTION_Q、Q务定义keyQTASK_DEF_KEY_Q、所属hQOWNER_Q、代理h?(ASSIGNEE_)、代理团QDELEGATION_Q、优先权QPRIORITY_Q、创建时_CREATE_TIME_Q、执行时_DUE_DATE_Q、暂停状态(SUSPENSION_STATE_Q?/p>
6、ACT_RU_VARIABLEQ实时变量)
变量名称QNAME_Q、编码类?TYPE_)、执行实例ID(EXECUTION_ID_)、流E实例Id(PROC_INST_ID_)、Q务id(TASK_ID_)、字节组IDQBYTEARRAY_ID_Q、DOUBLE_、LONG_、TEXT_、TEXT2_
程历史信息表,activiti历史记录表包括节点信息表、附件信息表、历史审批记录表、理惌l信息表、历史n份信息表、流E实例历史表、Q务历史表、历史变量表。(节点信息表、附件信息表、历史审批记录表、理惌l信息表、历史n份信息表Q这些表目前q未知是如何用的。(程实例历史表、Q务历史表、历史变量)三个表可以查询我已完成Q务、Q务追t等?/p>
1、ACT_HI_ACTINSTQ活动实例信息)
程定义IDQPROC_DEF_ID_Q、流E实例IDQPROC_INST_ID_Q、流E执行IDQEXECUTION_ID_Q、活动IDQACT_ID_Q、活动名UͼTASK_ID_Q、活动类型(ACT_TYPE_Q、Q务ID、(TASK_ID_Q、请求流E实例IDQCALL_PROC_INST_ID_Q、代理h员(ASSIGNEE_Q、开始时_START_TIME_Q、结束时?END_TIME_)、时长(DURATION_Q?/p>
2、ACT_HI_ATTACHMENTQ附件信息)
用户idQUSER_ID_Q、名UͼNAME_Q、描qͼDESCRIPTION_Q、类型(TYPE_Q、Q务IdQTASK_ID_Q、流E实例IDQPROC_INST_ID_Q、连接(URL_Q、内容IdQCONTENT_ID_Q?/p>
3、ACT_HI_COMMENTQ历史审批信息)
cdQTYPE_Q、时_TIME_Q、用户IdQUSER_ID_Q、Q务IdQTASK_ID_Q、流E实例IdQPROC_INST_ID_Q、活动(ACTION_Q、消息(MESSAGE_Q、全部消息(FULL_MSG_Q?/p>
4、ACT_HI_DETAILQ历史详l信息)
数据cdQTYPE_Q、创建时?TIME_)、名U?NAME_)、流E实例IDQPROC_INST_ID_Q、执行实例Id(EXECUTION_ID_)、Q务Id(TASK_ID_)、活动实例Id(ACT_INST_ID_)、变量类?VAR_TYPE_)、字节数lId、DOUBLE_、LONG_、|TEXT_Q、?QTEXT2_Q?/p>
5、ACT_HI_IDENTITYLINKQ历史n份信息)
dIdQTASK_ID_Q、流E实例IdQPROC_INST_ID_Q、userIdQUSER_ID_Q、用LcdTypeQTYPE_Q、用LIDQGROUP_ID_Q?/p>
6、ACT_HI_PROCINSTQ历史流E实例信息)核心?/p>
程实例IDQPROC_INST_ID_Q、业务KeyQBUSINESS_KEY_Q、流E定义IdQPROC_DEF_ID_Q、开始时_START_TIME_Q、结束时_END_TIME_Q、时长(DURATION_Q、发起h员IdQSTART_USER_ID_Q、开始节点(START_ACT_ID_Q、结束节点(END_ACT_ID_Q、超U流E实例IdQSUPER_PROCESS_INSTANCE_ID_Q、删除理由(DELETE_REASON_Q?/p>
7、ACT_HI_TASKINSTQ历史Q务流E实例信息)核心?/p>
程实例IDQPROC_INST_ID_Q、Q务定义KeyQBUSINESS_KEY_Q、流E定义IdQPROC_DEF_ID_Q、执行IDQEXECUTION_ID_Q、名UͼNAME_Q、父diDQPARENT_TASK_ID_Q、描qͼDESCRIPTION_Q、所属hQOWNER_Q、代理hQASSIGNEE_Q、开始时_START_TIME_Q、结束时_END_TIME_Q、时长(DURATION_Q、删除理由(DELETE_REASON__Q、优先QPRIORITY_Q、应完成旉QDUE_DATE_Q、表单keyQFORM_KEY_Q?/p>
8、ACT_HI_VARINSTQ历史变量信息)
程实例IDQPROC_INST_ID_Q、执行IDQEXECUTION_ID_Q、Q务Id、名UͼNAME_Q、变量(TASK_ID_Q、类型(VAR_TYPE_Q、字节数lIDQBYTEARRAY_ID_Q、DOUBLE_、LONG_、TEXT_、TEXT2_
1、ACT_GE_BYTEARRAYQ字节数据表Q?/p>
名称QNAME_Q、部|IdQDEPLOYMENT_ID_Q、字节数据(BYTES_Q、发生的QGENERATED_Q?/p>
2、ACT_GE_PROPERTYQ一般属性表Q?/p>
名称QNAMe_Q、?VALUe_)
Activit 的用LL表,包括用户信息、用L信息、用户与用户l间的关pR用户信息与用户之间的关pR在实际开发中未采用,用的实际pȝ中用戗?/p>
1、ACT_ID_GROUPQ用L表)
名称QNAME_Q、类?TYPE_)
2、ACT_ID_USERQ用戯Q?/p>
?FIRST_)、名U?LAST_)、邮?EMAIL_)、密?PWD_)、头像Id (PICTURE_ID_)
3、ACT_ID_INFOQ用户信息表Q?/p>
用户Id(USER_ID_)、类?TYPE_)、formINPut名称(KEY_)、?VALUE_)、密?PASSWORD_)、父节点(PARENT_ID_)
4、ACT_ID_MEMBERSHIPQ用LL兌表)
用户Id(user_ID_)、用LIdQgroup_IdQ?/p>
Activiti表结构分析完成,׃5个小Ӟq有很多问题不明白。后l慢慢开发过E中再理一ơ表之间关系吧,初步x在系l中需要扩Q把业务数据和流E数据分开?/p>
Druid是一个JDBClgQ它包括四个部分Q?/p>
DruidDriverQ是一个ProxyJdbcDriverQ它提供了Filter-Chain模式的扩展机Ӟ使得在Jdbc扩展~程特别方便?/p>
Druid提供了一些内|的扩展机制Q包?u>Stat?u>Log?u>Trace、HA{扩展?/p>
DruidDataSource是一个数据库q接池的实现Q它的设计目标是提供一个当前最好的数据库连接池Q在性能、扩展性等斚w取得最合适的qQ取代DBCP、C3P0{连接池?/p>
q是DruidDataSource的设计图C:
http://code.alibabatech.com/svn/druid/trunk/doc/druid-pool.txt
如果发现有ؕ码,请选择utf-8的编码方式查看?/p>
Druid提供一个手工编写的高性能的方便扩展的SQL Parser。将会支持MySQL、Oracle{流行关pL据库的SQL Parser?/p>
Parserlg包括如下几个部分Q?/p>
Druid提供了强大的监控功能Q能够监控连接池行ؓ和SQL执行情况Q让你能够详l了解应用的数据库访问行为?/p>
Z使神l网l有效,我们必须Ҏ据进行正态化。这是激zd数的正确计算所需要的。正态化是一U数学处理,数据{换ؓ 0..1 ?-1..1 的范围。正态化后的数据可以q行L态化Q即转换回原来的范围?br />
The cron4j main entity is the scheduler. With a it.sauronsoftware.cron4j.Scheduler instance you can execute tasks at fixed moments, during all the year. A scheduler can execute a task once a minute, once every five minutes, Friday at 10:00, on February the 16th at 12:30 but only if it is Saturday, and so on.
The use of the cron4j scheduler is a four steps operation:
Consider this simple example:
import it.sauronsoftware.cron4j.Scheduler; public class Quickstart { public static void main(String[] args) { // Creates a Scheduler instance. Scheduler s = new Scheduler(); // Schedule a once-a-minute task. s.schedule("* * * * *", new Runnable() { public void run() { System.out.println("Another minute ticked away..."); } }); // Starts the scheduler. s.start(); // Will run for ten minutes. try { Thread.sleep(1000L * 60L * 10L); } catch (InterruptedException e) { ; } // Stops the scheduler. s.stop(); } }
This example runs for ten minutes. At every minute change it will print the sad (but true) message "Another minute ticked away...".
Some other key concepts:
A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intended as:
The star wildcard character is also admitted, indicating "every minute of the hour", "every hour of the day", "every day of the month", "every month of the year" and "every day of the week", according to the sub-pattern in which it is used.
Once the scheduler is started, a task will be launched when the five parts in its scheduling pattern will be true at the same time.
Scheduling patterns can be represented with it.sauronsoftware.cron4j.SchedulingPattern instances. Invalid scheduling patterns are cause of it.sauronsoftware.cron4j.InvalidPatternExceptions. The SchedulingPattern class offers also a static validate(String) method, that can be used to validate a string before using it as a scheduling pattern.
Some examples:
5 * * * *
This pattern causes a task to be launched once every hour, at the begin of the fifth minute (00:05, 01:05, 02:05 etc.).
* * * * *
This pattern causes a task to be launched every minute.
* 12 * * Mon
This pattern causes a task to be launched every minute during the 12th hour of Monday.
* 12 16 * Mon
This pattern causes a task to be launched every minute during the 12th hour of Monday, 16th, but only if the day is the 16th of the month.
Every sub-pattern can contain two or more comma separated values.
59 11 * * 1,2,3,4,5
This pattern causes a task to be launched at 11:59AM on Monday, Tuesday, Wednesday, Thursday and Friday.
Values intervals are admitted and defined using the minus character.
59 11 * * 1-5
This pattern is equivalent to the previous one.
The slash character can be used to identify step values within a range. It can be used both in the form */c and a-b/c. The subpattern is matched every c values of the range 0,maxvalue or a-b.
*/5 * * * *
This pattern causes a task to be launched every 5 minutes (0:00, 0:05, 0:10, 0:15 and so on).
3-18/5 * * * *
This pattern causes a task to be launched every 5 minutes starting from the third minute of the hour, up to the 18th (0:03, 0:08, 0:13, 0:18, 1:03, 1:08 and so on).
*/15 9-17 * * *
This pattern causes a task to be launched every 15 minutes between the 9th and 17th hour of the day (9:00, 9:15, 9:30, 9:45 and so on... note that the last execution will be at 17:45).
All the fresh described syntax rules can be used together.
* 12 10-16/2 * *
This pattern causes a task to be launched every minute during the 12th hour of the day, but only if the day is the 10th, the 12th, the 14th or the 16th of the month.
* 12 1-15,17,20-25 * *
This pattern causes a task to be launched every minute during the 12th hour of the day, but the day of the month must be between the 1st and the 15th, the 20th and the 25, or at least it must be the 17th.
Finally cron4j lets you combine more scheduling patterns into one, with the pipe character:
0 5 * * *|8 10 * * *|22 17 * * *
This pattern causes a task to be launched every day at 05:00, 10:08 and 17:22.
The simplest manner to build a task is to implement the well-known java.lang.Runnable interface. Once the task is ready, it can be scheduled with the it.sauronsoftware.cron4j.Scheduler.schedule(String, Runnable) method. This method throws an it.sauronsoftware.cron4j.InvalidPatternException when the supplied string does not represent a valid scheduling pattern.
Another way to build a task is to extend the it.sauronsoftware.cron4j.Task abstract class, which is more powerful and let the developer access some other cron4j features. This is better discussed in the "Building your own task" paragraph. Task instances can be scheduled with the schedule(String, Task) and the schedule(SchedulingPattern, Task) methods.
Scheduling methods available in the scheduler always return an ID used to recognize and retrieve the scheduled operation. This ID can be used later to reschedule the task (changing its scheduling pattern) with the reschedule(String, String) or the reschedule(String, SchedulingPattern) methods, and to deschedule the task (remove the task from the scheduler) with the deschedule(String) method.
The same ID can also be used to retrieve the scheduling pattern associated with a scheduled task, with the getSchedulingPattern(String) method, or to retrieve the task itself, with the getTask(String) method.
System processes can be easily scheduled using the ProcessTask class:
ProcessTask task = new ProcessTask("C:\\Windows\\System32\\notepad.exe"); Scheduler scheduler = new Scheduler(); scheduler.schedule("* * * * *", task); scheduler.start(); // ...
Arguments for the process can be supplied by using a string array instead of a single command string:
String[] command = { "C:\\Windows\\System32\\notepad.exe", "C:\\File.txt" }; ProcessTask task = new ProcessTask(command); // ...
Environment variables for the process can be supplied using a second string array, whose elements have to be in the NAME=VALUE form:
String[] command = { "C:\\tomcat\\bin\\catalina.bat", "start" }; String[] envs = { "CATALINA_HOME=C:\\tomcat", "JAVA_HOME=C:\\jdks\\jdk5" }; ProcessTask task = new ProcessTask(command, envs); // ...
The default working directory for the process can be changed using a third parameter in the constructor:
String[] command = { "C:\\tomcat\\bin\\catalina.bat", "start" }; String[] envs = { "CATALINA_HOME=C:\\tomcat", "JAVA_HOME=C:\\jdks\\jdk5" }; File directory = "C:\\MyDirectory"; ProcessTask task = new ProcessTask(command, envs, directory); // ...
If you want to change the default working directory but you have not any environment variable, the envs parameter of the constructor can be set to null:
ProcessTask task = new ProcessTask(command, null, directory);
When envs is null the process inherits every environment variable of the current JVM:
Environment variables and the working directory can also be set by calling the setEnvs(String[]) and setDirectory(java.io.File) methods.
The process standard output and standard error channels can be redirected to files by using the setStdoutFile(java.io.File) and setStderrFile(java.io.File) methods:
ProcessTask task = new ProcessTask(command, envs, directory); task.setStdoutFile(new File("out.txt")); task.setStderrFile(new File("err.txt"));
In a siminal manner, the standard input channel can be read from an existing file, calling the setStdinFile(java.io.File) method:
ProcessTask task = new ProcessTask(command, envs, directory); task.setStdinFile(new File("in.txt"));
The cron4j scheduler can also schedule a set of processes from a file.
You have to prepare a file, very similar to the ones used by the UNIX crontab, and register it in the scheduler calling the scheduleFile(File) method. The file can be descheduled by calling the descheduleFile(File) method. Scheduled files can be retrieved by calling the getScheduledFiles() method.
Scheduled files are parsed every minute. The scheduler will launch every process declared in the file whose scheduling pattern matches the current system time.
Syntax rules for cron4j scheduling files are reported in the "Cron parser" paragraph.
A java.lang.Runnable object is the simplest task ever possible, but to gain control you need to extend the it.sauronsoftware.cron4j.Task class. In the plainest form, implementing Runnable or extending Task are very similar operations: while the first requires a run() method, the latter requires the implementation of execute(TaskExecutionContext). The execute(TaskExecutionContext) method provides a it.sauronsoftware.cron4j.TaskExecutionContext instance, which the Runnable.run() method does not provide. The context can be used in the following ways:
A task can communicate with its executor, by notifying its internal state with a textual description. This is called status tracking. If you are interested in supporting status tracking in your task, you have to override the supportsStatusTracking() method, which should return true. Once this has been done, within the execute(TaskExecutionContext) method you are enabled to call the context setStatusMessage(String) method. This will propagate your task status message to its executor. The status message, through the executor, can be retrieved by an external user (see the "
A task can communicate with its executor, by notifying its completeness level with a numeric value. This is called completeness tracking. If you are interested in supporting completeness tracking in your task, you have to override the supportsCompletenessTracking() method, which should return true. Once this has been done, within the execute(TaskExecutionContext) method you are enabled to call the context setCompleteness(double) method, with a value between 0 and 1. This will propagate your task completeness level to its executor. The completeness level, through the executor, can be retrieved by an external user (see the "
A task can be optionally paused. If you are interested in supporting pausing and resuming in your task, you have to override the canBePaused() method, which should return true. Once this has been done, within the execute(TaskExecutionContext) method you have to periodically call the context pauseIfRequested() method. This will pause the task execution until it will be resumed (or stopped) by an external user (see the "
A task can be optionally stopped. If you are interested in supporting stopping in your task, you have to override the canBeStopped() method, which should return true. Once this has been done, within the execute(TaskExecutionContext) method you have to periodically call the context isStopped() method. This will return true when the execution has be demanded to be stopped by an external user (see the "
Through the context, the task can retrieve the scheduler, calling getScheduler().
Through the context, the task can retrieve its executor, calling getTaskExecutor().
A custom task can be scheduled, launched immediately or returned by a task collector.
You can build and plug within the scheduler your own task source, via the task collector API.
The cron4j scheduler supports the registration of one or more it.sauronsoftware.cron4j.TaskCollector instances, with the addTaskCollector(TaskCollector) method. Registered collectors can be retrieved with the scheduler getTaskCollectors() method. A previously registered collector can be removed from the scheduler with the removeTaskCollector(TaskCollector) method. Collectors can be added, queried or removed at every moment, also when the scheduler is started and it is running.
Each registered task collector is queried by the scheduler once a minute. The scheduler calls the collector getTasks() method. The implementation must return a it.sauronsoftware.cron4j.TaskTable instance. A TaskTable is a table that associates tasks and scheduling patterns. The scheduler, once the table has been retrieved, will examine the reported entries, and it will execute every task whose scheduling pattern matches the current system time.
A custom collector can be used to tie the scheduler with an external task source, i.e. a database or a XML file, which can be managed and changed in its contents also at run time.
The it.sauronsoftware.cron4j.SchedulerListener API can be used to listen to scheduler events.
The SchedulerListener interface requires the implementation of the following methods:
taskLaunching(TaskExecutor)
This one is called every time a task is launched by the scheduler.
taskSucceeded(TaskExecutor)
This one is called every time a task execution has been successfully completed.
taskFailed(TaskExecutor, Throwable)
This one is called every time a task execution fails due to an uncaught exception.
See the " Once your SchedulerListener instance is ready, you can register it on a Scheduler object by calling its addSchedulerListener(SchedulerListener) method. Already registered listeners can be removed by calling the removeSchedulerListener(SchedulerListener) method. The scheduler can also give back any registered listener, with the getSchedulerListeners() method. SchedulerListeners can be added and removed at every moment, also while the scheduler is running.
The scheduler, once it has been started and it is running, can be queried to give back its executors. An executor is similar to a thread. Executors is used by the scheduler to execute tasks.
By calling the Scheduler.getExecutingTasks() method you can obtain the currently ongoing executors.
You can also obtain an executor through a SchedulerListener instance (see the "Building your own scheduler listener" paragraph).
Each executor, represented by a it.sauronsoftware.cron4j.TaskExecutor instance, performs a different task execution.
The task can be retrieved with the getTask() method.
The executor status can be checked with the isAlive() method: it returns true if the executor is currently running.
If the executor is running, the current thread can be paused until the execution will be completed, calling the join() method.
The supportsStatusTracking() method returns true if the currently executing task supports status tracking. It means that the task communicates to the executor its status, represented by a string. The current status message can be retrieved by calling the executor getStatusMessage() method.
The supportsCompletenessTracking() method returns true if the currently executing task supports completeness tracking. It means that the task communicates to the executor its own completeness level. The current completeness level can be retrieved by calling the executor getCompleteness() method. Returned values are between 0 (task just started and still nothing done) and 1 (task completed).
The canBePaused() method returns true if the currently executing task supports execution pausing. It means that the task execution can be paused by calling the executor pause() method. The pause status of the executor can be checked with the isPaused() method. A paused executor can be resumed by calling its resume() method.
The canBeStopped() method returns true if the currently executing task supports execution interruption. It means that the task execution can be stopped by calling the executor stop() method. The interruption status of the executor can be checked with the isStopped() method. Stopped executors cannot be resumed.
The getStartTime() method returns a time stamp reporting the start time of the executor, or a value less than 0 if the executor has not been yet started.
The getScheduler() method returns the scheduler which is the owner of the executor.
The getGuid() method returns a textual GUID for the executor.
Executors offer also an event-driven API, through the it.sauronsoftware.cron4j.TaskExecutorListener class. A TaskExecutorListener can be added to a TaskExecutor with its addTaskExecutorListener(TaskExecutorListener) method. Listeners can be removed with the removeTaskExecutorListener(TaskExecutorListener) method, and they can also be retrieved with the getTaskExecutorListeners() method. A TaskExecutorListener must implement the following methods:
executionPausing(TaskExecutor)
Called when the executor is requested to pause the ongoing task. The given parameter represents the source TaskExecutor instance.
executionResuming(TaskExecutor)
Called when the executor is requested to resume the execution of the previously paused task. The given parameter represents the source TaskExecutor instance.
executionStopping(TaskExecutor)
Called when the executor is requested to stop the task execution. The given parameter represents the source TaskExecutor instance.
executionTerminated(TaskExecutor, Throwable)
Called when the executor has completed the task execution. The first parameter represents the source TaskExecutor instance, while the second is the optional exception that has caused the task to be terminated. If the task has been completed successfully, the given value is null.
statusMessageChanged(TaskExecutor, String)
Called every time the execution status message changes. The first parameter represents the source TaskExecutor instance, while the second is the new message issued by the task.
completenessValueChanged(TaskExecutor, double)
Called every time the execution completeness value changes. The first parameter represents the source TaskExecutor instance, while the second is the new completeness value (between 0 and 1) issued by the task.
If the scheduler is started and running, it is possible to manually launch a task, without scheduling it with a pattern. The method is Scheduler.launch(Task). The task will be immediately launched, and a TaskExecutor instace is returned to the caller. The returned object can be used to control the task execution (see the "
Scheduler instances, by default, work with the system default Time Zone. I.e. a scheduling pattern whose value is 0 2 * * * will activate its task at 02:00 AM according to the default system Time Zone. The scheduler can be requested to work with a different Time Zone, which is not the system default one. Call Scheduler.setTimeZone(TimeZone) and Scheduler.getTimeZone() to control this feature.
Once the default Time Zone has been changed, system current time is adapted to the supplied zone before comparing it with registered scheduling patterns. The result is that any supplied scheduling pattern is treated according to the specified Time Zone. Suppose this situation:
The scheduler, before comparing system time with patterns, translates 10:00 from GMT+1 to GMT+3. It means that 10:00 becomes 12:00. The resulted time is then used by the scheduler to activate tasks. So, in the given configuration at the given moment, any task scheduled as 0 12 * * * will be executed, while any 0 10 * * * will not.
The Java Virtual Machine exits when the only threads running are all daemon threads. The cron4j scheduler can be configured to spawn only daemon threads. To control this feature call the Scheduler.setDaemon(boolean) method. This method must be called before the scheduler is started. Default value is false. To check the scheduler current daemon status call the Scheduler.isDaemon() method.
The it.sauronsoftware.cron4j.Predictor class is able to predict when a scheduling pattern will be matched.
Suppose you want to know when the scheduler will execute a task scheduled with the pattern 0 3 * jan-jun,sep-dec mon-fri. You can predict the next n execution of the task using a Predictor instance:
String pattern = "0 3 * jan-jun,sep-dec mon-fri"; Predictor p = new Predictor(pattern); for (int i = 0; i < n; i++) { System.out.println(p.nextMatchingDate()); }
The it.sauronsoftware.cron4j.CronParser class can be used to parse crontab-like formatted file and character streams.
If you want to schedule a list of tasks declared in a crontab-like file you don't need the CronParser, since you can do it by adding the file to the scheduler, with the Scheduler.scheduleFile(File) method.
Consider to use the CronParser if the Scheduler.scheduleFile(File) method is not enough for you. In example, you may need to fetch the task list from a remote source which is not representable as a java.io.File object (a document on a remote server, a DBMS result set and so on). To solve the problem you can implement your own it.sauronsoftware.cron4j.TaskCollector, getting the advantage of the CronParser to easily parse any crontab-like content.
You can parse a whole file/stream, but you can also parse a single line.
A line can be empty, can contain a comment or it can be a scheduling line.
A line containing no characters or a line with only space characters is considered an empty line.
A line whose first non-space character is a number sign (#) is considered a comment.
Empty lines and comment lines are ignored by the parser.
Any other kind of line is parsed as a scheduling line.
A valid scheduling line respects the following structure:
scheduling-pattern [options] command [args]
After the scheduling pattern item, other tokens in each line are space separated or delimited with double quotation marks (").
Double quotation marks delimited items can take advantage of the following escape sequences:
The options token collection can include one or more of the following elements:
It is also possible to schedule the invocation of a method of a Java class in the scope of the parser ClassLoader. The method has to be static and it must accept an array of strings as its sole argument. To invoke a method of this kind the syntax is:
scheduling-pattern java:className#methodName [args]
The #methodName part can be omitted: in this case the main(String[]) method will be assumed.
Please note that static methods are invoked within the scheduler same JVM, without spawning any external process. Thus IN, OUT, ERR, ENV and DIR options can't be applied.
Invalid scheduling lines are discarded without blocking the parsing procedure, but an error message is sent to the application standard error channel.
Valid examples:
0 5 * * * sol.exe 0,30 * * * * OUT:C:\ping.txt ping 10.9.43.55 0,30 4 * * * "OUT:C:\Documents and Settings\Carlo\ping.txt" ping 10.9.43.55 0 3 * * * ENV:JAVA_HOME=C:\jdks\1.4.2_15 DIR:C:\myproject OUT:C:\myproject\build.log C:\myproject\build.bat "Nightly Build" 0 4 * * * java:mypackage.MyClass#startApplication myOption1 myOption2
阉K云是最q新出的一个镜像源。得益与阉K云的高速发展,q么大的需求,肯定会推q镜像源?br style="padding: 0px; margin: 0px;" />阉K云Linux安装镜像源地址Qhttp://mirrors.aliyun.com/
CentOSpȝ更换软g安装?br style="padding: 0px; margin: 0px;" />W一步:备䆾你的原镜像文Ӟ以免出错后可以恢复?/p>
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
W二步:下蝲新的CentOS-Base.repo ?etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
W三步:q行yum makecache生成~存
yum clean all
yum makecache
CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm |
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm |
CentOS/RHEL 5.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm |
Now you can install PHP 5.5’s mod_php SAPI (along with an opcode cache) by doing:
yum install php55w php55w-opcache |
You can alternatively install PHP 5.5’s php-fpm SAPI (along with an opcode cache by doing: