Cues-JMS

Got a chance to learn JMS .JMS Provider is JBossMQ.Learnt things about topic,queue,non persistent ,persistent mode of message deliveries,durable and non-durable subscriptions,message listeners.

Irrespective of all this scenarios we faced a situtation where messages are non-persistent,no durable subscriptions still messages are not deleted from Microsoft SQL Server DB.

Another strange situation when these messages gets deleted in DB after they get consumed and where these delete queries created lock on one another leading to some many abnormal situations.This made us to truncate the table.


ConnectionFactory--->Connection--->Session--->whatever (consumer/producer)get here.


Learnt little about MDB's ,message listeners.....

Cues-Migrating Java Webservices application from Apache Tomcat 5.5.27 to JBoss5.1.0

Not so gud at webservices but i was assigned a task of migrating an application from Tomcat 5.5.27 JDK1.5 environment to JBoss5.1.0.

Underestimated JDK and thought it has nothing to play role but has much to do.

Approach the application followed was all the web-services are written and taking this class as reference server side classes and client side classes are generated using JAX-WS RI2.0 Implementations.

With jdk1.5 and above jax-ws ri everyhting is built successfully and deployed .

I migrated this to JDK1.6 JBoss5.1.0..

The application first didnot get builded using jdk1.6 reason is jdk1.5 and jaxws-ri2.o generated some client and server side classes with annotations @AccessType which is replaced by @XmlAccessType .

So once again regenerated all the client side and server side classes and bundled these to the application and builded .Then application got builded successfully.

Next is the deployment in the JBoss-5.1.0 GA server on which i dont hav any experienc at all.

Forgotten to mention one point.After regenerating the client sode ands server side classes i hav to bundle the same jars to the application but didnot did that.Because i dont know if anything happens if i replace the jars.(Replaced the jars then also application is working).

Application didnot get deployed successfully.Many issues with jar conflicts.Deployed the application in JBoss adding jboss-web.xml with the following content .


java2ParentDelegation=false


Then application deployed successfully but not able to access the webservices.Then added 4 jars to lib/endorsed hamammama everythin cool now....

To understand all this stuff it took me 45 days...

Cues-Differences

What is the difference between an Enterprise Java Bean and JavaBean?
What is the difference between RPC and RMI?
Is there any thing lik closing the EJB Container in EJB3.0 if so wat benefits do we gain by closing the container and wat losses we get by closing the container ?

Cues-Answer for my Last q's

Does spring framework also needs container to work out with spring beans i.e; Does spring container needs a server to work out with?

EJB3.0 provides Dependency Injection for JNDI Objects.In other words,EJB3 dependency injection capabilities are limited in making the JNDI lookups more convinent,but do not go beyond that.
And there seems there is no point in making every internal object of the application to be managed by the application server.

In contrast to the above Spring Framework does it in a different way.Spring works in such a way that it lets the server does not know about each and every object of the application. You can link in objects from JNDI if you need to, but most of your application objects are not managed by the server.

Spring can manage application objects in all sorts of environments ,while EJB3 allows you to run them only in an EJB container.

Cues-Spring Sample Application for Aspect Oriented Programming

IDE:Eclipse GanyMede
This Aspect i took to work out is logging.
Jars:spring-context-2.5.6.jar
spring-aop-2.5.6.jar
commons-logging-1.1.1.jar
aspectjweaver-1.6.2.jar
spring-2.5.6.jar
Steps:

  1. Create an interface Foo.java
  2. Create an java class that implements this interface.
  3. Create one class which include the methods that are used for Aspect Oriented Programming.
  4. Create one more class which contains the public static void main method.
  5. Create spring's application context.xml (here it is spring.xml)where the spring beans are configured and AOP is configured.(Will be explained in detail in the coming lines)
Foo.java(Interface)
package org.check;
public interface Foo {
void getAfter();
//void getBefore(String myName,String change);
//public void getBefore(SetFields fields,String myChange);
public void getBefore(SetFields fields,SetFields fields1,String myChange);
}



Default Foo Service.java(Class Implementing Above Interface)
package org.check;
public class DefaultFooService implements Foo {
public void getAfter() {
}
}



