View Javadoc

1   /*
2    *   Copyright (C) Christian Schulte, 2005-206
3    *   All rights reserved.
4    *
5    *   Redistribution and use in source and binary forms, with or without
6    *   modification, are permitted provided that the following conditions
7    *   are met:
8    *
9    *     o Redistributions of source code must retain the above copyright
10   *       notice, this list of conditions and the following disclaimer.
11   *
12   *     o Redistributions in binary form must reproduce the above copyright
13   *       notice, this list of conditions and the following disclaimer in
14   *       the documentation and/or other materials provided with the
15   *       distribution.
16   *
17   *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18   *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19   *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20   *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
21   *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22   *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23   *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24   *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25   *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26   *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27   *
28   *   $JOMC: TestModletProvider.java 4209 2012-01-27 19:51:47Z schulte2005 $
29   *
30   */
31  package org.jomc.modlet.test.support;
32  
33  import java.net.URL;
34  import org.jomc.modlet.ModelContext;
35  import org.jomc.modlet.ModelException;
36  import org.jomc.modlet.ModelProcessor;
37  import org.jomc.modlet.ModelProvider;
38  import org.jomc.modlet.ModelValidator;
39  import org.jomc.modlet.Modlet;
40  import org.jomc.modlet.ModletProvider;
41  import org.jomc.modlet.Modlets;
42  import org.jomc.modlet.Service;
43  import org.jomc.modlet.Services;
44  
45  /**
46   * {@code ModletProvider} test implementation.
47   *
48   * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
49   * @version $JOMC: TestModletProvider.java 4209 2012-01-27 19:51:47Z schulte2005 $
50   */
51  public final class TestModletProvider implements ModletProvider
52  {
53  
54      private boolean booleanProperty;
55  
56      private char characterProperty;
57  
58      private byte byteProperty;
59  
60      private short shortProperty;
61  
62      private int intProperty;
63  
64      private long longProperty;
65  
66      private float floatProperty;
67  
68      private double doubleProperty;
69  
70      private String stringProperty;
71  
72      private String stringPropertyWithoutSetter;
73  
74      private String stringPropertyWithoutGetter;
75  
76      private URL urlProperty;
77  
78      private Thread.State enumProperty;
79  
80      private Object objectProperty;
81  
82      private Math unsupportedPropertyType;
83  
84      private InstantiationExceptionPropertyType instantiationExceptionProperty;
85  
86      private InvocationTargetExceptionPropertyType invocationTargetExceptionProperty;
87  
88      public TestModletProvider()
89      {
90          super();
91      }
92  
93      public Modlets findModlets( final ModelContext context ) throws ModelException
94      {
95          final Modlets modlets = new Modlets();
96          final Modlet modlet = new Modlet();
97          modlets.getModlet().add( modlet );
98          modlet.setName( TestModletProvider.class.getName() );
99          modlet.setModel( TestModletProvider.class.getName() );
100         modlet.setServices( new Services() );
101 
102         Service s = new Service();
103         s.setClazz( TestModelProvider.class.getName() );
104         s.setIdentifier( ModelProvider.class.getName() );
105         modlet.getServices().getService().add( s );
106 
107         s = new Service();
108         s.setClazz( TestModelProcessor.class.getName() );
109         s.setIdentifier( ModelProcessor.class.getName() );
110         modlet.getServices().getService().add( s );
111 
112         s = new Service();
113         s.setClazz( TestModelValidator.class.getName() );
114         s.setIdentifier( ModelValidator.class.getName() );
115         modlet.getServices().getService().add( s );
116 
117         context.setAttribute( TestModletProvider.class.getName(), this );
118         return modlets;
119     }
120 
121     public boolean isBooleanProperty()
122     {
123         return this.booleanProperty;
124     }
125 
126     public void setBooleanProperty( final boolean value )
127     {
128         this.booleanProperty = value;
129     }
130 
131     public char getCharacterProperty()
132     {
133         return this.characterProperty;
134     }
135 
136     public void setCharacterProperty( final char value )
137     {
138         this.characterProperty = value;
139     }
140 
141     public byte getByteProperty()
142     {
143         return this.byteProperty;
144     }
145 
146     public void setByteProperty( final byte value )
147     {
148         this.byteProperty = value;
149     }
150 
151     public short getShortProperty()
152     {
153         return this.shortProperty;
154     }
155 
156     public void setShortProperty( final short value )
157     {
158         this.shortProperty = value;
159     }
160 
161     public int getIntProperty()
162     {
163         return this.intProperty;
164     }
165 
166     public void setIntProperty( final int value )
167     {
168         this.intProperty = value;
169     }
170 
171     public long getLongProperty()
172     {
173         return this.longProperty;
174     }
175 
176     public void setLongProperty( final long value )
177     {
178         this.longProperty = value;
179     }
180 
181     public float getFloatProperty()
182     {
183         return this.floatProperty;
184     }
185 
186     public void setFloatProperty( final float value )
187     {
188         this.floatProperty = value;
189     }
190 
191     public double getDoubleProperty()
192     {
193         return this.doubleProperty;
194     }
195 
196     public void setDoubleProperty( final double value )
197     {
198         this.doubleProperty = value;
199     }
200 
201     public String getStringProperty()
202     {
203         return this.stringProperty;
204     }
205 
206     public void setStringProperty( final String value )
207     {
208         this.stringProperty = value;
209     }
210 
211     public String getStringPropertyWithoutSetter()
212     {
213         return this.stringPropertyWithoutSetter;
214     }
215 
216     public void setStringPropertyWithoutGetter( final String value )
217     {
218         this.stringPropertyWithoutGetter = value;
219     }
220 
221     public URL getUrlProperty()
222     {
223         return this.urlProperty;
224     }
225 
226     public void setUrlProperty( final URL value )
227     {
228         this.urlProperty = value;
229     }
230 
231     public Thread.State getEnumProperty()
232     {
233         return this.enumProperty;
234     }
235 
236     public void setEnumProperty( final Thread.State value )
237     {
238         this.enumProperty = value;
239     }
240 
241     public Object getObjectProperty()
242     {
243         return this.objectProperty;
244     }
245 
246     public void setObjectProperty( final Object value )
247     {
248         this.objectProperty = value;
249     }
250 
251     public Math getUnsupportedPropertyType()
252     {
253         return this.unsupportedPropertyType;
254     }
255 
256     public void setUnsupportedPropertyType( final Math value )
257     {
258         this.unsupportedPropertyType = value;
259     }
260 
261     public InstantiationExceptionPropertyType getInstantiationExceptionProperty()
262     {
263         return this.instantiationExceptionProperty;
264     }
265 
266     public void setInstantiationExceptionProperty( final InstantiationExceptionPropertyType value )
267     {
268         this.instantiationExceptionProperty = value;
269     }
270 
271     public InvocationTargetExceptionPropertyType getInvocationTargetExceptionProperty()
272     {
273         return this.invocationTargetExceptionProperty;
274     }
275 
276     public void setInvocationTargetExceptionProperty( final InvocationTargetExceptionPropertyType value )
277     {
278         this.invocationTargetExceptionProperty = value;
279     }
280 
281 }