Presentation is loading. Please wait.

Presentation is loading. Please wait.

Aranea – Java Web Framework Construction and Integration Kit

Similar presentations


Presentation on theme: "Aranea – Java Web Framework Construction and Integration Kit"— Presentation transcript:

1 Aranea – Java Web Framework Construction and Integration Kit
Aranea -- Web Framework Construction and Integration Kit Aranea – Java Web Framework Construction and Integration Kit Oleg Mürk Chalmers University of Technology, Sweden Jevgeni Kabanov University of Tartu, Webmedia, Ltd., Estonia

2 Outline Introduction Hello World! In Aranea Framework construction
Framework integration Further work Voore 2006

3 Aranea -- Web Framework Construction and Integration Kit
Motivation At the moment web applications are barely reusable! Existing code cannot be reused for similar requirements without inserting if-then-else-s everywhere Legacy migration is very hard! Integrating applications built on different platforms is hard and often visible to user Object-Oriented Design to the rescue! OOD is all about structuring your application to make it more manageable and encapsulated. Voore 2006

4 Aranea -- Web Framework Construction and Integration Kit
Web is Procedural (Client calls server) Synchronized (One window – one request) Decomposable into pages Client is mostly stateless (Current state with result, cookies) In general web is based around a concept of a page, which is combining data, behavior and presentation Note the choice of words – procedural, not functional! Voore 2006

5 Aranea -- Web Framework Construction and Integration Kit
GUI applications are Often stateful Mostly synchronized (one window – one thread) Decomposable into components Comfortable to represent using OO concepts Model-View-Controller pattern suggest to keep data, presentation and behavior separately Voore 2006

6 Enter MVC Web Frameworks
Aranea -- Web Framework Construction and Integration Kit Enter MVC Web Frameworks Request-based: Struts, Spring MVC Page-based: JSF, Wicket, Tapestry Continuation/flow-based: RIFE, Spring WebFlow AJAX-based: Echo2, GWT OO-based: Wicket, Aranea Voore 2006

7 Aranea -- Web Framework Construction and Integration Kit
A Sea of Frameworks Do we really need all those approaches? They play out well for different requirements Can we combine them? We’ll try to do just that  We’ll also hint how to make the existing frameworks work together… Voore 2006

8 Aranea -- Web Framework Construction and Integration Kit
Introducing Aranea An Open-Source project available at A component object model styled after a variant of Hierarchical MVC pattern Reusable components, which can be assembled into an MVC framework Note that we are only examining the Controller part of MVC! Voore 2006

9 Aranea -- Web Framework Construction and Integration Kit
Hello World! NameWidget name.jsp Reads the name from requests and passes it to HelloWidget HelloWidget hello.jsp Renders the “Hello ${name}!” greeting, where name is given by the caller. Note that we need two widgets only for demonstration purposes Voore 2006

