001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: EBaseInternalCallbackOrder00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.base.lifecallback;
025:
026: import javax.annotation.PostConstruct;
027: import javax.annotation.Resource;
028: import javax.ejb.SessionContext;
029:
030: import org.ow2.easybeans.tests.common.ejbs.base.ItfCheckPostConstruct;
031: import org.ow2.util.log.Log;
032: import org.ow2.util.log.LogFactory;
033:
034: /**
035: * Tests the PostConstruct invocation order.
036: * @author Eduardo Studzinski Estima de Castro
037: * @author Gisele Pinheiro Souza
038: *
039: */
040: public class EBaseInternalCallbackOrder00 implements
041: ItfCheckPostConstruct {
042:
043: /**
044: * Log helper.
045: */
046: private Log logger = LogFactory
047: .getLog(EBaseInternalCallbackOrder00.class);
048:
049: /**
050: * Shows if a post construct method was executed.
051: */
052: private boolean okPostConstruct;
053:
054: /**
055: * PostConstruct status.
056: */
057: private boolean okAllPostConstruct;
058:
059: /**
060: * Session Context.
061: */
062: @Resource
063: private SessionContext ctx;
064:
065: /**
066: * PostConstruct callback.
067: */
068: @SuppressWarnings("unused")
069: @PostConstruct
070: private void postConstruct00() {
071: logger.debug("PostConstruct Method.");
072: if (ctx == null) {
073: throw new IllegalStateException(
074: "PostConstruct callback must be invoked after the dependency injection.");
075: }
076: okPostConstruct = true;
077: }
078:
079: /**
080: * Checks the PostConstruct invocation.
081: */
082: public void check() {
083: if (!okAllPostConstruct) {
084: throw new IllegalStateException(
085: "Some PostConstruct was not invoked.");
086: }
087:
088: }
089:
090: /**
091: * Gets the Postconstruct Invocation status.
092: * @return true if the postconstruct callback was invoked.
093: */
094: protected boolean isOKPostConstruct() {
095: return okPostConstruct;
096: }
097:
098: /**
099: * Sets the result of interceptor invocation.
100: * @param b true if ok, otherwise false.
101: */
102: public void setStatus(final boolean b) {
103: okAllPostConstruct = b;
104: }
105:
106: }
|