Results 1 to 7 of 7
- 04-30-2010, 07:51 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
java method injection in existing code
Hi,
I am new member in this Forums. This is my 1st post.
I have a java based jar file. This jar contains some business implementation, which is implemented in java. Now I have develop some java class which also have some business method.
I want to inject my newly created method into existing jar (without modified existing jar).
Let say,
Existing jar have class A, which contains method1() and method2(). My newly development class is B which contains xMethod(...). Now my target is something like that:
call sequence should be:
1. A.method1()
2. B.xMethod(...) [inject method]
3. A.method2()
Can anyone help me regarding this issue.
Thanks in advance.
- 04-30-2010, 09:12 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
Bit confused.
Are method1 and method2 in A public?
In which case why not simple make the calls as you show. No need to change anything.
How are method1 and method2 called is, I suppose, my question?
- 04-30-2010, 10:51 AM #3
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
I mean to say that, I have a jar file where I can't modify the code and insert my B class's xMethod(). Through documentation I know that in A, method1() and method2() are available [i.e. public] and between this two method call I want to call my method at run time.
After executes A.method1(), I want to call my method B.xMethod() then as usual other method will execute as it is.
- 04-30-2010, 10:54 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
So, just call them in that order?
I don't see the problem?
- 04-30-2010, 11:14 AM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What's the context? Can interceptors be of use?
- 04-30-2010, 11:54 AM #6
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
Is that method injection at run time ? If it is something like that, then what will be the way to do it ?
Last edited by abanmitra; 04-30-2010 at 12:02 PM.
- 04-30-2010, 12:02 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
I think you've abstracted the problem so far that it has disappeared, because I really cannot see what you're aiming for.
All I can see, from your description, is you have a class A with a couple of methods in it, and a class B with a method in it. Presumably you have instances of each of these classes, and you want to call:
...so why don't you?Java Code:instanceA.method1(); instanceB.method(); instanceA.method2();
In other words, I think you need to flesh out your requirements because, as they stand, they make little sense to me.
Similar Threads
-
What is need of method injection
By Java Tip in forum Java TipReplies: 0Last Post: 03-30-2008, 10:08 AM -
How to decide whether to use Setter injection or constructor injection in your code
By Java Tip in forum Java TipReplies: 0Last Post: 03-29-2008, 12:38 PM -
Look-Up Method Injection and it’s usage in Spring Framework
By JavaBean in forum Java TipReplies: 0Last Post: 09-26-2007, 08:40 PM -
What is need of method injection
By JavaBean in forum Java TipReplies: 0Last Post: 09-26-2007, 08:39 PM -
How to decide whether to use Setter injection or constructor injection in your code
By JavaBean in forum Java TipReplies: 0Last Post: 09-26-2007, 08:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks