Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.acme; |
| 18 | |
Gaurav Gupta | b8828e5 | 2020-05-01 16:04:26 +0530 | [diff] [blame] | 19 | import jakarta.interceptor.Interceptors; |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 20 | |
Lukas Jungmann | df23908 | 2020-04-29 13:37:31 +0200 | [diff] [blame] | 21 | import jakarta.annotation.PostConstruct; |
| 22 | import jakarta.annotation.ManagedBean; |
| 23 | import jakarta.annotation.PreDestroy; |
| 24 | import jakarta.annotation.Resource; |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 25 | |
| 26 | @ManagedBean("FooManagedBean") |
| 27 | @Interceptors(InterceptorA.class) |
| 28 | public class FooManagedBean { |
| 29 | |
| 30 | public boolean interceptorWasHere; |
| 31 | |
| 32 | @PostConstruct |
| 33 | private void init() { |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 34 | System.out.println("In FooManagedBean:init()"); |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | public void hello() { |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 38 | System.out.println("In FooManagedBean::hello()"); |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | |
| 42 | public void assertInterceptorBinding() { |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 43 | if( !interceptorWasHere ) { |
| 44 | throw new RuntimeException("interceptor was not here"); |
| 45 | } |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | @PreDestroy |
| 49 | private void destroy() { |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 50 | System.out.println("In FooManagedBean:destroy()"); |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | |
| 54 | } |