Search in sources :

Example 1 with RelationshipDescriptor

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

the class RelationshipsNode method writeDescriptor.

public Node writeDescriptor(Node parent, String nodeName, EjbBundleDescriptorImpl descriptor) {
    Node relationshipsNode = super.writeDescriptor(parent, nodeName, descriptor);
    appendTextChild(relationshipsNode, TagNames.DESCRIPTION, descriptor.getRelationshipsDescription());
    EjbRelationNode subNode = new EjbRelationNode();
    for (RelationshipDescriptor rd : descriptor.getRelationships()) {
        subNode.writeDescriptor(relationshipsNode, EjbTagNames.EJB_RELATION, rd);
    }
    return relationshipsNode;
}
Also used : Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor)

Example 2 with RelationshipDescriptor

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

the class EjbBundleTracerVisitor method accept.

@Override
public void accept(BundleDescriptor descriptor) {
    if (descriptor instanceof EjbBundleDescriptorImpl) {
        EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) descriptor;
        accept(ejbBundle);
        for (EjbDescriptor anEjb : ejbBundle.getEjbs()) {
            anEjb.visit(getSubDescriptorVisitor(anEjb));
        }
        if (ejbBundle.hasRelationships()) {
            for (RelationshipDescriptor rd : ejbBundle.getRelationships()) {
                accept(rd);
            }
        }
        for (WebService ws : ejbBundle.getWebServices().getWebServices()) {
            accept(ws);
        }
    }
    super.accept(descriptor);
}
Also used : WebService(com.sun.enterprise.deployment.WebService) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 3 with RelationshipDescriptor

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

the class EjbBundleValidator method accept.

@Override
public void accept(BundleDescriptor descriptor) {
    this.bundleDescriptor = descriptor;
    this.application = descriptor.getApplication();
    if (descriptor instanceof EjbBundleDescriptorImpl) {
        EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) descriptor;
        accept(ejbBundle);
        for (EjbDescriptor anEjb : ejbBundle.getEjbs()) {
            anEjb.visit(getSubDescriptorVisitor(anEjb));
        }
        if (ejbBundle.hasRelationships()) {
            for (Iterator itr = ejbBundle.getRelationships().iterator(); itr.hasNext(); ) {
                RelationshipDescriptor rd = (RelationshipDescriptor) itr.next();
                accept(rd);
            }
        }
        for (WebService aWebService : ejbBundle.getWebServices().getWebServices()) {
            accept(aWebService);
        }
        // inject field.
        for (InjectionCapable injectable : ejbBundle.getInjectableResources(ejbBundle)) {
            accept(injectable);
        }
        super.accept(descriptor);
    } else {
        super.accept(descriptor);
    }
}
Also used : InjectionCapable(com.sun.enterprise.deployment.InjectionCapable) WebService(com.sun.enterprise.deployment.WebService) Iterator(java.util.Iterator) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) DummyEjbDescriptor(org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 4 with RelationshipDescriptor

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

the class EjbConversionHelper method getRealRelationRoleDescriptor.

private RelationRoleDescriptor getRealRelationRoleDescriptor(String ejbName, String cmrFieldName, boolean self) {
    ArrayList rels = (ArrayList) ejbRelMap.get(ejbName);
    for (int i = 0; i < rels.size(); i++) {
        RelationshipDescriptor rel = (RelationshipDescriptor) rels.get(i);
        RelationRoleDescriptor source = rel.getSource();
        RelationRoleDescriptor sink = rel.getSink();
        if (ejbName.equals(source.getOwner().getName()) && cmrFieldName.equals(source.getCMRField())) {
            return (self) ? source : sink;
        } else if (ejbName.equals(sink.getOwner().getName()) && cmrFieldName.equals(sink.getCMRField())) {
            return (self) ? sink : source;
        }
    }
    throw new IllegalArgumentException();
}
Also used : ArrayList(java.util.ArrayList) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) RelationRoleDescriptor(org.glassfish.ejb.deployment.descriptor.RelationRoleDescriptor)

Example 5 with RelationshipDescriptor

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

the class NameMapper method initGeneratedRelationshipMaps.

private void initGeneratedRelationshipMaps() {
    EjbBundleDescriptorImpl bundleDescriptor = getBundleDescriptor();
    Set relationships = bundleDescriptor.getRelationships();
    _generatedRelToInverseRelMap = new HashMap();
    _relToInverseGeneratedRelMap = new HashMap();
    // null check
    if (relationships != null) {
        Iterator iterator = relationships.iterator();
        List generatedRels = new ArrayList();
        int counter = 0;
        // gather list of generated cmr fields by examining source and sink
        while (iterator.hasNext()) {
            RelationshipDescriptor relationship = (RelationshipDescriptor) iterator.next();
            if (relationship.getSource().getCMRField() == null)
                generatedRels.add(relationship);
            if (relationship.getSink().getCMRField() == null)
                generatedRels.add(relationship);
        }
        // now update the maps to contain this info
        iterator = generatedRels.iterator();
        while (iterator.hasNext()) {
            RelationshipDescriptor relationship = (RelationshipDescriptor) iterator.next();
            RelationRoleDescriptor source = relationship.getSource();
            String sourceEjbName = source.getOwner().getName();
            String sourceCMRField = source.getCMRField();
            boolean sourceIsNull = (sourceCMRField == null);
            RelationRoleDescriptor sink = relationship.getSink();
            String sinkEjbName = sink.getOwner().getName();
            String ejbName = (sourceIsNull ? sourceEjbName : sinkEjbName);
            String otherEjbName = (sourceIsNull ? sinkEjbName : sourceEjbName);
            List ejbField = Arrays.asList(new String[] { otherEjbName, (sourceIsNull ? sink.getCMRField() : sourceCMRField) });
            PersistenceDescriptor pDescriptor = ((EjbCMPEntityDescriptor) bundleDescriptor.getEjbByName(ejbName)).getPersistenceDescriptor();
            List generatedField = null;
            String uniqueName = null;
            // with this name
            do {
                counter++;
                uniqueName = GENERATED_CMR_FIELD_PREFIX + counter;
            } while (hasField(pDescriptor, uniqueName));
            generatedField = Arrays.asList(new String[] { ejbName, uniqueName });
            _generatedRelToInverseRelMap.put(generatedField, ejbField);
            _relToInverseGeneratedRelMap.put(ejbField, generatedField);
        }
    }
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) RelationRoleDescriptor(org.glassfish.ejb.deployment.descriptor.RelationRoleDescriptor) PersistenceDescriptor(org.glassfish.ejb.deployment.descriptor.PersistenceDescriptor) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Aggregations

RelationshipDescriptor (org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor)7 Iterator (java.util.Iterator)4 RelationRoleDescriptor (org.glassfish.ejb.deployment.descriptor.RelationRoleDescriptor)4 ArrayList (java.util.ArrayList)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 WebService (com.sun.enterprise.deployment.WebService)2 Set (java.util.Set)2 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)2 InjectionCapable (com.sun.enterprise.deployment.InjectionCapable)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 Result (com.sun.enterprise.tools.verifier.Result)1 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)1 HashMap (java.util.HashMap)1 List (java.util.List)1 DummyEjbDescriptor (org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor)1 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)1 PersistenceDescriptor (org.glassfish.ejb.deployment.descriptor.PersistenceDescriptor)1 Node (org.w3c.dom.Node)1