Javascript have a method called window.onload(),it will be fired when all document(DOM,file,image) downloaded completely
but Jquery's $(document).ready() will be fired only when DOM is available for access,images may not be downloaded yet,so image's attributes like height may not available yet.
Monday, October 31, 2011
Thursday, October 27, 2011
Jquery's Chaining capability
with jquery's chaining capability,we can get multiple sets of elements and do multiple thing with them
$('td:contains("Henry")') //get every cell containing "Henry"
.parent() //get its parent
.find('td:eq(1)') //find inside the parent the 2nd cell
.addClass(highlight') //add the "highlight" class to that cell
.end() //revert back to the parent of the cell containing "Henry"
.find('td:eq(2)') //find inside the parent the 3rd cell
.addClass('highlight'); //add the "highlight" class to that cell
Jquery selectors
$('#selected-plays > li').addClass('horizontal');
means find each list item (li) that is a child (>) of an element with an ID of
selected-plays (#selected-plays).
$('#selected-plays li:not(.horizontal)').addClass('sub-level');
we are getting every list item (li) that:
1. Is a descendant of an element with an ID of selected-plays
(#selected-plays), and
2. Does not have a class of horizontal (:not(.horizontal)).
jquery also use XPath selectors,like
$('a[@title]') means select all links that has a title attribut
$()'div[ol]') means get all div elements that contain an ol element
$('a[@href^="mailto:"]') means get all anchor elements(a) with an href attributes([@href]) that begin with mailto(^="mailto:")
$('a[@href$=".pdf"]') means get all links with a href attribute that ends with .pdf
$('a[@href*="mysite.com"]') means get all internal linkes,
Jquery's custom selectors
$('div.horizontal:eq(1)') means select the second item from a matched set of divs with a class of horizontal
$('tr:odd')
$('tr:even')
$('td:contains("henry")')
Jquery factory function
the $() function remove the need to do a for loop to acces a group of lelement since whatever we put nside the parenthese will be looped through automatically end store as a jQuery objec,we cn put just about anything inside the parenthese of the $(),here are few examples
A tag name: $('p') gets all paragraphs in the document.
An ID: $('#some-id') gets the single element in the document that has the
corresponding some-id ID.
A class: $('.some-class') gets all elements in the document that have a
class of some-class.
In jQuery, the dollar sign $ is simply shorthand for jQuery
Javascript top Object
window object is the top one.it will be created after user open a browser,or we can create sub windows from current window.we can also refer to its properties(property and method),
navigator object represents the URL of the current window
like we can call following method:
var subwindow = window.open("define.html","def","height=200,width=300")
subwindow.close()
window.alert("the is a javascript alert dialog")
if(window.confirm("Are you sure you want to start over?")
{
location.href="index.html"
}
the word window could be ommited.
var answer = prompt("What is your name?","");
if (answer)
{
alert("Hello, " + answer + "!");
}
window.addEventListener(’load’, functionName, false);
window.attachEvent(’onload’, functionName);
navigator object represents the URL of the current window
Wednesday, October 26, 2011
logging with python
logging within python is pretty easy
import logging
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('/var/tmp/myapp.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.WARNING)
logger.error('We have a problem')
logger.info('While this is just chatty')
only error was logged
2003-07-08 16:49:45,896 ERROR We have a problem
python debug with urllib2 or httplib
with httplib,as see in dive into python if we put line
h=urllib2.HTTPHandler(debuglevel=1) into source code,we will see all debug information displayed
but that is not working with urllib2,with urllib2,we have to put
h=urllib2.HTTPHandler(debuglevel=1) in source code,and add h as a handler while build opener,then we see all debug information in console
h=urllib2.HTTPHandler(debuglevel=1) into source code,we will see all debug information displayed
but that is not working with urllib2,with urllib2,we have to put
h=urllib2.HTTPHandler(debuglevel=1) in source code,and add h as a handler while build opener,then we see all debug information in console
Tuesday, October 25, 2011
curl simulate HTTP POST
in windows I use following command
curl http://172.19.xx.xxx/XmlConfig -u guest:password -d@cmd.txt -basic -v -L -c c.txt-u for username and password
-d@ read HTTP message body from cmd.txt file
-basic: BASIC Authentication
-v: verbose output
-L : auto follow redirect
-c:save and load cookie from c.txt,and auto manage session by cookie
in linux:
curl http://172.19.xxx.xxx/XmlConfig -u guest:password -d ' ' -basic -v -L -c c.txt
this one I put the HTTP message body in command like directly
when curl output it will print curl message started with star(*), the data been send with by curl "<",data received with "<".
wget simulate HTTP POST
wget --http-user=guest --http-passwd=I$%##$@%H http://172.19.208.6/XMlConfig -d -S --post-file cmd.txt
-d: debug
-S:print server response
cmd.txt : HTTP message body send to server
python urllib2 module
play with python urllib2 module,try to make a HTTP POST with a http url,with 307 Redirection and Cookie management,Basic Authentication.here is what I learn
1)Redirect will managed bu urllib2 Httpredirecthandler automatically,we don't need any code to handle it,one thing need to remember that 307 with POST is not support by urllib,need to change the library
2)session can also be managed by module automatically,the only thing we need to do is add urllib2.HTTPCookieProcessor() while build opener
3)we need create HTTPBasicAuthHandler with a HTTPPasswordMgrWithDefaultRealm that need add username and password
here is the sample code that can handle redirection,Basic Authentication,session management(cookie processor)
4) when we add password to passwordmanagement,we need give the url of the server,not the url we point to to fetch data
5)cmd is the data we send in http message body.
server = 'http://172.19.xxx.xxx/'
url = server + 'XmlConfig'
username='guest'
password ='xxxxxxxxxxxx'
cmd =' '
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, server, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler,urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
response = urllib2.urlopen(url,cmd)
thepage = response.read()
print thepage
1)Redirect will managed bu urllib2 Httpredirecthandler automatically,we don't need any code to handle it,one thing need to remember that 307 with POST is not support by urllib,need to change the library
2)session can also be managed by module automatically,the only thing we need to do is add urllib2.HTTPCookieProcessor() while build opener
3)we need create HTTPBasicAuthHandler with a HTTPPasswordMgrWithDefaultRealm that need add username and password
here is the sample code that can handle redirection,Basic Authentication,session management(cookie processor)
4) when we add password to passwordmanagement,we need give the url of the server,not the url we point to to fetch data
5)cmd is the data we send in http message body.
server = 'http://172.19.xxx.xxx/'
url = server + 'XmlConfig'
username='guest'
password ='xxxxxxxxxxxx'
cmd ='
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, server, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler,urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
response = urllib2.urlopen(url,cmd)
thepage = response.read()
print thepage
make vi and ls in cygwin have color
Adding color to VIM and CygwinThese are notes-to-self more than anything, but maybe you can use them. You can add colorized text to Vim by adding the following to .vimrc
in your $HOME directory:
" Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endi
If you don't have this file, you can create it using :mkv
. You can change your font-settings by editing them with Edit >> Select Font and then typing :set guifont
, followed by :mkv!
. I prefer Courier New, 9pt.
If you want colors for file listings (using ls
) in Cygwin, add the following to your .bashrc
file in your $HOME directory:
alias ls="ls -CF --color"
Friday, October 21, 2011
Vi command tip
ctrl-Z go back to the shell,use fg return to vi
direct jump into a line :100
use :sh create a new shell,exit this shell will return back to vi
use -R open file read only
:set number will dislay line number,set nonumber close line number display
Wednesday, October 19, 2011
colorful code in VI from SecureCRT
go to Options menu,choose session options,select Emulation under Termainl,change Terminal from T100 to Xtern,check "ANSI Color" and "Use color scheme",click OK,and relogin,then when use VI or emacs,it will color your code
Tuesday, October 18, 2011
jquery selector
A tag name: $('p') gets all paragraphs in the document.
An ID: $('#some-id') gets the single element in the document that has the corresponding some-id ID.
A class: $('.some-class') gets all elements in the document that have a class of some-class.
following code will be explained,example from learning jquery
$('#selected-plays > li').addClass('horizontal');
the line used the child combinator(>) to add the horizontal class to all top-level items only,it says find each list item(li) that is a child (>) of an element within an ID of selected-plays(#selected-plays).
$('#selected-plays li:not(.horizontal)').addClass('sub-level');
get every list item(li) that is a descendant of an element with an ID of selected-plays(#selected-plays) and Does not have a class of horizontal(:not(.horizontal)).
$('a[@title]')
this is use XML Path Language (XPath),it says select all links that have a title attribute
$('div[ol]')
this is use XPath also,it says get all div elements that contain an ol element
$('a[@href^="mailto:"]').addClass('mailto');
this will look for all anchor elements(a) with href attribut([@href]) that begins(^)with mailto(^="mailto:")
$('a[@href$=".pdf"]').addClass('pdflink');
this will get all links with an href attribute that ends with .pdf,this is use a dollar sign($)
$('a[@href*="mysite.com"]').addClass('mysite');
this will get all links to other pages on mysite.com,this is use asterisk(*)
$('div.horizontal:eq(1)')
select second item from matched set of divs with a class of horizontal(this is custom selectors)
$('tr:odd').addClass('odd');
$('tr:even').addClass('even');
$('td:contains("Henry")').addClass('highlight');
another three useful custom selectors
An ID: $('#some-id') gets the single element in the document that has the corresponding some-id ID.
A class: $('.some-class') gets all elements in the document that have a class of some-class.
following code will be explained,example from learning jquery
$('#selected-plays > li').addClass('horizontal');
the line used the child combinator(>) to add the horizontal class to all top-level items only,it says find each list item(li) that is a child (>) of an element within an ID of selected-plays(#selected-plays).
$('#selected-plays li:not(.horizontal)').addClass('sub-level');
get every list item(li) that is a descendant of an element with an ID of selected-plays(#selected-plays) and Does not have a class of horizontal(:not(.horizontal)).
$('a[@title]')
this is use XML Path Language (XPath),it says select all links that have a title attribute
$('div[ol]')
this is use XPath also,it says get all div elements that contain an ol element
$('a[@href^="mailto:"]').addClass('mailto');
this will look for all anchor elements(a) with href attribut([@href]) that begins(^)with mailto(^="mailto:")
$('a[@href$=".pdf"]').addClass('pdflink');
this will get all links with an href attribute that ends with .pdf,this is use a dollar sign($)
$('a[@href*="mysite.com"]').addClass('mysite');
this will get all links to other pages on mysite.com,this is use asterisk(*)
$('div.horizontal:eq(1)')
select second item from matched set of divs with a class of horizontal(this is custom selectors)
$('tr:odd').addClass('odd');
$('tr:even').addClass('even');
$('td:contains("Henry")').addClass('highlight');
another three useful custom selectors
config emacs
emacs configuration done by a file called .emac in home directory,it will explain by Lisp language
1) set a variable (setq var_name var_value),in list, true is "t",False is "nil"
1) set a variable (setq var_name var_value),in list, true is "t",False is "nil"
evaluate your lisp code in emacs
while all configuration for emcs is reside in .emacs file,we need temporarily test those configurations before permanently put into .emacs file
1) open emacs
2)M-x(alt-X) emacs-lisp-mode
3) from menu Emacs-Lisp,choose interactive Expression evaluation,we will see a EList> prompt for you to input lisp code
EList>(setq test t)
t
EList>(setq test1 "test1")
test1
EList>
1) open emacs
2)M-x(alt-X) emacs-lisp-mode
3) from menu Emacs-Lisp,choose interactive Expression evaluation,we will see a EList> prompt for you to input lisp code
EList>(setq test t)
t
EList>(setq test1 "test1")
test1
EList>
how to use cx_Oracle
connection = cx_Oracle.Connection(connection_string)
cursor = cx_Oracle.Cursor(connection)
cursor.execute(query)
result= cursor.fetchall()
cursor.close()
connection.close()
for row in result:
print row
connection_string is username/password@tsnmame
or
connection = cx_Oracle.Connection(connection_string)
cur = connection.cursor()
cur.executemany("insert into net_eqam_info (sample_date, eqamip, rf_output, l2tp_session_id, cmts_name, eqam_name) values (trunc(sysdate),:1,:2,:3,:4,:5)",[{'1': '172.19.214.21', '2': '39000', '3': '1.1.1', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}, {'1': '172.19.214.21', '2': '39001', '3': '1.1.2', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}])
connection.commit()
cur.close()
connection.close()
remember whe execute a batch query,first parameter is query with named parameter,second one is a list of dictionaries
cursor = cx_Oracle.Cursor(connection)
cursor.execute(query)
result= cursor.fetchall()
cursor.close()
connection.close()
for row in result:
print row
connection_string is username/password@tsnmame
or
connection = cx_Oracle.Connection(connection_string)
cur = connection.cursor()
cur.executemany("insert into net_eqam_info (sample_date, eqamip, rf_output, l2tp_session_id, cmts_name, eqam_name) values (trunc(sysdate),:1,:2,:3,:4,:5)",[{'1': '172.19.214.21', '2': '39000', '3': '1.1.1', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}, {'1': '172.19.214.21', '2': '39001', '3': '1.1.2', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}])
connection.commit()
cur.close()
connection.close()
remember whe execute a batch query,first parameter is query with named parameter,second one is a list of dictionaries
three basic data structure in python
1)list,list is the sequence of data,created with [],and has order,can be accessed by index
2)dictionary,dictionary is key:value list,created with {} and do not have a order,key must be unique
3)tuple,tuple is a instance list that can not be changed,created by (),and do have order,accessed by index
2)dictionary,dictionary is key:value list,created with {} and do not have a order,key must be unique
3)tuple,tuple is a instance list that can not be changed,created by (),and do have order,accessed by index
Pexpect is help interact with ssh
I have a 400-500 ssh server that I need connect to by ssh,since those server are not real OS server,they are eqipment,they are response very slowly,even for the login,I tried jsch,it can not handle the server's delay,my command was inserted into the server's prompt information,and not been accepted and executed.
there is a tool call script expect that can help with this,but lack of database connection and data process(File read/write) and data structure
so I come up with a python and pexpect package,it was very neat to connect to ssh server interact with it and fetch the result,save it to a file,extract data I want,then save into database,here is the part of code for pexepect:
def readEqam(ip,userIndex):
print 'connecting to',ip
starttime = datetime.now()
logFile = file('eqam_'+ip+".txt",'w')
child=pexpect.spawn('ssh '+userNames[userIndex]+'@'+ip)
child.logfile=logFile
i=child.expect(["Are you sure you want to continue connecting","password:"])
print i
if i==0:
child.sendline('yes')
i=child.expect('password:')
child.sendline(passwords[userIndex])
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
child.sendline("show application m-cmts")
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
data = child.before
child.sendline("closeSession")
child=None
elif i==1:
child.sendline(passwords[userIndex])
i=child.expect('#>',60)
if i!=0:
child.kill(0)
return False
else:
child.sendline("show application m-cmts")
#print child.before
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
#print "START",child.before,"END"
data = child.before
child.sendline("closeSession")
child.sendline("\r")
child = None
logFile.close()
print 'total time used:',(datetime.now()-starttime).seconds
return True,data
there is a tool call script expect that can help with this,but lack of database connection and data process(File read/write) and data structure
so I come up with a python and pexpect package,it was very neat to connect to ssh server interact with it and fetch the result,save it to a file,extract data I want,then save into database,here is the part of code for pexepect:
def readEqam(ip,userIndex):
print 'connecting to',ip
starttime = datetime.now()
logFile = file('eqam_'+ip+".txt",'w')
child=pexpect.spawn('ssh '+userNames[userIndex]+'@'+ip)
child.logfile=logFile
i=child.expect(["Are you sure you want to continue connecting","password:"])
print i
if i==0:
child.sendline('yes')
i=child.expect('password:')
child.sendline(passwords[userIndex])
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
child.sendline("show application m-cmts")
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
data = child.before
child.sendline("closeSession")
child=None
elif i==1:
child.sendline(passwords[userIndex])
i=child.expect('#>',60)
if i!=0:
child.kill(0)
return False
else:
child.sendline("show application m-cmts")
#print child.before
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
#print "START",child.before,"END"
data = child.before
child.sendline("closeSession")
child.sendline("\r")
child = None
logFile.close()
print 'total time used:',(datetime.now()-starttime).seconds
return True,data
Compile the CX_Oracle
cx_Oracle is python library that help us connect to Oracle database run qery to retrieve data or update data in database
before use it we need setup the machine that use cx_Oracle
1)setup env variable call ORACLE_HOME,it should point to the path that Oracle database,standard client,or instant client(basic client,and SDK) installed
2)if still get error that can not import cx_Oracle from python,we need compile and install cx_Oracle in the machine it will be used
3)setup Oracle_Home as i said before,setup LD_LIBRARY_PATH to $ORALCE_PATH/lib folder
4) go to cx_Oracle folder,execute python setyp.py build,if it complains about one library can not be found,go to ORACLE_HOME(instant client),create a link for the library with the name gcc requested with the file has similar name but attach a version with the file.re-run build,if it success,then run python setup.py install,this one should be has a root privilege,otherwise will fail on copying file
5) when we connection to Oracle,we also need setup service name(tns name) in tnsnames.ora
we are good to go
before use it we need setup the machine that use cx_Oracle
1)setup env variable call ORACLE_HOME,it should point to the path that Oracle database,standard client,or instant client(basic client,and SDK) installed
2)if still get error that can not import cx_Oracle from python,we need compile and install cx_Oracle in the machine it will be used
3)setup Oracle_Home as i said before,setup LD_LIBRARY_PATH to $ORALCE_PATH/lib folder
4) go to cx_Oracle folder,execute python setyp.py build,if it complains about one library can not be found,go to ORACLE_HOME(instant client),create a link for the library with the name gcc requested with the file has similar name but attach a version with the file.re-run build,if it success,then run python setup.py install,this one should be has a root privilege,otherwise will fail on copying file
5) when we connection to Oracle,we also need setup service name(tns name) in tnsnames.ora
we are good to go
Monday, October 17, 2011
Cable Modem tech
Cable Modem is type of netwoek bridge and medem that provides bi-directionary communication var radio frequency channel on a HFC and RFoG infrastructure
HFC stand for Hybrid fibre-coaxial( chinese is 混合光缆同轴)
RFoG stands for Radio Frequency over Glass,in which the coax partion of HFC network replaced by a single-fiber,passive optical architecture(PON)
Friday, October 7, 2011
contract first webservice
while coding on existing wsdl file,after I add my customized DataType,messages and operations(In Port Types),then add Soap bindings(add these operations into Binding),we need add more stuff under operation from Binding,we need add soap operation under operation and add soap body under in and out parameter,add soap:fault under FAULT.
otherwise,it will complain about there are no SOAP BODY EXTENSION for some data
otherwise,it will complain about there are no SOAP BODY EXTENSION for some data
Thursday, October 6, 2011
test PL/SQL SP code
SQLDeveloper has a very good GUI,that can let you test the SP you developed
open a new SQL windows,drag and drop the SP into this windows,I will create code for you to test,you just need change IN parameter's value,print the OUT value when call is done.
one thing is not very handy that It can not gracefully handle cursor,If I define a Cursor in my SP as a IN parameter,when I direct run the test,It says syntax wrong,I need change the cursor defintion same as it was define in my SP.
I still need addtional code to iterator my OUT cursor.
from SQLPLUS,it will be very handy than that.
simplely define a refcursor like this,and call sp,then print result.
note that all the code we out in sqlplus can also be put in sqldeveloper and get the same result.
SQL> var rc refcursor
SQL> exec WS_PKG.Get_CMTS_By_Facility('AJAX',10,:rc);
PL/SQL procedure successfully completed.
SQL> print rc
no rows selected
SQL>
if there are some data,it will print it out,good way to handle cursor here.
TOAD do not have a drag and drop option,It will be more convinient to run in TOAD.following those steps
1) browse to you packages(package),right click run package
2) from Menu View,select DBMS Output.
3) it will pop up a window,let you select specific SP,and ask for input parameters.REMEMBER,there is a tab beside Arguments in this popup dialog,called option,in there,we need click "Print OUT arguments/Return values to DBMS Output",make sure select third option "LOAD into grid from memory",then click OK,it will run test code and display return cursor value in grid.
This is tested in TOAD for Oracle FreeWare 10.6.0.42
open a new SQL windows,drag and drop the SP into this windows,I will create code for you to test,you just need change IN parameter's value,print the OUT value when call is done.
one thing is not very handy that It can not gracefully handle cursor,If I define a Cursor in my SP as a IN parameter,when I direct run the test,It says syntax wrong,I need change the cursor defintion same as it was define in my SP.
I still need addtional code to iterator my OUT cursor.
from SQLPLUS,it will be very handy than that.
simplely define a refcursor like this,and call sp,then print result.
note that all the code we out in sqlplus can also be put in sqldeveloper and get the same result.
SQL> var rc refcursor
SQL> exec WS_PKG.Get_CMTS_By_Facility('AJAX',10,:rc);
PL/SQL procedure successfully completed.
SQL> print rc
no rows selected
SQL>
if there are some data,it will print it out,good way to handle cursor here.
TOAD do not have a drag and drop option,It will be more convinient to run in TOAD.following those steps
1) browse to you packages(package),right click run package
2) from Menu View,select DBMS Output.
3) it will pop up a window,let you select specific SP,and ask for input parameters.REMEMBER,there is a tab beside Arguments in this popup dialog,called option,in there,we need click "Print OUT arguments/Return values to DBMS Output",make sure select third option "LOAD into grid from memory",then click OK,it will run test code and display return cursor value in grid.
This is tested in TOAD for Oracle FreeWare 10.6.0.42
thinking about JAX-WS with NetBeans
for webservice developing in netbeans,it is very nice that netbeans have very good wsdl editor,you can add complex data type,you can add messages,you can add Port Type,Bindings and Services,it is very handy.
but,with a project I done long time ago,now I need to changes some of service's return data,say complex data type to include additional data.so I have edit my original wsdl file to include this change,and totoally delete current web service,create new web service based on my changed wsdl file,it override my original implementation with a empty one,I have manualy bring my previous implementation back and changed it to effect wsdl change.
looks like it will compile code to include all my changes in wsdl,when i build and deploy,it is successes,but it is not working.it says some class based on complex data type can not be find.
another step missed,it turns out that I need refresh my web service newly created to created another wsld file locally to pack inside war file(not my original edited wsdl file,they are same anyway),it was kindly asking for overriding my implementation and make a back up for you.so I did it,clean and build,deploy,test with soapUI,viola,it works.
so now in side my project,I have two wsdl files,I need to remember that which one is original one,I will need to edit it in future to change the service if the needs come.
one more thing to remember,logging,I using log4J for web service to logging
log file is look like this:
log4j.appender.logfile.File=${com.sun.aas.instanceRoot}/logs/DTTServices.log
that means web service will log to the file that reside in server's logs folder in Domain1,but If I run my unit test,I says it can not find file /logs/DTTServices.log
,since I am using linux,it is no possible to create a folder and file in root folder,so I need change that line like this
log4j.appender.logfile.File=logs/DTTServices.log
then I run the unit test,It will automatically create folder and log file for me.the logs folder will reside in root of the project,not in src, not in build either
that's all
but,with a project I done long time ago,now I need to changes some of service's return data,say complex data type to include additional data.so I have edit my original wsdl file to include this change,and totoally delete current web service,create new web service based on my changed wsdl file,it override my original implementation with a empty one,I have manualy bring my previous implementation back and changed it to effect wsdl change.
looks like it will compile code to include all my changes in wsdl,when i build and deploy,it is successes,but it is not working.it says some class based on complex data type can not be find.
another step missed,it turns out that I need refresh my web service newly created to created another wsld file locally to pack inside war file(not my original edited wsdl file,they are same anyway),it was kindly asking for overriding my implementation and make a back up for you.so I did it,clean and build,deploy,test with soapUI,viola,it works.
so now in side my project,I have two wsdl files,I need to remember that which one is original one,I will need to edit it in future to change the service if the needs come.
one more thing to remember,logging,I using log4J for web service to logging
log file is look like this:
log4j.appender.logfile.File=${com.sun.aas.instanceRoot}/logs/DTTServices.log
that means web service will log to the file that reside in server's logs folder in Domain1,but If I run my unit test,I says it can not find file /logs/DTTServices.log
,since I am using linux,it is no possible to create a folder and file in root folder,so I need change that line like this
log4j.appender.logfile.File=logs/DTTServices.log
then I run the unit test,It will automatically create folder and log file for me.the logs folder will reside in root of the project,not in src, not in build either
that's all
Wednesday, October 5, 2011
add oracle jdbc driver to maven local repository
mvn install:install-file -DgroupId=com.oracle -DartifactId=oracle -Dversion=11.2.0.4.0 -Dpackaging=jar -Dfile=/home/dttdev1/libs/ojdbc5.jar
check out specified reversion source code from remote sub version server
svn checkout -r 614 https://src.springframework.org/svn/spring-samples/configuration-basic configuration-basic
614 is the reversion
https://src.springframework.org/svn/spring-samples/configuration-basic is the url
configuration-basic is target folder
Tuesday, October 4, 2011
Spring AOP execution PCD(Pointcut designator) execution expression
mostly,we use execution,here is the execution expression format
execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern) throws-pattern?)
pay attention to the space after question mark,and only ret-type-pattern is mandatory,after name-pattern,there is not space between name-pattern and bracket
for example:@Pointcut("execution(* transfer(..))")
means: start is for return type pattern,start means any type
transfer is for name-pattern,it means any method named transfer
two dots .. is parameter pattern,it means any number of parameter with any type
if we change it to (*),it mean one parameter with any type
(*,String) means two parameter with first one can be any type,second one must be String
install and remove rpm in linux system
install rpm -iv VirtualBox-4.1-4.1.4_74291_rhel5-1.x86_64.rpm
find rpm -qa |grep -i VirtualBox
remove rpm -e VirtualBox-4.1-4.1.0_BETA3_72886_rhel5-1.x86_64
Spring PCD
Spring AOP supports the following AspectJ pointcut designators (PCD) for use in pointcut expressions:
execution - for matching method execution join points, this is the primary pointcut designator you will use when working with Spring AOP
within - limits matching to join points within certain types (simply the execution of a method declared within a matching type when using Spring AOP)
this - limits matching to join points (the execution of methods when using Spring AOP) where the bean reference (Spring AOP proxy) is an instance of the given type
target - limits matching to join points (the execution of methods when using Spring AOP) where the target object (application object being proxied) is an instance of the given type
args - limits matching to join points (the execution of methods when using Spring AOP) where the arguments are instances of the given types
@target - limits matching to join points (the execution of methods when using Spring AOP) where the class of the executing object has an annotation of the given type
@args - limits matching to join points (the execution of methods when using Spring AOP) where the runtime type of the actual arguments passed have annotations of the given type(s)
@within - limits matching to join points within types that have the given annotation (the execution of methods declared in types with the given annotation when using Spring AOP)
@annotation - limits matching to join points where the subject of the join point (method being executed in Spring AOP) has the given annotation
Spring AOP pointcut declaration
A pointcut declaration has two parts:
a signature comprising a name and any parameters, and a pointcut expression that determines exactly which method executions we are interested in.
In the @AspectJ annotation-style of AOP, a pointcut signature is provided by a regular method definition, and the pointcut expression is indicated using the @Pointcut annotation (the method serving as the pointcut signature must have a void return type).
Monday, October 3, 2011
Spring AOP concepts
Aspect: a modularization of a concern that cuts across multiple classes. Transaction management is a good example of a crosscutting concern in enterprise Java applications. In Spring AOP, aspects are implemented using regular classes (the schema-based approach) or regular classes annotated with the @Aspect annotation (the @AspectJ style).
Join point: a point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point always represents a method execution.
Advice: action taken by an aspect at a particular join point. Different types of advice include "around," "before" and "after" advice. (Advice types are discussed below.) Many AOP frameworks, including Spring, model an advice as an interceptor, maintaining a chain of interceptors around the join point.
Pointcut: a predicate that matches join points. Advice is associated with a pointcut expression and runs at any join point matched by the pointcut (for example, the execution of a method with a certain name). The concept of join points as matched by pointcut expressions is central to AOP, and Spring uses the AspectJ pointcut expression language by default.
Introduction: declaring additional methods or fields on behalf of a type. Spring AOP allows you to introduce new interfaces (and a corresponding implementation) to any advised object. For example, you could use an introduction to make a bean implement an IsModified interface, to simplify caching. (An introduction is known as an inter-type declaration in the AspectJ community.)
Target object: object being advised by one or more aspects. Also referred to as the advised object. Since Spring AOP is implemented using runtime proxies, this object will always be a proxied object.
AOP proxy: an object created by the AOP framework in order to implement the aspect contracts (advise method executions and so on). In the Spring Framework, an AOP proxy will be a JDK dynamic proxy or a CGLIB proxy.
Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.
Types of advice:
Before advice: Advice that executes before a join point, but which does not have the ability to prevent execution flow proceeding to the join point (unless it throws an exception).
After returning advice: Advice to be executed after a join point completes normally: for example, if a method returns without throwing an exception.
After throwing advice: Advice to be executed if a method exits by throwing an exception.
After (finally) advice: Advice to be executed regardless of the means by which a join point exits (normal or exceptional return).
Around advice: Advice that surrounds a join point such as a method invocation. This is the most powerful kind of advice. Around advice can perform custom behavior before and after the method invocation. It is also responsible for choosing whether to proceed to the join point or to shortcut the advised method execution by returning its own return value or throwing an exception.
Join point: a point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point always represents a method execution.
Advice: action taken by an aspect at a particular join point. Different types of advice include "around," "before" and "after" advice. (Advice types are discussed below.) Many AOP frameworks, including Spring, model an advice as an interceptor, maintaining a chain of interceptors around the join point.
Pointcut: a predicate that matches join points. Advice is associated with a pointcut expression and runs at any join point matched by the pointcut (for example, the execution of a method with a certain name). The concept of join points as matched by pointcut expressions is central to AOP, and Spring uses the AspectJ pointcut expression language by default.
Introduction: declaring additional methods or fields on behalf of a type. Spring AOP allows you to introduce new interfaces (and a corresponding implementation) to any advised object. For example, you could use an introduction to make a bean implement an IsModified interface, to simplify caching. (An introduction is known as an inter-type declaration in the AspectJ community.)
Target object: object being advised by one or more aspects. Also referred to as the advised object. Since Spring AOP is implemented using runtime proxies, this object will always be a proxied object.
AOP proxy: an object created by the AOP framework in order to implement the aspect contracts (advise method executions and so on). In the Spring Framework, an AOP proxy will be a JDK dynamic proxy or a CGLIB proxy.
Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.
Types of advice:
Before advice: Advice that executes before a join point, but which does not have the ability to prevent execution flow proceeding to the join point (unless it throws an exception).
After returning advice: Advice to be executed after a join point completes normally: for example, if a method returns without throwing an exception.
After throwing advice: Advice to be executed if a method exits by throwing an exception.
After (finally) advice: Advice to be executed regardless of the means by which a join point exits (normal or exceptional return).
Around advice: Advice that surrounds a join point such as a method invocation. This is the most powerful kind of advice. Around advice can perform custom behavior before and after the method invocation. It is also responsible for choosing whether to proceed to the join point or to shortcut the advised method execution by returning its own return value or throwing an exception.
fwe concept of ServiceMix(ESB)
JBI-- Java Business Integration
BC-Binding Components
SE-Service Engines
SA-service assembly
SU-service unit
the components for ServiceMix comes two flavors
1) Binding Components provide additional transports to the container.
An example: the servicemix-http binding component allows to send messages into the ESB using HTTP
2) Service Engines add support for another type of business logic to the container.
An example: the servicemix-saxon service engine allows you to easily build applications that do XSL-T transformations
BC-Binding Components
SE-Service Engines
SA-service assembly
SU-service unit
the components for ServiceMix comes two flavors
1) Binding Components provide additional transports to the container.
An example: the servicemix-http binding component allows to send messages into the ESB using HTTP
2) Service Engines add support for another type of business logic to the container.
An example: the servicemix-saxon service engine allows you to easily build applications that do XSL-T transformations
Subscribe to:
Posts (Atom)