Example #1
0
 public ProcessApplicationStartService(ICollection <ServiceName> deploymentServiceNames, AnnotationInstance postDeployDescription, AnnotationInstance preUndeployDescription, Module paModule)
 {
     this.deploymentServiceNames = deploymentServiceNames;
     this.postDeployDescription  = postDeployDescription;
     this.preUndeployDescription = preUndeployDescription;
     this.paModule = paModule;
 }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected Class getPaClass(org.jboss.jandex.AnnotationInstance annotation) throws ClassNotFoundException
        protected internal virtual Type getPaClass(AnnotationInstance annotation)
        {
            string paClassName = ((MethodInfo)annotation.target()).declaringClass().name().ToString();
            Type   paClass     = paModule.ClassLoader.loadClass(paClassName);

            return(paClass);
        }
Example #3
0
        public AnnotationInstanceAttribute EnsureAnnotationAttributeInto(AnnotationInstance annotationInstance, string attributeName, string attributeValue)
        {
            AnnotationInstanceAttribute attr;

            attr = this.CreateNewEntity <FAMIX.AnnotationInstanceAttribute>(typeof(FAMIX.AnnotationInstanceAttribute).FullName);

            attr.annotationTypeAttribute = this.EnsureAnnotationTypeAttribute(annotationInstance.annotationType, attributeName);
            attr.value = attributeValue;
            return(attr);
        }
