View Javadoc

1   package org.eclipse.jetty.deploy.bindings;
2   //========================================================================
3   //Copyright (c) Webtide LLC
4   //------------------------------------------------------------------------
5   //All rights reserved. This program and the accompanying materials
6   //are made available under the terms of the Eclipse Public License v1.0
7   //and Apache License v2.0 which accompanies this distribution.
8   //
9   //The Eclipse Public License is available at 
10  //http://www.eclipse.org/legal/epl-v10.html
11  //
12  //The Apache License v2.0 is available at
13  //http://www.apache.org/licenses/LICENSE-2.0.txt
14  //
15  //You may elect to redistribute this code under either of these licenses. 
16  //========================================================================
17  
18  import java.util.LinkedList;
19  
20  import org.eclipse.jetty.deploy.App;
21  import org.eclipse.jetty.deploy.AppLifeCycle;
22  import org.eclipse.jetty.deploy.graph.Node;
23  
24  /**
25   * Provides a way of forcing the ordered execution of bindings within 
26   * a declared binding target.
27   * 
28   */
29  public class OrderedGroupBinding implements AppLifeCycle.Binding
30  {
31      private String[] _bindingTargets;
32      
33      private LinkedList<AppLifeCycle.Binding> _orderedBindings;
34      
35      public OrderedGroupBinding( String[] bindingTargets )
36      { 
37          _bindingTargets = bindingTargets;
38      }
39      
40      public void addBinding(AppLifeCycle.Binding binding)
41      {
42          if ( _orderedBindings == null )
43           {
44              _orderedBindings = new LinkedList<AppLifeCycle.Binding>();
45           }   
46          
47          _orderedBindings.add(binding);
48      }
49      
50      public void addBindings(AppLifeCycle.Binding[] bindings)
51      {
52          if ( _orderedBindings == null )
53          {
54             _orderedBindings = new LinkedList<AppLifeCycle.Binding>();
55          }
56          
57          for (AppLifeCycle.Binding binding : bindings)
58          {
59              _orderedBindings.add(binding);
60          }
61      }
62       
63      public String[] getBindingTargets()
64      {
65          return _bindingTargets;
66      }
67  
68      public void processBinding(Node node, App app) throws Exception
69      {
70          for ( AppLifeCycle.Binding binding : _orderedBindings )
71          {
72              binding.processBinding(node,app);
73          }
74      }
75  }