Class<?> clazz;
try {
clazz = classLoader.loadClass(className);
classes.add(clazz);
} catch (ClassNotFoundException e) {
throw new OpenEJBException("Unable to load REST class: " + className, e);
}
}
}
} else {
for (String rawClassName : restApp) {
final String application = realClassName(rawClassName);
if (application != null) {
Class<?> clazz;
try {
clazz = classLoader.loadClass(application);
classes.add(clazz);
} catch (ClassNotFoundException e) {
throw new OpenEJBException("Unable to load Application class: " + application, e);
}
try {
Application app = Application.class.cast(clazz.newInstance());
classes.addAll(app.getClasses());
} catch (InstantiationException e) {
throw new OpenEJBException("Unable to instantiate Application class: " + application, e);
} catch (IllegalAccessException e) {
throw new OpenEJBException("Unable to access Application class: " + application, e);
}
}
}
}
/*
* Servlet classes are scanned
*/
for (Servlet servlet : webApp.getServlet()) {
String servletClass = realClassName(servlet.getServletClass());
if (servletClass == null) { // try with servlet name, @see org.apache.openejb.arquillian.tests.jaxrs.basicapp.BasicApplication
servletClass = realClassName(servlet.getServletName());
}
if (servletClass != null) {
if (!"org.apache.openejb.server.rest.OpenEJBRestServlet".equals(servletClass)) {
try {
Class clazz = classLoader.loadClass(servletClass);
classes.add(clazz);
if (servlet.getServletClass() == null) {
servlet.setServletClass(servletClass);
}
} catch (ClassNotFoundException e) {
if (servlet.getServletClass() != null) {
throw new OpenEJBException("Unable to load servlet class: " + servletClass, e);
} else {
logger.error("servlet " + servlet.getServletName() + " has no servlet-class defined and is not a subclass of Application");
}
}
}
// if the servlet is a rest init servlet don't deploy rest classes automatically
for (ParamValue param : servlet.getInitParam()) {
if (param.getParamName().equals(Application.class.getName())) {
webModule.getRestApplications().clear();
webModule.getRestApplications().add(param.getParamValue());
break;
}
}
}
}
/*
* Filter classes are scanned
*/
for (Filter filter : webApp.getFilter()) {
String filterClass = realClassName(filter.getFilterClass());
if (filterClass != null) {
try {
Class clazz = classLoader.loadClass(filterClass);
classes.add(clazz);
} catch (ClassNotFoundException e) {
throw new OpenEJBException("Unable to load servlet filter class: " + filterClass, e);
}
}
}
/*
* Listener classes are scanned
*/
for (Listener listener : webApp.getListener()) {
String listenerClass = realClassName(listener.getListenerClass());
if (listenerClass != null) {
try {
Class clazz = classLoader.loadClass(listenerClass);
classes.add(clazz);
} catch (ClassNotFoundException e) {
throw new OpenEJBException("Unable to load servlet listener class: " + listenerClass, e);
}
}
}
for (TldTaglib taglib : webModule.getTaglibs()) {
/*
* TagLib Listener classes are scanned
*/
for (Listener listener : taglib.getListener()) {
String listenerClass = realClassName(listener.getListenerClass());
if (listenerClass != null) {
try {
Class clazz = classLoader.loadClass(listenerClass);
classes.add(clazz);
} catch (ClassNotFoundException e) {
logger.error("Unable to load tag library servlet listener class: " + listenerClass);
}
}
}
/*
* TagLib Tag classes are scanned
*/
for (Tag tag : taglib.getTag()) {
String tagClass = realClassName(tag.getTagClass());
if (tagClass != null) {
try {
Class clazz = classLoader.loadClass(tagClass);
classes.add(clazz);
} catch (ClassNotFoundException e) {
logger.error("Unable to load tag library tag class: " + tagClass);
}
}
}
}
/*
* WebService HandlerChain classes are scanned
*/
if (webModule.getWebservices() != null) {
for (WebserviceDescription webservice : webModule.getWebservices().getWebserviceDescription()) {
for (PortComponent port : webservice.getPortComponent()) {
// skip ejb port defs
if (port.getServiceImplBean().getEjbLink() != null) continue;
if (port.getHandlerChains() == null) continue;
for (org.apache.openejb.jee.HandlerChain handlerChain : port.getHandlerChains().getHandlerChain()) {
for (Handler handler : handlerChain.getHandler()) {
String handlerClass = realClassName(handler.getHandlerClass());
if (handlerClass != null) {
try {
Class clazz = classLoader.loadClass(handlerClass);
classes.add(clazz);
} catch (ClassNotFoundException e) {
throw new OpenEJBException("Unable to load webservice handler class: " + handlerClass, e);
}
}
}
}
}