if (component instanceof EJBComponentDescription) { final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) component; componentStartServices.add(component.getStartServiceName()); injectedValues.put(component.getCreateServiceName(), componentInjectedValue); final Map<String, InjectedValue<ComponentView>> remoteViews = new HashMap<String, InjectedValue<ComponentView>>(); final Map<String, InjectedValue<ComponentView>> localViews = new HashMap<String, InjectedValue<ComponentView>>(); remoteViews.put(view.getViewClassName(), componentViewInjectedValue); } else { localViews.put(view.getViewClassName(), componentViewInjectedValue); injectedValues.put(view.getServiceName(), componentViewInjectedValue); final StartupCountdown countdown = deploymentUnit.getAttachment(Attachments.STARTUP_COUNTDOWN); final ModuleDeployment deployment = new ModuleDeployment(identifier, deploymentInformationMap); ServiceName moduleDeploymentService = deploymentUnit.getServiceName().append(ModuleDeployment.SERVICE_NAME); final ServiceBuilder<ModuleDeployment> builder = phaseContext.getServiceTarget().addService(moduleDeploymentService, deployment); for (Map.Entry<ServiceName, InjectedValue<?>> entry : injectedValues.entrySet()) { builder.addDependency(entry.getKey(), Object.class, (InjectedValue<Object>) entry.getValue()); final ServiceBuilder<Void> startBuilder = phaseContext.getServiceTarget().addService(deploymentUnit.getServiceName().append(ModuleDeployment.START_SERVICE_NAME), deploymentStart); for (final ServiceName componentStartService : componentStartServices) { startBuilder.requires(componentStartService);
@Override protected void addCurrentInvocationContextFactory(ViewDescription view) { view.getConfigurators().add(new ViewConfigurator() { @Override public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException { configuration.addViewInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.View.INVOCATION_CONTEXT_INTERCEPTOR); } }); }
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEResourceReferenceProcessorRegistry registry = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY); final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); final PropertyReplacer replacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit); if(compositeIndex == null) { ViewDescription viewDescription = new ViewDescription(componentDescription, beanClassName); viewDescription.getConfigurators().addFirst(new ViewConfigurator() { public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { viewDescription.getBindingNames().addAll(Arrays.asList("java:module/" + beanName, "java:app/" + moduleDescription.getModuleName() + "/" + beanName)); componentDescription.getViews().add(viewDescription); moduleDescription.addComponent(componentDescription);
private void addViewSerializationInterceptor(final ViewDescription view) { view.setSerializable(true); view.setUseWriteReplace(true); view.getConfigurators().add(new ViewConfigurator() { @Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX); ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class); for (Method method : (Collection<Method>)classIndex.getMethods()) { configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE); } } }); }
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { boolean appclient = context.getDeploymentUnit().getAttachment(Attachments.EE_MODULE_DESCRIPTION).isAppClient(); // Create view bindings final List<BindingConfiguration> bindingConfigurations = configuration.getBindingConfigurations(); for (String bindingName : description.getBindingNames()) { bindingConfigurations.add(new BindingConfiguration(bindingName, description.createInjectionSource(description.getServiceName(), Values.immediateValue(componentConfiguration.getModuleClassLoader()), appclient))); } } }
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = context.getDeploymentUnit(); final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE); final ProxyMetadataSource proxyReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.PROXY_REFLECTION_INDEX); for (ViewDescription view : description.getViews()) { Class<?> viewClass; try { viewClass = module.getClassLoader().loadClass(view.getViewClassName()); } catch (ClassNotFoundException e) { throw EeLogger.ROOT_LOGGER.cannotLoadViewClass(e, view.getViewClassName(), configuration); proxyConfiguration.setProtectionDomain(viewClass.getProtectionDomain()); proxyConfiguration.setMetadataSource(proxyReflectionIndex); if (view.isSerializable()) { proxyConfiguration.addAdditionalInterface(Serializable.class); if (view.isUseWriteReplace()) { proxyConfiguration.addAdditionalInterface(WriteReplaceInterface.class); proxyConfiguration.setSuperClass(Object.class); proxyConfiguration.addAdditionalInterface(viewClass); viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration)); } else { proxyConfiguration.setSuperClass(viewClass); viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration)); for (final ViewConfigurator configurator : view.getConfigurators()) { configurator.configure(context, configuration, view, viewConfiguration);
final Map<String, List<InterceptorFactory>> userPreDestroyByInterceptorClass = new HashMap<String, List<InterceptorFactory>>(); instantiators.addFirst(new ManagedReferenceInterceptorFactory(factory, instanceKey)); destructors.addLast(new ManagedReferenceReleaseInterceptorFactory(instanceKey)); Class<?> viewClass; try { viewClass = module.getClassLoader().loadClass(view.getViewClassName()); } catch (ClassNotFoundException e) { throw MESSAGES.cannotLoadViewClass(e, view.getViewClassName(), configuration); proxyConfiguration.setProtectionDomain(viewClass.getProtectionDomain()); proxyConfiguration.setMetadataSource(proxyReflectionIndex); if (view.isSerializable()) { proxyConfiguration.addAdditionalInterface(Serializable.class); if (view.isUseWriteReplace()) { proxyConfiguration.addAdditionalInterface(WriteReplaceInterface.class); proxyConfiguration.setSuperClass(Object.class); proxyConfiguration.addAdditionalInterface(viewClass); viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration)); } else { proxyConfiguration.setSuperClass(viewClass); viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration)); for (final ViewConfigurator configurator : view.getConfigurators()) { configurator.configure(context, configuration, view, viewConfiguration);
static ServiceName registerView(final ComponentDescription componentDescription, final String componentClassName) { final ViewDescription pojoView = new ViewDescription(componentDescription, componentClassName); componentDescription.getViews().add(pojoView); pojoView.getConfigurators().add(new ViewConfigurator() { @Override public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException { // add WS POJO component instance associating interceptor configuration.addViewInterceptor(WSComponentInstanceAssociationInterceptor.FACTORY, InterceptorOrder.View.ASSOCIATING_INTERCEPTOR); } }); return pojoView.getServiceName(); }
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));
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())); } }); } private void registerControlPointBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName, final DeploymentUnit deploymentUnit) {
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final ClassReflectionIndex classIndex = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX).getClassIndex(configuration.getComponentClass()); final Constructor<?> ctor = classIndex.getConstructor(new String[0]); boolean noInterface = false; for(ViewDescription view : description.getViews()) { if(view.getViewClassName().equals(description.getComponentClassName())) { noInterface = true; } } EjbValidationsUtil.getBusinessMethods(configuration.getComponentClass()); EjbValidationsUtil.verifyEjbClassAndDefaultConstructor(ctor, configuration.getComponentClass().getEnclosingClass(), noInterface, description.getComponentName(), description.getComponentClassName(), configuration.getComponentClass().getModifiers()); EjbValidationsUtil.verifyEjbPublicMethodAreNotFinalNorStatic(configuration.getComponentClass().getDeclaredMethods(),description.getComponentClassName()); for ( Class<?> interfaceClass : configuration.getComponentClass().getInterfaces()) EjbValidationsUtil.verifyEjbPublicMethodAreNotFinalNorStatic(interfaceClass.getDeclaredMethods(), interfaceClass.getCanonicalName()); } }
final DeploymentUnit deploymentUnit = context.getDeploymentUnit(); final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentConfiguration.getComponentDescription(); final boolean isSecurityDomainKnown = ejbComponentDescription.isSecurityDomainKnown(); final String viewClassName = viewDescription.getViewClassName(); final EJBViewDescription ejbViewDescription = (EJBViewDescription) viewDescription; if ((! deploymentUnit.hasAttachment(SecurityAttachments.SECURITY_ENABLED)) && (! isSecurityDomainKnown)) { final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX); String contextID = deploymentUnit.getName(); if (deploymentUnit.getParent() != null) { contextID = deploymentUnit.getParent().getName() + "!" + contextID;
public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); final Set<ViewDescription> componentsForViewName = applicationDescription.getComponentsForViewName(typeName, deploymentRoot.getRoot()); final Iterator<ViewDescription> iterator = componentsForViewName.iterator(); if (!iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.componentNotFound(typeName); } final ViewDescription description = iterator.next(); if (iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.multipleComponentsFound(typeName); } //TODO: should ComponentView also be a managed reference factory? serviceBuilder.addDependency(description.getServiceName(), ComponentView.class, new ViewManagedReferenceFactory.Injector(injector)); }
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX); for (final Method method : configuration.getProxyFactory().getCachedMethods()) { configuration.addClientInterceptor(method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); } else if(method.getDeclaringClass() != Object.class && method.getDeclaringClass() != WriteReplaceInterface.class) { throw EjbLogger.ROOT_LOGGER.couldNotFindViewMethodOnEjb(method, description.getViewClassName(), componentConfiguration.getComponentName());
@Override protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentConfiguration) throws DeploymentUnitProcessingException { final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE); processTransactionAttributeAnnotation(applicationClasses, deploymentReflectionIndex, componentClass, null, componentConfiguration); processTransactionTimeoutAnnotation(applicationClasses, deploymentReflectionIndex, componentClass, null, componentConfiguration); for (ViewDescription view : componentConfiguration.getViews()) { try { final Class<?> viewClass = module.getClassLoader().loadClass(view.getViewClassName()); EJBViewDescription ejbView = (EJBViewDescription) view; processTransactionAttributeAnnotation(applicationClasses, deploymentReflectionIndex, viewClass, ejbView.getMethodIntf(), componentConfiguration); processTransactionTimeoutAnnotation(applicationClasses, deploymentReflectionIndex, viewClass, ejbView.getMethodIntf(), componentConfiguration); } catch (ClassNotFoundException e) { throw MESSAGES.failToLoadEjbViewClass(e); } } }
/** * Add a component to this application. * * @param description the component description * @param deploymentRoot */ public void addComponent(final ComponentDescription description, final VirtualFile deploymentRoot) { for (final ViewDescription viewDescription : description.getViews()) { List<ViewInformation> viewComponents = componentsByViewName.get(viewDescription.getViewClassName()); if (viewComponents == null) { viewComponents = new ArrayList<ViewInformation>(1); componentsByViewName.put(viewDescription.getViewClassName(), viewComponents); } viewComponents.add(new ViewInformation(viewDescription, deploymentRoot, description.getComponentName())); } List<Description> components = componentsByName.get(description.getComponentName()); if (components == null) { componentsByName.put(description.getComponentName(), components = new ArrayList<Description>(1)); } components.add(new Description(description, deploymentRoot)); }
protected ServiceName getProcessApplicationViewServiceName(ComponentDescription paComponent) { Set<ViewDescription> views = paComponent.getViews(); if(views == null || views.isEmpty()) { return null; } else { ViewDescription next = views.iterator().next(); return next.getServiceName(); } }
for (ViewDescription view : componentConfiguration.getComponentDescription().getViews()) { viewServices.put(view.getViewClassName(), view.getServiceName()); this.ejbLocalObject = ejbLocalObject == null ? null : ejbLocalObject.getServiceName(); this.applicationName = componentConfiguration.getApplicationName(); this.earApplicationName = componentConfiguration.getComponentDescription().getModuleDescription().getEarApplicationName(); this.moduleName = componentConfiguration.getModuleName(); this.distinctName = componentConfiguration.getComponentDescription().getModuleDescription().getDistinctName(); this.shutDownInterceptorFactory = ejbComponentDescription.getShutDownInterceptorFactory(); this.securityRequired = ejbComponentDescription.isSecurityRequired();
@Override // TODO: what to do in JNDI if multiple views are available for no interface view ? public ServiceName getServiceName() { return super.getServiceName().append(methodIntf.toString()); }
final String viewClassName = view.getViewClassName(); localInterfaces.add(new BusinessInterfaceDescriptorImpl<Object>(beanDeploymentArchive, viewClassName)); } else if (getMethodIntf(view) == MethodIntf.REMOTE) { remoteInterfaces.add(new BusinessInterfaceDescriptorImpl<Object>(beanDeploymentArchive, view.getViewClassName())); viewServicesMap.put(loader.classForName(view.getViewClassName()), view.getServiceName());