10 Aranea -- Web Framework Construction and Integration Kit
NameWidget public class NameWidget extends BaseUIWidget { //Called on “hello” event public void handleEventHello() { String name = //reads “name” from request parameters (String) getInputData().getGlobalData().get("name"); getFlowCtx().replace(new HelloWidget(name), null); } name.jsp: The important part is on line 2, where we both create the new object by hand and navigate (or rather switch) to it using Java API. <ui:systemForm method="GET"> Insert your name: <input type=“text“ name="name"/><br/><br/> <ui:eventButton labelId="#Say hello" eventId="hello"/> </ui:systemForm> Voore 2006

11 Aranea -- Web Framework Construction and Integration Kit
HelloWidget public class HelloWidget extends BaseUIWidget { private String name; //Widget state is in its fields public HelloWidget(String name) { this.name = name; //We could pass any Java object here } public String getName() { return this.name; hello.jsp:  Hello <c:out value="${widget.name}"/>! Voore 2006

12 Hello World! reexamined
Aranea -- Web Framework Construction and Integration Kit Hello World! reexamined NameWidget name.jsp handleEventHello() getFlowCtx().replace(new HelloWidget(name)); HelloWidget hello.jsp Note that we can pass any Java object to the widget constructor, enabling e.g. polymorphism Voore 2006

13 Framework construction
Aranea -- Web Framework Construction and Integration Kit Framework construction Components are assembled in a chain Only 3 component kinds (components, services & widgets) Some components may contain more than one child Servlet: only dispatches the HTTP call to adaptor Voore 2006

14 Aranea -- Web Framework Construction and Integration Kit
Component interface Component { void init(Environment env); void destroy(); } Voore 2006

15 Aranea -- Web Framework Construction and Integration Kit
Service Services correspond to the procedural unsynchronized HTTP model Unlike servlets no binding or configuration specified interface Service extends Component { void action( Path path, //Routing destination for Composite case InputData input, //Request abstraction OutputData output); //Response abstraction } Services are similar to servlets, but unlike those they is no convention on how they are configured, associated or used. Voore 2006

16 SynchronizingFilterService
Aranea -- Web Framework Construction and Integration Kit SynchronizingFilterService Synchronizes the underlying calls In reality childService is handled by the base class (BaseFilterService) public class SynchronizingFilterService extends BaseService { protected Service childService; public void setChildService(Service childService) { this.childService = childService; } synchronized void action( Path path, InputData input, OutputData output) { childService.action(path, input, output); E.g. user clicks a button, the processing takes some time and user stops and refreshes the browser getting an inconsistent state. Voore 2006

17 Aranea -- Web Framework Construction and Integration Kit
Environment Environment allows parents to let children access their features interface Environment { Object getEntry(Object key); } Usage example: L10nContext locCtx = (L10nContext) getEnvironment().getEntry(L10nContext.class); String message = locCtx.localize("message.key"); Voore 2006

18 LocalizationFilterService
Aranea -- Web Framework Construction and Integration Kit LocalizationFilterService Provides localization features public class LocalizationFilterService extends BaseFilterService implements L10nContext { public void init(Environment env) { childService.init( new StandardEnvironment(env, L10nContext.class, this); } public String localize(String key) { //Look up a ResourceBundle and return the message Voore 2006

19 SessionRouterService
Aranea -- Web Framework Construction and Integration Kit SessionRouterService Routes the action() to a service associated with the HTTP session Creates new services using a service factory (assigned via setter) public class SessionRouterService extends BaseService { void action(Path p, InputData input, OutputData output) { HttpSession sess = … //Lookup logic if (sess.get(SERVICE_KEY) == null) createService(sess); //Build service using factory ((Service) sess.get(SERVICE_KEY)).action(p, input, output); } Voore 2006

20 Aranea -- Web Framework Construction and Integration Kit
Half of a framework Service adaptor: creates Input- & OutputData Session router: saves service chain under itself in session Synchronizing filter: protects session state from concurrent modification HTTP filter: sets headers Voore 2006

21 Aranea -- Web Framework Construction and Integration Kit
Widget Widget corresponds to a stateful synchronized GUI component Most applications are built from widgets interface Widget extends Service { //Calls must be made in the same order: void update(InputData data); //Sent to all widgets void event(Path path, InputData input); //Routed to one widget void process(); //Preparing to render void render(OutputData output); //May be called several times } We split the one action() calls in the update()/event()/process()/render() call chain. We also allow render() to be called outside the cycle to allow for re-rendering on refresh or back-button & such. Voore 2006

22 Flows Flows are pages which preserve nested state and can return values Voore 2006

23 Aranea -- Web Framework Construction and Integration Kit
Flows examined Flow container is a widget that contains a stack of widgets representing flows Being a usual widget flow container can be used at an arbitrary place in framework or application public interface FlowContext { void start(Widget flow, Handler handler); void replace(Widget flow) void finish(Object result); void cancel(); } Voore 2006

24 Aranea -- Web Framework Construction and Integration Kit
And the final touch Widget adapter: calls update(), event(), process() and render() for each action() call Widget container: creates Path for event routing Flow container: provides FlowContext and a widget stack Voore 2006

25 Other configurations We can assemble a system to bind stateless services to URLs like Struts actions We can also assemble a system that will bind stateful widgets to URLs like Wicket pages In fact it is easy to simulate all of the mentioned approaches Voore 2006

26 Aranea -- Web Framework Construction and Integration Kit
Our goal is to use Aranea component model to structure our application And then use it as glue to integrate with all other web frameworks In fact Aranea was specially designed with integration in mind But before 1.0 release we had to put our energy elsewhere Well, rather well thought through goals :) Voore 2006

27 Integration Picture Voore 2006

28 Aranea -- Web Framework Construction and Integration Kit
Summary A HMVC component model A modular web framework supporting all common GUI approaches A platform for web framework development and research An Object-Oriented web framework with support for first-class flows A web framework integration platform Voore 2006

29 Aranea -- Web Framework Construction and Integration Kit
Further work Remote integration: a service protocol with Environment over Web Services Weaver: templating framework compatible with JSP tags, Wicket markup, JSF components, Facelets, … Blocking continuation support Integration with Wicket, JSF, Struts, Spring MVC & WebFlow, Echo2, GWT … Aranea for rich client (Eclipse RCP) Voore 2006

30 Thank you! Questions? Voore 2006


Download ppt "Aranea – Java Web Framework Construction and Integration Kit"

Similar presentations


Ads by Google