Example #4
0
        public const int PRIORITY = 0x0000;   // this can happen at the beginning of the phase

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void deploy(org.jboss.as.server.deployment.DeploymentPhaseContext phaseContext) throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
        public override void deploy(DeploymentPhaseContext phaseContext)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.server.deployment.DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
            DeploymentUnit deploymentUnit = phaseContext.DeploymentUnit;

            if (!ProcessApplicationAttachments.isProcessApplication(deploymentUnit))
            {
                return;
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.ee.component.ComponentDescription paComponent = getProcessApplicationComponent(deploymentUnit);
            ComponentDescription paComponent = getProcessApplicationComponent(deploymentUnit);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.msc.service.ServiceName paViewServiceName = getProcessApplicationViewServiceName(paComponent);
            ServiceName paViewServiceName = getProcessApplicationViewServiceName(paComponent);

            Module module = deploymentUnit.getAttachment(Attachments.MODULE);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String moduleName = module.getIdentifier().toString();
            string moduleName = module.Identifier.ToString();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.msc.service.ServiceName paStartServiceName = org.camunda.bpm.container.impl.jboss.service.ServiceNames.forProcessApplicationStartService(moduleName);
            ServiceName paStartServiceName = ServiceNames.forProcessApplicationStartService(moduleName);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.msc.service.ServiceName paStopServiceName = org.camunda.bpm.container.impl.jboss.service.ServiceNames.forProcessApplicationStopService(moduleName);
            ServiceName paStopServiceName = ServiceNames.forProcessApplicationStopService(moduleName);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.msc.service.ServiceName noViewStartService = org.camunda.bpm.container.impl.jboss.service.ServiceNames.forNoViewProcessApplicationStartService(moduleName);
            ServiceName noViewStartService = ServiceNames.forNoViewProcessApplicationStartService(moduleName);

            IList <ServiceName> deploymentServiceNames = new List <ServiceName>();

            ProcessApplicationStopService paStopService = new ProcessApplicationStopService();
            ServiceBuilder <ProcessApplicationStopService> stopServiceBuilder = phaseContext.ServiceTarget.addService(paStopServiceName, paStopService).addDependency(phaseContext.PhaseServiceName).addDependency(ServiceNames.forBpmPlatformPlugins(), typeof(BpmPlatformPlugins), paStopService.PlatformPluginsInjector).setInitialMode(ServiceController.Mode.ACTIVE);

            if (paViewServiceName != null)
            {
                stopServiceBuilder.addDependency(paViewServiceName, typeof(ComponentView), paStopService.PaComponentViewInjector);
            }
            else
            {
                stopServiceBuilder.addDependency(noViewStartService, typeof(ProcessApplicationInterface), paStopService.NoViewProcessApplication);
            }

            stopServiceBuilder.install();

            // deploy all process archives
            IList <ProcessesXmlWrapper> processesXmlWrappers = ProcessApplicationAttachments.getProcessesXmls(deploymentUnit);

            foreach (ProcessesXmlWrapper processesXmlWrapper in processesXmlWrappers)
            {
                ProcessesXml processesXml = processesXmlWrapper.ProcessesXml;
                foreach (ProcessArchiveXml processArchive in processesXml.ProcessArchives)
                {
                    ServiceName processEngineServiceName = getProcessEngineServiceName(processArchive);
                    IDictionary <string, sbyte[]> deploymentResources = getDeploymentResources(processArchive, deploymentUnit, processesXmlWrapper.ProcessesXmlFile);

                    // add the deployment service for each process archive we deploy.
                    ProcessApplicationDeploymentService deploymentService = new ProcessApplicationDeploymentService(deploymentResources, processArchive, module);
                    string processArachiveName = processArchive.Name;
                    if (string.ReferenceEquals(processArachiveName, null))
                    {
                        // use random name for deployment service if name is null (we cannot ask the process application yet since the component might not be up.
                        processArachiveName = System.Guid.randomUUID().ToString();
                    }
                    ServiceName deploymentServiceName = ServiceNames.forProcessApplicationDeploymentService(deploymentUnit.Name, processArachiveName);
                    ServiceBuilder <ProcessApplicationDeploymentService> serviceBuilder = phaseContext.ServiceTarget.addService(deploymentServiceName, deploymentService).addDependency(phaseContext.PhaseServiceName).addDependency(paStopServiceName).addDependency(processEngineServiceName, typeof(ProcessEngine), deploymentService.ProcessEngineInjector).setInitialMode(ServiceController.Mode.ACTIVE);

                    if (paViewServiceName != null)
                    {
                        // add a dependency on the component start service to make sure we are started after the pa-component (Singleton EJB) has started
                        serviceBuilder.addDependency(paComponent.StartServiceName);
                        serviceBuilder.addDependency(paViewServiceName, typeof(ComponentView), deploymentService.PaComponentViewInjector);
                    }
                    else
                    {
                        serviceBuilder.addDependency(noViewStartService, typeof(ProcessApplicationInterface), deploymentService.NoViewProcessApplication);
                    }

                    JBossCompatibilityExtension.addServerExecutorDependency(serviceBuilder, deploymentService.ExecutorInjector, false);

                    serviceBuilder.install();

                    deploymentServiceNames.Add(deploymentServiceName);
                }
            }

            AnnotationInstance postDeploy  = ProcessApplicationAttachments.getPostDeployDescription(deploymentUnit);
            AnnotationInstance preUndeploy = ProcessApplicationAttachments.getPreUndeployDescription(deploymentUnit);

            // register the managed process application start service
            ProcessApplicationStartService paStartService = new ProcessApplicationStartService(deploymentServiceNames, postDeploy, preUndeploy, module);
            ServiceBuilder <ProcessApplicationStartService> serviceBuilder = phaseContext.ServiceTarget.addService(paStartServiceName, paStartService).addDependency(phaseContext.PhaseServiceName).addDependency(ServiceNames.forDefaultProcessEngine(), typeof(ProcessEngine), paStartService.DefaultProcessEngineInjector).addDependency(ServiceNames.forBpmPlatformPlugins(), typeof(BpmPlatformPlugins), paStartService.PlatformPluginsInjector).addDependencies(deploymentServiceNames).setInitialMode(ServiceController.Mode.ACTIVE);

            if (paViewServiceName != null)
            {
                serviceBuilder.addDependency(paViewServiceName, typeof(ComponentView), paStartService.PaComponentViewInjector);
            }
            else
            {
                serviceBuilder.addDependency(noViewStartService, typeof(ProcessApplicationInterface), paStartService.NoViewProcessApplication);
            }

            serviceBuilder.install();
        }
