Posts Tagged google

Online video presentatie: Android & Augmented Reality

Op 11 november 2009 gaf Arjan Schaaf op de NLJUG een presentatie over Android en Augmented Reality. De video van deze presentatie is inmiddels online beschikbaar. De gehele presentatie van 50 minuten kan je hier (175mb) downloaden. Maar de eerste tien minuten zijn hieronder gelijk op YouTube te bekijken.

English: The whole presentation can be downloaded here (175mb).

Augmented Reality op mobiele devices heeft een enorme vlucht genomen met de introductie van Google Android. Android biedt out-of-the-box de componenten om met augmented reality aan de slag te gaan. In deze sessie staan we stil bij de frameworks die beschikbaar zijn om augemented reality applicaties / content te deployen op Android. Aan de hand van een voorbeeld applicatie gaan we in op de mogelijkheden om zelf een augmented reality applicatie te ontwikkelen met de faciliteiten die door Android worden geboden. Praktische uitdagingen waarmee wij zijn geconfronteerd worden gedeeld en geven inzicht in de mogelijkheden en onmogelijkheden van het Android platform. Opbouw van de presentatie:

  • Introductie over augmented reality: location based vs beeldherkenning;
  • Wat is te krijgen in de markt? Layar, Wikitude, etc;
  • Wat zijn de mogelijkheden om applicaties te ontwikkelen met de beschikbare frameworks;
  • Hoe ontwikkel je zelf een augmented reality applicatie op Android?

De slides van de presentatie zijn te vinden op de NLJUG website.

, , , , , , , , , ,

No Comments

Using GWT to create an OSGi-aware web application

Update 2010-02-20 Both Pax Runner 1.3.0 and GWT 2.0 have caused quite some changes to this post. I have tried to stay up to date as well as I could (the zipped project now uses GWT 2.0), but you might find some inconsistencies when following the tutorial.

Google Web Toolkit is cool, and so is OSGi. However, when building a web UI for Apache ACE, I found out that creating a web application that can use OSGi services is not that easy. By the end of this tutorial, you will have created a GWT project that delivers a usable jar. If you’re impatient, skip to the end for the downloadable Eclipse project.

Step 1: Create a GWT project

Create a regular GWT project using the regular webAppCreator; this will give you a project that includes an Ant buildfile, we will need that later on.

angelos:workspace angelos$ ./gwt-mac-1.6.4/webAppCreator -out GwtDemo net.luminis.gwt.gwtdemo
Created directory GwtDemo/src
Created directory GwtDemo/war
Created directory GwtDemo/war/WEB-INF
Created directory GwtDemo/war/WEB-INF/lib
Created directory GwtDemo/src/net/luminis/gwt
Created directory GwtDemo/src/net/luminis/gwt/client
Created directory GwtDemo/src/net/luminis/gwt/server
Created file GwtDemo/src/net/luminis/gwt/gwtdemo.gwt.xml
Created file GwtDemo/war/gwtdemo.html
Created file GwtDemo/war/gwtdemo.css
Created file GwtDemo/war/WEB-INF/web.xml
Created file GwtDemo/src/net/luminis/gwt/client/gwtdemo.java
Created file GwtDemo/src/net/luminis/gwt/client/GreetingService.java
Created file GwtDemo/src/net/luminis/gwt/client/GreetingServiceAsync.java
Created file GwtDemo/src/net/luminis/gwt/server/GreetingServiceImpl.java
Created file GwtDemo/build.xml
Created file GwtDemo/README.txt
Created file GwtDemo/.project
Created file GwtDemo/.classpath
Created file GwtDemo/gwtdemo.launch
Created file GwtDemo/war/WEB-INF/lib/gwt-servlet.jar

If you want to, you can import this project directly into your Eclipse. If you check the mark “use Google Web Toolkit” in the project properties, you can use all the same goodies that creating the project in Eclipse would have given you. Remember to replace the buildpath entries for gwt-user.jar and gwt-dev-*.jar by a Library import for GWT.

Step 2: Include the necessary OSGi references

Create an ‘ext’ directory, and add org.osgi.core.jar to that. In Eclipse, add this jar to your build path.

Step 3: Use OSGi services from your web applicaiton

We will first add a simple Activator on the server side.

package net.luminis.gwt.server;
 
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
 
public class Activator implements BundleActivator {
    private static BundleContext m_context;
 
    public static BundleContext getContext() {
        return m_context;
    }
 
    public void start(BundleContext context) throws Exception {
        m_context = context;
    }
 
    public void stop(BundleContext context) throws Exception {
    }
}

Then, we up the GreetingServiceImpl to actually use this BundleContext (note that we use it directly here, but you could use it to get other services, create a ServiceTracker, etc.)

