PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/ejb3/src/main/java/org/jboss/as/ejb3/component/entity/entitycache/ReadyEntityCache.java

#
Java | 98 lines | 11 code | 11 blank | 76 comment | 0 complexity | 2dfb6c3283b2074bf2f14bece38ff911 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2007, 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.ejb3.component.entity.entitycache;
  23. import javax.ejb.NoSuchEntityException;
  24. import org.jboss.as.ejb3.component.entity.EntityBeanComponentInstance;
  25. /**
  26. * A cache for entity beans that are in the ready state.
  27. *
  28. * @author Stuart Douglas
  29. */
  30. public interface ReadyEntityCache {
  31. /**
  32. * Called after an entity bean has been created and associated with a new identity.
  33. *
  34. * This corresponds to an ejbCreate call on the entity bean.
  35. *
  36. * The newly created object will be marked as in use, and must be released in the normal manner
  37. *
  38. * @param instance The new instance
  39. */
  40. void create(EntityBeanComponentInstance instance);
  41. /**
  42. * Gets an entity bean instance for the given primary key. This may return a cached instance,
  43. * or may associate the given ket with a pooled entity.
  44. *
  45. * The returned entity will be referenced, and will have its reference count increased by one. It must be de-referenced
  46. * via {@link #release(org.jboss.as.ejb3.component.entity.EntityBeanComponentInstance, boolean)}
  47. *
  48. *
  49. * Implementors of this method must ensure that repeated calls to get within the same transaction
  50. * return the same instance for a given primary key. This must also take into account entity beans
  51. * created in the same transaction using the {@link #create(org.jboss.as.ejb3.component.entity.EntityBeanComponentInstance)}
  52. * method.
  53. *
  54. * Implementations are free to use a 1 to 1 instance -> pk mapping, or create multiple instances per
  55. * primary key.
  56. *
  57. * @param key the identifier of the object
  58. * @return the object
  59. * @throws javax.ejb.NoSuchEntityException if the object identity association failed
  60. */
  61. EntityBeanComponentInstance get(Object key) throws NoSuchEntityException;
  62. /**
  63. * Release the object from use. This will be called at transaction commit time.
  64. *
  65. * If the entity bean has been removed it should be released back into the pool.
  66. *
  67. * This method is called before the lock on the instance has been released.
  68. *
  69. * @param instance The entity
  70. * @param transactionSuccess True if the transaction succeeded
  71. */
  72. void release(EntityBeanComponentInstance instance, boolean transactionSuccess);
  73. /**
  74. * Discard the object, called when an exception occurs
  75. *
  76. * @param instance The instance to discard
  77. */
  78. void discard(EntityBeanComponentInstance instance);
  79. /**
  80. * Start the cache.
  81. */
  82. void start();
  83. /**
  84. * Stop the cache.
  85. */
  86. void stop();
  87. }