001: /*
002: * $Id: Listener.java 521 2005-09-15 07:11:37Z hengels $
003: * (c) Copyright 2004 con:cern development team.
004: *
005: * This file is part of con:cern (http://concern.sf.net).
006: *
007: * con:cern is free software; you can redistribute it and/or modify
008: * it under the terms of the GNU Lesser General Public License
009: * as published by the Free Software Foundation; either version 2.1
010: * of the License, or (at your option) any later version.
011: *
012: * Please see COPYING for the complete licence.
013: */
014: package org.concern.model;
015:
016: import org.concern.model.parser.ParseException;
017:
018: /**
019: * @author hengels
020: */
021: public class Listener extends Element implements Implementable,
022: Interactable {
023: String implementation;
024: String precondition;
025: int retryDelay = 60 * 60;
026: int trials = 3;
027: Interaction interaction;
028:
029: private transient SimpleNegatedFormVisitor simpleNegatedFormVisitor = new SimpleNegatedFormVisitor();
030:
031: public Listener(String name) {
032: super (name);
033: }
034:
035: public Listener(String name, String implementation) {
036: super (name);
037: this .implementation = implementation;
038: }
039:
040: public Listener() {
041: super (null);
042: }
043:
044: public String getImplementation() {
045: return implementation;
046: }
047:
048: public void setImplementation(String implementation) {
049: Object old = this .implementation;
050: this .implementation = implementation;
051: changes.firePropertyChange("implementation", old,
052: implementation);
053: }
054:
055: public String getPrecondition() {
056: return precondition;
057: }
058:
059: public void setPrecondition(String precondition) {
060: try {
061: precondition = getSimpleNegatedFormVisitor()
062: .transformCondition(precondition);
063: } catch (ParseException e) {
064: throw new RuntimeException(e);
065: }
066: Object old = this .precondition;
067: this .precondition = precondition;
068: changes.firePropertyChange("precondition", old, precondition);
069: }
070:
071: public int getRetryDelay() {
072: return retryDelay;
073: }
074:
075: public void setRetryDelay(int retryDelay) {
076: int old = this .retryDelay;
077: this .retryDelay = retryDelay;
078: changes.firePropertyChange("retryDelay", old, retryDelay);
079: }
080:
081: public int getTrials() {
082: return trials;
083: }
084:
085: public void setTrials(int trials) {
086: int old = this .trials;
087: this .trials = trials;
088: changes.firePropertyChange("trials", old, trials);
089: }
090:
091: public Interaction getInteraction() {
092: return interaction;
093: }
094:
095: public void setInteraction(Interaction interaction) {
096: Object old = this .interaction;
097: this .interaction = interaction;
098: changes.firePropertyChange("interaction", old, interaction);
099: }
100:
101: private SimpleNegatedFormVisitor getSimpleNegatedFormVisitor() {
102: if (simpleNegatedFormVisitor == null)
103: simpleNegatedFormVisitor = new SimpleNegatedFormVisitor();
104: return simpleNegatedFormVisitor;
105: }
106:
107: public Object clone() {
108: Interactable interactable = (Interactable) super .clone();
109: if (interaction != null)
110: interactable.setInteraction((Interaction) getInteraction()
111: .clone());
112: return interactable;
113: }
114: }
|