Search in sources :

Example 1 with IASEjbCMPFinder

use of org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder in project Payara by payara.

the class MethodHelper method getFinder.

private IASEjbCMPFinder getFinder(Method method) {
    IASEjbCMPEntityDescriptor cmpDescriptor = (IASEjbCMPEntityDescriptor) getDescriptor();
    IASEjbCMPFinder finder = cmpDescriptor.getIASEjbCMPFinder(method);
    if (finder == null) {
        String methodSignature = cmpDescriptor.getName() + '.' + method.getName() + JavaClassWriterHelper.parenleft_ + JavaClassWriterHelper.getParameterTypesList(method) + JavaClassWriterHelper.parenright_;
        String msg = I18NHelper.getMessage(messages, "EXC_MissingCMP11Finder", // NOI18N
        methodSignature);
        throw new RuntimeException(msg);
    }
    return finder;
}
Also used : IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor) IASEjbCMPFinder(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder)

Example 2 with IASEjbCMPFinder

use of org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder in project Payara by payara.

the class CmpNode method writeDescriptor.

@Override
public Node writeDescriptor(Node parent, String nodeName, IASEjbCMPEntityDescriptor ejbDescriptor) {
    Node cmpNode = super.writeDescriptor(parent, nodeName, ejbDescriptor);
    appendTextChild(cmpNode, RuntimeTagNames.MAPPING_PROPERTIES, ejbDescriptor.getMappingProperties());
    Map finders = ejbDescriptor.getOneOneFinders();
    if (!finders.isEmpty()) {
        Node findersNode = appendChild(cmpNode, RuntimeTagNames.ONE_ONE_FINDERS);
        FinderNode fn = new FinderNode();
        for (Iterator finderIterator = finders.values().iterator(); finderIterator.hasNext(); ) {
            IASEjbCMPFinder aFinder = (IASEjbCMPFinder) finderIterator.next();
            fn.writeDescriptor(findersNode, RuntimeTagNames.FINDER, aFinder);
        }
    }
    // prefetch-disabled
    PrefetchDisabledDescriptor prefetchDisabledDesc = ejbDescriptor.getPrefetchDisabledDescriptor();
    if (prefetchDisabledDesc != null) {
        PrefetchDisabledNode prefetchDisabledNode = new PrefetchDisabledNode();
        prefetchDisabledNode.writeDescriptor(cmpNode, RuntimeTagNames.PREFETCH_DISABLED, prefetchDisabledDesc);
    }
    return cmpNode;
}
Also used : PrefetchDisabledDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.PrefetchDisabledDescriptor) Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) Iterator(java.util.Iterator) IASEjbCMPFinder(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder) Map(java.util.Map)

Example 3 with IASEjbCMPFinder

use of org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder in project Payara by payara.

the class IASEjbCMPEntityDescriptor method getOneOneFinders.

/**
 * Returns a Map which maps between a method signature and the
 * corresponding IASEjbCMPFinder instance. The key is the method
 * signature as a string and consists of methodName(type1, type2.....).
 */
public Map getOneOneFinders() {
    // the array arrOneOneFinders.
    if (!arrOneOneFinders.isEmpty()) {
        if (queryParser == null) {
            String msg = localStrings.getLocalString(// NOI18N
            "enterprise.deployment.error_missing_queryparser", // NOI18N
            "IASEjbCMPEntityDescriptor.getOneOneFinders");
            _logger.log(Level.WARNING, msg);
            throw new RuntimeException(msg);
        }
        // parse the query declaration parameter and store the query object
        for (Iterator i = arrOneOneFinders.iterator(); i.hasNext(); ) {
            IASEjbCMPFinder finder = (IASEjbCMPFinder) i.next();
            String key = generateKey(finder, queryParser);
            oneOneFinders.put(key, finder);
        }
        arrOneOneFinders.clear();
    }
    return oneOneFinders;
}
Also used : Iterator(java.util.Iterator) IASEjbCMPFinder(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder)

Example 4 with IASEjbCMPFinder

use of org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder in project Payara by payara.

the class ASEjbCMP method testFinders.

public void testFinders(Map finders, Result result) {
    try {
        Set keySet = finders.keySet();
        Iterator it = keySet.iterator();
        while (it.hasNext()) {
            Object obj = it.next();
            IASEjbCMPFinder finder = (IASEjbCMPFinder) finders.get(obj);
            // method-name
            String methodName = finder.getMethodName();
            if (methodName.length() == 0) {
                oneFailed = true;
                result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB finder] : method-name cannot be an empty string."));
            } else {
                result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-EJB finder] : method-name is {0}", new Object[] { methodName }));
            }
            // query-params
            String value = finder.getQueryParameterDeclaration();
            testQuery(value, result, "finder", "query-params");
            // query-filter
            value = finder.getQueryFilter();
            testQuery(value, result, "finder", "query-filter");
            // query-variables
            value = finder.getQueryVariables();
            testQuery(value, result, "finder", "query-variables");
            // query-ordering
            value = finder.getQueryOrdering();
            testQuery(value, result, "finder", "query-ordering");
        }
    } catch (Exception ex) {
        oneFailed = true;
        result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
    }
}
Also used : Set(java.util.Set) Iterator(java.util.Iterator) IASEjbCMPFinder(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder)

Aggregations

IASEjbCMPFinder (org.glassfish.ejb.deployment.descriptor.runtime.IASEjbCMPFinder)4 Iterator (java.util.Iterator)3 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 Map (java.util.Map)1 Set (java.util.Set)1 IASEjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor)1 PrefetchDisabledDescriptor (org.glassfish.ejb.deployment.descriptor.runtime.PrefetchDisabledDescriptor)1 Node (org.w3c.dom.Node)1