Put the property Files in the classpath ,which contains key value pairs.
If the files are putin any other location thean classpath , give the path in tomcat startup.sh or classpath.sh next to the bootstrap jar listing.
Now access the files as accessing any other Bundle
ResourceBundle myResources = ResourceBundle.getBundle("propertfilename");
Then u can do a bundle.getValue() to the required key value pair.
Wednesday, November 12, 2008
Fetching Property Files Using Resource Bundle
XML -RPC
Apache XML-RPC is a Java implementation of XML-RPC, a popular protocol that uses XML over HTTP to implement remote procedure calls.
Steps
1.Client class
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://127.0.0.1:8080/xmlrpc"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[]{new Integer(33), new Integer(9)};
Integer result = (Integer) client.execute("Calculator.add", params);
2.Server Class
public class Calculator {
public int add(int i1, int i2) {
return i1 + i2;
}
public int subtract(int i1, int i2) {
return i1 - i2;
}
}
3. Create Propert File
Create a property file, which contains at least one property. The property name is arbitrary, and the property value is the fully qualified name of the Calculator class. For example, like that:
Calculator=org.apache.xmlrpc.demo.Calculator
The property file must be called XmlRpcServlet.properties, and it must be located in the package org.apache.xmlrpc.webserver. In other words, you would typically put it into the directory org/apache/xmlrpc/webserver and add it to your jar file.
4. Add Entry to Web.xml
<servlet>
<servlet-name> XmlRpcServlet</servlet-name>
<servlet-class>org.apache.xmlrpc.webserver.XmlRpcServlet</servlet-class>
<init-param>
<param-name>
enabledForExtensions</param-name>
<param-value>true</param-value>
<description> Sets, whether the servlet supports vendor extensions for XML-RPC. </description>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc</url-pattern>
</servlet-mapping>
Reference http://ws.apache.org/xmlrpc/
XStream - Convert XMl to Java & Vice Versa
</person></code>
Saturday, November 1, 2008
Multiple Ajax Requests - Consequtively
When Ajax requests are submitted one after the other by hitting the same URL requests
will not be submitted by property of ajax requests, since it tries to stop multiple requests
being submitted .
This can be avoided by appending Date field with milliseconds to the url.
By doing so the Ajax identifies it as a different request and request will be re-submitted.
OSWORKFLOW - Workflow Engine
OSWorkflow is fairly different from most other workflow systems available, both commercially and in the open source world. What makes OSWorkflow different is that it is extremely flexible.
OSWorkflow can be considered a "low level" workflow implementation. Situations like "loops" and "conditions" that might be represented by a graphical icon in other workflow systems must be "coded" in OSWorkflow.
Almost all of the required libraries for OSWorkflow are included in the distribution:
OSCore 2.0.1+
PropertySet 1.2+
Jakarta commons-logging
BeanShell (optional)
BSF (optional)
EJB interfaces (not neccesarily an EJB container)
XML parser (Not required for JDK 1.4)
Various concepts in oSWorkFlow are
Workflow Definition
Workflow Concepts
Common and Global Actions
Functions
Validators
Registers
Conditions
SOAP Support
Reference
http://www.opensymphony.com/osworkflow/
JNotify - Java library that allows java application to listen to file system events
JNotify works on both Windows (Windows 2000, XP, Vista) and Linux with INotify support (Kernel 2.6.14 and above).
JNotify is a java library that allow java application to listen to file system events, such as:
file created.
file modified.
file renamed.
file deleted.
This property can be used in a number of scenarios.I have used it to reload resource bundles
whenever there is a modiofication in it.
Reference:
http://jnotify.sourceforge.net/
Wednesday, September 24, 2008
Quartz - For Scheduling
Quartz is a full-featured, open source job scheduling system that can be integrated with,or used along side virtually any J2EE or J2SE application.It can mainly be used for Driving WrkFlow and System maintainance.
It can be integrated with any system with ease.It can perform simple or complicated schedules based on given cron expression.The execution logic can be embedded into simple java classes by implementing certain intefaces.
The job information can either be stored in memory through RAMJobStore or can be stored in relational databases using JDBCJobStore.If RAMJobStore is used whenever the server restarts, previously scheduled data is lost.
For scheduling jobs a scheduler needs to be started and jobs can be added as shown below.
SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
Scheduler sched = schedFact.getScheduler();
sched.start();
JobDetail jobDetail = new JobDetail("myJob", null, DumbJob.class);
Trigger trigger = TriggerUtils.makeHourlyTrigger(); // fire every hour trigger.setStartTime(TriggerUtils.getEvenHourDate(new Date())); // start on the next even hour trigger.setName("myTrigger");
sched.scheduleJob(jobDetail, trigger);
Custom job should implement the following interface
Job Interfacepackage org.quartz;
public interface Job {
public void execute(JobExecutionContext context) throws JobExecutionException; }
CronTrigger needs to be used for more complicated schedules.
An example of a complete cron-expression is the string "0 0 12 ? * WED" - which means "every Wednesday at 12:00 pm".
.jpg)