예제 #1
0
 bool IsDoTActive(OverTimeStateComponent targOtComp, DotName name)
 {
     foreach (DoT d in targOtComp.DotList)
     {
         if (d.Name == name && d.IsActive == true)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
        decimal TimeLeftOnDot(OverTimeStateComponent targOtComp, DotName name, decimal timer)
        {
            foreach (DoT d in targOtComp.DotList)
            {
                if (d.Name == name && d.IsActive == true)
                {
                    return(d.Duration - timer + d.Start);
                }
            }

            // If no buff was found
            throw new Exception("No dot found.");
        }
예제 #3
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);
            }
        }