Sounds more than great :-). But we have to prove that it is doable.
Would you please add this as an enhancement JIRA ? so it is not
forgotten.

On Mon, Feb 16, 2009 at 7:23 PM, Karan Malhi <[email protected]> wrote:
> That would be something the user would have to do. Checkout the applet
> example which I added. It has an index.jsp which has the following to
> specify the dependent jars
>
> <applet alt="could not load applet" height="100" width="300"
>    codebase="."
>    archive="app.jar,javaee-api-5.0-1.jar,openejb-client-3.1.jar"
>    code="org.superbiz.applet.CalculatorApplet">
> </applet>
>
> I dont know if two or more applets can share the same jar in the browser, if
> the following conditions are met by the user, then we could take care of
> that too, ie. we could
> 1. add a jspf named applet.jspf to the webapp
> 2. add an entry in web.xml to include the above jspf in all jsp pages (or
> some )
>
> <jsp-config>
>        <jsp-property-group>
>                <url-pattern>*.jsp</url-pattern>
>                <page-encoding>UTF-8</page-encoding>
>                <include-prelude>/applet.jspf</include-prelude>
>        </jsp-property-group>
> </jsp-config>
>
> In applet.jspf we could then add an empty applet which would be responsible
> for loading jars in teh browser i.e. applet.jspf would look like
>
> <applet alt="Only used to load dependent jars" height="0" width="0"
>    codebase="."
>    archive="javaee-api-5.0-1.jar,openejb-client-3.1.jar"
>    code="org.apache.openejb.applet.LoaderApplet">
> </applet>
>
> Now index.jsp would just need to add applets it needs to display
>
> <applet alt="could not load applet" height="100" width="300"
>    codebase="."
>    archive="app.jar"
>    code="org.superbiz.applet.CalculatorApplet">
> </applet>
>
> Notice how the above applet just adds app.jar (which contains the applet
> class), and not any openejb/jee specific jars .
>
> I have not tried the above scenario, but do know that the browser caches
> jars, so the above might work.
>
> Having said that.. even if we give instructions to the user (just like we
> did in the applet example I added), that would be enough too.
>
> On Mon, Feb 16, 2009 at 11:52 AM, Mohammad Nour El-Din <
> [email protected]> wrote:
>
>> I like the idea but there is one question I have, how would the
>> Browser/User-Agent would resolve dependencies required to run such
>> API(s) ?
>>
>> On Mon, Feb 16, 2009 at 5:58 PM, Karan Malhi <[email protected]>
>> wrote:
>> > I was having this crazy idea on adding injection support to applets too.
>> > Okay, so applets are created and inited in a remote VM, but we could
>> still
>> > allow the applet author to use annotations, example follows
>> >
>> > public class MyCrazyApplet extends Applet {
>> >      @EJB(name="CalculatorImplLocal") Calculator calculator;
>> >
>> >      public void paint(Graphics g){
>> >         double result = calc.add(10,20);
>> >         g.drawString(result,10,10);
>> >      }
>> > }
>> >
>> > On our end what we could do is enhance the class and add the following in
>> > the init method/constructor/setter (we could introduce a concept called
>> > init-injection for applets -- and maybe even servlets)
>> >        Properties props = new Properties();
>> >        props.put(Context.INITIAL_CONTEXT_FACTORY,
>> >                "org.apache.openejb.client.RemoteInitialContextFactory");
>> >        props.put(Context.PROVIDER_URL,"http://127.0.0.1:8080/applet/ejb
>> ");
>> >        try {
>> >            ctx = new InitialContext(props);
>> >            final Object ref = ctx.lookup("CalculatorImplRemote");
>> >                    Calculator calc = (Calculator)
>> > PortableRemoteObject.narrow(
>> >                            ref, Calculator.class);
>> >        } catch (NamingException e) {
>> >            throw new RuntimeException(e);
>> >        }
>> >
>> > So, behind the scenes this is not pure injection, but we can always make
>> it
>> > easier for users to work with applets and EJB's . There could possibly be
>> a
>> > better way to simulate injection.
>> >
>> > Thoughts?
>> >
>> > --
>> > Karan Singh Malhi
>> >
>>
>>
>>
>> --
>> ----
>> Thanks
>> - Mohammad Nour
>> - LinkedIn: http://www.linkedin.com/in/mnour
>> ----
>> "Life is like riding a bicycle. To keep your balance you must keep moving"
>> - Albert Einstein
>>
>
>
>
> --
> Karan Singh Malhi
>



-- 
----
Thanks
- Mohammad Nour
- LinkedIn: http://www.linkedin.com/in/mnour
----
"Life is like riding a bicycle. To keep your balance you must keep moving"
- Albert Einstein

Reply via email to