1 /* 2 * Copyright (c) 2005-2007 Creative Sphere Limited. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * 10 * Creative Sphere - initial API and implementation 11 * 12 */ 13 package org.abstracthorizon.danube.mvc; 14 15 import org.abstracthorizon.danube.connection.Connection; 16 import org.abstracthorizon.danube.connection.ConnectionHandler; 17 18 import java.io.IOException; 19 20 /** 21 * Tihs class is driver of MVC. It invokes action that returns view (and modem) and then view 22 * renderer is called with that invformation. 23 * 24 * @author Daniel Sendula 25 * 26 * @assoc - - - org.abstracthorizon.danube.mvc.ModelAndView 27 */ 28 public class MVCConnectionHandler implements ConnectionHandler { 29 30 /** Action manager */ 31 protected Controller controller; 32 33 /** View renderer */ 34 protected View view; 35 36 /** Constructor */ 37 public MVCConnectionHandler() { 38 } 39 40 /** 41 * This method calls action manager to obtain view and model and then 42 * view renderer with that information 43 * @param connection connection 44 * @throws IOException when there are problems with rendering the view 45 */ 46 public void handleConnection(Connection connection) { 47 ModelAndView modelAndView = controller.handleRequest(connection); 48 view.render(connection, modelAndView); 49 } 50 51 /** 52 * Returns action manager 53 * @return action manager 54 */ 55 public Controller getController() { 56 return controller; 57 } 58 59 /** 60 * Sets action manager 61 * @param controller action manager 62 */ 63 public void setController(Controller controller) { 64 this.controller = controller; 65 } 66 67 /** 68 * Returns view renderer 69 * @return view renderer 70 */ 71 public View getView() { 72 return view; 73 } 74 75 /** 76 * Sets view renderer 77 * @param view view renderer 78 */ 79 public void setView(View view) { 80 this.view = view; 81 } 82 83 }