001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * bstefanescu 011 */ 012package org.nuxeo.ecm.webengine.jaxrs.servlet.config; 013 014import javax.servlet.ServletContextListener; 015 016import org.nuxeo.common.xmap.annotation.XNode; 017import org.nuxeo.common.xmap.annotation.XObject; 018import org.nuxeo.ecm.webengine.jaxrs.BundleNotFoundException; 019import org.nuxeo.ecm.webengine.jaxrs.Utils; 020import org.nuxeo.ecm.webengine.jaxrs.Utils.ClassRef; 021 022/** 023 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 024 */ 025@XObject("listener") 026public class ListenerDescriptor { 027 028 @XNode("@class") 029 protected String classRef; 030 031 private ClassRef ref; 032 033 public ClassRef getClassRef() throws ClassNotFoundException, BundleNotFoundException { 034 if (ref == null) { 035 ref = Utils.getClassRef(classRef); 036 } 037 return ref; 038 } 039 040 public ServletContextListener getListener() throws ReflectiveOperationException, BundleNotFoundException { 041 return (ServletContextListener) getClassRef().get().newInstance(); 042 } 043 044 @Override 045 public String toString() { 046 return classRef; 047 } 048 049}