public String greetServer(String input) {
  String serverInfo = getServletContext().getServerInfo();
  String userAgent = getThreadLocalRequest().getHeader("User-Agent");
  return "Hello, " + input + "!
 
I am running " + serverInfo
    + ".
 
It looks like you are using:" + userAgent +
    "The framework we run from has " + Activator.getContext().getBundles().length + " bundles in it.";
}

Step 4: Add OSGi dependencies for the compiler

Add our OSGi dependencies to the classpath, so the compiler can find all of it.

    <!-- Add any additional non-server libs (such as JUnit) -->

Right, let’s give it a try!

angelos:GwtDemo angelos$ ant war
Buildfile: build.xml
 
...some output removed...
 
war:
[zip] Building zip: /Users/angelos/workspace/workspace/GwtDemo/gwtdemo.war
 
BUILD SUCCESSFUL
Total time: 36 seconds

You will find a war in your project directory now. There still is one ingredient we need. We need to make this into a proper bundle. We can use bnd to help us with that.

Step 5: use bnd to create a proper war

Download bnd, and put into a lib directory, and add it to your buildfile.

We create a new target that transforms our war into a jar.

<target name="jar">
    <copy file="gwtdemo.war" tofile="gwtdemo.jar"/>
    <echo file="gwtdemo.bnd">Import-Package: junit.framework;resolution:=optional, com.google.gwt.*;resolution:=optional, org.w3c.*;resolution:=optional, sun.misc;resolution:=optional, javax.imageio;resolution:=optional, javax.servlet.*;resolution:=optional, *
Bundle-Name: GWT Demo
Bundle-ClassPath: WEB-INF/classes, WEB-INF/lib/gwt-servlet.jar
Bundle-SymbolicName: net.luminis.gwt.gwtdemo
Webapp-Context: gwtdemo
Bundle-Activator: net.luminis.gwt.server.Activator
    </echo>
    <bndwrap jars="gwtdemo.jar" output="gwtdemo.jar"/>
    <jar file="gwtdemo.jar" update="true">
    <manifest>
        <attribute name="Bundle-ClassPath" value="WEB-INF/classes, WEB-INF/lib/gwt-servlet.jar, ."/>
     </manifest>
    </jar>
    <delete file="gwtdemo.bnd"/>
</target>

What’s happening here?

  • we copy our war to the same file, but with a jar extension,
  • we create a file for bnd to use, stating that we
    • want optional imports for junit and the gwt benchmarks, and non-optional imports for everything else (that what the * is for),
    • have some classes that we want bnd to scan for finding dependencies,
    • want to use a given Webapp-Context (this is a Pax war extender specific entry),
  • let bnd do its magic,
  • update our manifest: we put the . back on the classpath. This is important for the web application to find all resources, but if we would tell bnd to do it like this, it would treat . as the root of the classpath.
  • Finally, we delete that temporary bnd file.

What does that give us?

angelos:GwtDemo angelos$ ant jar
Buildfile: build.xml
 
...some output removed...
 
jar:
[copy] Copying 1 file to /Users/angelos/workspace/workspace/GwtDemo
[bndwrap] gwtdemo 41 910305
[bndwrap] Warnings
[bndwrap] Superfluous export-package instructions: [WEB-INF.classes.net, gwtdemo.gwt.standard.images, WEB-INF, gwtdemo, WEB-INF.classes.net.luminis.gwt, gwtdemo.gwt.standard, WEB-INF.classes.net.luminis, WEB-INF.lib, WEB-INF.classes, gwtdemo.gwt.standard.images.ie6, WEB-INF.classes.net.luminis.gwt.client, WEB-INF.classes.net.luminis.gwt.server, gwtdemo.gwt]
[jar] Updating jar: /Users/angelos/workspace/workspace/GwtDemo/gwtdemo.jar
[delete] Deleting: /Users/angelos/workspace/workspace/GwtDemo/gwtdemo.bnd
 
BUILD SUCCESSFUL
Total time: 23 seconds

That’s it! You can now deploy this jar into a framework that uses the pax web tools. Right, let’s give that a try.

Download pax-runner, and unzip that somewhere. Copy in your new jar, an try the following command

angelos:pax-runner angelos$ sh bin/pax-run.sh --profiles=war,compendium gwtdemo.jar

Now visit http://localhost:8080/gwtdemo:

gwtdemo

Summary

So, what did we need?

  • A fairly regular GWT project, create with an Ant file,
  • some code that tries to use OSGi services,
  • some bnd magic to make the war into a jar,
  • Pax tools to get it all running quickly.

If you don’t want to use pax runner, you can need to deploy pax-web-extender-war(jar, snapshot 23 June) and an http server, preferably pax-web-service(jar), into your framework.

