PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/jboss-as-7.1.1.Final/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPADeploymentMarker.java

#
Java | 58 lines | 17 code | 8 blank | 33 comment | 1 complexity | 5a4fec1c163a67b51e9329325a9ff44f MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2011, Red Hat, Inc., 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.jpa.processor;
  23. import org.jboss.as.server.deployment.AttachmentKey;
  24. import org.jboss.as.server.deployment.DeploymentUnit;
  25. import org.jboss.as.server.deployment.DeploymentUtils;
  26. /**
  27. * JPA Deployment marker
  28. *
  29. * @author Scott Marlow (copied from WeldDeploymentMarker)
  30. */
  31. public class JPADeploymentMarker {
  32. private static final AttachmentKey<Boolean> MARKER = AttachmentKey.create(Boolean.class);
  33. /**
  34. * Mark the top level deployment as being a JPA deployment. If the deployment is not a top level deployment the parent is
  35. * marked instead
  36. */
  37. public static void mark(DeploymentUnit unit) {
  38. unit = DeploymentUtils.getTopDeploymentUnit(unit);
  39. unit.putAttachment(MARKER, Boolean.TRUE);
  40. }
  41. /**
  42. * return true if the {@link DeploymentUnit} is part of a JPA deployment
  43. */
  44. public static boolean isJPADeployment(DeploymentUnit unit) {
  45. unit = DeploymentUtils.getTopDeploymentUnit(unit);
  46. return unit.getAttachment(MARKER) != null;
  47. }
  48. private JPADeploymentMarker() {
  49. }
  50. }