paulwong

#

javaee7-samples

http://git.oschina.net/ld/javaee7-samples

posted @ 2014-04-06 08:33 paulwong 阅读(562) | 评论 (0)编辑 收藏

也谈基于Web的含工作流项目的一般开发流程(转)

该项目包含的通用模块代码等我有时间一并剥离贡献出来(基于WebSocket的通知引擎,工作流整合模块,自定义表单(详见这里),基于RBAC权限设计),最近太忙了,Web项目有一段时间没碰,有点生疏的感觉,主要在忙GQT项目,一套基于桌面开发的框架,详见这里,写代码写的有点手酸的感觉。  

基于Web的含工作流的项目看起来并不如想象的那么简单,主要需求:
  1. 灵活定制工作流,并跟踪流程进度;
  2. 每个Order含有历史轨迹记录,可在历史中查看;
  3. 工作流的Action灵活,认领任务不一定非要先提取表单,因为很多节点都只有几个动作,直接按钮操作即可;
  4. 待办事宜列表在不刷新页面情况下也能变动;
项目要求:
  1. 操作简单高效;
  2. 权限细节到按钮级别;
  3. 并发数少,不超过3000个在线用户;
主要可能使用到技术:
  1. 工作流引擎,我这里选用Activiti5,很灵活好用;
  2. 权限使用Spring Security,基于标签式管理权限很方便;
  3. 通知引擎使用WebSocket,基于Flash实时通信,基于socket.io;
  4. 权限粒度基于经典的RBAC;
  5. 总体框架Spring MVC+Mybatis;
实现的WebSocket的总体思路:
  1. WebSocket Server独立于Web项目,Web Server与WebSocket Server之间的局域网通信基于简单的Socket通信,这样这个组件可以完全解耦和通用;
  2. 当Web项目要Push消息到Client时,通过Web Server的Socket Client向WebSocket Server的Socker Server发送消息,然后WebSocket Server收到消息后解码,广播到所有浏览器;
我们实现的事件通知非常简单,设定全局变量并让浏览器侦听:
var G_WebSocket=false; 
var EVENT_ORDER_CHANGE_STATUS = "orderChange";
var EVENT_ORDER_CHANGE_AMOUNT = "amountChange";
var EVENT_ORDER_CHANGE_REFUND = "refundChange";
WebSocket.init = function(callbackFunc){
socket = io.connect(connUrl, connOptions);
socket.on('connect', function() {
G_WebSocket=true;
callbackFunc("connect",null);
});
socket.on('disconnect', function() {
G_WebSocket=false;
callbackFunc("disconnect",null);
});
socket.on('clientQuit', function(obj){
G_WebSocket=false;
callbackFunc("clientQuit",obj);
});
socket.on('broadcast', function(obj) {
callbackFunc("broadcast",obj);
});
};
 
在需要侦听WebSocket接受Web Server推送消息的地方加上一个函数即可:
	WebSocket.init(function(command,jsonObj){ 
if(command=="broadcast"){
if(jsonObj.e == EVENT_ORDER_CHANGE_STATUS){
//TODO:write your code here
}else if(jsonObj.e == EVENT_ORDER_CHANGE_AMOUNT){
//TODO:write your code here
}else if(jsonObj.e == EVENT_ORDER_CHANGE_REFUND){
//TODO:write your code here
}
}
});

这样的结构要扩展推送服务很简单,比如按频道推送等,都可以很容易的扩展。
再看看看工作流,我们实现了activiti通用的申请提交任务流程和自定义表单功能,提取跟踪流程图功能等,这样你要设计一个新流程也变得非常简单,只需要在eclipse里划上工作流图,在后台发布,然后通过SpringMVC的RestAPI启动实例流程,申领完成任务等,如下图:




流程走到了分支的两个节点上,这样对后续新增的工作流提供了极大的遍历。

最后说说Spring Security,基于RBAC的权限体系搭建好后(可以用在任何管理系统中),要在页面中访问一个资源,首先判断一下是否有权限,如下HTML:


