001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.jca.inflow;
023:
024: import java.net.InetAddress;
025: import java.util.Properties;
026: import javax.resource.ResourceException;
027: import javax.resource.spi.ActivationSpec;
028: import javax.resource.spi.InvalidPropertyException;
029: import javax.resource.spi.ResourceAdapter;
030:
031: /**
032: * A TestActivationSpec that has non-string java bean properties.
033: *
034: * @author <a href="adrian@jboss.com">Adrian Brock</a>
035: * @version $Revision: 57211 $
036: */
037: public class TestActivationSpec implements ActivationSpec {
038: private ResourceAdapter ra;
039:
040: private String name;
041: /** An int between 1-10 */
042: private int anInt;
043: /** An Integer between 50-100 */
044: private Integer anInteger;
045: /** The 127.0.0.1 address */
046: private InetAddress localhost;
047: /** Properties of the form key1=*;key2=*;... */
048: private Properties props;
049:
050: /**
051: *
052: * @throws InvalidPropertyException
053: */
054: public void validate() throws InvalidPropertyException {
055: /** An int between 1-10 */
056: if (anInt <= 0 || anInt > 10)
057: throw new InvalidPropertyException(
058: "anInt is not between 1-10");
059: /** An int between 50-100 */
060: if (anInteger.intValue() <= 49 || anInteger.intValue() > 100)
061: throw new InvalidPropertyException(
062: "anInt is not between 50-100");
063: /** The 127.0.0.1 address */
064: if (localhost.getHostAddress().equals("127.0.0.1") == false)
065: throw new InvalidPropertyException(
066: "localhost is not 127.0.0.1");
067: /** Properties of the key1=*;key2=*;... */
068: if (props.size() == 0)
069: throw new InvalidPropertyException("props has no values");
070: }
071:
072: public String getName() {
073: return name;
074: }
075:
076: public void setName(String name) {
077: this .name = name;
078: }
079:
080: public int getAnInt() {
081: return anInt;
082: }
083:
084: public void setAnInt(int anInt) {
085: this .anInt = anInt;
086: }
087:
088: public Integer getAnInteger() {
089: return anInteger;
090: }
091:
092: public void setAnInteger(Integer anInteger) {
093: this .anInteger = anInteger;
094: }
095:
096: public InetAddress getLocalhost() {
097: return localhost;
098: }
099:
100: public void setLocalhost(InetAddress localhost) {
101: this .localhost = localhost;
102: }
103:
104: public Properties getProps() {
105: return props;
106: }
107:
108: public void setProps(Properties props) {
109: this .props = props;
110: }
111:
112: public ResourceAdapter getResourceAdapter() {
113: return ra;
114: }
115:
116: public void setResourceAdapter(ResourceAdapter ra)
117: throws ResourceException {
118: this .ra = ra;
119: }
120:
121: public String toString() {
122: return "TestActivationSpec with name " + name;
123: }
124: }
|