Re: [jetty-user] starting an android.app.Activity inside serverside code on i-jetty-2.2

Simon-Lennert Raesch <[email protected]> Wed, 6 Apr 2011 22:21:20 +0200
Newsgroups gmane.comp.java.jetty.support
Message-ID <[email protected]>
Hi,

thanks a lot for your reply Jan. I didn't even look at the HelloWorld implementation but started off with the Console and Chat, which didn't get me far. Right now I am trying to take your information and apply them to my GWT project, which I hope will work out. It doesn't have a class that extends the javax.servlet.http.HttpServlet directly but instead it has a RemoteServiceServlet which extends AbstractRemoteServiceServlet which extends javax.servlet.http.HttpServlet. I hope implementing an init-method similar to the one you posted in my RemoteServiceServlet class will actually lead to it being called upon initialization. Do you know if the GWT compile might break this setup and if I should head straight to just implementing my own HttpServlet, building it similar to the examples? In case everything works I would like to write a little howto in case anyone needs similar behavior, any chance it can be put on the i-jetty wiki?

Thanks again,
Lennert


Simon-Lennert Raesch
[email protected]

> Hi,
> 
> If you look at the HelloWorld.java servlet class in the hello
> webapp in the i-jetty srcs, you will see that webapps deployed
> with i-jetty will have an android ContentResolver and an android Context (that of i-jetty) pushed into the servlet context attributes.
> Here's the snippet:
> 
>    /* ------------------------------------------------------------ */
>    public void init(ServletConfig config) throws ServletException
>    {
>        super.init(config);
>        //to demonstrate it is possible
>        Object o = config.getServletContext().
>                   getAttribute("org.mortbay.ijetty.contentResolver");
>        android.content.ContentResolver resolver =
>                  (android.content.ContentResolver)o;
>        android.content.Context androidContext =
>                  (android.content.Context)config.getServletContext().
>                  getAttribute("org.mortbay.ijetty.context");
>        proofOfLife = androidContext.getApplicationInfo().packageName;
>    }
> 
> We make sure that the webapps' parent classloader is the android
> loader that loaded i-jetty, so they have access to the android classes.
> 
> Hope that answers the questions,
> Jan
> 
> On 06/04/11 01:33, Simon-Lennert Raesch wrote:
>> Hi,
>> I have a gwt project running on my i-jetty-2.2 installation and want to =
>> start an android.app.Activity. I tried including the android.jar in the =
>> build process of the .war but it can't processed by dex (without the =
>> core-library feature, which I don't want to use).
>> 
>> What is the preferred way of using the Android SDK from within a web =
>> application? There is hardly any info on this on the web, I read one =
>> email with a similar demand on one of the jetty mailing lists, but it =
>> didn't get any replies. I hope this one does, as I really need to =
>> achieve this behavior.
>> 
>> Thanks in advance,
>> 
>> Simon-Lennert Raesch
>> [email protected] <mailto:[email protected]>
>> 
>> University of Kassel
>> Software Engineering
>> 
>> Germany
> 
> -- 
> Jan Bartel, Webtide LLC | [email protected] | http://www.webtide.com