Example #5
0
        /// <summary>
        /// Detect an existing <seealso cref="ProcessApplication"/> component.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.jboss.as.ee.component.ComponentDescription detectExistingComponent(org.jboss.as.server.deployment.DeploymentUnit deploymentUnit) throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
        protected internal virtual ComponentDescription detectExistingComponent(DeploymentUnit deploymentUnit)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.ee.component.EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
            EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.ee.component.EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
            EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.server.deployment.annotation.CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
            CompositeIndex compositeIndex = deploymentUnit.getAttachment([email protected]_ANNOTATION_INDEX);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.web.common.WarMetaData warMetaData = deploymentUnit.getAttachment(org.jboss.as.web.common.WarMetaData.ATTACHMENT_KEY);
            WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);

            // extract deployment metadata
            IList <AnnotationInstance> processApplicationAnnotations = null;
            IList <AnnotationInstance> postDeployAnnnotations        = null;
            IList <AnnotationInstance> preUndeployAnnnotations       = null;
            ISet <ClassInfo>           servletProcessApplications    = null;

            if (compositeIndex != null)
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                processApplicationAnnotations = compositeIndex.getAnnotations(DotName.createSimple(typeof(ProcessApplication).FullName));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                postDeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(typeof(PostDeploy).FullName));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                preUndeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(typeof(PreUndeploy).FullName));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                servletProcessApplications = compositeIndex.getAllKnownSubclasses(DotName.createSimple(typeof(ServletProcessApplication).FullName));
            }
            else
            {
                return(null);
            }

            if (processApplicationAnnotations.Count == 0)
            {
                // no pa found, this is not a process application deployment.
                return(null);
            }
            else if (processApplicationAnnotations.Count > 1)
            {
                // found multiple PAs -> unsupported.
                throw new DeploymentUnitProcessingException("Detected multiple classes annotated with @" + typeof(ProcessApplication).Name + ". A deployment must only provide a single @" + typeof(ProcessApplication).Name + " class.");
            }
            else
            {
                // found single PA

                AnnotationInstance annotationInstance = processApplicationAnnotations[0];
                ClassInfo          paClassInfo        = (ClassInfo)annotationInstance.target();
                string             paClassName        = paClassInfo.name().ToString();

                ComponentDescription paComponent = null;

                // it can either be a Servlet Process Application or a Singleton Session Bean Component or
                if (servletProcessApplications.Contains(paClassInfo))
                {
                    // Servlet Process Applications can only be deployed inside Web Applications
                    if (warMetaData == null)
                    {
                        throw new DeploymentUnitProcessingException("@ProcessApplication class is a ServletProcessApplication but deployment is not a Web Application.");
                    }

                    // check whether it's already a servlet context listener:
                    JBossWebMetaData         mergedJBossWebMetaData = warMetaData.MergedJBossWebMetaData;
                    IList <ListenerMetaData> listeners = mergedJBossWebMetaData.Listeners;
                    if (listeners == null)
                    {
                        listeners = new List <ListenerMetaData>();
                        mergedJBossWebMetaData.Listeners = listeners;
                    }

                    bool isListener = false;
                    foreach (ListenerMetaData listenerMetaData in listeners)
                    {
                        if (listenerMetaData.ListenerClass.Equals(paClassInfo.name().ToString()))
                        {
                            isListener = true;
                        }
                    }

                    if (!isListener)
                    {
                        // register as Servlet Context Listener
                        ListenerMetaData listener = new ListenerMetaData();
                        listener.ListenerClass = paClassName;
                        listeners.Add(listener);

                        // synthesize WebComponent
                        WebComponentDescription paWebComponent = new WebComponentDescription(paClassName, paClassName, eeModuleDescription, deploymentUnit.ServiceName, eeApplicationClasses);

                        eeModuleDescription.addComponent(paWebComponent);

                        deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, paWebComponent.StartServiceName);

                        paComponent = paWebComponent;
                    }
                    else
                    {
                        // lookup the existing component
                        paComponent = eeModuleDescription.getComponentsByClassName(paClassName).get(0);
                    }

                    // deactivate sci
                }
                else
                {
                    // if its not a ServletProcessApplication it must be a session bean component

                    IList <ComponentDescription> componentsByClassName = eeModuleDescription.getComponentsByClassName(paClassName);

                    if (componentsByClassName.Count > 0 && (componentsByClassName[0] is SessionBeanComponentDescription))
                    {
                        paComponent = componentsByClassName[0];
                    }
                    else
                    {
                        throw new DeploymentUnitProcessingException("Class " + paClassName + " is annotated with @" + typeof(ProcessApplication).Name + " but is neither a ServletProcessApplication nor an EJB Session Bean Component.");
                    }
                }

                // attach additional metadata to the deployment unit

                if (postDeployAnnnotations.Count > 0)
                {
                    if (postDeployAnnnotations.Count == 1)
                    {
                        ProcessApplicationAttachments.attachPostDeployDescription(deploymentUnit, postDeployAnnnotations[0]);
                    }
                    else
                    {
                        throw new DeploymentUnitProcessingException("There can only be a single method annotated with @PostDeploy. Found [" + postDeployAnnnotations + "]");
                    }
                }

                if (preUndeployAnnnotations.Count > 0)
                {
                    if (preUndeployAnnnotations.Count == 1)
                    {
                        ProcessApplicationAttachments.attachPreUndeployDescription(deploymentUnit, preUndeployAnnnotations[0]);
                    }
                    else
                    {
                        throw new DeploymentUnitProcessingException("There can only be a single method annotated with @PreUndeploy. Found [" + preUndeployAnnnotations + "]");
                    }
                }

                return(paComponent);
            }
        }
Example #6
0
 /// <summary>
 /// Attach the <seealso cref="AnnotationInstance"/>s for the PreUndeploy methods
 /// </summary>
 public static void attachPreUndeployDescription(DeploymentUnit deploymentUnit, AnnotationInstance annotation)
 {
     deploymentUnit.putAttachment(PRE_UNDEPLOY_METHOD, annotation);
 }