Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30696

Re: Optimal way to call methods of dynamcic loaded calls (from Jars) and vice versa.

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Optimal way to call methods of dynamcic loaded calls (from Jars) and vice versa.
Date 2015-01-13 14:10 -0800
Organization Canadian Mind Products
Message-ID <dd5bbap9a2dbdo1u028bkbjugjlbbtq1m3@4ax.com> (permalink)
References <13fa0735-411b-4a42-8e3a-b5b016269abd@googlegroups.com>

Show all headers | View raw


On Mon, 12 Jan 2015 03:30:46 -0800 (PST),
diamantis.kiriakakis@gmail.com wrote, quoted or indirectly quoted
someone who said :

>
>I need to create a java application that will use a plugin system to enable=
> extra features. The plugins will be actually .JAR files. The process is we=
>ll understandable, but in case i need to call a method of main application =
>from the dynamically loaded .JAR, what are the best practices to do it? I m=
>anaged to do it using Callbacks but im not sure if this is the best way to =
>achieve it.

Your plugins must implement an interface or an abstract class.

Let's say that abstract class were called "Macro".

final Class<? extends Macro> macroClass = Class.forName(
binaryClassName ).asSubclass( Macro.class );

return macroClass.newInstance();

You might want to cache your class objects if you are doing frequent
repeat lookups.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
To solve an interesting problem, start by finding a problem
that is interesting to you.
~ Eric S. Raymond (born: 1957-12-04 age: 57)

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Optimal way to call methods of dynamcic loaded calls (from Jars) and vice versa. diamantis.kiriakakis@gmail.com - 2015-01-12 03:30 -0800
  Re: Optimal way to call methods of dynamcic loaded calls (from Jars) and vice versa. Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-01-12 10:27 -0500
  Re: Optimal way to call methods of dynamcic loaded calls (from Jars) and vice versa. Roedy Green <see_website@mindprod.com.invalid> - 2015-01-13 14:10 -0800
  Re: Optimal way to call methods of dynamcic loaded calls (from Jars) and vice versa. Arne Vajhøj <arne@vajhoej.dk> - 2015-01-19 16:18 -0500

csiph-web