001    /*
002     *   Copyright (C) Christian Schulte, 2005-206
003     *   All rights reserved.
004     *
005     *   Redistribution and use in source and binary forms, with or without
006     *   modification, are permitted provided that the following conditions
007     *   are met:
008     *
009     *     o Redistributions of source code must retain the above copyright
010     *       notice, this list of conditions and the following disclaimer.
011     *
012     *     o Redistributions in binary form must reproduce the above copyright
013     *       notice, this list of conditions and the following disclaimer in
014     *       the documentation and/or other materials provided with the
015     *       distribution.
016     *
017     *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
018     *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
019     *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
020     *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
021     *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
022     *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
023     *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
024     *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025     *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
026     *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027     *
028     *   $JOMC: TestModletProvider.java 4209 2012-01-27 19:51:47Z schulte2005 $
029     *
030     */
031    package org.jomc.modlet.test.support;
032    
033    import java.net.URL;
034    import org.jomc.modlet.ModelContext;
035    import org.jomc.modlet.ModelException;
036    import org.jomc.modlet.ModelProcessor;
037    import org.jomc.modlet.ModelProvider;
038    import org.jomc.modlet.ModelValidator;
039    import org.jomc.modlet.Modlet;
040    import org.jomc.modlet.ModletProvider;
041    import org.jomc.modlet.Modlets;
042    import org.jomc.modlet.Service;
043    import org.jomc.modlet.Services;
044    
045    /**
046     * {@code ModletProvider} test implementation.
047     *
048     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
049     * @version $JOMC: TestModletProvider.java 4209 2012-01-27 19:51:47Z schulte2005 $
050     */
051    public final class TestModletProvider implements ModletProvider
052    {
053    
054        private boolean booleanProperty;
055    
056        private char characterProperty;
057    
058        private byte byteProperty;
059    
060        private short shortProperty;
061    
062        private int intProperty;
063    
064        private long longProperty;
065    
066        private float floatProperty;
067    
068        private double doubleProperty;
069    
070        private String stringProperty;
071    
072        private String stringPropertyWithoutSetter;
073    
074        private String stringPropertyWithoutGetter;
075    
076        private URL urlProperty;
077    
078        private Thread.State enumProperty;
079    
080        private Object objectProperty;
081    
082        private Math unsupportedPropertyType;
083    
084        private InstantiationExceptionPropertyType instantiationExceptionProperty;
085    
086        private InvocationTargetExceptionPropertyType invocationTargetExceptionProperty;
087    
088        public TestModletProvider()
089        {
090            super();
091        }
092    
093        public Modlets findModlets( final ModelContext context ) throws ModelException
094        {
095            final Modlets modlets = new Modlets();
096            final Modlet modlet = new Modlet();
097            modlets.getModlet().add( modlet );
098            modlet.setName( TestModletProvider.class.getName() );
099            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    }