<sec:authorize ifAllGranted="r_pd"> 
<a href="#">resource access here</a>
</sec:authorize>

 

<sec:authorize url="/XXX/XXX/XXX.html"> 
<a href="XXX/XXX/XXX.html'">
<span>XXX功能</span>
</a>
</sec:authorize>

  

前台由于项目比较小,没有用到js的MVC框架,如backbone等,这里就不再记录了。

posted @ 2014-04-04 08:23 paulwong 阅读(552) | 评论 (0)编辑 收藏

LOGBACK TUTORIA

https://github.com/abdulwaheed18/Slf4jTutorial 

http://stackoverflow.com/questions/10465301/tomcat-war-configure-logback-to-use-app-name-in-path

<configuration>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
            </Pattern>
        </encoder>
    </appender>


    <appender name="FILE"
        class
="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>testFile7.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover
            Once any of the below condition met, it will change the file name as below and compressed it. 
-->

            <fileNamePattern>logFile.%d{yyyy-MM-dd}.%i.log.zip
            </fileNamePattern>

            <!-- keep 30 days' worth of history -->
            <maxHistory>30</maxHistory>
            <!-- or whenever the file size reaches 10MB -->
            <timeBasedFileNamingAndTriggeringPolicy
                
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>

        <encoder>
            <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n
            </pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>
</configuration>

posted @ 2014-04-03 08:10 paulwong 阅读(519) | 评论 (0)编辑 收藏

如何在WEB应用中绑定微信公众帐号

http://www.chanzhi.org/book/weixin.html

http://demo.chanzhi.org/chanzhiadmin.php?m=wechat&f=admin

posted @ 2014-04-01 08:41 paulwong 阅读(682) | 评论 (0)编辑 收藏

SPRING中多开发+测试多环境中的资源文件配置

property文件有几份,如
mongo_dev.properties
#intranet
mongo.replicationset=10.120.141.229:27017,10.120.141.226:27017,10.120.141.228:27017
mongo.username=cms
mongo.password=cms

mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true

mongo.debug=true
mongo.trace=true


mongo_test.properties
#internet
mongo.replicationset=10.120.11.221:27017,10.120.11.122:27017,10.120.11.212:27017
mongo.username=cms
mongo.password=cms

mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true

mongo.debug=false
mongo.trace=false

Spring的配置文件中加入
<context:property-placeholder
        
location="classpath*:/properties/mongodb/mongo_${spring.profiles.active}.properties />



#将下面参数放在JVM中,如果是TOMCAT则放在catalina.sh
#开发:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev "

#测试:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=test "

#如果是ECLIPSE中启动TOMCAT,则只需加
-Dspring.profiles.active=dev





posted @ 2014-03-28 10:57 paulwong 阅读(4527) | 评论 (0)编辑 收藏

MYSQL HA资源

http://stackoverflow.com/questions/22495722/mysql-master-slave-replication-connect-to-master-even-for-read-queries-does-d

http://www.dragishak.com/?p=307

http://blog.csdn.net/lixiucheng005/article/details/17391857

http://blog.csdn.net/cutesource/article/details/5710645



posted @ 2014-03-23 22:51 paulwong 阅读(280) | 评论 (0)编辑 收藏

Packt Publishing celebrates their 2000th title with an exclusive offer - We've got IT covered!

Packt Publishing celebrates their 2000th title with an exclusive offer - We've got IT covered!


 


