rajan singh

Greenhorn
+ Follow
since Jun 08, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by rajan singh

The transaction will be propogated from the container.

Below is the reason why "requiresNew" is not suitable for MDB.

If the transaction is commited, the message will be considered as delivered otherwise the container may keep the message alive.

Now suppose the the transaction type is "requiresNew" then the scope of OnMessage will demarcate the transaction boundry and calling transaction[initiated by conainer] will be suspended and will not bother what happened to new transaction[onMessage's new transaction].In this case container will not have any clue what happened to the message[ Please note container associate successfull message delivery with the commit of the trasaction ]

That is why MDB does not have requiresNew attribute.
Hi Satou,

I believe only "requiresNew" attribute will force to start new transaction on method invocation.

For MDB "required" attribute means, the mdb will run in global transaction started by ejb container, this transaction starts before the onMessage itself.

Implies the OnMessage method never starts the transaction , it always runs inside the already started transaction from the container.[Since this transaction completion is tied with the acknowledgement,message redelivery etc, That's is the reason it does not support the attribute type "requiresNew"]

Hi Senthi ,

What Trasactional context of the client(who sends the message) is got to do with the message consumption [asynchrnously], Both should be in different transaction and does not depend on each other.
[ June 28, 2007: Message edited by: rajan singh ]
Calson Hope there is typing err in your post...

You are right stateless SB[ can not ]call getUserTransaction() in ejbCreate & ejbRemove but stateful SB [ can ] do so. The question is asking methods that both stateful SB and stateless SB can access userTransaction methods.
BMT and CMT both can call setRollbackonly, the only difference is that BMT should call it on UserTransaction where as CMT should call on it's context. It will be useful only when there is multiple component inlvolves in single transaction and you would like to do transaction commit or rollback based on other component outcome.

Example :

UserTransaction ut = context.getUserTransaction();
ut.begin;
OtherComponent oth = new OtherComponent();
oth.doStuff(ut);
if(ut.getStatus() == javax.transaction.Status.STATUS_MARKED_ROLLBACK) {
ut.rollback();
}
else
{
do some processing
ut.commit;
}

//OtherComponent

public void doStuff(UserTransaction ut){
do processing1
if(something went wrong){
ut.setRollbackOnly();
}
else{
do processing 2
}
}

Though above things can be achieved using proper exception handling instead of using setRollbackOnly.

Regards,
Rajan

[ May 31, 2007: Message edited by: rajan singh ]
[ May 31, 2007: Message edited by: rajan singh ]
according to me answeres are correct...

1.
since interface is member of class Test. It means we can apply any modifiers which we can apply to member of class. That is why we can provide public ,private and protected modifiers.
abstract is redundant but we can apply it.

2.
in interface we can never have private or protected modifiers.
so modifiers for member of interfaces are
public
final static
abstarct(redundant)
and we can never use final with interface because intefaces are meant to be implemented.

please let me know if i am wrong...
here "this(9)" is used to invoke one argument construtor from default constructor.
[ June 21, 2005: Message edited by: rajan singh ]
These methods are invoked on objects so they are member of object. and these methods deal with lock and each object supposed to have lock for synchronization that is why these methods are in Object class. And by making these methods(final methods) as a member of Object,all objects in java can have lock control..

PLEASE LET ME KNOW IF I AM WRONG....
[ June 17, 2005: Message edited by: rajan singh ]
hii pawan,

you are right...using reference of base type we can invoke the method of subclass if it is overridden in sub class otherwise not.
and since method1() is private we are not overriding it....even if invoke method1() using base class reference(though it is pointing to base class) it will not complile because the using base class reference(pointing to subclass object) only overriden method is called.

PLEASE LET ME KNOW IF I AM WRONG......
since Foo is subclass of Bar => Foo[] is subclass of Bar[]
public class Runner3 {

public static void main(String[] args) {
Base b = new Derived();
Derived d = new Derived();
System.out.println(b.id);
System.out.println(d.id);
}
}
class Base
{
String id = "i am base";
}
class Derived extends Base
{
String id = "i am derived";
}

output.....

i am base
i am derived

above prg suggest that field access depends upon refernece type not upon actual object created.

and this reference is implicitly passed...in base class this(reference) is of type of base(since base class has no idea about derived class)though it is pointing to object of subclass..that is the reason hidden field is printed...

PLEASE LET ME KNOW IF I AM WRONG.....
[ June 14, 2005: Message edited by: rajan singh ]
whenever we call non static method implicit this will be passed and this
will point to actual object created.
hii marzo,

we have OverrideStatic override = new OverrideStatic();

and we call override.local();

local() having this reference which is pointing to instance of OverrideStatic. and this.hii()=> (instance of OverrideStatic).hii()

remember when we call superclass method through subclass object..this(reference) always point to subclass's object.
hii pawan,

when local() is called, this(reference) is available to local().
and with the help of this(reference) only non static function will be called(remember this(reference) is pointing to object of OverrideStatic class)... since init() is static and superclass doesnot know about subclass so A's init willbe called.

if we provide overriiden local in OverrideStatic class then OverrideStatic's init() will be called..

if i am wrong plz correct me...
[ June 14, 2005: Message edited by: rajan singh ]
hii
when we use String s2 = new String("garbage") we actually have two String objects.
one is "garbage" which is local to constructor of String and since this is literal it's reference will be stored in pool(static member of class String).
second is the string which is pointed by s2 and since it is created by new operator.it will not get stored in pool.
so object pointed by s2 will be freed where as string "garbage" will not be freed(reference is already there in pool).
hii anil
since we r using new operator, which means we are creating two new objects so str3 and str4 pointing to two different objects. and since pool is maintained only for literals not for objects created by new.