View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.cdi.util;
21  
22  import javax.enterprise.context.spi.CreationalContext;
23  import java.io.Serializable;
24  
25  /**
26   * This data holder contains all necessary data you need to
27   * store a Contextual Instance in a CDI Context.
28   * 
29   * NOTE: Taken from Apache DeltaSpike
30   */
31  public class ContextualInstanceInfo<T> implements Serializable
32  {
33      /**
34       * The actual Contextual Instance in the context
35       */
36      private T contextualInstance;
37  
38      /**
39       * We need to store the CreationalContext as we need it for
40       * properly destroying the contextual instance via
41       * {@link javax.enterprise.context.spi.Contextual#destroy(Object, javax.enterprise.context.spi.CreationalContext)}
42       */
43      private CreationalContext<T> creationalContext;
44  
45      /**
46       * @return the CreationalContext of the bean
47       */
48      public CreationalContext<T> getCreationalContext()
49      {
50          return creationalContext;
51      }
52  
53      /**
54       * @param creationalContext the CreationalContext of the bean
55       */
56      public void setCreationalContext(CreationalContext<T> creationalContext)
57      {
58          this.creationalContext = creationalContext;
59      }
60  
61      /**
62       * @return the contextual instance itself
63       */
64      public T getContextualInstance()
65      {
66          return contextualInstance;
67      }
68  
69      /**
70       * @param contextualInstance the contextual instance itself
71       */
72      public void setContextualInstance(T contextualInstance)
73      {
74          this.contextualInstance = contextualInstance;
75      }
76  
77  }