This project has retired. For details please refer to its Attic page.
DefinitionsFactoryUtil xref
View Javadoc

1   /*
2    * $Id: DefinitionsFactoryUtil.java 734110 2009-01-13 11:49:19Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  package org.apache.tiles.definition.util;
23  
24  import org.apache.tiles.TilesContainer;
25  import org.apache.tiles.access.TilesAccess;
26  import org.apache.tiles.definition.DefinitionsFactory;
27  import org.apache.tiles.definition.Refreshable;
28  import org.apache.tiles.impl.BasicTilesContainer;
29  
30  /***
31   * Various {@link DefinitionsFactory} utilities.
32   *
33   * @version $Rev: 734110 $ $Date: 2009-01-13 12:49:19 +0100 (mar, 13 gen 2009) $
34   */
35  public final class DefinitionsFactoryUtil {
36  
37      /***
38       * Private constructor to avoid instatiation.
39       */
40      private DefinitionsFactoryUtil() {
41      }
42  
43      /***
44       * Reloads the definitions factory content, if necessary.
45       *
46       * @param context The context object to use
47       * @throws org.apache.tiles.definition.DefinitionsFactoryException If
48       * something goes wrong during reload.
49       * @deprecated Let the definitions DAO manage auto-reload.
50       */
51      @Deprecated
52      public static void reloadDefinitionsFactory(Object context) {
53          TilesContainer container = TilesAccess.getContainer(context);
54          if (container instanceof BasicTilesContainer) {
55              BasicTilesContainer basic = (BasicTilesContainer) container;
56              DefinitionsFactory factory = basic.getDefinitionsFactory();
57              if (factory instanceof Refreshable) {
58                  Refreshable rFactory = (Refreshable) factory;
59                  if (rFactory.refreshRequired()) {
60                      rFactory.refresh();
61                  }
62              }
63          }
64      }
65  }