2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   *
17   * $Id: RequestBean.java 495383 2007-01-11 21:31:37Z rahul $
18   */
19  
20  package org.apache.shale.examples.test.tiger;
21  
22  import org.apache.shale.tiger.managed.Bean;
23  import org.apache.shale.tiger.managed.Property;
24  import org.apache.shale.tiger.managed.Scope;
25  import org.apache.shale.tiger.view.Destroy;
26  import org.apache.shale.tiger.view.Init;
27  import org.apache.shale.tiger.view.Request;
28  
29  /***
30   * <p>Request scope managed bean declared with annotations.</p>
31   */
32  @Request
33  @Bean(name="requestBean", scope=Scope.REQUEST)
34  public class RequestBean {
35      
36  
37      // ------------------------------------------------------- Public Properties
38  
39  
40      /***
41       * <p>Injected application bean instance.</p>
42       */
43      @Property(value="#{applicationBean}")
44      private ApplicationBean applicationBean;
45  
46      public ApplicationBean getApplicationBean() {
47          return this.applicationBean;
48      }
49  
50      public void setApplicationBean(ApplicationBean applicationBean) {
51          this.applicationBean = applicationBean;
52      }
53  
54  
55      /***
56       * <p>Return the events that have occurred so far.</p>
57       */
58      private StringBuffer events = new StringBuffer();
59  
60      public String getEvents() {
61          return events.toString();
62      }
63  
64  
65  
66      /***
67       * <p>Injected session bean instance.</p>
68       */
69      @Property(value="#{sessionBean}")
70      private SessionBean sessionBean;
71  
72      public SessionBean getSessionBean() {
73          return this.sessionBean;
74      }
75  
76      public void setSessionBean(SessionBean sessionBean) {
77          this.sessionBean = sessionBean;
78      }
79  
80  
81      // -------------------------------------------------------- Lifecycle Events
82  
83  
84      @Init
85      public void myInit() {
86          events.append("init/");
87          System.out.println("RequestBean.init()");
88      }
89  
90  
91      @Destroy
92      public void myDestroy() {
93          events.append("destroy/");
94          System.out.println("RequestBean.destroy()");
95      }
96  
97  
98  }