JBoss rules is a library. It provide the DRL file to store the 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.
Thursday, April 19, 2007
Wednesday, April 18, 2007
oracle reverse enginee and select sql query with case
It is a important page to talk oracle walk though which table to reverse.
http://www.eveandersson.com/writing/data-model-reverse-engineering#columns
use Select sql query with case:
syntax
case when then
when then
...
else
end
sample:
else 'category 4'
end
from emp;
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
MyDoggy . Open source free Java docking framework
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
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
It is a simple function act as recycle bin to store the drop table ... etc.
http://dbaoracle.itpub.net/post/901/271132
How to purge the recycle bin:
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.
Tuesday, November 14, 2006
Spring JDBC connection
Download Spring.jar version 2.0
- configure the xml
- DriverManagerDataSource class help you to configuration and get the connection from database
- DataSourceTransactionManager class that help to create the transaction when you want to insert or update the database.
- Create your own Dao Class, it just like a class represent a table but i do not help you to maintain the Has-a relationship.
In my sample project (you can import to Eclipse)
App.java - contain main method to execute (but i am connecting SQL Server... you can teach the concert)
OrderDao - interface class to represent what method contain in OrderDaoImpl
OrderDaoImpl - contain code to process
Order - Order represent the table Orders in Database
OrderRowMap - It help you to mapping value from resultset to create the object instance
It contain the method call "public Object mapRow(ResultSet rs, int index)" from the name you know it for mapping.
- configure the xml
- DriverManagerDataSource class help you to configuration and get the connection from database
- DataSourceTransactionManager class that help to create the transaction when you want to insert or update the database.
- Create your own Dao Class, it just like a class represent a table but i do not help you to maintain the Has-a relationship.
In my sample project (you can import to Eclipse)
App.java - contain main method to execute (but i am connecting SQL Server... you can teach the concert)
OrderDao - interface class to represent what method contain in OrderDaoImpl
OrderDaoImpl - contain code to process
Order - Order represent the table Orders in Database
OrderRowMap - It help you to mapping value from resultset to create the object instance
It contain the method call "public Object mapRow(ResultSet rs, int index)" from the name you know it for mapping.
Tuesday, October 24, 2006
Use single value to store multiple settings
example use binary compare:
static final int problem1 = 0x1;
static final int problem2 = 0x10;
static final int problem3 = 0x100;
- when user selected problem1 and problem2
we can store the value like that
int userSelVal;
userSelVal = userSelVal | problem1;
userSelVal = userSelVal | problem2;
-then you will ask how to know the user is selected problem1 and problem2
if((userSelVal & problem1) == problem1){
//represent user select problem1
System.out.println("User is selected problem1");
}
if((userSelVal & problem2) == problem2){
//represent user select problem2
System.out.println("User is selected problem2");
}
if((userSelVal & problem3) == problem3){
//represent user select problem3
System.out.println("User is selected problem3");
}
- via to compare the binary position value, each position represent one setting then we can store int binary size setting in one int.
static final int problem1 = 0x1;
static final int problem2 = 0x10;
static final int problem3 = 0x100;
- when user selected problem1 and problem2
we can store the value like that
int userSelVal;
userSelVal = userSelVal | problem1;
userSelVal = userSelVal | problem2;
-then you will ask how to know the user is selected problem1 and problem2
if((userSelVal & problem1) == problem1){
//represent user select problem1
System.out.println("User is selected problem1");
}
if((userSelVal & problem2) == problem2){
//represent user select problem2
System.out.println("User is selected problem2");
}
if((userSelVal & problem3) == problem3){
//represent user select problem3
System.out.println("User is selected problem3");
}
- via to compare the binary position value, each position represent one setting then we can store int binary size setting in one int.
Sunday, October 22, 2006
Create a signed jar
Create a signed Jar file
description:
need to use keytool and jarsigner
C:\> keytool -genkey -validity
C:\> keytool -selfcert -validity -keypass
C:\> jarsigner test.jar mykey
http://www.ccw.com.cn/htm/center/prog/02_7_8_4.asp
http://www.owasp.org/index.php/Signing_jar_files_with_jarsigner#Create_a_new_DSA_Key_Pair_for_Bob
Not all the detail, it will be edit later but you can use the upper command to finish it.
signed jar for web start application.
description:
need to use keytool and jarsigner
C:\> keytool -genkey -validity
C:\> keytool -selfcert -validity
C:\> jarsigner test.jar mykey
http://www.ccw.com.cn/htm/center/prog/02_7_8_4.asp
http://www.owasp.org/index.php/Signing_jar_files_with_jarsigner#Create_a_new_DSA_Key_Pair_for_Bob
Not all the detail, it will be edit later but you can use the upper command to finish it.
signed jar for web start application.
Ant jar file ( Do you remember the script? )
Very simple Ant to create jar file
*project name="XDoclet Generator" default="jar"*
*target name="jar" description="Create binary distribution after xxx"*
*!-- Create application JAR file --*
*mkdir dir="MyJarDir"*
*jar jarfile="MyJarDir/MyJarFile.jar" basedir="classes"*
*/jar*
*/mkdir*
Simple easy under stand but let me write down.... thx. I easy forget
*project name="XDoclet Generator" default="jar"*
*target name="jar" description="Create binary distribution after xxx"*
*!-- Create application JAR file --*
*mkdir dir="MyJarDir"*
*jar jarfile="MyJarDir/MyJarFile.jar" basedir="classes"*
*/jar*
*/mkdir*
Simple easy under stand but let me write down.... thx. I easy forget
Saturday, October 21, 2006
readExif php script
It is very simple sample only a few lines of code.
- description
It read the JPEG file's EXIF information, and use the DateTime value to separate the image file to different folder.
-execution
1. Set php installed folder in envirnment variable.
2. then you can directly type "php" to execute php script on local computer.
3. enable the in php.ini (it may locate on Windows / WINNT folder):
extension=php_mbstring.dll
extension=php_exif.dll
4. put readExif.php into the image folder.
5. type "php readExif.php"
6. It will process.
- description
It read the JPEG file's EXIF information, and use the DateTime value to separate the image file to different folder.
-execution
1. Set php installed folder in envirnment variable.
2. then you can directly type "php" to execute php script on local computer.
3. enable the in php.ini (it may locate on Windows / WINNT folder):
extension=php_mbstring.dll
extension=php_exif.dll
4. put readExif.php into the image folder.
5. type "php readExif.php"
6. It will process.
Thursday, October 19, 2006
convert number to English words
I am finding the sample code to convert number to words.
I find one java sample:
reference: site
my own copy and modify code: my modify source file
It is quite simple to convert, just use a little bit time to understand
I think it can help to ppl no need to convert number when write cheque.
I find one java sample:
reference: site
my own copy and modify code: my modify source file
It is quite simple to convert, just use a little bit time to understand
I think it can help to ppl no need to convert number when write cheque.
Wednesday, October 18, 2006
one-to-one bidirectional (in hibernate example) xDoclet
create xDoclet tag both one side
1. assume each user only have one car
user class reference car
car class reference user
2. identify From & To direction
assume that user (from) - car (to)
then user primary key store to car table (foreign key)
3. xDoclet tag
== code ==
car class:
/**
* @hibernate.many-to-one
* class = "local.sample.oo.User"
* column = "userId"
*/
public User getUser()
{
return _user;
}
== code ==
car is to --> so that is many-to-one relationship (from logic it is one-to-one but if both side one to one cannot be identify to & from)
column -> represent the user primary key store column on car table
== code ==
user class:
/**
* @hibernate.one-to-one
* cascade = "save-update"
*/
public Car getCar()
{
return _car;
}
== code ==
user is from -> so that is one-to-one relationship
cascade -> when update user, it also request car to update (if car is modified)
1. assume each user only have one car
user class reference car
car class reference user
2. identify From & To direction
assume that user (from) - car (to)
then user primary key store to car table (foreign key)
3. xDoclet tag
== code ==
car class:
/**
* @hibernate.many-to-one
* class = "local.sample.oo.User"
* column = "userId"
*/
public User getUser()
{
return _user;
}
== code ==
car is to --> so that is many-to-one relationship (from logic it is one-to-one but if both side one to one cannot be identify to & from)
column -> represent the user primary key store column on car table
== code ==
user class:
/**
* @hibernate.one-to-one
* cascade = "save-update"
*/
public Car getCar()
{
return _car;
}
== code ==
user is from -> so that is one-to-one relationship
cascade -> when update user, it also request car to update (if car is modified)
Monday, October 16, 2006
Simple Sample to use Spring, xDoclet and Hibernate
I just revision how to use Hibernate, you need to understand about the one-to-one, one-to-many, many-to-many before use the Hibernate. Hibernate is not very complicate but you don't use any tools to help develop the application with Hibernate, you will feel hard.
In my experience, I suggest to use Eclipse 3.1.x & JBoss IDE plugins to develop the Hibernate and Spring application.
I will provide the simple project. It demo how to create one-to-one, one-to-many, many-to-many.
You need to pay attention on :
** Sample download**
Useful resource to futher study Hibernate.
- HibernateGossip
Any problem, please feel free to contact me:
mingkit@gmail.com
In my experience, I suggest to use Eclipse 3.1.x & JBoss IDE plugins to develop the Hibernate and Spring application.
I will provide the simple project. It demo how to create one-to-one, one-to-many, many-to-many.
You need to pay attention on :
- persistent classes xDoclect's Hibernate tag.
- Spring configuration xml file ( hibernate.xml) - datasource, hbm config, bean of spring
- xDoclet configuration. Project > right click > property > XDoclect configuration
** Sample download**
Useful resource to futher study Hibernate.
- HibernateGossip
Any problem, please feel free to contact me:
mingkit@gmail.com
Mylar is eclipse plugin for project management
Interest! I will read about it and write some article.
http://www-128.ibm.com/developerworks/java/library/j-mylar1/?ca=dgr-jw01Mylar-1
http://www.hibernate.org/43.html
http://www-128.ibm.com/developerworks/java/library/j-mylar1/?ca=dgr-jw01Mylar-1
http://www.hibernate.org/43.html
MySQL add new user account
It is a very simple procedure but i usually forget. We also can search ther result from MYSQL homepage. Please login by root account.
mysql -u root
1. create user account.
- CREATE USER mingkit IDENTIFIED BY 'password';
2. grant right for the accout.
- for localhost
GRANT ALL PRIVILEGES ON *.* TO 'mingkit'localhost'IDENTIFIED BY 'password' WITH GRANT OPTION;
- for worldwide or certain ip
GRANT ALL PRIVILEGES ON *.* TO 'mingkit'%'IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql -u root
1. create user account.
- CREATE USER mingkit IDENTIFIED BY 'password';
2. grant right for the accout.
- for localhost
GRANT ALL PRIVILEGES ON *.* TO 'mingkit'localhost'IDENTIFIED BY 'password' WITH GRANT OPTION;
- for worldwide or certain ip
GRANT ALL PRIVILEGES ON *.* TO 'mingkit'%'IDENTIFIED BY 'password' WITH GRANT OPTION;
Subscribe to:
Posts (Atom)