use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class OpenEJBContextConfig method cleanUpRestServlets.
private void cleanUpRestServlets() {
final WebAppInfo webAppInfo = info.get();
final AppInfo appInfo = info.app();
if (webAppInfo == null || appInfo == null || "false".equalsIgnoreCase(appInfo.properties.getProperty("openejb.jaxrs.on", "true"))) {
return;
}
final Container[] children = context.findChildren();
final Map<String, Container> mappedChildren = new HashMap<String, Container>();
if (children != null) {
// index potential rest containers by class to cleanup applications defined as servlet
for (final Container c : children) {
if (!(c instanceof StandardWrapper)) {
continue;
}
final StandardWrapper wrapper = (StandardWrapper) c;
final String appSpec = wrapper.getInitParameter("javax.ws.rs.Application");
if (appSpec != null) {
mappedChildren.put(appSpec, c);
} else {
final String app = wrapper.getInitParameter(Application.class.getName());
if (app != null) {
mappedChildren.put(app, c);
} else if (wrapper.getServletClass() == null) {
try {
if (Application.class.isAssignableFrom(context.getLoader().getClassLoader().loadClass(wrapper.getServletName()))) {
// remove directly since it is not in restApplications
context.removeChild(c);
}
} catch (final Exception e) {
// no-op
}
}
}
}
// cleanup
for (final String clazz : webAppInfo.restApplications) {
final Container child = mappedChildren.get(clazz);
try {
// remove only "fake" servlets to let users use their own stuff
if (child != null) {
final String servletClass = StandardWrapper.class.cast(child).getServletClass();
if (servletClass == null || "org.apache.openejb.server.rest.OpenEJBRestServlet".equals(servletClass) || !HttpServlet.class.isAssignableFrom(info.loader().loadClass(servletClass))) {
context.removeChild(child);
}
}
} catch (final NoClassDefFoundError | ClassNotFoundException e) {
context.removeChild(child);
}
}
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class HessianService method start.
@Override
public void start() throws ServiceException {
SystemInstance.get().addObserver(this);
SystemInstance.get().setComponent(HessianService.class, this);
registry = setRegistry();
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
if (assembler != null) {
for (final AppInfo appInfo : assembler.getDeployedApplications()) {
deploy(new AssemblerAfterApplicationCreated(appInfo, SystemInstance.get().getComponent(ContainerSystem.class).getAppContext(appInfo.appId), null));
}
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class DeployerEjbTest method testDeployProperties.
@Test
public void testDeployProperties() throws Exception {
final Properties p = new Properties();
final String path = warArchive.get().getAbsolutePath();
p.setProperty(Deployer.FILENAME, path);
p.setProperty(OPENEJB_DEPLOYER_SAVE_DEPLOYMENTS, Boolean.FALSE.toString());
final Deployer deployer = getDeployer();
final AppInfo appInfo = deployer.deploy(p);
Assert.assertTrue("Paths do not match: " + path + " - " + appInfo.path, path.equals(appInfo.path));
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class AltDDPrefixTest method testPersistenceUnit.
/**
* OPENEJB-1059: altdd does not work with a persistence.xml when no embedded
* in EjbModule/Client module.
*
* @throws Exception if something wrong happen
*/
public void testPersistenceUnit() throws Exception {
System.out.println("*** testPersistenceUnit ***");
final Assembler assmbler = new Assembler();
SystemInstance.get().setProperty("openejb.altdd.prefix", "footest, test");
DeploymentLoader.reloadAltDD();
final ConfigurationFactory factory = new ConfigurationFactory();
final URL resource = AltDDPrefixTest.class.getClassLoader().getResource("altddPU1");
final File file = URLs.toFile(resource);
final AppInfo appInfo = factory.configureApplication(file);
assertNotNull(appInfo);
assertEquals(0, appInfo.ejbJars.size());
assertEquals(1, appInfo.persistenceUnits.size());
final PersistenceUnitInfo info = appInfo.persistenceUnits.get(0);
// a space must be present before hashcode
assertTrue(info.id.startsWith("footest-unit "));
// appInfo = factory.configureApplication(file);
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class AltDDPrefixTest method testTestOnlyModule.
/**
* This module has only a "test.ejb-jar.xml" file and no equivalent
* non-test ejb-jar.xml file. It should still get discovered even though
* there is not an ejb-jar.xml file and only a test.ejb-jar.xml file
*
* @throws Exception
*/
public void testTestOnlyModule() throws Exception {
System.out.println("*** testTestOnlyModule ***");
final Assembler assmbler = new Assembler();
SystemInstance.get().setProperty("openejb.altdd.prefix", "test");
DeploymentLoader.reloadAltDD();
final ConfigurationFactory factory = new ConfigurationFactory();
final URL resource = AltDDPrefixTest.class.getClassLoader().getResource("altddapp1");
final File file = URLs.toFile(resource);
final AppInfo appInfo = factory.configureApplication(file);
assertNotNull(appInfo);
assertEquals(1, appInfo.ejbJars.size());
}
Aggregations