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