use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class CheckAssemblyBindings method validate.
public void validate(final EjbModule ejbModule) {
checkUnusedInterceptors(ejbModule);
final Map<String, EnterpriseBean> ejbsByName = ejbModule.getEjbJar().getEnterpriseBeansByEjbName();
final AssemblyDescriptor assembly = ejbModule.getEjbJar().getAssemblyDescriptor();
if (assembly == null) {
return;
}
for (final InterceptorBinding binding : assembly.getInterceptorBinding()) {
final List<String> interceptorClasses = binding.getInterceptorClass();
if (binding.getInterceptorOrder() != null) {
interceptorClasses.addAll(binding.getInterceptorOrder().getInterceptorClass());
}
if (binding.getEjbName() != null && !binding.getEjbName().equals("*") && !ejbsByName.containsKey(binding.getEjbName())) {
fail("InterceptorBinding", "interceptorBinding.noSuchEjbName", binding.getEjbName(), join(",", interceptorClasses));
}
if (binding.getMethod() != null) {
if (binding.getEjbName() == null) {
fail("InterceptorBinding", "interceptorBinding.ejbNameRequiredWithMethod", binding.getMethod().getMethodName(), join(",", interceptorClasses));
}
}
}
for (final MethodPermission permission : assembly.getMethodPermission()) {
for (final Method method : permission.getMethod()) {
if (method.getEjbName() == null) {
fail("MethodPermission", "methodPermission.ejbNameRequired", method.getMethodName(), join(",", permission.getRoleName()));
} else if (method.getEjbName().equals("*")) {
//NOPMD
// no-op. Just continue the loop.
} else if (!ejbsByName.containsKey(method.getEjbName())) {
fail("MethodPermission", "methodPermission.noSuchEjbName", method.getEjbName(), method.getMethodName(), join(",", permission.getRoleName()));
}
}
}
for (final ContainerTransaction transaction : assembly.getContainerTransaction()) {
for (final Method method : transaction.getMethod()) {
if (method.getEjbName() == null) {
fail("ContainerTransaction", "containerTransaction.ejbNameRequired", method.getMethodName(), transaction.getTransAttribute());
} else if (method.getEjbName().equals("*")) {
//NOPMD
// no-op. Just continue the loop.
} else if (!ejbsByName.containsKey(method.getEjbName())) {
fail("ContainerTransaction", "containerTransaction.noSuchEjbName", method.getEjbName(), method.getMethodName(), transaction.getTransAttribute());
}
}
}
}
use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class TomEEConfigurableJohnzonTest method service.
@Module
public static EjbModule service() throws Exception {
final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
final EnterpriseBean bean = new SingletonBean(Endpoint.class).localBean();
module.getEjbJar().addEnterpriseBean(bean);
final Resources resources = new Resources();
final Service sorter = new Service("testSorter", null);
sorter.setClassName(Sorter.class.getName());
resources.getService().add(sorter);
final Service converter = new Service("customerConverter", null);
converter.setClassName(MyConverter.class.getName());
resources.getService().add(converter);
final Service johnzon = new Service("johnzon", null);
johnzon.setClassName(TomEEConfigurableJohnzon.class.getName());
johnzon.getProperties().put("datePattern", "yyyy");
// johnzon.getProperties().put("converter", "$customerConverter"); // or the collection syntax
johnzon.getProperties().put("converters", "collection:$customerConverter,$customerConverter");
johnzon.getProperties().put("attributeOrder", "$testSorter");
resources.getService().add(johnzon);
module.initResources(resources);
final PojoDeployment e = new PojoDeployment();
e.setClassName("jaxrs-application");
e.getProperties().setProperty("cxf.jaxrs.providers", "johnzon");
module.getOpenejbJar().getPojoDeployment().add(e);
return module;
}
use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class LoggingJAXRSCommons method getEjbModule.
protected EjbModule getEjbModule(String pojoDeploymentClassName, String ejbModuleId) throws Exception {
final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
if (ejbModuleId != null) {
module.setModuleId(ejbModuleId);
}
final EnterpriseBean bean = new SingletonBean(LogginTestBean.class).localBean();
module.getEjbJar().addEnterpriseBean(bean);
final Resources resources = new Resources();
final Service feature = new Service("xml", null);
feature.setClassName(JAXBElementProvider.class.getName());
feature.getProperties().put("eventHandler", "$handler");
resources.getService().add(feature);
module.initResources(resources);
if (pojoDeploymentClassName != null) {
final PojoDeployment e = new PojoDeployment();
e.setClassName(pojoDeploymentClassName);
e.getProperties().setProperty("cxf.jaxrs.providers", "xml");
module.getOpenejbJar().getPojoDeployment().add(e);
}
return module;
}
use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class AdvancedProviderConfigTest method service.
@Module
public static EjbModule service() throws Exception {
final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
final EnterpriseBean bean = new SingletonBean(AdvancedBean.class).localBean();
module.getEjbJar().addEnterpriseBean(bean);
final Resources resources = new Resources();
final Service feature = new Service("xml", null);
feature.setClassName(JAXBElementProvider.class.getName());
feature.getProperties().put("eventHandler", "$handler");
resources.getService().add(feature);
final Service handler = new Service("handler", null);
handler.setClassName(MyValidator.class.getName());
resources.getService().add(handler);
module.initResources(resources);
final PojoDeployment e = new PojoDeployment();
e.setClassName("jaxrs-application");
e.getProperties().setProperty("cxf.jaxrs.providers", "xml");
module.getOpenejbJar().getPojoDeployment().add(e);
return module;
}
use of org.apache.openejb.jee.EnterpriseBean in project aries by apache.
the class OpenEJBLocator method findEJBs.
public void findEJBs(BundleManifest manifest, IDirectory bundle, EJBRegistry registry) throws ModellerException {
logger.debug("Scanning " + manifest.getSymbolicName() + "_" + manifest.getManifestVersion() + " for EJBs");
String ejbJarLocation = (manifest.getRawAttributes().getValue("Web-ContextPath") == null) ? "META-INF/ejb-jar.xml" : "WEB-INF/ejb-jar.xml";
try {
//If we have an ejb-jar.xml then parse it
IFile file = bundle.getFile(ejbJarLocation);
EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
EjbModule module = new EjbModule(ejbJar);
//We build our own because we can't trust anyone to get the classpath right otherwise!
module.setFinder(new IDirectoryFinder(AnnotationDeployer.class.getClassLoader(), getClassPathLocations(manifest, bundle)));
//Scan our app for annotated EJBs
AppModule app = new AppModule(module);
new AnnotationDeployer().deploy(app);
//Register our session beans
for (EnterpriseBean eb : ejbJar.getEnterpriseBeans()) {
if (!!!(eb instanceof SessionBean))
continue;
else
registerSessionBean(registry, (SessionBean) eb);
}
} catch (Exception e) {
throw new ModellerException(e);
}
}
Aggregations