Results 1 to 7 of 7
  1. #1
    abanmitra is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default 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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    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?

  3. #3
    abanmitra is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default

    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.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    So, just call them in that order?
    I don't see the problem?

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What's the context? Can interceptors be of use?

  6. #6
    abanmitra is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default

    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.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    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:
    Java Code:
    instanceA.method1();
    instanceB.method();
    instanceA.method2();
    ...so why don't you?

    In other words, I think you need to flesh out your requirements because, as they stand, they make little sense to me.

Similar Threads

  1. What is need of method injection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-30-2008, 10:08 AM
  2. Replies: 0
    Last Post: 03-29-2008, 12:38 PM
  3. Replies: 0
    Last Post: 09-26-2007, 08:40 PM
  4. What is need of method injection
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 09-26-2007, 08:39 PM
  5. Replies: 0
    Last Post: 09-26-2007, 08:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •