KK

Kim-'s-Blog.Object-Everything.I'm POJO.

.紀-錄.爲了忘卻的記憶..真的勇士,要敢于直面遇到的問題,敢于正視繁雜的原碼......在實踐中積累!

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  74 Posts :: 1 Stories :: 70 Comments :: 0 Trackbacks

#

官网打不开最近,
但是可以通过下面这个官网连接直接下载
http://downloads.myeclipseide.com/downloads/products/eworkbench/7.0/myeclipse-7.1-win32.exe
posted @ 2009-03-22 21:46 Kim' 阅读(4357) | 评论 (5)编辑 收藏

与 数据库 db 相关操作有两种:
1.从DB中读cronExpression
2.Job持久化到数据库
对于1:
Quartz 在Spring中动态设置cronExpression
参考 小刀的blog
http://www.blogjava.net/xiaodaoxiaodao/articles/103437.html 

通过DB加载cronException

一个类是可以的
2个类会出问题

 <bean id="test2" class="cn.edu.hust.mes.service.quartz.Test">  
   
<property name="scheduler" ref="schedulerFactoryBean"/>         
   
</bean>  
     
   
<bean id="test" class="Test">  
   
<property name="scheduler" ref="schedulerFactoryBean"/>  
   
</bean>  
     
   
<bean name="schedulerFactoryBean"  
             
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
          
<property name="triggers">  
               
<list>  
                 
<ref bean="cronTriggerForPLCRead"/>  
                 
<ref bean="cronTrigger"/>  
              
</list>  
         
</property>  
   
         
<property name="configLocation" value="classpath:quartz.properties"/>  
    
</bean> 


Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'schedulerFactoryBean': FactoryBean which is currently in creation returned null from getObject

如果写了拦截器的化 还会报这个错 :

Error creating bean with name 'test2': Bean with name 'test2' has been injected into other beans [schedulerJobDetailForPLCRead] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.


对于2:
MethodInvokingJobDetailFactoryBean 不能持久化
必须用JobDetailBean 需继承QuartzJobBean  不够pojo
使用MethodInvokingJobDetailFactoryBean的化会报:
org.quartz.JobPersistenceException: Couldn't store job: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean [See nested exception: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property
API上说了
There's a note in the JavaDoc, I'd presume this might be your problem.
JobDetails created via this FactoryBean are not serializable and thus not suitable for persistent job stores. You need to implement your own Quartz Job as a thin wrapper for each case where you want a persistent job to delegate to a specific service method.
http://www.springframework.org/docs/api/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.html
用MethodInvokingJobDetailFactoryBean不可持久化 除非加个thin wrapper
但查不到任何资料
但愿spring后续版本有好的方案 现在还是老老实实的用JobDetailBean吧

另:
不可用于web action action 用了session等作用域...
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
posted @ 2009-03-19 22:19 Kim' 阅读(4221) | 评论 (0)编辑 收藏

Quartz Cron Expression 网上收集的资料 备忘:

一个Cron-表达式是一个由六至七个字段组成由空格分隔的字符串,其中6个字段是必须的而一个是可选的,如下:


字段名     允许的值     允许的特殊字符 
秒     0-59     , - * / 
分     0-59     , - * / 
小时     0-23     , - * / 
日     1-31     , - * ? / L W C 
月     1-12 or JAN-DEC     , - * / 
周几     1-7 or SUN-SAT     , - * ? / L C # 
年 (可选字段)     empty, 1970-2099     , - * /


'*' 字符可以用于所有字段,在“分”字段中设为"*"表示"每一分钟"的含义。

'?' 字符可以用在“日”和“周几”字段. 它用来指定 '不明确的值'. 这在你需要指定这两个字段中的某一个值而不是另外一个的时候会被用到。在后面的例子中可以看到其含义。

'-' 字符被用来指定一个值的范围,比如在“小时”字段中设为"10-12"表示"10点到12点".

',' 字符指定数个值。比如在“周几”字段中设为"MON,WED,FRI"表示"the days Monday, Wednesday, and Friday".