You can download the gwtdemo Eclipse project to play around with it. I have not provided the GWT runtime in this download; you should edit line 4 of the build.xml to point to your installation of GWT.

, , , , , , , , , , ,

14 Comments

Google Wave – Ze doen het weer….

Google presenteerde recentelijk een van de nieuwe ontwikkelingen waarmee ze bezig zijn: Waves. Volgens de documentatie op de Google Wave API website is een wave:


“A wave is a threaded conversation, consisting of one or more participants (which may include both human participants and robots). The wave is a dynamic entity which contains state and stores historical information. A wave is a living thing, with participants communicating and modifying the wave in real time.”

Google Wave draait in je browser. Het is een Javascript applicatie die je browser omtovert tot een collaboration-tool die de concurrentie met een heleboel duurbetaalde tools probleemloos aankan. En het is gratis. De gehele code-base wordt ge-opensourced zodat iedereen heel snel en makkelijk met zijn eigen Wave implementatie aan de slag kan

Is het mooi?

Ja, wat je ziet op de demo die ze gaven op de Google IO conference is absoluut spectaculair. Het duurt even voordat het tot je doordringt (thick skull, sorry), maar dan zie je (als techneut in ieder geval) dat het heel knap is wat ze daar aanbieden. Of je het wilt hebben, of dat het de wereld gaat veranderen of de hoeveelheid CO2 in de atmosfeer gaat verminderen? Geen idee, maar hieronder licht ik even de punten toe die mij erg aanspraken.

Real-time

Alles wat je in een Wave intikt, is onmiddellijk zichtbaar bij alle andere mensen die jouw Wave open hebben staan. Dit biedt dus in ieder geval Instant Messaging, maar dan zonder het wachten op “Mr.X is typing a message”. Er is een open protocol ontwikkelt dat deze communicatie regelt. Even ter herinnering: dit is in je browser. Dus real-time communicatie tussen 2 of meer browsers.

Concurrent

Je werkt met alle betrokkenen tegelijk aan een Wave. Iedereen kan reply-en binnen een Wave, maar kan ook
corrigeren wat een ander nog aan het intikken is. In dat proces wordt bijgehouden wie wat heeft gedaan.

Multi-media

Letterlijk. Het maakt niet uit welk type medium je wilt gebruiken: tekst, beeld, film, geluid. Je kunt het allemaal drag-n-droppen in een wave. Als je een serie plaatjes in een Wave gooit, krijgen alle deelnemers onmiddellijk thumbnails te zien.

Playback

Alle wijzigingen op de Wave staan op een time-line die je kunt terugspelen. Als je met een groep mensen aan een stuk tekst werkt kun je de hele conversatie terughalen, wat noodzakelijk kan zijn omdat iedereen alle tekst kan wijzigen en je alleen het uiteindelijke resultaat ziet. Er is een demo van een schaak-applicatie die in een Wave draait. Behalve dat iedereen op de Wave onmiddellijk de gedane zetten ziet, kun je het hele spel opnieuw afspelen door de time-line te manipuleren. Als ontwikkelaar van een dergelijke app hoef je niets te doen voor de real-time en play-back functionaliteit. Die zit in de Wave en krijg je er gratis bij!

Robots

Er is al een grote hoeveelheid robots geschreven die deelnemen aan een conversatie zoals mensen dat kunnen doen. Deze robots werken voor je als een soort tool of plug-in. Er is bijvoorbeeld een spelling-checker robot die jouw Wave edit terwijl je ermee bezig bent. En zelfs een vertaal-robot die jouw tekst bij jouw Franse collega in het Frans vertaald laat zien. Maar ook robots die tekst herkennen als links en ze meteen clikable maken, of robots die een link naar video herkennen en je meteen de optie geven om een player te embedden.

APIs

Er is een uitgebreide API beschikbaar om zelf robots te maken of om een Wave in je eigen (web)applicatie te embedden. Je vindt er meer over op: http://code.google.com/apis/wave.

Conclusie

Het is eigenlijk nog te vroeg om conclusies te trekken. De developers wereld is er al flink opgesprongen en heeft een veelheid aan robots en gadgets geproduceerd. Dat zegt niet alles. Zoals uit mijn enthousiasme al blijkt is het voor techneuten echt een heel interessant platform. Of het een killer-app is weet ik niet. Het zou heel goed de manier van communicatie kunnen veranderen, omdat je mail, chat en IM in één en dezelfde vormt giet. Ik denk dat het net zo gaat als met de iPhone. Op zichzelf niet briljant, maar doorr de juiste onderliggende technologie maakt het applicaties mogelijk die echt briljant zijn en het product tot grotere hoogte tillen.

, , , , ,

No Comments