View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.support.wsrm;
14  
15  import java.beans.PropertyChangeListener;
16  import java.beans.PropertyChangeSupport;
17  import java.math.BigInteger;
18  
19  import com.eviware.soapui.config.WsrmConfigConfig;
20  import com.eviware.soapui.config.WsrmVersionTypeConfig;
21  import com.eviware.soapui.support.PropertyChangeNotifier;
22  
23  public class WsrmConfig implements PropertyChangeNotifier
24  {
25  
26  	private WsrmConfigConfig wsrmConfig;
27  	private String sequenceIdentifier;
28  	private Long lastMessageId;
29  	private String uuid;
30  
31  	private PropertyChangeSupport propertyChangeSupport;
32  
33  	private final WsrmContainer container;
34  
35  	public WsrmConfig( WsrmConfigConfig wsrmConfig, WsrmContainer container )
36  	{
37  		this.setWsrmConfig( wsrmConfig );
38  		this.container = container;
39  		this.setPropertyChangeSupport( new PropertyChangeSupport( this ) );
40  		lastMessageId = 1l;
41  
42  		if( !wsrmConfig.isSetVersion() )
43  		{
44  			wsrmConfig.setVersion( WsrmVersionTypeConfig.X_1_2 );
45  		}
46  	}
47  
48  	public void addPropertyChangeListener( PropertyChangeListener listener )
49  	{
50  		propertyChangeSupport.addPropertyChangeListener( listener );
51  	}
52  
53  	public void addPropertyChangeListener( String propertyName, PropertyChangeListener listener )
54  	{
55  		propertyChangeSupport.addPropertyChangeListener( propertyName, listener );
56  	}
57  
58  	public void removePropertyChangeListener( PropertyChangeListener listener )
59  	{
60  		propertyChangeSupport.removePropertyChangeListener( listener );
61  	}
62  
63  	public void removePropertyChangeListener( String propertyName, PropertyChangeListener listener )
64  	{
65  		propertyChangeSupport.removePropertyChangeListener( propertyName, listener );
66  	}
67  
68  	public void setWsrmConfig( WsrmConfigConfig wsrmConfig )
69  	{
70  		this.wsrmConfig = wsrmConfig;
71  	}
72  
73  	public WsrmConfigConfig getWsrmConfig()
74  	{
75  		return wsrmConfig;
76  	}
77  
78  	public void setPropertyChangeSupport( PropertyChangeSupport propertyChangeSupport )
79  	{
80  		this.propertyChangeSupport = propertyChangeSupport;
81  	}
82  
83  	public PropertyChangeSupport getPropertyChangeSupport()
84  	{
85  		return propertyChangeSupport;
86  	}
87  
88  	public WsrmContainer getContainer()
89  	{
90  		return container;
91  	}
92  
93  	public void setAckTo( String newAckTo )
94  	{
95  		String oldValue = wsrmConfig.getAckTo();
96  		wsrmConfig.setAckTo( newAckTo );
97  		propertyChangeSupport.firePropertyChange( "ackTo", oldValue, newAckTo );
98  	}
99  
100 	public String getAckTo()
101 	{
102 		return wsrmConfig.getAckTo();
103 	}
104 
105 	public void setSequenceExpires( BigInteger newTimeout )
106 	{
107 		BigInteger oldValue = wsrmConfig.getSequenceExpires();
108 		wsrmConfig.setSequenceExpires( newTimeout );
109 		propertyChangeSupport.firePropertyChange( "sequenceExpires", oldValue, newTimeout );
110 	}
111 
112 	public BigInteger getSequenceExpires()
113 	{
114 		return wsrmConfig.getSequenceExpires();
115 	}
116 
117 	public void setWsrmEnabled( boolean enable )
118 	{
119 		boolean oldValue = isWsrmEnabled();
120 		container.setWsrmEnabled( enable );
121 		propertyChangeSupport.firePropertyChange( "wsrmEnabled", oldValue, enable );
122 	}
123 
124 	public boolean isWsrmEnabled()
125 	{
126 		return container.isWsrmEnabled();
127 	}
128 
129 	public void setVersion( String arg0 )
130 	{
131 		String oldValue = getVersion();
132 		wsrmConfig.setVersion( WsrmVersionTypeConfig.Enum.forString( arg0 ) );
133 		propertyChangeSupport.firePropertyChange( "version", oldValue, arg0 );
134 	}
135 
136 	public String getVersion()
137 	{
138 		return wsrmConfig.getVersion().toString();
139 	}
140 
141 	public void setSequenceIdentifier( String sequenceIdentifier )
142 	{
143 		this.sequenceIdentifier = sequenceIdentifier;
144 	}
145 
146 	public String getSequenceIdentifier()
147 	{
148 		return sequenceIdentifier;
149 	}
150 
151 	public Long nextMessageId()
152 	{
153 		this.lastMessageId++ ;
154 		return lastMessageId;
155 	}
156 
157 	public Long getLastMessageId()
158 	{
159 		return lastMessageId;
160 	}
161 
162 	public void setLastMessageId( long msgId )
163 	{
164 		lastMessageId = msgId;
165 	}
166 
167 	public void setUuid( String uuid )
168 	{
169 		this.uuid = uuid;
170 	}
171 
172 	public String getUuid()
173 	{
174 		return uuid;
175 	}
176 
177 	public String getVersionNameSpace()
178 	{
179 		return WsrmUtils.getWsrmVersionNamespace( wsrmConfig.getVersion() );
180 	}
181 }