View Javadoc

1   /**
2    * Copyright (C) 2010 Daniel Manzke <daniel.manzke@googlemail.com>
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.onami.autobind.integrations.metro;
17  
18  import javax.servlet.ServletContextAttributeEvent;
19  import javax.servlet.ServletContextEvent;
20  import javax.servlet.ServletContextListener;
21  
22  import com.google.inject.Module;
23  import com.sun.xml.ws.transport.http.servlet.WSServletContextListener;
24  
25  public abstract class GuiceContextListener implements ServletContextListener{
26  	private WSServletContextListener delegate = new WSServletContextListener();
27  
28  	public void attributeAdded(ServletContextAttributeEvent event) {
29  		delegate.attributeAdded(event);
30  	}
31  
32  	public void attributeRemoved(ServletContextAttributeEvent event) {
33  		delegate.attributeRemoved(event);
34  	}
35  
36  	public void attributeReplaced(ServletContextAttributeEvent event) {
37  		delegate.attributeReplaced(event);
38  	}
39  
40  	public void contextDestroyed(ServletContextEvent event) {
41  		delegate.contextDestroyed(event);
42  	}
43  
44  	public void contextInitialized(ServletContextEvent event) {
45  		AutomaticGuiceManager.inject(getModule());
46  		delegate.contextInitialized(event);
47  	}
48  
49  	public boolean equals(Object obj) {
50  		return delegate.equals(obj);
51  	}
52  
53  	public int hashCode() {
54  		return delegate.hashCode();
55  	}
56  
57  	public String toString() {
58  		return delegate.toString();
59  	}
60  	
61  	protected abstract Module getModule();
62  }