use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class DeploymentContextPropertiesTest method testAppContextProperties.
public void testAppContextProperties() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
{
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
}
{
// Setup the descriptor information
final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
final EjbJar ejbJar = ejbModule.getEjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
final AppModule appModule = new AppModule(ejbModule);
appModule.getProperties().setProperty("color", "orange");
final AppInfo appInfo = config.configureApplication(appModule);
assertProperty(appInfo.properties, "color", "orange");
assembler.createApplication(appInfo);
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
final Properties properties = beanContext.getModuleContext().getAppContext().getProperties();
assertProperty(properties, "color", "orange");
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class GreetingServiceTest method app.
@Module
public EjbModule app() {
final SingletonBean bean = (SingletonBean) new SingletonBean(GreetingService.class).localBean();
bean.setRestService(true);
// now create an ejbjar and an openejb-jar to hold the provider config
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
final OpenejbJar openejbJar = new OpenejbJar();
openejbJar.addEjbDeployment(new EjbDeployment(ejbJar.getEnterpriseBeans()[0]));
final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
properties.setProperty("cxf.jaxrs.providers", IllegalArgumentExceptionMapper.class.getName());
// link all and return this module
final EjbModule module = new EjbModule(ejbJar);
module.setOpenejbJar(openejbJar);
return module;
}
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