'/' 字符用来指定一个值的的增加幅度. 比如在“秒”字段中设置为"0/15"表示"第0, 15, 30, 和 45秒"。而 "5/15"则表示"第5, 20, 35, 和 50". 在'/'前加"*"字符相当于指定从0秒开始. 每个字段都有一系列可以开始或结束的数值。对于“秒”和“分”字段来说,其数值范围为0到59,对于“小时”字段来说其为0到23, 对于“日”字段来说为0到31, 而对于“月”字段来说为1到12。"/"字段仅仅只是帮助你在允许的数值范围内从开始"第n"的值。 因此 对于“月”字段来说"7/6"只是表示7月被开启而不是“每六个月”, 请注意其中微妙的差别。

'L'字符可用在“日”和“周几”这两个字段。它是"last"的缩写, 但是在这两个字段中有不同的含义。例如,“日”字段中的"L"表示"一个月中的最后一天" —— 对于一月就是31号对于二月来说就是28号(非闰年)。而在“周几”字段中, 它简单的表示"7" or "SAT",但是如果在“周几”字段中使用时跟在某个数字之后, 它表示"该月最后一个星期×" —— 比如"6L"表示"该月最后一个周五"。当使用'L'选项时,指定确定的列表或者范围非常重要,否则你会被结果搞糊涂的。

'W' 可用于“日”字段。用来指定历给定日期最近的工作日(周一到周五) 。比如你将“日”字段设为"15W",意为: "离该月15号最近的工作日"。因此如果15号为周六,触发器会在14号即周五调用。如果15号为周日, 触发器会在16号也就是周一触发。如果15号为周二,那么当天就会触发。然而如果你将“日”字段设为"1W", 而一号又是周六, 触发器会于下周一也就是当月的3号触发,因为它不会越过当月的值的范围边界。'W'字符只能用于“日”字段的值为单独的一天而不是一系列值的时候。

'L'和'W'可以组合用于“日”字段表示为'LW',意为"该月最后一个工作日"。

'#' 字符可用于“周几”字段。该字符表示“该月第几个周×”,比如"6#3"表示该月第三个周五( 6表示周五而"#3"该月第三个)。再比如: "2#1" = 表示该月第一个周一而 "4#5" = 该月第五个周三。注意如果你指定"#5"该月没有第五个“周×”,该月是不会触发的。

'C' 字符可用于“日”和“周几”字段,它是"calendar"的缩写。 它表示为基于相关的日历所计算出的值(如果有的话)。如果没有关联的日历, 那它等同于包含全部日历。“日”字段值为"5C"表示"日历中的第一天或者5号以后",“周几”字段值为"1C"则表示"日历中的第一天或者周日以后"。

对于“月份”字段和“周几”字段来说合法的字符都不是大小写敏感的。

下面是一些完整的例子:


表达式     含义 
"0 0 12 * * ?"     每天中午十二点触发 
"0 15 10 ? * *"     每天早上10:15触发 
"0 15 10 * * ?"     每天早上10:15触发 
"0 15 10 * * ? *"     每天早上10:15触发 
"0 15 10 * * ? 2005"     2005年的每天早上10:15触发 
"0 * 14 * * ?"     每天从下午2点开始到2点59分每分钟一次触发 
"0 0/5 14 * * ?"     每天从下午2点开始到2:55分结束每5分钟一次触发 
"0 0/5 14,18 * * ?"     每天的下午2点至2:55和6点至6点55分两个时间段内每5分钟一次触发 
"0 0-5 14 * * ?"     每天14:00至14:05每分钟一次触发 
"0 10,44 14 ? 3 WED"     三月的每周三的14:10和14:44触发 
"0 15 10 ? * MON-FRI"     每个周一、周二、周三、周四、周五的10:15触发 
"0 15 10 15 * ?"     每月15号的10:15触发 
"0 15 10 L * ?"     每月的最后一天的10:15触发 
"0 15 10 ? * 6L"     每月最后一个周五的10:15触发 
"0 15 10 ? * 6L"     每月最后一个周五的10:15触发 
"0 15 10 ? * 6L 2002-2005"     2002年至2005年的每月最后一个周五的10:15触发 
"0 15 10 ? * 6#3"     每月的第三个周五的10:15触发

---------------------------------------------

