Posts

Showing posts from June, 2013
Installing Liferay on JBoss 5.1 Note: Java 7 deprecated some classes used by JBoss 5.1. Use Java 5 or Java 6 to run JBoss 5.1. Liferay Home is one folder above JBoss’s install location. Download and install JBoss EAP 5.1.x into your preferred directory. This directory is referred to as $JBOSS_HOME throughout this section. Download the latest version of the Liferay Portal .war file. Download Liferay’s Portal Dependencies. Now that you have all of your installation files, you are ready to start installing and configuring Liferay on JBoss. Configuring Dependencies First we’ll take care of dependencies and potential conflicts. Unzip Liferay’s dependencies to $JBOSS_HOME/server/default/lib . Download your database driver .jar file and put it into the folder as well. For demonstration purposes, we’ll download the MySQL Connector/J driver from http://dev.mysql.com/downloads/connector...
JOB SCHEDULING USING QUARTZ IN JAVA An easy example for JOB scheduling class 1 MainApplication :- import java.util.Calendar; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import org.apache.catalina.util.URLEncoder; class MainApplication { public static void main(String[] args) { Timer timer = new Timer(); Calendar date = Calendar.getInstance(); date.set( Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY ); date.set(Calendar.HOUR, 5); date.set(Calendar.MINUTE,0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); // Schedule to run every Sunday in midnight timer.schedule( new ReportGenerator(), date.getTime(), 1000 * 60 * 60 * 24 * 7 ); } } class 2 ReportGenerator :- import java.util.TimerTask; public class ReportGenerator extends TimerTask { public void run() { System.out.println("This is VIKASSSSSSSSSSSSSSSSSSSSSSSS:: "); //TODO generate report ...
  Using JSON in JavaScript.  JSON Simply is a way of representation of data and its access and this is by default supported by javascript JSON is a subset of the object literal notation of JavaScript. Since JSON is a subset of JavaScript, it can be used in the language with no muss or fuss. var myJSONObject = {"bindings": [ {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}, {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"}, {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"} ] }; Members can be retrieved using dot or subscript operators. myJSONObject.bindings[0].method // "newURI" To convert a JSON text into an object, you can use the eval() function. eval() invokes the JavaScript co...
How to create mail functionality in java  We just need mail.jar imported into our Eclipse project for this mail functionality. package Mail; import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class MailManager { private static Properties properties = System.getProperties(); static { String mailhost = "relay.company.com"; properties.put("mail.smtp.host", mailhost); properties.put("mail.mime.charset", "utf-8"); } public static void main(String[] args) throws Throwable { try { // System.out.println("Start-----------"); // String userName = "Vikas"; // String from = userName + "@gma...
Two Way Encryption mechanism for Passwords Encryption of passwords in any application is an important part which need to have some security inputs and good knowledge of Encryption Mechanism . This part concentrates on the same .. Encryption and Decryption Encryption is the process of converting normal data or plaintext to something incomprehensible or cipher-text by applying mathematical transformations. These transformations are known as encryption algorithms and require an encryption key. Decryption is the reverse process of getting back the original data from the cipher-text using a decryption key. The encryption key and the decryption key could be the same as in symmetric or secret key cryptography, or different as in asymmetric or public key cryptography. Algorithms A number of encryption algorithms have been developed over time for both symmetric and asymmetric cryptography. The ones supported by the default providers in J2SE v1.4 are: DES, TripleDES, ...
liferay performance tuning Performance Improvement ways in liferay a) Memory - garbage collection thru Admin interface b) Parameters to JVM while starting tomcat -Xms128m -Xmx1024m -XX:MaxPermSize=128m c) DBCP instances - increase it in ROOT.xml d) Properties file changes last.modified.check=false theme.css.fast.load=true javascript.fast.load=true e) Servlet Filters Total of 15 filters. Disable the ones that are not required. eg. CompressionFilter StripFilter Open web.xml and comment the entries for these filters. Similarly for, CASFilter NtlmFilter VirtualHostFilter The fewer servlet filters you are running, the less processing power is needed. f) Portlet Edit the following files to disable certain portlets from getting deployed to the portal server. portlet.xml liferay-portlet.xml Restart the server g) Database design Ensure all the search colums are indiced properly. Do periodic house-keeping on the database indices. Proper design of the database tables keepin...
Lazy Initilization in Hibernate 1) when loading an object that has a collection, hibernate loads collection elements ONLY when actually you ask for them; so this improves performance. 2) lazy initialization improves performance by delaying the fetch from the database until the returned object is actually queried for the data...it works similar to write behind caching on your hard disk ;-) . 3) when you use hibernate you can make lazy=true or lazy=false. if you mentioned lazy=true and you call from a company bean like Collection x = company.getAllEmployees(); x will be empty; if u mentioned lazy=false x will contain the data as output of the getter funtion. So if you put lazy=true then you need to write HQL query getting these kind of collections. else if lazy = false u can get the collection at the time when u fetch company object. So taking performance(time cost and memory cost) as criter...
Image
Hibernate Integration with Spring Hear comes the integration of Hibernate and Spring Prerequisite Steps 1) Create java class (bean) Employee 2) Create Database and table employee 3) Create hbm.xml 4) make all mappings 3.4) Creating the Spring Configuration File This section deals with configuring the various information needed for the Spring Framework. In Spring, all the business objects are configured in Xml file and the configured business objects are called Spring Beans . These Spring Beans are maintained by the IOC which is given to the Client Application upon request. Let us define a data source as follows, spring-hibernate.xml Refer : http://www.javabeat.net/articles/42-integrating-spring-framework-with- hibernate-orm-framewo-3.html The above bean defines a data-source of type 'org.apache.commons.dbcp.BasicDataSource' . More importantly, it defines the various connection properties that are needed for accessing the database. For accessing the ...