View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
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.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.deploy.bindings;
20  
21  import java.util.LinkedList;
22  
23  import org.eclipse.jetty.deploy.App;
24  import org.eclipse.jetty.deploy.AppLifeCycle;
25  import org.eclipse.jetty.deploy.graph.Node;
26  
27  /**
28   * Provides a way of forcing the ordered execution of bindings within 
29   * a declared binding target.
30   * 
31   */
32  public class OrderedGroupBinding implements AppLifeCycle.Binding
33  {
34      private String[] _bindingTargets;
35      
36      private LinkedList<AppLifeCycle.Binding> _orderedBindings;
37      
38      public OrderedGroupBinding( String[] bindingTargets )
39      { 
40          _bindingTargets = bindingTargets;
41      }
42      
43      public void addBinding(AppLifeCycle.Binding binding)
44      {
45          if ( _orderedBindings == null )
46           {
47              _orderedBindings = new LinkedList<AppLifeCycle.Binding>();
48           }   
49          
50          _orderedBindings.add(binding);
51      }
52      
53      public void addBindings(AppLifeCycle.Binding[] bindings)
54      {
55          if ( _orderedBindings == null )
56          {
57             _orderedBindings = new LinkedList<AppLifeCycle.Binding>();
58          }
59          
60          for (AppLifeCycle.Binding binding : bindings)
61          {
62              _orderedBindings.add(binding);
63          }
64      }
65       
66      public String[] getBindingTargets()
67      {
68          return _bindingTargets;
69      }
70  
71      public void processBinding(Node node, App app) throws Exception
72      {
73          for ( AppLifeCycle.Binding binding : _orderedBindings )
74          {
75              binding.processBinding(node,app);
76          }
77      }
78  }