PageRenderTime 54ms CodeModel.GetById 33ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

/jboss-as-7.1.1.Final/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldResourceAdapter.java

#
Java | 162 lines | 70 code | 14 blank | 78 comment | 11 complexity | 22456bb769aa2fa71f75ab2d90fe5c8b MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1/*
  2 * JBoss, Home of Professional Open Source.
  3 * Copyright 2010, Red Hat Middleware LLC, and individual contributors
  4 * as indicated by the @author tags. See the copyright.txt file in the
  5 * distribution for a 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 */
 22package org.jboss.as.test.smoke.rar;
 23
 24import java.util.logging.Logger;
 25
 26import javax.resource.ResourceException;
 27import javax.resource.spi.ActivationSpec;
 28import javax.resource.spi.BootstrapContext;
 29import javax.resource.spi.ConfigProperty;
 30import javax.resource.spi.Connector;
 31import javax.resource.spi.ResourceAdapter;
 32import javax.resource.spi.ResourceAdapterInternalException;
 33import javax.resource.spi.TransactionSupport;
 34import javax.resource.spi.endpoint.MessageEndpointFactory;
 35import javax.transaction.xa.XAResource;
 36
 37/**
 38 * HelloWorldResourceAdapter
 39 *
 40 * @version $Revision: $
 41 */
 42@Connector(
 43   reauthenticationSupport = false,
 44   transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction)
 45public class HelloWorldResourceAdapter implements ResourceAdapter {
 46   /** The logger */
 47   private static Logger log = Logger.getLogger("HelloWorldResourceAdapter");
 48
 49   /** Name property */
 50   @ConfigProperty(defaultValue="AS 7", supportsDynamicUpdates=true)
 51   private String name;
 52
 53   /**
 54    * default constructor
 55    */
 56   public HelloWorldResourceAdapter() {
 57   }
 58
 59   /**
 60    * set name
 61    * @param name The value
 62    */
 63   public void setName(String name) {
 64      this.name = name;
 65   }
 66
 67   /**
 68    * get name
 69    * @return The value
 70    */
 71   public String getName() {
 72      return name;
 73   }
 74
 75   /**
 76    * This is called during the activation of a message endpoint.
 77    *
 78    * @param endpointFactory a message endpoint factory instance.
 79    * @param spec an activation spec JavaBean instance.
 80    * @throws ResourceException generic exception
 81    */
 82   public void endpointActivation(MessageEndpointFactory endpointFactory,
 83                                  ActivationSpec spec) throws ResourceException {
 84   }
 85
 86   /**
 87    * This is called when a message endpoint is deactivated.
 88    *
 89    * @param endpointFactory a message endpoint factory instance.
 90    * @param spec an activation spec JavaBean instance.
 91    */
 92   public void endpointDeactivation(MessageEndpointFactory endpointFactory,
 93                                    ActivationSpec spec) {
 94   }
 95
 96   /**
 97    * This is called when a resource adapter instance is bootstrapped.
 98    *
 99    * @param ctx a bootstrap context containing references
100    * @throws ResourceAdapterInternalException indicates bootstrap failure.
101    */
102   public void start(BootstrapContext ctx)
103      throws ResourceAdapterInternalException {
104   }
105
106   /**
107    * This is called when a resource adapter instance is undeployed or
108    * during application server shutdown.
109    */
110   public void stop() {
111   }
112
113   /**
114    * This method is called by the application server during crash recovery.
115    *
116    * @param specs an array of ActivationSpec JavaBeans
117    * @throws ResourceException generic exception
118    * @return an array of XAResource objects
119    */
120   public XAResource[] getXAResources(ActivationSpec[] specs)
121      throws ResourceException {
122      return null;
123   }
124
125   /**
126    * Returns a hash code value for the object.
127    * @return a hash code value for this object.
128    */
129   @Override
130   public int hashCode() {
131      int result = 17;
132      if (name != null)
133         result += 31 * result + 7 * name.hashCode();
134      else
135         result += 31 * result + 7;
136      return result;
137   }
138
139   /**
140    * Indicates whether some other object is equal to this one.
141    * @param   other   the reference object with which to compare.
142    * @return true if this object is the same as the obj argument; false otherwise.
143    */
144   @Override
145   public boolean equals(Object other) {
146      if (other == null)
147         return false;
148      if (other == this)
149         return true;
150      if (!(other instanceof HelloWorldResourceAdapter))
151         return false;
152      HelloWorldResourceAdapter obj = (HelloWorldResourceAdapter)other;
153      boolean result = true;
154      if (result) {
155         if (name == null)
156            result = obj.getName() == null;
157         else
158            result = name.equals(obj.getName());
159      }
160      return result;
161   }
162}