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;
}
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);
}
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);
}
}
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();
}
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);
}
}
}
Aggregations