
2016年4月30日
//允許輸入字母、點(diǎn)、回退鍵、數(shù)字
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;
//允許輸入字母、回退鍵、數(shù)字
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;
// 只能輸入字母數(shù)字以及中文字
if ((e.KeyChar != '\b') && (!Char.IsLetter(e.KeyChar)) && (!char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
//只輸入數(shù)字
if (e.KeyChar != 8 && (!Char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
只能輸入數(shù)字以及字母X
if (e.KeyChar != 88 && e.KeyChar != 8 && (!Char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
posted @
2020-06-13 10:46 華夢(mèng)行 閱讀(159) |
評(píng)論 (0) |
編輯 收藏
Install-Package NLog.Config -Version 3.2.1
Install-Package NLog -Version 3.2.1
posted @
2020-01-06 16:10 華夢(mèng)行 閱讀(125) |
評(píng)論 (0) |
編輯 收藏
- mysql5.7以上版本在常會(huì)報(bào)關(guān)于
only_full_group_by
的錯(cuò)誤,可以在sql_mode中關(guān)閉他,網(wǎng)上查找的解 - 在[mysqld]中添加代碼
sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
重啟mysql
sudo service mysql restart
mysql5.7以上版本在常會(huì)報(bào)關(guān)于only_full_group_by
的錯(cuò)誤,可以在sql_mode中關(guān)閉他,網(wǎng)上查找的解
查看參數(shù)是否存在
1 row in set (0.00 sec)
1 row in set (0.00 sec)
posted @
2019-09-15 22:02 華夢(mèng)行 閱讀(154) |
評(píng)論 (0) |
編輯 收藏
MYSQL_HOME 解壓路徑 C:\DevelopTool\MySQL\mysql-5.7.25-winx64

Path %MYSQL_HOME%\bin
>mysqld --initialize --user=mysql --console
mysqld -install
先啟動(dòng)服務(wù):
net start MySQL【或者是MySQL57】
修改密碼
mysqladmin -uroot -p123456 password 123
sc delete 服務(wù)名例如: sc delete mysqlhttps://www.cnblogs.com/july7/p/11489029.html 遠(yuǎn)程訪問
use mysql;
GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
flush privileges;
posted @
2019-09-14 22:51 華夢(mèng)行 閱讀(131) |
評(píng)論 (0) |
編輯 收藏
需要添加一個(gè)環(huán)境變量POSTMAN_DISABLE_GPU = true。
posted @
2019-05-18 11:11 華夢(mèng)行 閱讀(526) |
評(píng)論 (0) |
編輯 收藏
在了解REST API URI設(shè)計(jì)的規(guī)則之前,讓我們快速瀏覽一些我們將要討論的術(shù)語。
URIs
REST API使用統(tǒng)一資源標(biāo)識(shí)符(URI)來尋址資源。在當(dāng)今互聯(lián)網(wǎng)上,充斥著各種各樣的URI設(shè)計(jì)規(guī)則,既有像//api.example.com/louvre/leonardo-da-vinci/mona-lisa這樣能夠清楚的傳達(dá)API資源模型的文章,也有很難理解的文章,例如://api.example.com/68dd0-a9d3-11e0-9f1c-0800200c9a66 ;Tim Berners-Lee在他的“Axioms of Web Architecture”一文中將URI的不透明度總結(jié)成一句話:
唯一可以使用標(biāo)識(shí)符的是引用對(duì)象。在不取消引用時(shí),就不應(yīng)該查看URI字符串的內(nèi)容以獲取其他信息。
——蒂姆·伯納斯 - 李
客戶端必須遵循Web的鏈接范例,將URI視為不透明標(biāo)識(shí)符。
REST API設(shè)計(jì)人員應(yīng)該在考慮將REST API資源模型傳達(dá)給潛在的客戶端開發(fā)者的前提下,創(chuàng)造URI。在這篇文章中,我將嘗試為REST API URI 引入一套設(shè)計(jì)規(guī)則。
先跳過規(guī)則,URI的通用語法也適用與本文中的URI。RFC 3986定義了通用URI語法,如下所示:
URI = scheme “://” authority “/” path [ “?” query ][ “#” fragment ]
規(guī)則1:URI結(jié)尾不應(yīng)包含(/)
這是作為URI路徑中處理中最重要的規(guī)則之一,正斜杠(/)不會(huì)增加語義值,且可能導(dǎo)致混淆。REST API不允許一個(gè)尾部的斜杠,不應(yīng)該將它們包含在提供給客戶端的鏈接的結(jié)尾處。
許多Web組件和框架將平等對(duì)待以下兩個(gè)URI:
http://api.canvas.com/shapes/
http://api.canvas.com/shapes
但是,實(shí)際上URI中的每個(gè)字符都會(huì)計(jì)入資源的唯一身份的識(shí)別中。
兩個(gè)不同的URI映射到兩個(gè)不同的資源。如果URI不同,那么資源也是如此,反之亦然。因此,REST API必須生成和傳遞精確的URI,不能容忍任何的客戶端嘗試不精確的資源定位。
有些API碰到這種情況,可能設(shè)計(jì)為讓客戶端重定向到相應(yīng)沒有尾斜杠的URI(也有可能會(huì)返回301 - 用來資源重定向)。
規(guī)則2:正斜杠分隔符(/)必須用來指示層級(jí)關(guān)系
URI的路徑中的正斜杠(/)字符用于指示資源之間的層次關(guān)系。
例如:
(http://api.canvas.com/shapes/polygons/quadrilaterals/squares ;
規(guī)則3:應(yīng)使用連字符( - )來提高URI的可讀性
為了使您的URI容易讓人們理解,請(qǐng)使用連字符( - )字符來提高長路徑中名稱的可讀性。在路徑中,應(yīng)該使用連字符代空格連接兩個(gè)單詞 。
例如:
http://api.example.com/blogs/guy-levin/posts/this-is-my-first-post
規(guī)則4:不得在URI中使用下劃線(_)
一些文本查看器為了區(qū)分強(qiáng)調(diào)URI,常常會(huì)在URI下加上下劃線。這樣下劃線(_)字符可能被文本查看器中默認(rèn)的下劃線部分地遮蔽或完全隱藏。
為避免這種混淆,請(qǐng)使用連字符( - )而不是下劃線
規(guī)則5:URI路徑中首選小寫字母
方便時(shí),URI路徑中首選小寫字母,因?yàn)榇髮懽帜赣袝r(shí)會(huì)導(dǎo)致一些問題。RFC 3986將URI定義為區(qū)分大小寫,但scheme 和 host components除外。
例如:
http://api.example.com/my-folder/my-doc
HTTP://API.EXAMPLE.COM/my-folder/my-doc
這個(gè)URI很好。URI格式規(guī)范(RFC 3986)認(rèn)為該URI與URI#1相同。
http://api.example.com/My-Folder/my-doc
而這個(gè)URI與URI 1和2不同,這可能會(huì)導(dǎo)致不必要的混淆。
規(guī)則6:文件擴(kuò)展名不應(yīng)包含在URI中
在Web上,(.)字符通常用于分隔URI的文件名和擴(kuò)展名。
REST API不應(yīng)在URI中包含人造文件擴(kuò)展名,來指示郵件實(shí)體的格式。相反,他們應(yīng)該依賴通過Content-Type中的header傳遞media type,來確定如何處理正文的內(nèi)容。
http://api.college.com/students/3248234/courses/2005/fall.json
http://api.college.com/students/3248234/courses/2005/fall
如上所示:不應(yīng)使用文件擴(kuò)展名來表示格式。
應(yīng)鼓勵(lì)REST API客戶端使用HTTP提供的格式選擇機(jī)制Accept request header。
為了是鏈接和調(diào)試更簡單,REST API應(yīng)該支持通過查詢參數(shù)來支持媒體類型的選擇。
規(guī)則7:端點(diǎn)名稱是單數(shù)還是復(fù)數(shù)?
keep-it-simple的原則在這里同樣適用。雖然一些”語法學(xué)家”會(huì)告訴你使用復(fù)數(shù)來描述資源的單個(gè)實(shí)例是錯(cuò)誤的,但實(shí)際上為了保持URI格式的一致性建議使用復(fù)數(shù)形式。
本著API提供商更容易實(shí)施和API使用者更容易操作的原則,可以不必糾結(jié)一些奇怪的復(fù)數(shù)(person/people,goose/geese)。
但是應(yīng)該怎么處理層級(jí)關(guān)系呢?如果一個(gè)關(guān)系只能存在于另一個(gè)資源中,RESTful原則就會(huì)提供有用的指導(dǎo)。我們來看一下這個(gè)例子。學(xué)生有一些課程。這些課程在邏輯上映射到學(xué)生終端,如下所示:
http://api.college.com/students/3248234/courses - 檢索id為3248234的學(xué)生學(xué)習(xí)的所有課程的清單。
http://api.college.com/students/3248234/courses/physics -檢索該學(xué)生的物理課程
結(jié)論
當(dāng)你在設(shè)計(jì)REST API服務(wù)時(shí),您必須注意這些由URI定義的資源。
正在構(gòu)建的服務(wù)中的每個(gè)資源將至少有一個(gè)URI標(biāo)識(shí)它。這個(gè)URI最好是有意義的,且能充分描述資源。URI應(yīng)遵循可預(yù)測(cè)的層次結(jié)構(gòu),用來提高其可理解性,可用性:可預(yù)測(cè)的意義在于它們是一致的,它的層次結(jié)構(gòu)在數(shù)據(jù)關(guān)系上是有意義的。
RESTful API是為使用者編寫的。URI的名稱和結(jié)構(gòu)應(yīng)該能夠向使用者傳達(dá)更清晰的含義。通過遵循上述規(guī)則,您將創(chuàng)建一個(gè)更清晰的的REST API與更友好的客戶端。這些并不是REST的規(guī)則或約束,僅僅是API的增強(qiáng)和補(bǔ)充。
我也建議你來看看http://blog.restcase.com/5-basic-rest-api-design-guidelines/這篇文章。
最后,望大家牢記:你在為你的客戶端設(shè)計(jì)API URI,而不僅僅是為你的數(shù)據(jù)。
posted @
2017-06-26 09:50 華夢(mèng)行 閱讀(226) |
評(píng)論 (0) |
編輯 收藏
* this.getClass().getClassLoader().getResourceAsStream("testVariables.bpmn")
從classpath根目錄下加載指定名稱的文件
* this.getClass().getResourceAsStream("testVariables.bpmn")
從當(dāng)前包下加載指定名稱的文件
* this.getClass().getResourceAsStream("/testVariables.bpmn")
從classpath根目錄下加載指定名稱的文件
posted @
2017-06-19 14:45 華夢(mèng)行 閱讀(117) |
評(píng)論 (0) |
編輯 收藏
package org.gdharley.activiti.integration.rest;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.delegate.JavaDelegate;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContextBuilder;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpMethod;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
/**
* Created by gharley on 5/2/17.
*/
public class SimpleRestDelegate implements JavaDelegate {
private static final Logger logger = LoggerFactory.getLogger(SimpleRestDelegate.class);
protected Expression endpointUrl;
protected Expression httpMethod;
protected Expression isSecure;
protected Expression payload;
// 一個(gè)Content-Type是application/json的請(qǐng)求,具體看起來是這樣的:
// POST /some-path HTTP/1.1
// Content-Type: application/json
//
// { "foo" : "bar", "name" : "John" }
//
//
// { "foo" : "bar", "name" : "John" } 就是這個(gè)請(qǐng)求的payload
protected Expression headers;
protected Expression responseMapping;
protected ObjectMapper objectMapper = new ObjectMapper();
// Create a mixin to force the BasicNameValuePair constructor
protected static abstract class BasicNameValuePairMixIn {
private BasicNameValuePairMixIn(@JsonProperty("name") String name, @JsonProperty("value") String value) {
}
}
public void execute(DelegateExecution execution) throws Exception {
logger.info("Started Generic REST call delegate");
if (endpointUrl == null || httpMethod == null) {
throw new IllegalArgumentException("An endpoint URL and http method are required");
}
String restUrl = getExpressionAsString(endpointUrl, execution);
String payloadStr = getExpressionAsString(payload, execution);
String headersJSON = getExpressionAsString(headers, execution); // [{"name":"headerName", "value":"headerValue"}]
String method = getExpressionAsString(httpMethod, execution);
String rMapping = getExpressionAsString(responseMapping, execution);
String secure = getExpressionAsString(isSecure, execution);
String scheme = secure == "true" ? "https" : "http";
// validate URI and create create request
URI restEndpointURI = composeURI(restUrl, execution);
logger.info("Using Generic REST URI " + restEndpointURI.toString());
HttpRequestBase httpRequest = createHttpRequest(restEndpointURI, scheme, method, headersJSON, payloadStr, rMapping);
// create http client
CloseableHttpClient httpClient = createHttpClient(httpRequest, scheme, execution);
// execute request
HttpResponse response = executeHttpRequest(httpClient, httpRequest);
// map response to process instance variables
if (responseMapping != null) {
mapResponse(response, rMapping, execution);
}
logger.info("Ended Generic REST call delegate");
}
protected URI composeURI(String restUrl, DelegateExecution execution)
throws URISyntaxException {
URIBuilder uriBuilder = null;
uriBuilder = encodePath(restUrl, uriBuilder);
return uriBuilder.build();
}
protected URIBuilder encodePath(String restUrl, URIBuilder uriBuilder) throws URISyntaxException {
if (StringUtils.isNotEmpty(restUrl)) {
// check if there are URL params
if (restUrl.indexOf('?') > -1) {
List<NameValuePair> params = URLEncodedUtils.parse(new URI(restUrl), "UTF-8");
if (params != null && !params.isEmpty()) {
restUrl = restUrl.substring(0, restUrl.indexOf('?'));
uriBuilder = new URIBuilder(restUrl);
uriBuilder.addParameters(params);
}
} else {
uriBuilder = new URIBuilder(restUrl);
}
}
return uriBuilder;
}
protected HttpRequestBase createHttpRequest(URI restEndpointURI, String scheme, String httpMethod, String headers, String payload, String responseMapping) {
if (StringUtils.isEmpty(httpMethod)) {
throw new ActivitiException("no HTTP method provided");
}
if (restEndpointURI == null) {
throw new ActivitiException("no REST endpoint URI provided");
}
HttpRequestBase httpRequest = null;
HttpMethod parsedMethod = HttpMethod.valueOf(httpMethod.toUpperCase());
StringEntity input;
URIBuilder builder = new URIBuilder(restEndpointURI);
switch (parsedMethod) {
case GET:
try {
httpRequest = new HttpGet(builder.build());
httpRequest = addHeadersToRequest(httpRequest, headers);
} catch (URISyntaxException use) {
throw new ActivitiException("Error while building GET request", use);
}
break;
case POST:
try {
httpRequest = new HttpPost(builder.build());
input = new StringEntity(payload);
// input.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
((HttpPost) httpRequest).setEntity(input);
httpRequest = addHeadersToRequest(httpRequest, headers);
break;
} catch (Exception e) {
throw new ActivitiException("Error while building POST request", e);
}
case PUT:
try {
httpRequest = new HttpPut(builder.build());
input = new StringEntity(payload);
// input.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
((HttpPut) httpRequest).setEntity(input);
httpRequest = addHeadersToRequest(httpRequest, headers);
break;
} catch (Exception e) {
throw new ActivitiException("Error while building PUT request", e);
}
case DELETE:
try {
httpRequest = new HttpDelete(builder.build());
httpRequest = addHeadersToRequest(httpRequest, headers);
} catch (URISyntaxException use) {
throw new ActivitiException("Error while building DELETE request", use);
}
break;
default:
throw new ActivitiException("unknown HTTP method provided");
}
return httpRequest;
}
protected CloseableHttpClient createHttpClient(HttpRequestBase request, String scheme, DelegateExecution execution) {
SSLConnectionSocketFactory sslsf = null;
// Allow self signed certificates and hostname mismatches.
if (StringUtils.equalsIgnoreCase(scheme, "https")) {
try {
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
sslsf = new SSLConnectionSocketFactory(builder.build(), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} catch (Exception e) {
logger.warn("Could not configure HTTP client to use SSL", e);
}
}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
if (sslsf != null) {
httpClientBuilder.setSSLSocketFactory(sslsf);
}
return httpClientBuilder.build();
}
protected HttpResponse executeHttpRequest(CloseableHttpClient httpClient, HttpRequestBase httpRequest) {
CloseableHttpResponse response = null;
try {
response = httpClient.execute(httpRequest);
} catch (IOException e) {
throw new ActivitiException("error while executing http request: " + httpRequest.getURI(), e);
}
if (response.getStatusLine().getStatusCode() >= 400) {
throw new ActivitiException("error while executing http request " + httpRequest.getURI() + " with status code: "
+ response.getStatusLine().getStatusCode());
}
return response;
}
protected void mapResponse(HttpResponse response, String responseMapping, DelegateExecution execution) {
if (responseMapping == null || responseMapping.trim().length() == 0) {
return;
}
JsonNode jsonNode = null;
try {
String jsonString = EntityUtils.toString(response.getEntity());
jsonNode = objectMapper.readTree(jsonString);
} catch (Exception e) {
throw new ActivitiException("error while parsing response", e);
}
if (jsonNode == null) {
throw new ActivitiException("didn't expect an empty response body");
}
execution.setVariable(responseMapping, jsonNode.toString());
}
protected HttpRequestBase addHeadersToRequest(HttpRequestBase httpRequest, String headerJSON) {
Boolean contentTypeDetected = false;
if (headerJSON != null) {
// Convert JSON to array
try {
// configuration for Jackson/fasterxml
objectMapper.addMixInAnnotations(BasicNameValuePair.class, BasicNameValuePairMixIn.class);
NameValuePair[] headers = objectMapper.readValue(headerJSON, BasicNameValuePair[].class);
for (NameValuePair header : headers) {
httpRequest.addHeader(header.getName(), header.getValue());
if (header.getName().equals(HTTP.CONTENT_TYPE)) {
contentTypeDetected = true;
}
}
} catch (Exception e) {
throw new ActivitiException("Unable to parse JSON header array", e);
}
}
// Now add content type if necessary
if (!contentTypeDetected) {
httpRequest.addHeader(HTTP.CONTENT_TYPE, "application/json");
}
return httpRequest;
}
/**
* @return string value of expression.
* @throws {@link IllegalArgumentException} when the expression resolves to a value which is not a string
* or if the value is null.
*/
protected String getExpressionAsString(Expression expression, DelegateExecution execution) {
if (expression == null) {
return null;
} else {
Object value = expression.getValue(execution);
if (value instanceof String) {
return (String) value;
} else {
throw new IllegalArgumentException("Expression does not resolve to a string or is null: " + expression.getExpressionText());
}
}
}
}
posted @
2017-05-26 08:01 華夢(mèng)行 閱讀(231) |
評(píng)論 (0) |
編輯 收藏
1、概述
activiti系統(tǒng)一共有23個(gè)表,包括流程定義表、一般數(shù)據(jù)信息表、流程運(yùn)行實(shí)例表、流程歷史記錄表、用戶用戶組表。
2、Activiti 流程定義表
流程定義表,流程定義表也可以叫做是靜態(tài)資源庫,靜態(tài)資源包括圖片、定義規(guī)則等。它有部署信息表、流程模型表、流程定義表
1、ACT_RE_DEPLOYMENT(部署信息表)
包括:部署流程名稱、類型、部署時(shí)間
2、ACT_RE_MODEL(模型表)
名稱,key、類型、創(chuàng)建時(shí)間、最后修改時(shí)間、版本、數(shù)據(jù)源信息、部署ID、編輯源值ID、編輯源額外值ID(外鍵ACT_GE_BYTEARRAY )
3、ACT_RE_PROCDEF(流程定義表)
包括流程定義、類型、流程名稱、流程key、版本號(hào)、部署ID、資源名稱、圖片資源名稱、描述信息、是否從key啟動(dòng)、暫停狀態(tài)。
3、Activiti 運(yùn)行實(shí)例表
運(yùn)行實(shí)例表記錄流程流轉(zhuǎn)過程中產(chǎn)生的數(shù)據(jù),一般數(shù)據(jù)分為兩個(gè)部分流程數(shù)據(jù)、業(yè)務(wù)數(shù)據(jù)。流程數(shù)據(jù)是指activiti流程引擎流轉(zhuǎn)過程中的數(shù)據(jù),包括流程執(zhí)行實(shí)例數(shù)據(jù)接、任務(wù)數(shù)據(jù)、執(zhí)行任務(wù)人員信息、變量信息。業(yè)務(wù)數(shù)據(jù)則是流程過程中保存的表單數(shù)據(jù),例如:如請(qǐng)假的請(qǐng)假單數(shù)據(jù)、報(bào)銷單數(shù)據(jù)、審批意見信息等,此部分?jǐn)?shù)據(jù)一般需要自己建數(shù)據(jù)表進(jìn)行保存,在之前的jbpm4中沒有保存業(yè)務(wù)數(shù)據(jù)。
1、ACT_RU_EVENT_SUBSCR(事件子腳本)作用未知
事件名稱(EVENT_NAME_)、事件類型(EVENT_TYPE_)、流程執(zhí)行ID(EXECUTION_ID_)、流程實(shí)例ID(PROC_INST_ID_)、活動(dòng)ID(ACTIVITY_ID_)、配置信息(CONFIGURATION_)、創(chuàng)建時(shí)間(CREATED_)
2、ACT_RU_EXECUTION(執(zhí)行中流程執(zhí)行)核心我的代辦任務(wù)查詢表
流程實(shí)例ID(PROC_INST_ID_),業(yè)務(wù)key(BUSINESS_KEY_)、父執(zhí)行流程(PARENT_ID_)、流程定義Id(外鍵PROC_DEF_ID_)、實(shí)例id(ACT_ID_)、激活狀態(tài)(IS_ACTIVE_)、并發(fā)狀態(tài)(is_concurrent)、is_scope、is_evnet_scope、暫停狀態(tài)(suspension_state)、緩存結(jié)束狀態(tài)(cached_end_state)
3、ACT_RU_IDENTITYLINK(身份聯(lián)系)
用戶組ID(GROUP_ID_)、用戶組類型(TYPE_)、用戶ID(USER_ID_)、任務(wù)Id(外鍵:TASK_ID_)、流程實(shí)例ID(外鍵:PROC_INST_ID_)、流程定義Id(外鍵:PROC_DEF_ID_)
4、ACT_RU_JOB(運(yùn)行中的任務(wù))
5、ACT_RU_TASK(執(zhí)行中實(shí)時(shí)任務(wù))代辦任務(wù)查詢表
實(shí)例id(外鍵EXECUTION_ID_)、流程實(shí)例ID(外鍵PROC_INST_ID_)、流程定義ID(PROC_DEF_ID_)、任務(wù)名稱(NAME_)、父節(jié)任務(wù)ID(PARENT_TASK_ID_)
、任務(wù)描述(DESCRIPTION_)、任務(wù)定義key(TASK_DEF_KEY_)、所屬人(OWNER_)、代理人員 (ASSIGNEE_)、代理團(tuán)(DELEGATION_)、優(yōu)先權(quán)(PRIORITY_)、創(chuàng)建時(shí)間(CREATE_TIME_)、執(zhí)行時(shí)間(DUE_DATE_)、暫停狀態(tài)(SUSPENSION_STATE_)
6、ACT_RU_VARIABLE(實(shí)時(shí)變量)
變量名稱(NAME_)、編碼類型(TYPE_)、執(zhí)行實(shí)例ID(EXECUTION_ID_)、流程實(shí)例Id(PROC_INST_ID_)、任務(wù)id(TASK_ID_)、字節(jié)組ID(BYTEARRAY_ID_)、DOUBLE_、LONG_、TEXT_、TEXT2_
3、流程歷史記錄
流程歷史信息表,activiti歷史記錄表包括節(jié)點(diǎn)信息表、附件信息表、歷史審批記錄表、理想詳細(xì)信息表、歷史身份信息表、流程實(shí)例歷史表、任務(wù)歷史表、歷史變量表。(節(jié)點(diǎn)信息表、附件信息表、歷史審批記錄表、理想詳細(xì)信息表、歷史身份信息表)這些表目前還未知是如何用的。(流程實(shí)例歷史表、任務(wù)歷史表、歷史變量)三個(gè)表可以查詢我已完成任務(wù)、任務(wù)追蹤等。
1、ACT_HI_ACTINST(活動(dòng)實(shí)例信息)
流程定義ID(PROC_DEF_ID_)、流程實(shí)例ID(PROC_INST_ID_)、流程執(zhí)行ID(EXECUTION_ID_)、活動(dòng)ID(ACT_ID_)、活動(dòng)名稱(TASK_ID_)、活動(dòng)類型(ACT_TYPE_)、任務(wù)ID、(TASK_ID_)、請(qǐng)求流程實(shí)例ID(CALL_PROC_INST_ID_)、代理人員(ASSIGNEE_)、開始時(shí)間(START_TIME_)、結(jié)束時(shí)間(END_TIME_)、時(shí)長(DURATION_)
2、ACT_HI_ATTACHMENT(附件信息)
用戶id(USER_ID_)、名稱(NAME_)、描述(DESCRIPTION_)、類型(TYPE_)、任務(wù)Id(TASK_ID_)、流程實(shí)例ID(PROC_INST_ID_)、連接(URL_)、內(nèi)容Id(CONTENT_ID_)
3、ACT_HI_COMMENT(歷史審批信息)
類型(TYPE_)、時(shí)間(TIME_)、用戶Id(USER_ID_)、任務(wù)Id(TASK_ID_)、流程實(shí)例Id(PROC_INST_ID_)、活動(dòng)(ACTION_)、消息(MESSAGE_)、全部消息(FULL_MSG_)
4、ACT_HI_DETAIL(歷史詳細(xì)信息)
數(shù)據(jù)類型(TYPE_)、創(chuàng)建時(shí)間(TIME_)、名稱(NAME_)、流程實(shí)例ID(PROC_INST_ID_)、執(zhí)行實(shí)例Id(EXECUTION_ID_)、任務(wù)Id(TASK_ID_)、活動(dòng)實(shí)例Id(ACT_INST_ID_)、變量類型(VAR_TYPE_)、字節(jié)數(shù)組Id、DOUBLE_、LONG_、值(TEXT_)、值2(TEXT2_)
5、ACT_HI_IDENTITYLINK(歷史身份信息)
任務(wù)Id(TASK_ID_)、流程實(shí)例Id(PROC_INST_ID_)、userId(USER_ID_)、用戶組類型Type(TYPE_)、用戶組ID(GROUP_ID_)
6、ACT_HI_PROCINST(歷史流程實(shí)例信息)核心表
流程實(shí)例ID(PROC_INST_ID_)、業(yè)務(wù)Key(BUSINESS_KEY_)、流程定義Id(PROC_DEF_ID_)、開始時(shí)間(START_TIME_)、結(jié)束時(shí)間(END_TIME_)、時(shí)長(DURATION_)、發(fā)起人員Id(START_USER_ID_)、開始節(jié)點(diǎn)(START_ACT_ID_)、結(jié)束節(jié)點(diǎn)(END_ACT_ID_)、超級(jí)流程實(shí)例Id(SUPER_PROCESS_INSTANCE_ID_)、刪除理由(DELETE_REASON_)
7、ACT_HI_TASKINST(歷史任務(wù)流程實(shí)例信息)核心表
流程實(shí)例ID(PROC_INST_ID_)、任務(wù)定義Key(BUSINESS_KEY_)、流程定義Id(PROC_DEF_ID_)、執(zhí)行ID(EXECUTION_ID_)、名稱(NAME_)、父任務(wù)iD(PARENT_TASK_ID_)、描述(DESCRIPTION_)、所屬人(OWNER_)、代理人(ASSIGNEE_)、開始時(shí)間(START_TIME_)、結(jié)束時(shí)間(END_TIME_)、時(shí)長(DURATION_)、刪除理由(DELETE_REASON__)、優(yōu)先級(jí)(PRIORITY_)、應(yīng)完成時(shí)間(DUE_DATE_)、表單key(FORM_KEY_)
8、ACT_HI_VARINST(歷史變量信息)
流程實(shí)例ID(PROC_INST_ID_)、執(zhí)行ID(EXECUTION_ID_)、任務(wù)Id、名稱(NAME_)、變量(TASK_ID_)、類型(VAR_TYPE_)、字節(jié)數(shù)組ID(BYTEARRAY_ID_)、DOUBLE_、LONG_、TEXT_、TEXT2_
4、一般數(shù)據(jù)
1、ACT_GE_BYTEARRAY(字節(jié)數(shù)據(jù)表)
名稱(NAME_)、部署Id(DEPLOYMENT_ID_)、字節(jié)數(shù)據(jù)(BYTES_)、發(fā)生的(GENERATED_)
2、ACT_GE_PROPERTY(一般屬性表)
名稱(NAMe_)、值(VALUe_)
5、用戶用戶組表
Activit 的用戶用戶組表,包括用戶信息、用戶組信息、用戶與用戶組間的關(guān)系、用戶信息與用戶之間的關(guān)系。在實(shí)際開發(fā)中未采用,用的實(shí)際系統(tǒng)中用戶。
1、ACT_ID_GROUP(用戶組表)
名稱(NAME_)、類型(TYPE_)
2、ACT_ID_USER(用戶表)
姓(FIRST_)、名稱(LAST_)、郵件(EMAIL_)、密碼(PWD_)、頭像Id (PICTURE_ID_)
3、ACT_ID_INFO(用戶信息表)
用戶Id(USER_ID_)、類型(TYPE_)、formINPut名稱(KEY_)、值(VALUE_)、密碼(PASSWORD_)、父節(jié)點(diǎn)(PARENT_ID_)
4、ACT_ID_MEMBERSHIP(用戶用戶組關(guān)聯(lián)表)
用戶Id(user_ID_)、用戶組Id(group_Id)
Activiti表結(jié)構(gòu)分析完成,花了5個(gè)小時(shí),還有很多問題不明白。后續(xù)慢慢開發(fā)過程中再理一次表之間關(guān)系吧,初步想法在系統(tǒng)中需要擴(kuò)建表,把業(yè)務(wù)數(shù)據(jù)和流程數(shù)據(jù)分開。
posted @
2017-05-16 16:31 華夢(mèng)行 閱讀(2120) |
評(píng)論 (0) |
編輯 收藏
摘要: Activiti工作流引擎數(shù)據(jù)庫表結(jié)構(gòu)
數(shù)據(jù)庫表的命名
Acitiviti數(shù)據(jù)庫中表的命名都是以ACT_開頭的。第二部分是一個(gè)兩個(gè)字符用例表的標(biāo)識(shí)。此用例大體與服務(wù)API是匹配的。
l ACT_RE_*:’RE’表示repository。帶此前綴的表包含的是靜態(tài)信息,如,流程定義,流程的資源(圖片,規(guī)則等)。
l ACT_RU_*:̵...
閱讀全文
posted @
2017-05-15 22:23 華夢(mèng)行 閱讀(230) |
評(píng)論 (0) |
編輯 收藏
@Transient
可選
@Transient表示該屬性并非一個(gè)到數(shù)據(jù)庫表的字段的映射,ORM框架將忽略該屬性.
如果一個(gè)屬性并非數(shù)據(jù)庫表的字段映射,就務(wù)必將其標(biāo)示為@Transient,否則,ORM框架默認(rèn)其注解為@Basic
示例:
//根據(jù)birth計(jì)算出age屬性
@Transient
public int getAge() {
return getYear(new Date()) - getYear(birth);
}
注意是加在get方法上的
posted @
2017-05-10 16:59 華夢(mèng)行 閱讀(1094) |
評(píng)論 (0) |
編輯 收藏
Snmpwalk –v 2 –c public 192.168.20.114 1.3.6.1.2.1.2.2.1.3
snmpget -r:127.0.0.1 -o:.1.3.6.1.2.1.25.3.3.1.2
E:\>snmpget -r:127.0.0.1 -o:.1.3.6.1.2.1.1.1.0
SnmpGet v1.01 - Copyright (C) 2009 SnmpSoft Company
[ More useful network tools on http://www.snmpsoft.com ]
OID=.1.3.6.1.2.1.1.1.0
Type=OctetString
Value=Hardware: Intel64 Family 6 Model 60 Stepping 3 AT/AT COMPATIBLE - Software
: Windows Version 6.1 (Build 7601 Multiprocessor Free)
snmpwalk -v:2c -c:public -r:127.0.0.1
posted @
2017-03-22 15:28 華夢(mèng)行 閱讀(134) |
評(píng)論 (0) |
編輯 收藏
Druid是什么?
Druid是一個(gè)JDBC組件,它包括四個(gè)部分:
http://download.csdn.net/download/feelnature/1580901
http://tomcat.apache.org/tomcat-8.5-doc/monitoring.html#Enabling_JMX_Remote
http://download.csdn.net/detail/qq_21163257/9695557
-
DruidDriver 代理Driver,能夠提供基于Filter-Chain模式的插件體系。
-
DruidDataSource 高效可管理的數(shù)據(jù)庫連接池。
-
SQLParser
-
擴(kuò)展組件
-
Binary: http://code.alibabatech.com/mvn/releases/com/alibaba/druid/0.1.2/druid-0.1.2.jar
-
Source: http://code.alibabatech.com/mvn/releases/com/alibaba/druid/0.1.2/druid-0.1.2-sources.jar
Druid可以做什么?
-
可以監(jiān)控?cái)?shù)據(jù)庫訪問性能,Druid內(nèi)置提供了一個(gè)功能強(qiáng)大的StatFilter插件,能夠詳細(xì)統(tǒng)計(jì)SQL的執(zhí)行性能,這對(duì)于線上分析數(shù)據(jù)庫訪問性能有幫助。
-
替換DBCP和C3P0。Druid提供了一個(gè)高效、功能強(qiáng)大、可擴(kuò)展性好的數(shù)據(jù)庫連接池。
-
數(shù)據(jù)庫密碼加密。直接把數(shù)據(jù)庫密碼寫在配置文件中,這是不好的行為,容易導(dǎo)致安全問題。DruidDruiver和DruidDataSource都支持PasswordCallback。
-
SQL執(zhí)行日志,Druid提供了不同的LogFilter,能夠支持Common-Logging、Log4j和JdkLog,你可以按需要選擇相應(yīng)的LogFilter,監(jiān)控你應(yīng)用的數(shù)據(jù)庫訪問情況。
-
擴(kuò)展JDBC,如果你要對(duì)JDBC層有編程的需求,可以通過Druid提供的Filter機(jī)制,很方便編寫JDBC層的擴(kuò)展插件。
DruidDriver,是一個(gè)ProxyJdbcDriver,它提供了Filter-Chain模式的擴(kuò)展機(jī)制,使得在Jdbc擴(kuò)展編程特別方便。
Druid提供了一些內(nèi)置的擴(kuò)展機(jī)制,包括Stat、Log、Trace、HA等擴(kuò)展。
DruidDataSource是一個(gè)數(shù)據(jù)庫連接池的實(shí)現(xiàn),它的設(shè)計(jì)目標(biāo)是提供一個(gè)當(dāng)前最好的數(shù)據(jù)庫連接池,在性能、擴(kuò)展性等方面取得最合適的平衡,取代DBCP、C3P0等連接池。
-
高性能。測(cè)試數(shù)據(jù)表明,Druid比DBCP、C3P0、BoneCP的性能都好很多。具體請(qǐng)看測(cè)試數(shù)據(jù)
-
可管理性,DruidDataSource本身提供了很多監(jiān)控屬性,具體看這里。DruidDataSource支持StatFilter,具體配置看 這里
-
可擴(kuò)展性,提供基于Filter-Chain模式的擴(kuò)展機(jī)制。具體自定義擴(kuò)展的例子看這里。
-
替換DBCP,配置和DBCP兼容,可以方便替換DBCP。
-
適合大規(guī)模應(yīng)用。結(jié)合Alibaba使用數(shù)據(jù)庫連接池的經(jīng)驗(yàn),避免一些已知問題,例如數(shù)據(jù)庫不可用恢復(fù)之后產(chǎn)生的連接風(fēng)暴問題等。
設(shè)計(jì)
這是DruidDataSource的設(shè)計(jì)圖示:
http://code.alibabatech.com/svn/druid/trunk/doc/druid-pool.txt
如果發(fā)現(xiàn)有亂碼,請(qǐng)選擇utf-8的編碼方式查看。
Druid提供一個(gè)手工編寫的高性能的方便擴(kuò)展的SQL Parser。將會(huì)支持MySQL、Oracle等流行關(guān)系數(shù)據(jù)庫的SQL Parser。
Parser組件包括如下幾個(gè)部分:
-
Lexer 詞法解析
-
Parser,Parser包括ExprParser,各種StatementParser。
-
AST, Abstract Syntax Tree。ParserParse出來的結(jié)果就是AST。
-
Visitor。對(duì)AST做各種處理,比如FormatOutput,遍歷等等。
簡介
Druid提供了強(qiáng)大的監(jiān)控功能,能夠監(jiān)控連接池行為和SQL執(zhí)行情況,讓你能夠詳細(xì)了解應(yīng)用的數(shù)據(jù)庫訪問行為。
監(jiān)控對(duì)象
-
Druid的統(tǒng)計(jì)信息定義代碼實(shí)現(xiàn)在com/alibaba/druid/stat下。所有的Stat都全局靜態(tài)變量的方式保存,這樣做使得外部獲取監(jiān)控信息更容易。
-
獲取Druid監(jiān)控信息的入口是com.alibaba.druid.stat.JdbcStatManager
-
Druid的監(jiān)控統(tǒng)計(jì)信息都是通過StatFilter來實(shí)現(xiàn)的,如果你需要數(shù)據(jù)源進(jìn)行監(jiān)控,那你需要啟用StatFilter
posted @
2017-03-21 00:11 華夢(mèng)行 閱讀(277) |
評(píng)論 (0) |
編輯 收藏
http://repo.spring.io/release/org/springframework/spring/4.3.6.RELEASE/
http://spring.io/tools/sts
http://www.loveweir.com/posts/view/19
https://github.com/rahulyewale/springmvcjpa
http://download.csdn.net/download/jiuqiyuliang/8640621
http://blog.csdn.net/suzunshou/article/details/49949005
https://repo1.maven.org/maven2/org/mybatis/mybatis/
http://blog.csdn.net/jiuqiyuliang/article/details/45132493/
https://github.com/mybatis/generator/releases
posted @
2017-03-19 22:39 華夢(mèng)行 閱讀(149) |
評(píng)論 (0) |
編輯 收藏
今天從windows上導(dǎo)出一個(gè)sql執(zhí)行文件,再倒入到unbutn中,結(jié)果出現(xiàn)亂碼,折騰7-8分鐘,
解決方式
在導(dǎo)出mysql sql執(zhí)行文件的時(shí)候,指定一下編碼格式:
復(fù)制代碼 代碼如下:
mysqldump -uroot -p --default-character-set=utf8 mo(dbname) > E://xxxx.sql
導(dǎo)入的時(shí)候OK了
執(zhí)行如下
復(fù)制代碼 代碼如下:
mysql -u root -p --default-character-set=utf8
use dbname
source /root/newsdata.sql
posted @
2016-07-21 13:33 華夢(mèng)行 閱讀(130) |
評(píng)論 (0) |
編輯 收藏
CentOS
1、備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下載新的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
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之后運(yùn)行yum makecache生成緩存
相關(guān)鏈接
##官方主頁: http://www.centos.org/
##郵件列表: http://www.centos.org/modules/tinycontent/index.php?id=16
##論壇: http://www.centos.org/modules/newbb/
##文檔: http://www.centos.org/docs/
##Wiki: http://wiki.centos.org/
posted @
2016-06-27 17:42 華夢(mèng)行 閱讀(141) |
評(píng)論 (0) |
編輯 收藏
對(duì)輸入數(shù)據(jù)進(jìn)行正態(tài)化
為了使神經(jīng)網(wǎng)絡(luò)有效,我們必須對(duì)數(shù)據(jù)進(jìn)行正態(tài)化。這是激活函數(shù)的正確計(jì)算所需要的。正態(tài)化是一種數(shù)學(xué)處理,將數(shù)據(jù)轉(zhuǎn)換為 0..1 或 -1..1 的范圍。正態(tài)化后的數(shù)據(jù)可以進(jìn)行去正態(tài)化,即轉(zhuǎn)換回原來的范圍。
要將神經(jīng)網(wǎng)絡(luò)輸出解碼為人類可讀的形式,需要對(duì)數(shù)據(jù)進(jìn)行去正態(tài)化。謝天謝地,負(fù)責(zé)標(biāo)準(zhǔn)化和去標(biāo)準(zhǔn)化,因此不需要實(shí)施它。如果您對(duì)它的工作原理感到好奇,您可以分析以下代碼:
public static double INPUT_LOW = -20;
public static double INPUT_HIGH = 20;
public static double OUTPUT_HIGH = 1;
public static double OUTPUT_LOW = -1;
public static double normalize(final double value) {
return ((value - INPUT_LOW) / (INPUT_HIGH - INPUT_LOW))
* (OUTPUT_HIGH - OUTPUT_LOW) + OUTPUT_LOW;
// return ((10f + 20f) / (40f)) * (2f) + OUTPUT_LOW;
}
public static double deNormalize(final double data) {
double result = ((INPUT_LOW - INPUT_HIGH) * data - OUTPUT_HIGH
* INPUT_LOW + INPUT_HIGH * OUTPUT_LOW)
/ (OUTPUT_LOW - OUTPUT_HIGH);
return result;
}
x=-5:.01:5;
plot(x,tanh(x)),grid on;
posted @
2016-05-11 18:27 華夢(mèng)行 閱讀(233) |
評(píng)論 (0) |
編輯 收藏
1. Quickstart
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:
- Create your Scheduler instance.
- Schedule your actions. To schedule an action you have to tell the scheduler what it has to do and when. You can specify what using a java.lang.Runnable or a it.sauronsoftware.cron4j.Task instance, and you can specify when using a scheduling pattern, which can be represented with a string or with a it.sauronsoftware.cron4j.SchedulingPattern instance.
- Starts the scheduler.
- Stops the scheduler, when you don't need it anymore.
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:
- You can schedule how many tasks you want.
- You can schedule a task when you want, also after the scheduler has been started.
- You can change the scheduling pattern of an already scheduled task, also while the scheduler is running (reschedule operation).
- You can remove a previously scheduled task, also while the scheduler is running (deschedule operation).
- You can start and stop a scheduler how many times you want.
- You can schedule from a file.
- You can schedule from any source you want.
- You can supply listeners to the scheduler in order to receive events about the executed task.
- You can control any ongoing task.
- You can manually launch a task, without using a scheduling pattern.
- You can change the scheduler working Time Zone.
- You can validate your scheduling patterns before using them with the scheduler.
- You can predict when a scheduling pattern will cause a task execution.
Back to index
2. Scheduling patterns
A UNIX crontab-like pattern is a string split in five space separated parts. Each part is intended as:
- Minutes sub-pattern. During which minutes of the hour should the task been launched? The values range is from 0 to 59.
- Hours sub-pattern. During which hours of the day should the task been launched? The values range is from 0 to 23.
- Days of month sub-pattern. During which days of the month should the task been launched? The values range is from 1 to 31. The special value "L" can be used to recognize the last day of month.
- Months sub-pattern. During which months of the year should the task been launched? The values range is from 1 (January) to 12 (December), otherwise this sub-pattern allows the aliases "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov" and "dec".
- Days of week sub-pattern. During which days of the week should the task been launched? The values range is from 0 (Sunday) to 6 (Saturday), otherwise this sub-pattern allows the aliases "sun", "mon", "tue", "wed", "thu", "fri" and "sat".
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.
Back to index
3. How to schedule, reschedule and deschedule a task
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.
Back to index
4. How to schedule a system process
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"));
5. How to schedule processes from a file
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.
Back to index
6. Building your own task
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.
Back to index
7. Building your own 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.
Back to index
8. Building your own scheduler listener
The it.sauronsoftware.cron4j.SchedulerListener API can be used to listen to scheduler events.
The SchedulerListener interface requires the implementation of the following methods:
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.
Back to index
9. Executors
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.
Back to index
10. Manual task launch
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 "Back to index
11. Working with Time Zones
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:
- System time: 10:00
- System time zone: GMT+1
- Scheduler time zone: GMT+3
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.
Back to index
12. Daemon threads
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.
Back to index
13. Predictor
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()); }
Back to index
14. Cron parser
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]
- scheduling-pattern is a valid scheduling pattern, according with the definition given by the it.sauronsoftware.cron4j.SchedulingPattern class.
- options is a list of optional information used by cron4j to prepare the task execution environment. See below for a more detailed description.
- command is a system valid command, such an executable call.
- args is a list of optional arguments for the command.
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:
- \" - quotation mark
- \\ - back slash
- \/ - slash
- \b - back space
- \f - form feed
- \n - new line
- \r - carriage return
- \t - horizontal tab
- \ufour-hex-digits - the character at the given Unicode index
The options token collection can include one or more of the following elements:
- IN:file-path - Redirects the command standard input channel to the specified file.
- OUT:file-path - Redirects the command standard output channel to the specified file.
- ERR:file-path - Redirects the command standard error channel to the specified file.
- ENV:name=value - Defines an environment variable in the scope of the command.
- DIR:directory-path - Sets the path of the working directory for the command. This feature is not supported if the executing JVM is less than 1.3.
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
posted @
2016-05-07 15:39 華夢(mèng)行 閱讀(2002) |
評(píng)論 (0) |
編輯 收藏
阿里云Linux安裝軟件鏡像源
阿里云是最近新出的一個(gè)鏡像源。得益與阿里云的高速發(fā)展,這么大的需求,肯定會(huì)推出自己的鏡像源。
阿里云Linux安裝鏡像源地址:http://mirrors.aliyun.com/
CentOS系統(tǒng)更換軟件安裝源
第一步:備份你的原鏡像文件,以免出錯(cuò)后可以恢復(fù)。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:下載新的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
第三步:運(yùn)行yum makecache生成緩存
yum clean all
yum makecache
posted @
2016-04-30 21:11 華夢(mèng)行 閱讀(221) |
評(píng)論 (0) |
編輯 收藏