Main Class
package org.check;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class Boo {
public static void main(final String[] args) throws Exception {
BeanFactory ctx = new FileSystemXmlApplicationContext("E:/SECH_WS/TestLog/spring.xml");
Foo foo = (Foo) ctx.getBean("fooService");
foo.getAfter();
}
}
The line BeanFactory ctx = new FileSystemXmlApplicationContext"E:/SECH_WS/TestLog/spring.xml")
  • Bean factory class here we used is the spring container.
  • After loading the spring.xml into the container an instance of the bean is created.
  • The instance of the required class is obtained from getBean Method and referred there after.

SimpleProfiler.class

package org.check;
import org.check.BeanLogger;
public class SimpleProfiler {

public void afterMethod() throws Throwable {
System.out.println("afterMethod");}
public void beforeMethod(){
System.out.println("beforeMethod"); }

Now coming into the core part of the spring framework spring.xml.

spring.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="fooService" class="org.check.DefaultFooService"/>
<bean id="profiler" class="org.check.SimpleProfiler"/>
<bean id="myprofiler" class="org.check.MyProfiler"/>
<aop:config>
<aop:aspect ref="profiler">
<aop:pointcut id="aopafterMethod" expression="execution(* org.check.DefaultFooService.*(..))"/>
<aop:pointcut id="aopBefore" expression="execution(* org.check.DefaultFooService.*(..))"/>
<aop:after pointcut-ref="aopafterMethod" method="afterMethod"/>
<aop:before pointcut-ref="aopBefore" method="beforeMethod"/>
<aop:aspect/>

<aop:aspect ref="myprofiler">
<aop:pointcut id="aopBeforeOne" expression="execution(* org.check.DefaultFooService.*(..))"/>
<aop:pointcut id="aopBeforeTwo" expression="execution(* org.check.DefaultFooService.*(..))"/>
<aop:aspect/>
<aop:config/>
beans>

Things configured in the spring.xml and their explanation.

  • Three Beans are configured i.e.Default Foo Service,Simple Profiler,My Profiler.
  • Simple Profiler and My Profiler are the classes which i have used for writing the Logging logic.
  • These classes have many methods and these methods are executed before/after execution of any other classes methods or the entire class.
  • refers to beginning and ending of an aspect.
  • Now the profiler what is defined as the bean is made an aspect.
  • Next we need to define Point-cuts.Point Cuts are nothing but declarative expressions stating on what classes methods we need to execute this Aspect(here my aspect is Logging) logic.
  • gives the information that the method afterMethod inside the SimpleProfiler.class must be executed on all methods which comes under the format (* org.check.DefaultFooService.*(..))" after the execution of the method
  • gives the information that the method beforeMethod inside the SimpleProfiler.class must be executed on all methods which comes under the format (* org.check.DefaultFooService.*(..))" before the execution of the method.

Now Run the application as Java Application.

Output:
beforeMethod
afterMethod

So the logging methods are executed everytime when the corresponding methods are executed.



Cues--T.I.E

Look into the things this way..
  • How much knowledge we have about design patterns?
  • Tel me any of the design patterns followed for EJB'S?
  • Key performance issues faced with JSF?
  • What is Cartesian Product,Aggregate functions in Java?
  • How much we know about Comparable,Comparator Interfaces,Hashtable and Hash Set?
  • Do we really need Design Patterns?
  • How to refer EJB'S earlier to EJB3.0?

Cues--Interesting??

These are some of the questions for which no answers are found for me .Let me put the questions and ll update with answers in the coming posts.
  • How to test EJB's?
  • Does Hibernate need any performance Tuning?If so is it preferrable to do DBFine Tuning or Hibernate Fine Tuning??
  • Does transactions propagate for EJB's during the remote calls?
  • Does spring framework also needs container to work out with spring beans i.e; Does spring container needs a server to work out with?
  • Read that EJB's are heavy weight components.What does it mean?
  • How useful are Hudson and Maven build for the project..
  • What is the procedure to initalize lo4j.
  • What is the difference between the component and Service??
  • Can the entity manager be Cached using the TOPLINK ORM?
  • HPROF Profiler,Wily IntroScope Profiler,Optimizeit Profiler,JProbe profiler wat are all these..?

My Space

Hang over--Wrath of Grapes