Known for their extensive range of pragmatic IT ebooks, Packt Publishing are celebrating their 2000th book title `Learning Dart’– they want their customers to celebrate too.

To mark this milestone Packt Publishing will launch a ‘Buy One Get One Free’ offer across all eBooks on March 18th – for a limited period only.

Packt is one of the most prolific and fast-growing tech book publishers in the world. Originally focused on open source software, Packt contributes back into the community paying a royalty on relevant books directly to open source projects. These projects have received over $400,000 as part of Packt’s Open Source Royalty Scheme to date.

Their books focus on practicality, recognising that readers are ultimately concerned with getting the job done. Packt’s digitally-focused business model allows them to quickly publish up-to-date books in very specific areas across a range of key categories – web development, game development, big data, application development, and more. Their commitment to providing a comprehensive range of titles has seen Packt publish 1054% more titles in 2013 than in 2006.

Here are some of the best titles across Packt's main categories - but Buy One, Get One Free will apply across all 2000 titles:

·       Web Development

·       Big Data & Cloud

·       Game Development

·       App Development

posted @ 2014-03-23 21:53 paulwong 阅读(201) | 评论 (0)编辑 收藏

数据库的防单点故障和分表分库

通常数据库是安装在一台服务器上,如果服务器DOWN机,则数据服务停止。这样在生产环境是不合适的,必须部署两台以上的服务器且都安装有相同数据的数据库。这样就产生了一个问题,同一份数据在不同的机子上,会导致数据不同步的问题。一般的方案是:

服务端:
互责数据同步,一台服务器专门做写操作,其他服务器只做读操作,即主从模式。当主服务器DOWN机时,会在从服务器中选出一台做主服务器。在MONGODB中叫REPLICATION。

客户端:
要判断当前与数据库的链接,如果是读操作,则使用与从服务器的链接,如果是写操作,则使用与主服务器的链接。这样的判断一般是由驱动程序去做,配置的时候如果是MYSQL,就要使用REPLYCATION的驱动。

如果数据库里的某张表数据太多,会导致简单的查询会需时过长的问题。一般的方案是限制每张表中不能放太多的数据,如第一个月的数据放一张表,下一个月的数据放第二张表,这种做法称为SHARDING,分表。但这样会导致查询的复杂性,如数据在第二张表,则要具体指明表名,否则查不出数据。目前的数据库,可以事先指定分表的规则,这样查询的语句不需改变,数据库端会自动判断数据在哪张表,然后路由到那张表,去查找数据然后返回给客户端。ORACLE叫分区表,MONGODB叫AUTO SHARDING。

服务端:
需事先指定数据分表规则,这样收到查询语句时数据库就知道数据在哪张表中。

客户端:
查询数据时无需再指定分区表名了

posted @ 2014-03-23 21:27 paulwong 阅读(1419) | 评论 (0)编辑 收藏

TOMCAT的SESSION保存到MONGODB

TOMCAT集群时的SESSION如果是采用集群中的机子互相拷贝的话,会带来性能问题,一般是保存到数据库中。如果是高并发的系统,一般是保存至MONGODB中。

现有一开源的项目是做这个的:

https://github.com/simplicityitself/Mongo-Tomcat-Sessions


db:sessions, collection:sessions,相应配置在conf目录下context.xml中的如下:
<Valve className="com.dawsonsystems.session.MongoSessionTrackerValve" /> 
<Manager className="com.dawsonsystems.session.MongoManager" host="10.120.11.221,10.120.11.122,10.120.11.212" port="27017" database="sessions" maxInactiveInterval="60"/>


MEMCACHED版:
http://www.oschina.net/p/memcached-session-manager

posted @ 2014-03-20 17:33 paulwong 阅读(805) | 评论 (0)编辑 收藏

使用Power Designer工具设计需求模型RQM

     摘要: 3.1需求模型简介IEEE的软件工程标准术语表将“需求”定义为:用户所需的解决某个问题或达到某个目标所要具备的条件或能力。系统或系统组件为符合合同、标准、规范或其它正式文档而必须满足的条件或必须具备的能力。上述第一项或第二项中定义的条件和能力的文档表述。RUP将“需求”定义为:需求描述了系统必须满足的情况或提供的能力,它就可以是直接来自客户需要,也可...  阅读全文

posted @ 2014-03-11 16:14 paulwong 阅读(1088) | 评论 (0)编辑 收藏

仅列出标题
共115页: First 上一页 55 56 57 58 59 60 61 62 63 下一页 Last