1 15 package org.apache.tapestry.binding; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.hivemind.Location; 19 import org.apache.hivemind.util.Defense; 20 import org.apache.tapestry.coerce.ValueConverter; 21 import org.apache.tapestry.engine.state.ApplicationStateManager; 22 23 30 public class StateBinding extends AbstractBinding 31 { 32 private ApplicationStateManager _applicationStateManager; 33 34 private String _objectName; 35 36 public StateBinding(String description, ValueConverter valueConverter, Location location, 37 ApplicationStateManager applicationStateManager, String objectName) 38 { 39 super(description, valueConverter, location); 40 41 Defense.notNull(applicationStateManager, "applicationStateManager"); 42 Defense.notNull(objectName, "objectName"); 43 44 _applicationStateManager = applicationStateManager; 45 _objectName = objectName; 46 } 47 48 public Object getObject() 49 { 50 try 51 { 52 boolean exists = _applicationStateManager.exists(_objectName); 53 54 return exists ? Boolean.TRUE : Boolean.FALSE; 55 } 56 catch (Exception ex) 57 { 58 throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex); 59 } 60 } 61 } | Popular Tags |