Create the bean which should be called on regular intervals.
This bean should extend the TimerTask and should have the run method which will be called on timely basis.
<bean id="example" class="com.examples.foo">
Make the bean a task and provide the time interval when it needs to be called. The time could be picked from property files.
<bean id="exampleTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="period" value="${exampleTime}">
<property name="timerTask" ref="example">
</property>
Add the tasks as part of Timerfactory which will be called based on the time given.
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="exampleTask">
</ref>
</list>
</property>
All the above entries will be part of the spring xml.More then one tasks can be added to the timerfactory
</bean></property></bean></bean>
Monday, August 4, 2008
Spring timer tasks for Threads
Prototip for easy and Fancy tool Tips
Just came across Prototip which helps to create javascript based tool tips with ease
http://www.nickstakenburg.com/projects/prototip2/.
Could not work more on it as we needed something which supports from IE 5+ versions. Protip supports IE 6+ and Firefox 2+
Running Parallel Db queries on huge Databases.
When the size of the table is very high and the column you are looking for is not indexed then the best way to run the query would be by parallel execution.
This really speeds up the process . But the catch here is that the CPU utilization is high and in production systems this may end up in locks.
This technique can be safely used in backup db servers.
Example
SELECT /*+ parallel(huge_table,4 ) */ * FROM huge_table;
where 4 is the degree of parallelism.The degree of parallelism depends on the capacity of the machines.
Friday, August 1, 2008
Loading multiple property files using Spring
While loading multiple files using spring the following property needs to be added
into
Some useful unix commands i came across today
vmstat [pamam1] [param2]
shows the server statics along with swap space, cache,io and cpu utilization.
this stats are shown [param2] number of times with [param1] duration in between.
top
this command also shows the server statistics in detail with
contribution from each process.
This also shows the memory used,cpu utilization and command used for each thread.
finger
Shows the user who are currently logged into the node.
Simplest way to Configure Logging using Log4j
Ensure the log4j.jar & log4j.properties are in the classpath
Add the following into the required classes where logging is needed , so that log shows file name for each logger statement .
private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger([classname].class);
folowed by logger.[info,debug,error,fatal etc]("logger message");
Contents in Log 4j.properties
log4j.rootLogger=ON, ROOT[enabling the root logger]
log4j.appender.ROOT=org.apache.log4j.DailyRollingFileAppender[saving logs on the daily basis with date appended]
log4j.appender.ROOT.File=/a/b/c.log[root log file path]
log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
log4j.appender.ROOT.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss } %-5p [%t] %c{2} - %m%n [pattern for display in each line]
#FILE APPENDER [another logger file ]
log4j.appender.F2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.F2.File=/a/b/d.log
log4j.appender.F2.layout=org.apache.log4j.PatternLayout
log4j.appender.F2.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss } %-5p [%t] %c{2} - %m%n
log4j.logger.org.apache=ERROR[apache specific errors to be shown on both logger files]
log4j.logger.com.example=DEBUG,F2[for com.example modules debug status messages to be shown in second logger file]
For Log4j debugging
Append -Dlog4j.debug in JAVA_OPTS in catalina.sh which will enable detailed logs in catalina.out showing the logger configerations.
Thursday, July 31, 2008
Apache Basics
Apache Restart
sudo /etc/rc.d/init.d/httpd restart
All requests with port :8080 are caught by tomcat as apache is listening at port 80
requests without ports are heard by apache which listens at port 80 and later redirects through 8009
Directory Structure
etc/httpd/
conf/ conf.d/ logs/ modules/ run/
conf/
httpd.conf ssl.crl ssl.crt ssl.csr ssl.key ssl.prm workers.properties
conf.d/
authz_ldap.conf jk.conf perl.conf php.conf python.conf README ssl.conf webalizer.conf welcome.conf
1. etc/httpd/conf/httpd.conf
Attributes include
DocumentRoot "/home/partyaccount/website/htdocs"
DirectoryIndex index.jsp index.html inde
DefaultType text/plain
ErrorLog logs/error_log
AddEncoding x-compress Z
ErrorDocument 500 "The server made a boo boo."
2. worker/properties
worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
[uri:/ws/*]
worker=ajp13:localhost:80
3. etc/httpd/conf.d/jk.conf
worker assighnments with respective .jsp,.html etc
4. etc/httpd/conf.d/ssl.conf
will have virtual hosts configured here ex:pa112 etc
document root
server admin
servername
Rewrite rules per vhost klike
RewriteEngine on
RewriteRule ^(.*)/.jsp$ $1.do [L]
.jpg)