Search in sources :

Example 1 with HessianRegistry

use of org.apache.openejb.server.hessian.HessianRegistry in project tomee by apache.

the class HessianExtension method shutdown.

protected void shutdown(@Observes final BeforeShutdown unused) {
    final HessianService service = SystemInstance.get().getComponent(HessianService.class);
    if (service == null) {
        return;
    }
    final HessianRegistry registry = service.getRegistry();
    for (final DeployedEndpoint pair : deployed) {
        registry.undeploy(service.getVirtualHost(), pair.app, pair.name);
        LOGGER.info("Undeployed CDI hessian service " + pair.name);
    }
    deployed.clear();
}
Also used : HessianRegistry(org.apache.openejb.server.hessian.HessianRegistry) HessianService(org.apache.openejb.server.hessian.HessianService)

Example 2 with HessianRegistry

use of org.apache.openejb.server.hessian.HessianRegistry in project tomee by apache.

the class HessianExtension method deploy.

protected void deploy(@Observes final AfterDeploymentValidation afterDeploymentValidation, final BeanManager bm) {
    final HessianService service = SystemInstance.get().getComponent(HessianService.class);
    if (service == null) {
        LOGGER.severe("HessianService not yet started, no hessian CDI webservices will be deployed");
        return;
    }
    final HessianRegistry registry = service.getRegistry();
    final String appName = findAppName();
    for (final Deployment deployment : toDeploy) {
        final Hessian hessian = deployment.itf.getAnnotation(Hessian.class);
        final HessianServer server;
        try {
            server = new HessianServer(deployment.bean.getBeanClass().getClassLoader());
        } catch (final HessianServer.HessianIsMissingException e) {
            LOGGER.info("Hessian is not available so openejb-hessian will not deploy any service");
            break;
        }
        try {
            if (hessian != null && hessian.serializerFactory() != Object.class && !hessian.serializerFactory().isInstance(server.getSerializerFactory())) {
                server.serializerFactory(hessian.serializerFactory().newInstance());
            }
        } catch (final Exception e) {
            throw new OpenEJBRuntimeException(e);
        }
        if (hessian != null) {
            server.sendCollectionType(hessian.sendCollectionType());
        }
        if (Dependent.class.equals(deployment.bean.getScope())) {
            LOGGER.warning("@Dependent can lead to memory leaks ATM");
        }
        server.createSkeleton(bm.getReference(deployment.bean, deployment.itf, null), deployment.itf);
        final String name = getName(deployment.path, deployment.itf);
        try {
            LOGGER.info("Hessian(url=" + registry.deploy(deployment.itf.getClassLoader(), server, service.getVirtualHost(), appName, service.getAuthMethod(), service.getTransportGuarantee(), service.getRealmName(), name) + ", interface=" + name + ")");
            deployed.add(new DeployedEndpoint(appName, name));
        } catch (final URISyntaxException e) {
            throw new OpenEJBRuntimeException(e);
        }
    }
    toDeploy.clear();
}
Also used : OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) HessianRegistry(org.apache.openejb.server.hessian.HessianRegistry) HessianService(org.apache.openejb.server.hessian.HessianService) URISyntaxException(java.net.URISyntaxException) Hessian(org.apache.openejb.cdi.api.Hessian) HessianServer(org.apache.openejb.server.hessian.HessianServer) URISyntaxException(java.net.URISyntaxException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException)

Aggregations

HessianRegistry (org.apache.openejb.server.hessian.HessianRegistry)2 HessianService (org.apache.openejb.server.hessian.HessianService)2 URISyntaxException (java.net.URISyntaxException)1 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)1 Hessian (org.apache.openejb.cdi.api.Hessian)1 HessianServer (org.apache.openejb.server.hessian.HessianServer)1