`AbstractGriffonModel.java`
`01 /* 02 * Copyright 2010-2012 the original author or authors. 03 * 04 * Licensed under the Apache License, Version 2.0 (the "License"); 05 * you may not use this file except in compliance with the License. 06 * You may obtain a copy of the License at 07 * 08 * http://www.apache.org/licenses/LICENSE-2.0 09 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.codehaus.griffon.runtime.core; 18 19 import griffon.core.GriffonModel; 20 import griffon.core.GriffonModelClass; 21 22 import java.beans.PropertyChangeEvent; 23 import java.beans.PropertyChangeListener; 24 import java.beans.PropertyChangeSupport; 25 26 /** 27 * Base implementation of the GriffonModel interface. 28 * 29 * @author Andres Almiray 30 * @since 0.9.1 31 */ 32 public abstract class AbstractGriffonModel extends AbstractGriffonMvcArtifact implements GriffonModel { 33 protected PropertyChangeSupport pcs; 34 35 protected String getArtifactType() { 36 return GriffonModelClass.TYPE; 37 } 38 39 public AbstractGriffonModel() { 40 pcs = new PropertyChangeSupport(this); 41 } 42 43 public void addPropertyChangeListener(PropertyChangeListener listener) { 44 pcs.addPropertyChangeListener(listener); 45 } 46 47 public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { 48 pcs.addPropertyChangeListener(propertyName, listener); 49 } 50 51 public void removePropertyChangeListener(PropertyChangeListener listener) { 52 pcs.removePropertyChangeListener(listener); 53 } 54 55 public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { 56 pcs.removePropertyChangeListener(propertyName, listener); 57 } 58 59 public PropertyChangeListener[] getPropertyChangeListeners() { 60 return pcs.getPropertyChangeListeners(); 61 } 62 63 public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { 64 return pcs.getPropertyChangeListeners(propertyName); 65 } 66 67 protected void firePropertyChange(PropertyChangeEvent event) { 68 pcs.firePropertyChange(event); 69 } 70 71 protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 72 pcs.firePropertyChange(propertyName, oldValue, newValue); 73 } 74 }`