01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.test.mdb;
18:
19: import javax.annotation.PostConstruct;
20: import javax.annotation.PreDestroy;
21: import javax.annotation.Resource;
22: import javax.ejb.EJB;
23: import javax.ejb.EJBException;
24: import javax.ejb.MessageDrivenContext;
25: import javax.interceptor.AroundInvoke;
26: import javax.interceptor.InvocationContext;
27: import javax.jms.Message;
28:
29: import org.apache.openejb.test.entity.bmp.BasicBmpHome;
30: import org.apache.openejb.test.stateful.BasicStatefulHome;
31: import org.apache.openejb.test.stateless.BasicStatelessHome;
32:
33: public class MdbInterceptor {
34: @Resource
35: private MessageDrivenContext mdbContext;
36: @EJB(beanName="BasicBmpBean")
37: private BasicBmpHome bmpHome;
38: @EJB(beanName="BasicStatefulBean")
39: private BasicStatefulHome statefulHome;
40: @EJB(beanName="BasicStatelessBean")
41: private BasicStatelessHome statelessHome;
42:
43: @AroundInvoke
44: public Object mdbInterceptor(InvocationContext ctx)
45: throws Exception {
46: Object[] objArr = ctx.getParameters();
47: Message msg = (Message) objArr[0];
48: msg.clearProperties();
49: msg.setBooleanProperty("ClassLevelBusinessMethodInterception",
50: true);
51: ctx.setParameters(objArr);
52: return ctx.proceed();
53: }
54:
55: @PreDestroy
56: public void interceptRemove(InvocationContext ctx) throws Exception {
57: ctx.proceed();
58: }
59:
60: @PostConstruct
61: public void postConstruct(InvocationContext ctx) throws Exception {
62: InterceptorMdbBean.classLevelCreateMethodInterception = true;
63: ctx.proceed();
64: }
65:
66: }
|