}
public ClientModule deploy(ClientModule clientModule) throws OpenEJBException {
if (clientModule.getApplicationClient() == null){
clientModule.setApplicationClient(new ApplicationClient());
}
// Lots of jars have main classes so this might not even be an app client.
// We're not going to scrape it for @LocalClient or @RemoteClient annotations
// unless they flag us specifically by adding a META-INF/application-client.xml
//
// ClientModules that already have a ClassFinder have been generated automatically
// from an EjbModule, so we don't skip those ever.
if (clientModule.getFinder() == null && clientModule.getAltDDs().containsKey("application-client.xml"))
if (clientModule.getApplicationClient() != null && clientModule.getApplicationClient().isMetadataComplete()) return clientModule;
ClassFinder finder = clientModule.getFinder();
if (finder == null) {
try {
if (clientModule.getJarLocation() != null) {
String location = clientModule.getJarLocation();
File file = new File(location);
URL url;
if (file.exists()) {
url = file.toURI().toURL();
} else {
url = new URL(location);
}
finder = new ClassFinder(clientModule.getClassLoader(), url);
} else {
finder = new ClassFinder(clientModule.getClassLoader());
}
} catch (MalformedURLException e) {
startupLogger.warning("startup.scrapeFailedForClientModule.url", clientModule.getJarLocation());
return clientModule;
} catch (Exception e) {
startupLogger.warning("startup.scrapeFailedForClientModule", e, clientModule.getJarLocation());
return clientModule;
}
}
// This method is also called by the deploy(EjbModule) method to see if those
// modules have any @LocalClient or @RemoteClient classes
for (Class<?> clazz : finder.findAnnotatedClasses(LocalClient.class)) {
clientModule.getLocalClients().add(clazz.getName());
}
for (Class<?> clazz : finder.findAnnotatedClasses(RemoteClient.class)) {
clientModule.getRemoteClients().add(clazz.getName());
}
if (clientModule.getApplicationClient() == null){
if (clientModule.getRemoteClients().size() > 0 || clientModule.getLocalClients().size() > 0) {
clientModule.setApplicationClient(new ApplicationClient());
}
}
return clientModule;
}