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  package org.apache.myfaces.lifecycle;
20  
21  /**
22   * Configuration for the org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext
23   * - it's customizable via the Alternative or Specializes mechanism of CDI.
24   */
25  public class WindowContextConfig
26  {
27      private static final long serialVersionUID = 8159770064249255686L;
28  
29      protected WindowContextConfig()
30      {
31      }
32  
33      /**
34       * Specifies if it is allowed to use URL params for forwarding the current window-id.
35       * (deactivate it e.g. for higher security - in this case it's required to use a window id provided by a
36       * component lib or a server-side window-handler)
37       * 
38       * @return true if it is allowed to add the window-id as URL parameter
39       */
40      public boolean isUrlParameterSupported()
41      {
42          return true;
43      }
44  
45      /**
46       * Allows to restrict window-ids.
47       * <p>With the default window handler (esp. for JSF 1.2), URLs have to contain the window-id.
48       * If users bookmark these links, they could open 2-n tabs (with the bookmark) which have the same window-id.
49       * It is only possible to prevent it if the ClientSideWindowHandler is used.
50       * </p>
51       *
52       * <p><b>ATTENTION:</b> Since CODI-1.0.6 this is set to <code>true</code> as defalt!</p>
53       *
54       * <p>
55       * This must be enabled to:
56       * </p>
57       * <ul>
58       *     <li>allow <i>target</i> attributes in a href</li>
59       *     <li>support multiple webapps in an EAR scenario. Since each webapp has it's own session,
60       *     they would otherwise trash their windowIds each time you link from one webapp to another one</li>
61       *     <li>play nicely with other frameworks which use the window.name for browser tab detection</li>
62       * </ul>
63       * 
64       * @return <code>true</code> to allow all windowIds already present in window.name.
65       *         <code>false</code> to only allow window-ids which are generated by CODI
66       */
67      public boolean isUnknownWindowIdsAllowed()
68      {
69          return true;
70      }
71  
72      /**
73       * if set to <code>true</code> CODI will add a windowId=xxx parameter
74       * while encoding each action URL.
75       * @return true if the window-id should be added, false otherwise
76       */
77      public boolean isAddWindowIdToActionUrlsEnabled()
78      {
79          return false;
80      }
81  
82      /**
83       * Specifies the time for the timeout for a window. After a timeout is detected all beans which are only linked
84       * to the window will be destroyed.
85       *
86       * @return the time for the timeout for a window
87       */
88      public int getWindowContextTimeoutInMinutes()
89      {
90          return 60;
91      }
92  
93      /**
94       * Restricts the number of active windows.
95       *
96       * @return limit for active windows
97       */
98      public int getMaxWindowContextCount()
99      {
100         return 64;
101     }
102 
103     /**
104      * Allows to activate the cleanup of empty window contexts to avoid cleanup e.g.
105      * of the eldest window context instances if the max. count is reached.
106      *
107      * @return true for activating it, false otherwise
108      */
109     public boolean isCloseEmptyWindowContextsEnabled()
110     {
111         return false;
112     }
113 
114     /**
115      * Allows to restore the window-context before the component tree gets built.
116      * 
117      * @return true for activating it, false otherwise
118      */
119     public boolean isEagerWindowContextDetectionEnabled()
120     {
121         return true;
122     }
123 
124     /*
125      * event config
126      */
127 
128     /**
129      * Specifies if the
130      * org.apache.myfaces.extensions.cdi.core.api.scope.conversation.event.CreateWindowContextEvent
131      * will be fired.
132      *
133      * @return true if the event should be fired, false otherwise
134      */
135     public boolean isCreateWindowContextEventEnabled()
136     {
137         return false;
138     }
139 
140     /**
141      * Specifies if the
142      * org.apache.myfaces.extensions.cdi.core.api.scope.conversation.event.CloseWindowContextEvent
143      * will be fired.
144      *
145      * @return true if the event should be fired, false otherwise
146      */
147     public boolean isCloseWindowContextEventEnabled()
148     {
149         return false;
150     }
151 
152     //boolean isResetWindowContextEventEnable();
153 }