PageRenderTime 51ms CodeModel.GetById 34ms app.highlight 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
23package org.jboss.as.jpa.processor;
24
25import org.jboss.as.server.deployment.AttachmentKey;
26import org.jboss.as.server.deployment.DeploymentUnit;
27import org.jboss.as.server.deployment.DeploymentUtils;
28
29/**
30 * JPA Deployment marker
31 *
32 * @author Scott Marlow (copied from WeldDeploymentMarker)
33 */
34public class JPADeploymentMarker {
35
36    private static final AttachmentKey<Boolean> MARKER = AttachmentKey.create(Boolean.class);
37
38    /**
39     * Mark the top level deployment as being a JPA deployment. If the deployment is not a top level deployment the parent is
40     * marked instead
41     */
42    public static void mark(DeploymentUnit unit) {
43        unit = DeploymentUtils.getTopDeploymentUnit(unit);
44        unit.putAttachment(MARKER, Boolean.TRUE);
45    }
46
47    /**
48     * return true if the {@link DeploymentUnit} is part of a JPA deployment
49     */
50    public static boolean isJPADeployment(DeploymentUnit unit) {
51        unit = DeploymentUtils.getTopDeploymentUnit(unit);
52        return unit.getAttachment(MARKER) != null;
53    }
54
55    private JPADeploymentMarker() {
56
57    }
58}