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 {@link 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       * <ul>
57       *     <li>allow <i>target</i> attributes in a href</li>
58       *     <li>support multiple webapps in an EAR scenario. Since each webapp has it's own session,
59       *     they would otherwise trash their windowIds each time you link from one webapp to another one</li>
60       *     <li>play nicely with other frameworks which use the window.name for browser tab detection</li>
61       * </ul>
62       * </p>
63       * @return <code>true</code> to allow all windowIds already present in window.name.
64       *         <code>false</code> to only allow window-ids which are generated by CODI
65       */
66      public boolean isUnknownWindowIdsAllowed()
67      {
68          return true;
69      }
70  
71      /**
72       * if set to <code>true</code> CODI will add a windowId=xxx parameter
73       * while encoding each action URL.
74       * @return true if the window-id should be added, false otherwise
75       */
76      public boolean isAddWindowIdToActionUrlsEnabled()
77      {
78          return false;
79      }
80  
81      /**
82       * Specifies the time for the timeout for a window. After a timeout is detected all beans which are only linked
83       * to the window will be destroyed.
84       *
85       * @return the time for the timeout for a window
86       */
87      public int getWindowContextTimeoutInMinutes()
88      {
89          return 60;
90      }
91  
92      /**
93       * Restricts the number of active windows.
94       *
95       * @return limit for active windows
96       */
97      public int getMaxWindowContextCount()
98      {
99          return 64;
100     }
101 
102     /**
103      * Allows to activate the cleanup of empty window contexts to avoid cleanup e.g.
104      * of the eldest window context instances if the max. count is reached.
105      *
106      * @return true for activating it, false otherwise
107      */
108     public boolean isCloseEmptyWindowContextsEnabled()
109     {
110         return false;
111     }
112 
113     /**
114      * Allows to restore the window-context before the component tree gets built.
115      * 
116      * @return true for activating it, false otherwise
117      */
118     public boolean isEagerWindowContextDetectionEnabled()
119     {
120         return true;
121     }
122 
123     /*
124      * event config
125      */
126 
127     /**
128      * Specifies if the
129      * {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.event.CreateWindowContextEvent}
130      * will be fired.
131      *
132      * @return true if the event should be fired, false otherwise
133      */
134     public boolean isCreateWindowContextEventEnabled()
135     {
136         return false;
137     }
138 
139     /**
140      * Specifies if the
141      * {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.event.CloseWindowContextEvent}
142      * will be fired.
143      *
144      * @return true if the event should be fired, false otherwise
145      */
146     public boolean isCloseWindowContextEventEnabled()
147     {
148         return false;
149     }
150 
151     //boolean isResetWindowContextEventEnable();
152 }