Field Name  Mandatory?  Allowed Values  Allowed Special Characters 
Seconds     YES         0-59             , - * / 
Minutes     YES         0-59             , - * / 
Hours       YES         0-23             , - * / 
Day of month  YES       1-31             , - * ? / L W C 
Month         YES        1-12 or JAN-DEC  , - * / 
Day of week   YES        1-7 or SUN-SAT   , - * ? / L C # 
Year          NO  empty, 1970-2099        , - * / 


项目实例:
              second  minute  hours  dayOfMonth  month  dayOfWeek  year
每月         0            0           6              ?                    *                6#3            ?
每周        59           59         18            ?                    *                1                ?
自定义    28          47          9             30                 7                ?             2006

每月:每个月的第三个星期五的上午6:00:00 触发
每周:每周的星期日的下午18:59:59 触发
自定义:2006年7月30日上午9:47:28 触发

所有星号对应的段位置,都可以出现后面的符号(, - * /)
(? / L C)这些符号可以出现在"一月哪天"和"星期"段位置
(w)只能出现在"一月哪天"段位置
(#)只能出现在"星期"段位置

解释符号代表的意思:
* 代表任意合法的字段
0 * 17 * * ? :表示在每天的5 PM 到 5:59之间的每一分钟启动scheduler

? 表示没值被指定
如果同时指定"一月哪天"和"星期",可能两者对应不起来
0 0,15,30,45 * * * ? :表示每刻钟启动scheduler
所以推荐用法是其中一个指定值,另一个用?指定

/ 表示时间的增量
0 0/15 * * * ? :表示每刻钟启动scheduler

- 表示值的范围
0 45 3-8 ? * *

L 如果用在"一月哪天"段上,表示一个月的最后一天;如果用在"星期"段上。表示一个星期的最后一天(星期六)
0 0 8 L * ? :表示每个月最后一天的8点启动scheduler

W 表示最靠近给定时间的一天,(必须是星期一到星期五)

# 例如 6#3表示一个月的第三个星期五
posted @ 2009-03-19 22:10 Kim' 阅读(2675) | 评论 (0)编辑 收藏

Myeclipse7  安装插件有点麻烦 记录于此备忘

 

导入项目

http://javapojo.javaeye.com/topics/download/d2d7696a-703e-3d82-8fcc-ad21c9b896fc

运行main方法

得到一段字符串

copy到Myeclipse7目录:Genuitec\MyEclipse 7.0\configuration\org.eclipse.equinox.simpleconfigurator\bundles.info

这个文件里面。

 

最近安装了个Drools fro eclipse3.4 的插件

下载 drools-5.0.0.CR1-eclipse-all.jar

解压到某文件夹

copy其plugins路径到main方法中(注意是plugins目录哦)

运行该类


public static void main(String[] args)
{
new CreatePluginsConfig().print("E:\\Genuitec\\kimplug\\drools-5.0.0.CR1-eclipse-all\\plugins");

}

 得到

org.guvnor.tools,5.0.0.CR1,file:/E:\Genuitec\kimplug\drools-5.0.0.CR1-eclipse-all\plugins\org.guvnor.tools_5.0.0.CR1.jar,4,false
org.eclipse.webdav,3.0.101,file:/E:\Genuitec\kimplug\drools-5.0.0.CR1-eclipse-all\plugins\org.eclipse.webdav_3.0.101.jar,4,false
org.drools.eclipse,5.0.0.CR1,file:/E:\Genuitec\kimplug\drools-5.0.0.CR1-eclipse-all\plugins\org.drools.eclipse_5.0.0.CR1.jar,4,false
org.drools.eclipse.task,5.0.0.CR1,file:/E:\Genuitec\kimplug\drools-5.0.0.CR1-eclipse-all\plugins\org.drools.eclipse.task_5.0.0.CR1.jar,4,false

 

将其拷入bundles.info尾部

重启myeclipse ok了



posted @ 2009-03-18 11:25 Kim' 阅读(2547) | 评论 (5)编辑 收藏

当然是修改注册表

 

1、打开注册表编辑器,打到[HKEY_CLASSES_ROOT\Folder\shell]子键,在其下面新建名为“命令提示符”的 项,再在这个项下面新建名为"Command"的 项。

2、选择"command"项,把“默认”字符窜值的数据设为“C:\windows\system32\cmd.exe cd "%l"”,然后确定。

这样任意目录甚至盘符的右键菜单中都增加了一项“命令提示符”。

 

比从cmd直接敲到目录要方便的多了......

posted @ 2009-03-17 14:08 Kim' 阅读(783) | 评论 (0)编辑 收藏

spring 某些类 从 DB 初始化 一些属性
在spring初始化过程中加载数据库中的数据

项目中有这个需求 需启动时将某些属性赋DB读到的值
达到同步数据的目的
考虑 1:构造函数 不可以 dao还未初始化 null point
2:xx 属性 = dao.getXX.... dao还未初始化

使用BeanPostProcessor可以

public class PBSTrackManagerPostProcessor implements BeanPostProcessor
{

    public Object postProcessAfterInitialization(Object obj, String s)
            throws BeansException
    {
        if(obj instanceof PBSTrackManager)
        {
            ((PBSTrackManager) obj).plcObjectInit();
        }
        return obj;
    }

    public Object postProcessBeforeInitialization(Object obj, String s)
            throws BeansException
    {
        return obj;
    }

}

但要注意配置文件
<bean id="pbsTrackManagerPostProcess" class="cn.edu.hust.mes.service.manager.productionplan.impl.PBSTrackManagerPostProcessor">

!!!!
default-lazy-init="false"
实时加载才可以


posted @ 2009-03-16 10:34 Kim' 阅读(2294) | 评论 (1)编辑 收藏

在项目中发现一个奇怪的问题

 

manager层使用 注入的dao ,dao.getHibernateTemplate() 结果得到的是null......

 

而在dao中使用 this.getHibernateTemplate()却一切正常...

 


经调试发现: <aop:pointcut id="logPointcut" expression="within(cn.edu.hust.mes.service.manager..*) or within(cn.edu.hust.mes.domain.dao..*)" /> 如果被自己写的 aop 拦截器 拦截了的话

dao就是 cglib的. 部分属性为null...

而让spring 自己注入就是ok的了


是延迟加载 但使用是报空指针 还是什么原因 未知

暂时去掉log拦截 一切ok

posted @ 2009-03-16 09:46 Kim' 阅读(990) | 评论 (0)编辑 收藏

http://javapojo.javaeye.com
同步发布
多多指教
posted @ 2009-03-14 14:05 Kim' 阅读(93) | 评论 (0)编辑 收藏

最近同事本机发布项目会出现
Tomcat 6 使用 JDK 1.6 和 jaxb2.17 问题
CXF 新版会用到jaxb2.17 但 Tomcat 6 JDK 会load jaxb2.0
解决办法:

找到tomcat 的默认 endorsed 目录
the default endorsed directory is: $CATALINA_HOME/endorsed.
如果没有这个目录 建这个目录讲jaxb的3个Jar包Copy来 OK
java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI
(from jar:file:/somedirectory/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)

It's actually a very simple fix, but painful enough to warrant a post. Put the jaxb-api.jar that you're trying to use into JDK_HOME/jre/lib/endorsed. If the endorsed directory doesn't exist, make it. This is apparently only a problem with JDK 1.6, not with JDK 1.5.


------------------------------------------
如Myeclipse Tomcat
将jaxb-api-2.1.jar jaxb-impl-2.1.7.jar jaxb-xjc-2.1.7.jar
拷贝到E:\Genuitec\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_7.9.100.zmyeclipse80020090924a\tomcat
新建的common\endorsed 目录里 便可。
posted @ 2009-03-14 14:04 Kim' 阅读(871) | 评论 (0)编辑 收藏

细节不仅仅是细节,他们构成了设计.
使其尽可能的简单,而不是简化.
如果我有更多的时间,我将写一封更短的信.
这可能是好的设计,或者坏的设计,但绝不可能没有设计!
posted @ 2008-12-31 12:52 Kim' 阅读(146) | 评论 (0)编辑 收藏

仅列出标题
共8页: 上一页 1 2 3 4 5 6 7 8 下一页 
jj