Search in sources :

Example 41 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class AccessTimeoutHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    AccessTimeout timeout = (AccessTimeout) ainfo.getAnnotation();
    for (EjbContext ejbContext : ejbContexts) {
        if (ejbContext.getDescriptor() instanceof EjbSessionDescriptor) {
            EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
            if (sessionDesc.isStateless()) {
                continue;
            }
            if (ElementType.TYPE.equals(ainfo.getElementType())) {
                // Delay processing Class-level default until after methods are processed
                ejbContext.addPostProcessInfo(ainfo, this);
            } else {
                Method annMethod = (Method) ainfo.getAnnotatedElement();
                // are overridden and applies the correct .xml overriding semantics.
                if (!matchesExistingAccessTimeoutMethod(annMethod, sessionDesc)) {
                    MethodDescriptor newMethodDesc = new MethodDescriptor(annMethod);
                    sessionDesc.addAccessTimeoutMethod(newMethodDesc, timeout.value(), timeout.unit());
                }
            }
        }
    }
    return getDefaultProcessedResult();
}
Also used : AccessTimeout(javax.ejb.AccessTimeout) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 42 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class AfterCompletionHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext ejbContext : ejbContexts) {
        EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
        Method annMethod = (Method) ainfo.getAnnotatedElement();
        checkValid(annMethod);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Setting AfterCompletion method " + annMethod);
        }
        ejbDesc.setAfterCompletionMethodIfNotSet(new MethodDescriptor(annMethod));
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 43 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class PersistenceDescriptor method setQueryFor.

public void setQueryFor(Method method, QueryDescriptor query) {
    // Use our own method equality check. This prevents problems
    // when a different classloader was used to load the input
    // method.  Also note that two methods with the same name and
    // signature on *different* interfaces are considered EQUAL.
    // This matches the spec requirement that the same finder
    // method defined on the LocalHome and RemoteHome has only
    // ONE query-method declaration in the deployment descriptor.
    // 
    MethodDescriptor md = new MethodDescriptor(method, "");
    setQueryFor(md, query);
}
Also used : MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 44 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class BaseAuthConfig method isMatchingMSD.

private static boolean isMatchingMSD(MethodDescriptor targetMD, MessageSecurityDescriptor mSD) {
    List<MessageDescriptor> messageDescriptors = mSD.getMessageDescriptors();
    if (messageDescriptors.isEmpty()) {
        // element, and the deployment will be allowed to succeed.
        return true;
    }
    for (int i = 0; i < messageDescriptors.size(); i++) {
        MessageDescriptor nextMD = (MessageDescriptor) messageDescriptors.get(i);
        MethodDescriptor mD = nextMD.getMethodDescriptor();
        String opName = nextMD.getOperationName();
        if (opName == null && (mD == null || mD.implies(targetMD))) {
            return true;
        }
    }
    return false;
}
Also used : MessageDescriptor(com.sun.enterprise.deployment.runtime.common.MessageDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 45 with MethodDescriptor

use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.

the class BaseAuthConfig method getContextForMethod.

/*
     * When method argument is null, returns the default AC if there is one, or the onePolicy shared by
     * all methods if there is one, or throws an error. method is called with null argument when the
     * method cannot be determined (e.g. when the message is encrypted)
     */
private Object getContextForMethod(Method m) {
    Object rvalue = null;
    synchronized (contextLock) {
        if (defaultContext_ != null) {
            rvalue = defaultContext_;
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "WSS: ForMethod returning default_context: {0}", rvalue);
            }
            return rvalue;
        }
    }
    if (m != null) {
        int match = -1;
        MethodDescriptor targetMD = new MethodDescriptor(m);
        for (int i = 0; i < messageSecurityDescriptors_.size(); i++) {
            if (isMatchingMSD(targetMD, (MessageSecurityDescriptor) messageSecurityDescriptors_.get(i))) {
                if (match < 0) {
                    match = i;
                } else if (!policiesAreEqual((MessageSecurityDescriptor) messageSecurityDescriptors_.get(match), (MessageSecurityDescriptor) messageSecurityDescriptors_.get(i))) {
                    // set to unprotected because of conflicting policies
                    rvalue = explicitNull;
                    match = -1;
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "WSS: ForMethod detected conflicting policies: {0}.{1}", new Object[] { match, i });
                    }
                    break;
                }
            }
        }
        if (match >= 0) {
            rvalue = contexts_.get(match);
            if (rvalue == null) {
                rvalue = explicitNull;
            }
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "WSS: ForMethod returning matched context: {0}", rvalue);
            }
        }
    } else if (onePolicy_ && contexts_.size() > 0) {
        // ISSUE: since the method is undefined we will not be
        // able to tell if the defined policy covers this method.
        // We will be optimistic and try the policy, because
        // the server will reject the call if the method is not
        // covered by the policy.
        // If the policy is not null, there remains a problem at the
        // client on the response side, as it is possible that the
        // client will enforce the wrong policy on the response.
        // For this reason, messages in sun-application-client.xml
        // should be keyed by operation-name.
        rvalue = contexts_.get(0);
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "WSS: ForMethod resorting to first context: {0}", rvalue);
        }
    } else {
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("WSS: Unable to select policy for SOAP Message");
        }
        throw new RuntimeException("Unable to select policy for Message");
    }
    return rvalue;
}
Also used : MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Aggregations

MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)108 Method (java.lang.reflect.Method)42 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)26 Iterator (java.util.Iterator)21 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)17 Enumeration (java.util.Enumeration)14 Set (java.util.Set)14 ArrayList (java.util.ArrayList)13 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)11 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)11 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)10 Result (com.sun.enterprise.tools.verifier.Result)9 MethodPermission (com.sun.enterprise.deployment.MethodPermission)8 MethodNode (com.sun.enterprise.deployment.node.MethodNode)7 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)7 Node (org.w3c.dom.Node)7 List (java.util.List)6 ScheduledTimerDescriptor (org.glassfish.ejb.deployment.descriptor.ScheduledTimerDescriptor)6 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)5 HashMap (java.util.HashMap)5