On 29 October 2011 I passed OCMJEA part 1, it was quite tricky exam but I enjoy it and everything went fine, I also completed required hands on training and subscribed for part 2 assignment which I must complete until may 2012.
I'm very happy now:).
Tuesday, December 6, 2011
Using thread pool starting from java5
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
/**
* Processing jobs thread pool
*/
public class ProcessingJobExecutorService {
private static ProcessingJobExecutorService _instance =null;
private ExecutorService executorService;
private ProcessingJobExecutorService(){
executorService = new ScheduledThreadPoolExecutor(500);
}
public static ProcessingJobExecutorService getInstance(){
if(_instance==null){
_instance=new ProcessingJobExecutorService();
}
return _instance;
}
public void execute (Runnable r){
executorService.execute(r);
}
}
Sunday, October 23, 2011
Developing Applications for the Java EE 6 Platform Oracle training
This week I completed this training from Oracle. It was a pleasure to listen and do some exercises with Netbeans and Glassfish. The course was quite expensive but I chose it for mandatory course attendance requirement in case of jee architect certification.
Labels:
SCEA
Wednesday, October 5, 2011
Tuesday, September 20, 2011
Friday, September 16, 2011
java to javascript in wicket
//
//---- code in wicket page constructor ----
//internationalised message to javascript visible in html page
String contributor = "";
add(new StringHeaderContributor(contributor));
//
Domain driven vs service oriented architecture/design
Domain driven design and service oriented design are opposite approaches, while service oriented approach is more stateless (SOA) and more procedural programming like, the domain driven approach is more stateful and object oriented.
The best practices in each case tend to become anti-patterns in the other case.
The best practices in each case tend to become anti-patterns in the other case.
Labels:
sw design
Thursday, September 15, 2011
md5 in java whitout reading file in a buffer
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Scanner;
public class MD5 {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String[] cmd = new String[]{"md5sum","/home/user/workspace/project/buildfile"};
ProcessBuilder pb = new ProcessBuilder(cmd);
Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuffer sb = new StringBuffer();
String line;
while ((line = br.readLine()) != null) {
sb.append(line).append("\n");
}
String answer = sb.toString();
int val = p.waitFor();
String md5 ="";
if(val == 0){
Scanner s = new Scanner(answer);
if(s.hasNext()){
md5 = s.next();
System.out.println(md5);
}
}else{
System.out.println("Error executing command md5sum");
}
}
}
Thursday, September 1, 2011
JQuery - select html elements with id starting with given string
//select all divs with id starting with 'jpassword'
$("div[id^='jpassword']").style.display = 'none';
Labels:
jquery,
Web Developement
Wednesday, August 24, 2011
Exit on ESC in Wicket ModalWindow
//Every modal dialog will extend this class
public class ModalPanelContainer extends ModalWindow implements IHeaderContributor {
//the magic is in this method
@Override
public void show(final AjaxRequestTarget target) {
if (!isShown()) {
final AppendingStringBuffer buffer = new AppendingStringBuffer(500);
buffer.append("function mwClose(ev) {\n" +
"var code = ev.keyCode || ev.which;\n" +
"if (code == 27) { " +
getCloseJavacript() +
"};" +
"}");
buffer.append("jQuery(document).keypress(mwClose);\n");
target.appendJavascript(buffer.toString());
}
super.show(target);
}
}
Labels:
Apache Wicket
Custom 404 error page in Wicket
In web.xml you must have something like this:
After this create a page with mounting point "errror404".
That's it.
WicketFilter
org.apache.wicket.protocol.http.WicketFilter
applicationClassName
com.yourproject.FrontendWebApplication
WicketFilter
/*
REQUEST
ERROR
404
/error404
After this create a page with mounting point "errror404".
That's it.
Labels:
Apache Wicket
Subscribe to:
Posts (Atom)