Skip to main content

Posts

Showing posts from November, 2009

Xmlbean Vs JAXB

As we know JAXB is used for XML binding with Java. Also Apache XmlBeans also used to XML binding with JAVA. Here I am going to say (Prove) which best to use? JAXB Advantages: Sun's Implementation well known with JAX-WS & JAX-RPC Disadvantages: To Marshall & UnMarshall we to write manual code. XmlBean Advantages: No need to write code to Marshall & UnMarshall Inbuilt support for Saxon xQuery & XPath All Bea products using (Weblogic Portal, Aqualogic Service Bus) Disadvantages: Not known by many developers JAXB sample code to bind XML: public class Main { public static void main(String[] args) { Object pud = unmarshall(some.pkg", TestDocument.class); marshall("poc.act.cms.poc", pud); } public static void marshall(String namesapce, Object object) { try { JAXBContext jc = JAXBContext.newInstance(namesapce); Marshaller m = jc.createMarshaller(); m.setProp

Why JPA?

A fundamental question for many Java developers is "Why JPA? Why do I need to know how to use this API when object-relational mapping tools like Hibernate and Toplink are already available?" The answer is that JPA is not a new technology; rather, it has collected the best ideas from existing persistence technologies like Hibernate, TopLink, and JDO. The result is a standardized specification that helps you build a persistence layer that is independent of any particular persistence provider.

Create Thread Pool in JAVA is Easy now

By using ExecutorService we can create a pool of threads and run in parallel. This feature has introduced in JAVA5. see the below links. ExecutorService ThreadPoolExecutor here is an example: ExecutorService exec = Executors.newFixedThreadPool(10); for (int i=0;i<100;i++) { exec.execute(new DoSomething(data)); } in this example we have created a pool of threads contains 10. Here new DoSomething(data) will be executed 10times parallel. this can be used, where we need to call Web services since we cannot create webservice connection pool.

Develope & deploy, debug JSR168 portlet with netbeans

As we know netbeans have portalpack plug in to develop JSR168 & 286 portlets. But we need portlet container to deploy & debug portlets. GateIn give a simple portlet container where we can test our portlets. To download click here Followed the below steps: Install portalpack plugin in netbeans Download and unzip GateIn Portlet Container Add new server(Tomcat) in netbeans as Unzipped folder like E:\jeeva\gatein-portletcontainer-2.1.0-Beta01-tomcat6 Create new web application and select Portlet support in netbeans For our webapp select server as created one. Develop portlet and deploy. this will deploy our app as normal webapp deployment in tomcat The GateIn Portlet Container will read this app and register with the container. Add the portlet in demo JSP of GateIn Portlet Container's simple-portal Access the url http://localhost:8080/simple-portal/demo/demo.jsp To debug our app start the server in debug mode from netbeans. So we can easily develop, deploy & debug our JSR p