use of org.apache.openejb.config.sys.Service 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.config.sys.Service in project tomee by apache.
the class FeatureTest method app.
@Module
public EjbModule app() {
final StatelessBean bean = (StatelessBean) new StatelessBean(MySecondRestClass.class).localBean();
bean.setRestService(true);
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
final OpenejbJar openejbJar = new OpenejbJar();
final PojoDeployment e = new PojoDeployment();
openejbJar.getPojoDeployment().add(e);
e.setClassName("jaxrs-application");
final Properties properties = e.getProperties();
properties.setProperty(CxfRsHttpListener.CXF_JAXRS_PREFIX + CxfUtil.FEATURES, "my-feature");
final EjbModule module = new EjbModule(ejbJar);
module.setOpenejbJar(openejbJar);
final Resources resources = new Resources();
final Service feature = new Service("my-feature", null);
feature.setClassName(MyFeature.class.getName());
resources.getService().add(feature);
module.initResources(resources);
return module;
}
use of org.apache.openejb.config.sys.Service in project tomee by apache.
the class ConfigurationFactory method getOpenEjbConfiguration.
public OpenEjbConfiguration getOpenEjbConfiguration(final Openejb providedConf) throws OpenEJBException {
if (sys != null) {
return sys;
}
if (providedConf != null) {
openejb = providedConf;
} else if (configLocation != null) {
openejb = JaxbOpenejb.readConfig(configLocation);
} else {
openejb = JaxbOpenejb.createOpenejb();
}
for (final SystemProperty sp : openejb.getSystemProperties()) {
final String name = sp.getName();
final String value = sp.getValue();
SystemInstance.get().setProperty(name, value);
JavaSecurityManagers.setSystemProperty(name, value);
}
loadPropertiesDeclaredConfiguration(openejb);
sys = new OpenEjbConfiguration();
sys.containerSystem = new ContainerSystemInfo();
sys.facilities = new FacilitiesInfo();
// listener + some config can be defined as service
for (final Service service : openejb.getServices()) {
final ServiceInfo info = configureService(service, ServiceInfo.class);
sys.facilities.services.add(info);
}
for (final JndiProvider provider : openejb.getJndiProvider()) {
final JndiContextInfo info = configureService(provider, JndiContextInfo.class);
sys.facilities.remoteJndiContexts.add(info);
}
sys.facilities.securityService = configureService(openejb.getSecurityService(), SecurityServiceInfo.class);
sys.facilities.transactionService = configureService(openejb.getTransactionManager(), TransactionServiceInfo.class);
List<ResourceInfo> resources = new ArrayList<>();
for (final Resource resource : openejb.getResource()) {
final ResourceInfo resourceInfo = configureService(resource, ResourceInfo.class);
resources.add(resourceInfo);
}
resources = sort(resources, null);
sys.facilities.resources.addAll(resources);
if (openejb.getProxyFactory() != null) {
sys.facilities.intraVmServer = configureService(openejb.getProxyFactory(), ProxyFactoryInfo.class);
}
for (final Container declaration : openejb.getContainer()) {
final ContainerInfo info = createContainerInfo(declaration);
sys.containerSystem.containers.add(info);
}
final List<File> declaredApps = getDeclaredApps();
for (final File jarFile : declaredApps) {
try {
final AppInfo appInfo = configureApplication(jarFile);
sys.containerSystem.applications.add(appInfo);
} catch (final OpenEJBException alreadyHandled) {
final DeploymentExceptionManager exceptionManager = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
if (exceptionManager != null) {
exceptionManager.pushDelpoymentException(alreadyHandled);
}
}
}
final boolean embedded = SystemInstance.get().hasProperty(EJBContainer.class.getName());
final Options options = SystemInstance.get().getOptions();
if (options.get("openejb.system.apps", false)) {
try {
final boolean extended = SystemApps.isExtended();
final AppInfo appInfo;
if (!extended) {
// do it manually, we know what we need and can skip a bunch of processing
appInfo = SystemAppInfo.preComputedInfo(this);
} else {
appInfo = configureApplication(new AppModule(SystemApps.getSystemModule()));
}
// they doesn't use CDI so no need to activate it
// 1) will be faster
// 2) will let embedded containers (tomee-embedded mainly) not be noised by it in our singleton service
appInfo.properties.put("openejb.cdi.activated", "false");
sys.containerSystem.applications.add(appInfo);
} catch (final OpenEJBException e) {
logger.error("Unable to load the system applications.", e);
}
} else if (options.get(DEPLOYMENTS_CLASSPATH_PROPERTY, !embedded)) {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ArrayList<File> jarFiles = getModulesFromClassPath(declaredApps, classLoader);
final String appId = "classpath.ear";
final boolean classpathAsEar = options.get(CLASSPATH_AS_EAR, true);
try {
if (classpathAsEar && !jarFiles.isEmpty()) {
final AppInfo appInfo = configureApplication(classLoader, appId, jarFiles);
sys.containerSystem.applications.add(appInfo);
} else {
for (final File jarFile : jarFiles) {
final AppInfo appInfo = configureApplication(jarFile);
sys.containerSystem.applications.add(appInfo);
}
}
if (jarFiles.size() == 0) {
logger.warning("config.noModulesFoundToDeploy");
}
} catch (final OpenEJBException alreadyHandled) {
logger.debug("config.alreadyHandled");
}
}
for (final Deployments deployments : openejb.getDeployments()) {
if (deployments.isAutoDeploy()) {
if (deployments.getDir() != null) {
sys.containerSystem.autoDeploy.add(deployments.getDir());
}
}
}
final OpenEjbConfiguration finished = sys;
sys = null;
openejb = null;
return finished;
}
use of org.apache.openejb.config.sys.Service in project tomee by apache.
the class FeatureTest method app.
@Module
public EjbModule app() {
final EjbJar jar = new EjbJar();
jar.addEnterpriseBean(new SingletonBean(AuthenticatorServiceBean.class).localBean());
final OpenejbJar openejbJar = new OpenejbJar();
openejbJar.addEjbDeployment(new EjbDeployment(jar.getEnterpriseBeans()[0]));
final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
properties.setProperty(CxfService.OPENEJB_JAXWS_CXF_FEATURES, MyFeature.class.getName());
properties.setProperty("cxf.jaxws.features", "my-feature");
properties.setProperty("cxf.jaxws.properties", "my-props");
final EjbModule module = new EjbModule(jar);
module.setOpenejbJar(openejbJar);
final Resources resources = new Resources();
final Service service = new Service("my-feature", null, null, null);
service.setClassName(MyFeature.class.getName());
resources.add(service);
final Service myProps = new Service("my-props", null, null, null);
myProps.setClassName(Properties.class.getName());
myProps.getProperties().setProperty("faultStackTraceEnabled", "true");
resources.add(myProps);
module.initResources(resources);
return module;
}
Aggregations