Friday, April 27, 2007
log4j good logging tool
Reference web page:
http://my.so-net.net.tw/idealist/Java/Log4j.html (chinese)
http://wiki.apache.org/logging-log4j/Log4jXmlFormat
Thursday, April 26, 2007
Quartz Basic structure: (referenece book: Quartz Job Schedule Framework)
Classes:
1. Job - interface class- provide method execute(JobExecutionContext c)
- JobExecutionContext - getJobDetail() to get the JobDetail instance.
- JobDetail contain the job name and JobDataMap instance from getJobDataMap.
- JobDataMap can help pass the data inside the Job.
Sample:
Create JobDetail, JobDataMap and Trigger.JobDetail jobDetail = new JobDetail("ScanDirectory", Scheduler.DEFAULT_GROUP, ScanDirectoryJob.class);
// Configure the directory to scan
jobDetail.getJobDataMap().put("SCAN_DIR", "c:\quartz-book\input");
// Create a trigger that fires every 10 seconds, forever
Trigger trigger = TriggerUtils.makeSecondlyTrigger(10); trigger.setName("scanTrigger");
// Start the trigger firing from now
trigger.setStartTime(new Date());
// Associate the trigger with the job in the scheduler scheduler.scheduleJob(jobDetail, trigger);
For CronTrigger
It could be help to develop a more complex trigger than SimpleTrigger.
Name | Required | Allowed Values | Special Characters |
---|---|---|---|
Seconds | Yes | 059 | , - * / |
Minutes | Yes | 059 | , - * / |
Hours | Yes | 23 | , - * / |
Day of Month | Yes | 131 | , - * ? / L W C |
Month | Yes | 112 or JAN-DEC | , - * / |
Day of Week | Yes | 17 or SUN-SAT | , - * ? / L C # |
Year | No | Blank or 19702099 | , - * / |
The names of months and days of the week are not case sensitive. FRI is the same as fri. |
Understanding the Special Characters
As with UNIX cron, Quartz cron expressions support special characters that can be used to create more complicated execution schedules. However, Quartz supports many more than the standard UNIX cron expression.
The * Character
Using the asterisk (*) in a field indicates that you want to include all legal values for that field. For example, using this character in the month field means to fire the trigger for every month.
Example expression:
0 * 17 * * ?
Meaning: Fire the trigger every minute, every day starting at 5 PM until 5:59 PM. It stops at 5:59 PM because the value 17 is in the hour field, and at 6 PM, the hour becomes 18 and doesn't agree with this trigger until the next day at 5 PM.
Use the * character when you want the trigger to fire for every valid value of the field.
The ? Character
The question mark (?) character can be used only in the dayofmonth and dayofweek fields, but not at the same time. You can think of the ? character as "I don't care what value is in this field." This is different from the asterisk, which indicates every value for the field. The ? character says that no value was specified for this field.
The reasons a value can't be specified for both fields are tough to explain and even tougher to understand. Basically, if a value was specified for each, the meaning would become ambiguous: Consider if an expression had the value 11 in a field for the day of the month and a value of WED in the field for the day of the week. Should that trigger fire only on the 11th of the month if it falls on a Wednesday? Or should it fire on both the 11th and every Wednesday? The ambiguity is removed by not allowing a value in both fields at the same time.
Just remember that if you specify a value in one of the two fields, you must put a ? in the other.
Example expression:
0 10,44 14 ? 3 WED
Meaning: Fire at 2:10 PM and 2:44 PM every Wednesday in the month of March.
The , Character
The comma (,) character is used to specify a list of additional values within a given field. For example, using the value 0,15,30,45 in the second field means to fire the trigger every 15 seconds.
Example expression:
0 0,15,30,45 * * * ?
Meaning: Fire the trigger on every quarter-hour.
The / Character
The slash (/) character is used to schedule increments. We just used the comma to increment every 15 minutes, but we could have also written it like 0/15.
Example expression:
0/15 0/30 * * * ?
Meaning: Fire the trigger every 15 seconds on the hour and half-hour.
You can't increment beyond the fields range. For example, you can't specify 30/20 in the second field and expect the scheduler to fire correctly.
The Character
The hyphen (-) character is used to specify a range. For example, 3-8 in the hour field means "the hours 3, 4, 5, 6, 7, and 8." The fields will not wrap, so values such as 50-10 are not allowed.
Example expression:
0 45 3-8 ? * *
Meaning: Fire the trigger on 45 past the hours 3 AM through 8 AM.
The L Character
The L character represents the last allowed value for the field. It is supported by the dayofmonth and dayofweek fields only. When used in the dayofmonth field, it represents the last day of the month for the value specified in the month field. For example, when the month field has JAN specified, using L in the dayofmonth field would cause the trigger to fire on January 31. If SEP was specified as the month, then L would mean to fire on September 30. In order words, it means to fire the trigger on the last day of whatever month is specified.
The expression 0 0 8 L * ? means to fire the trigger at 8:00 AM the last day of every month. The * character in the month field gives us the "every month" part.
When the L character is used in the dayofweek field, it indicates the last day of the week, which is Saturday (or, numerically, 7). So if you needed to fire the trigger on the last Saturday of every month at 11:59 PM, you could use the expression 0 59 23 ? * L.
When used in the dayofweek field, you can use a numerical value in conjunction with the L character to represent the last X day of the month. For example, the expression 0 0 12 ? * 2L says to fire the trigger on the last Monday of every month.
The W Character
The W character stands for weekday (MonFri) and can be used only in the dayofmonth field. It is used to specify the weekday that is nearest to the given day. Most business processes are based on the work week, so the W character can be very important. For example, a value of 15W in the dayofmonth field means "the nearest weekday to the 15th of the month." If the 15th was on a Saturday, the trigger would fire on Friday the 14th because it's closer to the 15th than Monday, which would be the 17th in this example. The W character can be specified only when the day of the month is a single day, not a range or list of days.
The # Character
The # character can be used only in the dayofweek field. It's used to specify the nth XXX day of the month. For example, if you specified the value 6#3 in the dayofweek field, it would mean the third Friday of the month (6 = Friday and #3 means the third one in the month). Another example of 2#1 means the first Monday of the month (2 = Monday and #1 means the first one of the month). Note that if you specify #5 and there is no 5 of the given day of the week in the month, no firing will occur that month.
Monday, April 23, 2007
Howtoforge
http://www.howtoforge.com/
A very good article for install Internet Explorer on Ubuntau
http://www.howtoforge.com/ubuntu_internet_explorer
Thursday, April 19, 2007
JBoss rules
DRL file is represent one package.
Under DRL file it contains many rule with a identify name with package.
JBoss IDE for JBoss rules (necessary install in Eclipse 3.2.x) . It just add some views and DRL and DSL Editor. (so i think it just good for help you to check the syntax).
the programming steps:
1. PackageBuilder -> Package
2. RunBaseFactory -> RunBase -> add -> Package
3. RunBase -> new -> WorkingMemory
4. WorkingMemory -> assertObject for fireAllRules().
It will use all assertObjects in WorkingMemory to run for all rules except you have add filter for call method of fireAllRules();
DRL sytax:
rule :
rule "name"
while "condition"
then "process"
end
e.g.
rule "Your First Rule"
salience 10
when
$m : Man(age <> 25)
then
System.out.println("first : " + $m.getName());
mans.add($m);
end
rule "Your Second Rule"
salience 5
when
$m : Man(age > 25, $name : name)
then
System.out.println("second : " + $name);
end
note: if miss salience .. then all rule by default salience = 0.
If fireAllRules() "Your Second Rule" execute first and then "Your First Rule"
query:
query "name"
"condition"
end
e.g. DRL
query "test"
$man Man(age > 25);
end
e.g. Java
QueryResults qrs = WorkingMemory.getQueryResults("test");
qrs.size();
It could return all valid the query objects.
Personal comment:
From example most rule only check about the assertObject and update the state of object ... but never return anything ..... such as only true/false.
If you have other thing out of set state, you need to define global object to return.
Wednesday, April 18, 2007
oracle reverse enginee and select sql query with case
http://www.eveandersson.com/writing/data-model-reverse-engineering#columns
use Select sql query with case:
syntax
case when
when
...
else
end
sample:
select sal, case when sal < style="font-family: monospace;">'category 1'
else 'category 4'
end
from emp;
Thursday, April 12, 2007
Open source free Java docking framework and discovery new DB Engine
http://mydoggy.sourceforge.net/
I tried the tutorial. It is a very simple docking framework. It cannot place more than panel on the same dock.
H2 Database Engine. it seems better than hypersonic SQL database
http://www.h2database.com/html/frame.html
Wednesday, April 11, 2007
oracle 10g FlashBack function
http://dbaoracle.itpub.net/post/901/271132
Issue one of the following statements:
ALTER SESSION SET recyclebin = ON/OFF;
SELECT object_name, original_name FROM dba_recyclebinThe recycle bin table name is "dba_recyclebin"
How to purge the recycle bin:
PURGE TABLE BIN$jsleilx392mk2=293$0;
or
PURGE RECYCLEBIN;
Maybe you also can append PURGE after drop table statement.
DROP TABLE ABC PURGE;
then the table will direct delete not add to recycle bin.