use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class Container method addCallersAsEjbModule.
private static void addCallersAsEjbModule(final ClassLoader loader, final AppModule app, final String... additionalCallers) {
final Set<String> callers = new HashSet<>(NewLoaderLogic.callers(Filters.classes(Container.class.getName(), "org.apache.openejb.maven.plugins.TomEEEmbeddedMojo")));
// we don't care of these
callers.remove("org.apache.tomee.embedded.Container");
callers.remove("org.apache.tomee.gradle.embedded.TomEEEmbeddedTask");
final Iterator<String> callerIt = callers.iterator();
while (callerIt.hasNext()) {
// TomEEEmbeddedMojo is also used with some anonymous classes (TomEEEmbeddedMojo$x)
if (callerIt.next().startsWith("org.apache.openejb.maven.plugins.TomEEEmbeddedMojo")) {
callerIt.remove();
// no break since we remove anonymous class+the mojo itself
}
}
if (additionalCallers != null && additionalCallers.length > 0) {
callers.addAll(asList(additionalCallers));
}
if (callers.isEmpty()) {
return;
}
final EjbJar ejbJar = new EjbJar();
final OpenejbJar openejbJar = new OpenejbJar();
for (final String caller : callers) {
try {
if (!AnnotationDeployer.isInstantiable(loader.loadClass(caller))) {
continue;
}
} catch (final ClassNotFoundException e) {
continue;
}
final String name = caller.replace("$", "_");
final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(caller.replace("$", "_"), caller, true));
bean.localBean();
bean.setTransactionType(TransactionType.BEAN);
final EjbDeployment ejbDeployment = openejbJar.addEjbDeployment(bean);
ejbDeployment.setDeploymentId(name);
}
final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
ejbModule.setBeans(new Beans());
app.getEjbModules().add(ejbModule);
}
Aggregations