use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class OutputGeneratedDescriptors method writeOpenejbJar.
private void writeOpenejbJar(final EjbModule ejbModule) {
try {
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final File tempFile = tempFile("openejb-jar-", ejbModule.getModuleId() + ".xml");
final OutputStream out = IO.write(tempFile);
try {
JaxbOpenejbJar3.marshal(OpenejbJar.class, openejbJar, out);
logger.info("Dumping Generated openejb-jar.xml to: " + tempFile.getAbsolutePath());
} catch (final JAXBException e) {
// no-op
} finally {
IO.close(out);
}
} catch (final Exception e) {
// no-op
}
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class RemoveWebServices method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
final String ejbName = bean.getEjbName();
final EjbDeployment ejbDeployment = deployments.get(ejbName);
// Clear any <service-ref> references from ejbs
bean.getServiceRef().clear();
if (!(bean instanceof SessionBean)) {
continue;
}
final SessionBean sessionBean = (SessionBean) bean;
if (sessionBean.getServiceEndpoint() == null) {
continue;
}
sessionBean.setServiceEndpoint(null);
// if not, then we should just delete it
if (sessionBean.getHome() != null) {
continue;
}
if (sessionBean.getLocalHome() != null) {
continue;
}
if (sessionBean.getBusinessLocal().size() > 0) {
continue;
}
if (sessionBean.getBusinessRemote().size() > 0) {
continue;
}
// Ok, delete away...
ejbJar.removeEnterpriseBean(ejbName);
openejbJar.removeEjbDeployment(ejbDeployment);
// As well, let's get rid of any transaction or security attributes
// associated with the bean we just deleted.
final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
for (final Method method : copy(permission.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
permission.getMethod().remove(method);
}
}
if (permission.getMethod().size() == 0) {
assemblyDescriptor.getMethodPermission().remove(permission);
}
}
for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
for (final Method method : copy(transaction.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
transaction.getMethod().remove(method);
}
}
if (transaction.getMethod().size() == 0) {
assemblyDescriptor.getContainerTransaction().remove(transaction);
}
}
for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
if (binding.getEjbName().equals(ejbName)) {
assemblyDescriptor.getInterceptorBinding().remove(binding);
}
}
}
}
// Clear any <service-ref> references from interceptors
for (final Interceptor interceptor : ejbJar.getInterceptors()) {
interceptor.getServiceRef().clear();
}
}
return appModule;
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class BusinessInterfacesTest method setUp.
@Override
protected void setUp() throws Exception {
final Assembler assembler = new Assembler();
config = new ConfigurationFactory();
ejbModule = new EjbModule(new EjbJar());
ejbModule.setOpenejbJar(new OpenejbJar());
ejbJar = ejbModule.getEjbJar();
strict(false);
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testEjbNameOverrideOpenejbJar.
@Test
public void testEjbNameOverrideOpenejbJar() throws Exception {
SystemInstance.reset();
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
{
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
final OpenejbJar openejbJar = new OpenejbJar();
final Properties properties = openejbJar.getProperties();
properties.setProperty("mdb.activation.maxSessions", "20");
properties.setProperty("mdb.activation.maxMessagesPerSessions", "100");
properties.setProperty("mdb.activation.destinationType", "javax.jms.Queue");
properties.setProperty("mdb.activation.destination", "OVERRIDDEN.QUEUE");
final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbModule);
assertEquals(2, ejbJarInfo.enterpriseBeans.size());
final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
assertEquals("20", orange.activationProperties.get("maxSessions"));
assertEquals("100", orange.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
assertEquals("OVERRIDDEN.QUEUE", orange.activationProperties.get("destination"));
assertEquals("20", yellow.activationProperties.get("maxSessions"));
assertEquals("100", yellow.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Queue", yellow.activationProperties.get("destinationType"));
assertEquals("OVERRIDDEN.QUEUE", yellow.activationProperties.get("destination"));
}
// Verify the openejb-jar level overrides do not affect other apps
{
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assertEquals(2, ejbJarInfo.enterpriseBeans.size());
final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
assertEquals("7", orange.activationProperties.get("maxSessions"));
assertEquals("4", orange.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
assertEquals("ORANGE.QUEUE", orange.activationProperties.get("destination"));
assertEquals("5", yellow.activationProperties.get("maxSessions"));
assertEquals("10", yellow.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Topic", yellow.activationProperties.get("destinationType"));
assertEquals("YELLOW.TOPIC", yellow.activationProperties.get("destination"));
}
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class AppInfoBuilderTest method testShouldCreateContainer.
public void testShouldCreateContainer() throws Exception {
final EjbJar ejbJar = new EjbJar();
final OpenejbJar openejbJar = new OpenejbJar();
final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
final AppModule appModule = new AppModule(ejbModule);
appModule.getContainers().add(new Container("my-container", "MESSAGE", null));
final AppInfo appInfo = new AppInfoBuilder(new ConfigurationFactory()).build(appModule);
assertEquals(1, appInfo.containers.size());
final ContainerInfo containerInfo = appInfo.containers.get(0);
assertEquals(appInfo.appId + "/my-container", containerInfo.id);
assertEquals(1, containerInfo.types.size());
assertEquals("MESSAGE", containerInfo.types.get(0));
assertEquals(MdbContainerFactory.class.getName(), containerInfo.className);
assertEquals("Default JMS Resource Adapter", containerInfo.properties.get("ResourceAdapter"));
assertEquals(MessageListener.class.getName(), containerInfo.properties.get("MessageListenerInterface"));
assertEquals(TomEEMessageActivationSpec.class.getName(), containerInfo.properties.get("ActivationSpecClass"));
assertEquals("10", containerInfo.properties.get("InstanceLimit"));
assertEquals("true", containerInfo.properties.get("FailOnUnknownActivationSpec"));
}
Aggregations