blob: 09cffcffce8c0da8a19060b17205b3c9bfffae8b [file] [log] [blame]
Vinay Vishal57171472018-09-18 20:22:00 +05301/*
2 * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
9 * Licenses when the conditions for such availability set forth in the
10 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11 * version 2 with the GNU Classpath Exception, which is available at
12 * https://www.gnu.org/software/classpath/license.html.
13 *
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15 */
16
17package com.acme;
18
Gaurav Guptab8828e52020-05-01 16:04:26 +053019import jakarta.interceptor.Interceptors;
Vinay Vishal57171472018-09-18 20:22:00 +053020
Lukas Jungmanndf239082020-04-29 13:37:31 +020021import jakarta.annotation.PostConstruct;
22import jakarta.annotation.ManagedBean;
23import jakarta.annotation.PreDestroy;
24import jakarta.annotation.Resource;
Vinay Vishal57171472018-09-18 20:22:00 +053025
26@ManagedBean("FooManagedBean")
27@Interceptors(InterceptorA.class)
28public class FooManagedBean {
29
30 public boolean interceptorWasHere;
31
32 @PostConstruct
33 private void init() {
David Matějčekf4dc06a2021-05-17 12:10:57 +020034 System.out.println("In FooManagedBean:init()");
Vinay Vishal57171472018-09-18 20:22:00 +053035 }
36
37 public void hello() {
David Matějčekf4dc06a2021-05-17 12:10:57 +020038 System.out.println("In FooManagedBean::hello()");
Vinay Vishal57171472018-09-18 20:22:00 +053039 }
40
41
42 public void assertInterceptorBinding() {
David Matějčekf4dc06a2021-05-17 12:10:57 +020043 if( !interceptorWasHere ) {
44 throw new RuntimeException("interceptor was not here");
45 }
Vinay Vishal57171472018-09-18 20:22:00 +053046 }
47
48 @PreDestroy
49 private void destroy() {
David Matějčekf4dc06a2021-05-17 12:10:57 +020050 System.out.println("In FooManagedBean:destroy()");
Vinay Vishal57171472018-09-18 20:22:00 +053051 }
52
53
54}