Search in sources :

Example 1 with RemoteViewInjectionSource

use of org.jboss.as.ejb3.remote.RemoteViewInjectionSource in project wildfly by wildfly.

the class EjbJndiBindingsDeploymentUnitProcessor method registerRemoteBinding.

private void registerRemoteBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName) {
    final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
    final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>();
    moduleDescription.getBindingConfigurations().add(new BindingConfiguration(jndiName, new RemoteViewInjectionSource(null, moduleDescription.getEarApplicationName(), moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), viewDescription.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient)));
    componentDescription.getConfigurators().add(new ComponentConfigurator() {

        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader()));
        }
    });
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) InjectedValue(org.jboss.msc.value.InjectedValue) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) RemoteViewInjectionSource(org.jboss.as.ejb3.remote.RemoteViewInjectionSource) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration)

Example 2 with RemoteViewInjectionSource

use of org.jboss.as.ejb3.remote.RemoteViewInjectionSource in project wildfly by wildfly.

the class EjbJndiBindingsDeploymentUnitProcessor method registerControlPointBinding.

private void registerControlPointBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName, final DeploymentUnit deploymentUnit) {
    final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
    final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>();
    final InjectedValue<ControlPoint> controlPointInjectedValue = new InjectedValue<>();
    final RemoteViewInjectionSource delegate = new RemoteViewInjectionSource(null, moduleDescription.getEarApplicationName(), moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), viewDescription.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient);
    final ServiceName depName = ControlPointService.serviceName(deploymentUnit.getParent() == null ? deploymentUnit.getName() : deploymentUnit.getParent().getName(), EJBComponentSuspendDeploymentUnitProcessor.ENTRY_POINT_NAME + deploymentUnit.getName() + "." + componentDescription.getComponentName());
    componentDescription.getConfigurators().add((context, description, configuration) -> {
        viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader()));
        configuration.getCreateDependencies().add((serviceBuilder, service) -> serviceBuilder.addDependency(depName, ControlPoint.class, controlPointInjectedValue));
    });
    //we need to wrap the injection source to allow graceful shutdown to function, although this is not ideal
    //as it will also reject local lookups as well, although in general local code should never be looking up the
    //exported bindings
    //the other option would be to reject it at the remote naming service level, however then we loose the per-deployment granularity
    final InjectionSource is = new InjectionSource() {

        @Override
        public void getResourceValue(ResolutionContext resolutionContext, ServiceBuilder<?> serviceBuilder, DeploymentPhaseContext phaseContext, Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
            final InjectedValue<ManagedReferenceFactory> delegateInjection = new InjectedValue<>();
            delegate.getResourceValue(resolutionContext, serviceBuilder, phaseContext, delegateInjection);
            injector.inject(new ManagedReferenceFactory() {

                @Override
                public ManagedReference getReference() {
                    ControlPoint cp = controlPointInjectedValue.getValue();
                    try {
                        RunResult res = cp.beginRequest();
                        if (res != RunResult.RUN) {
                            throw EjbLogger.ROOT_LOGGER.containerSuspended();
                        }
                        try {
                            return delegateInjection.getValue().getReference();
                        } finally {
                            cp.requestComplete();
                        }
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            });
        }
    };
    moduleDescription.getBindingConfigurations().add(new BindingConfiguration(jndiName, is));
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) RemoteViewInjectionSource(org.jboss.as.ejb3.remote.RemoteViewInjectionSource) ControlPoint(org.wildfly.extension.requestcontroller.ControlPoint) ManagedReference(org.jboss.as.naming.ManagedReference) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) InjectionSource(org.jboss.as.ee.component.InjectionSource) RemoteViewInjectionSource(org.jboss.as.ejb3.remote.RemoteViewInjectionSource) Injector(org.jboss.msc.inject.Injector) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) RunResult(org.wildfly.extension.requestcontroller.RunResult) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration)

Example 3 with RemoteViewInjectionSource

use of org.jboss.as.ejb3.remote.RemoteViewInjectionSource in project wildfly by wildfly.

the class EJBViewDescription method createInjectionSource.

@Override
protected InjectionSource createInjectionSource(final ServiceName serviceName, Value<ClassLoader> viewClassLoader, boolean appclient) {
    if (methodIntf != MethodIntf.REMOTE && methodIntf != MethodIntf.HOME) {
        return super.createInjectionSource(serviceName, viewClassLoader, appclient);
    } else {
        final EJBComponentDescription componentDescription = getComponentDescription();
        final EEModuleDescription desc = componentDescription.getModuleDescription();
        final String earApplicationName = desc.getEarApplicationName();
        return new RemoteViewInjectionSource(serviceName, earApplicationName, desc.getModuleName(), desc.getDistinctName(), componentDescription.getComponentName(), getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) RemoteViewInjectionSource(org.jboss.as.ejb3.remote.RemoteViewInjectionSource)

Aggregations

EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)3 RemoteViewInjectionSource (org.jboss.as.ejb3.remote.RemoteViewInjectionSource)3 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)2 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 InjectedValue (org.jboss.msc.value.InjectedValue)2 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)1 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 InjectionSource (org.jboss.as.ee.component.InjectionSource)1 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)1 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)1 ManagedReference (org.jboss.as.naming.ManagedReference)1 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)1 Injector (org.jboss.msc.inject.Injector)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceName (org.jboss.msc.service.ServiceName)1 ControlPoint (org.wildfly.extension.requestcontroller.ControlPoint)1 RunResult (org.wildfly.extension.requestcontroller.RunResult)1