KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > jca > inflow > TestActivationSpec


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.jca.inflow;
23
24 import java.net.InetAddress JavaDoc;
25 import java.util.Properties JavaDoc;
26 import javax.resource.ResourceException JavaDoc;
27 import javax.resource.spi.ActivationSpec JavaDoc;
28 import javax.resource.spi.InvalidPropertyException JavaDoc;
29 import javax.resource.spi.ResourceAdapter JavaDoc;
30
31 /**
32  * A TestActivationSpec that has non-string java bean properties.
33  *
34  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
35  * @version $Revision: 37459 $
36  */

37 public class TestActivationSpec implements ActivationSpec JavaDoc
38 {
39    private ResourceAdapter JavaDoc ra;
40    
41    private String JavaDoc name;
42    /** An int between 1-10 */
43    private int anInt;
44    /** An Integer between 50-100 */
45    private Integer JavaDoc anInteger;
46    /** The 127.0.0.1 address */
47    private InetAddress JavaDoc localhost;
48    /** Properties of the form key1=*;key2=*;... */
49    private Properties JavaDoc props;
50
51    /**
52     *
53     * @throws InvalidPropertyException
54     */

55    public void validate() throws InvalidPropertyException JavaDoc
56    {
57       /** An int between 1-10 */
58       if( anInt <= 0 || anInt > 10 )
59          throw new InvalidPropertyException JavaDoc("anInt is not between 1-10");
60       /** An int between 50-100 */
61       if( anInteger.intValue() <= 49 || anInteger.intValue() > 100 )
62          throw new InvalidPropertyException JavaDoc("anInt is not between 50-100");
63       /** The 127.0.0.1 address */
64       if( localhost.getHostAddress().equals("127.0.0.1") == false )
65          throw new InvalidPropertyException JavaDoc("localhost is not 127.0.0.1");
66       /** Properties of the key1=*;key2=*;... */
67       if( props.size() == 0 )
68          throw new InvalidPropertyException JavaDoc("props has no values");
69    }
70
71    public String JavaDoc getName()
72    {
73       return name;
74    }
75    public void setName(String JavaDoc name)
76    {
77       this.name = name;
78    }
79
80    public int getAnInt()
81    {
82       return anInt;
83    }
84    public void setAnInt(int anInt)
85    {
86       this.anInt = anInt;
87    }
88
89    public Integer JavaDoc getAnInteger()
90    {
91       return anInteger;
92    }
93    public void setAnInteger(Integer JavaDoc anInteger)
94    {
95       this.anInteger = anInteger;
96    }
97
98    public InetAddress JavaDoc getLocalhost()
99    {
100       return localhost;
101    }
102    public void setLocalhost(InetAddress JavaDoc localhost)
103    {
104       this.localhost = localhost;
105    }
106
107    public Properties JavaDoc getProps()
108    {
109       return props;
110    }
111    public void setProps(Properties JavaDoc props)
112    {
113       this.props = props;
114    }
115
116    public ResourceAdapter JavaDoc getResourceAdapter()
117    {
118       return ra;
119    }
120    
121    public void setResourceAdapter(ResourceAdapter JavaDoc ra) throws ResourceException JavaDoc
122    {
123       this.ra = ra;
124    }
125    
126    public String JavaDoc toString()
127    {
128       return "TestActivationSpec with name " + name;
129    }
130 }
131
Popular Tags