001/** 002 * GRANITE DATA SERVICES 003 * Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S. 004 * 005 * This file is part of the Granite Data Services Platform. 006 * 007 * Granite Data Services is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * Granite Data Services is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 015 * General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this library; if not, write to the Free Software 019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 020 * USA, or see <http://www.gnu.org/licenses/>. 021 */ 022package org.granite.tide.invocation; 023 024import java.io.Serializable; 025 026 027/** 028 * @author William DRAI 029 */ 030public class ContextUpdate implements Serializable { 031 032 private static final long serialVersionUID = 1L; 033 034 035 private String componentName; 036 private String componentClassName; 037 private String expression; 038 private Object value; 039 private int scope; 040 private boolean restrict; 041 042 043 public ContextUpdate() { 044 } 045 046 public ContextUpdate(String componentName, String expression, Object value, int scope, boolean restrict) { 047 this.componentName = componentName; 048 this.expression = expression; 049 this.value = value; 050 this.scope = scope; 051 this.restrict = restrict; 052 } 053 054 public String getComponentName() { 055 return componentName; 056 } 057 public void setComponentName(String componentName) { 058 this.componentName = componentName; 059 } 060 061 public String getComponentClassName() { 062 return componentClassName; 063 } 064 public void setComponentClassName(String componentClassName) { 065 this.componentClassName = componentClassName; 066 } 067 068 private Class<?> componentClass; 069 070 public Class<?> getComponentClass() { 071 if (componentClassName == null) 072 return null; 073 074 if (componentClass == null) { 075 try { 076 componentClass = Thread.currentThread().getContextClassLoader().loadClass(componentClassName); 077 } 078 catch (Exception e) { 079 throw new RuntimeException("Component class not found", e); 080 } 081 } 082 return componentClass; 083 } 084 085 public String getExpression() { 086 return expression; 087 } 088 public void setExpression(String expression) { 089 this.expression = expression; 090 } 091 092 public Object getValue() { 093 return value; 094 } 095 public void setValue(Object value) { 096 this.value = value; 097 } 098 099 public int getScope() { 100 return scope; 101 } 102 public void setScope(int scope) { 103 this.scope = scope; 104 } 105 106 public boolean getRestrict() { 107 return restrict; 108 } 109 public void setRestrict(boolean restrict) { 110 this.restrict = restrict; 111 } 112 113 114 @Override 115 public String toString() { 116 return componentName 117 + (componentClassName != null ? "(" + componentClassName + ")" : "") 118 + (expression != null ? "." + expression : "") 119 + (scope == 1 ? " (SESSION)" : (scope == 2 ? " (CONVERSATION)" : "")) 120 + (restrict ? " (restricted)" :""); 121 } 122}