use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor 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.EjbDescriptor in project Payara by payara.
the class EjbBundleValidator method handleOverloadedInterceptorMethodBindings.
private void handleOverloadedInterceptorMethodBindings(EjbBundleDescriptorImpl bundleDesc) {
List<InterceptorBindingDescriptor> origBindings = bundleDesc.getInterceptorBindings();
if (origBindings.isEmpty()) {
return;
}
ClassLoader cl = bundleDesc.getClassLoader();
List<InterceptorBindingDescriptor> newBindings = new LinkedList<InterceptorBindingDescriptor>();
for (InterceptorBindingDescriptor next : origBindings) {
if (next.getNeedsOverloadResolution()) {
MethodDescriptor overloadedMethodDesc = next.getBusinessMethod();
String methodName = overloadedMethodDesc.getName();
// For method-specific interceptors, there must be an ejb-name.
String ejbName = next.getEjbName();
EjbDescriptor ejbDesc = bundleDesc.getEjbByName(ejbName);
Class ejbClass = null;
try {
ejbClass = cl.loadClass(ejbDesc.getEjbClassName());
} catch (Exception e) {
RuntimeException re = new RuntimeException("Error loading ejb class " + ejbDesc.getEjbClassName());
re.initCause(e);
throw re;
}
boolean isMethod = false;
for (Method ejbClassMethod : ejbClass.getDeclaredMethods()) {
if (ejbClassMethod.getName().equals(methodName)) {
isMethod = true;
InterceptorBindingDescriptor newInterceptorBinding = new InterceptorBindingDescriptor();
MethodDescriptor newMethodDesc = new MethodDescriptor(ejbClassMethod, MethodDescriptor.EJB_BEAN);
newInterceptorBinding.setEjbName(ejbName);
newInterceptorBinding.setBusinessMethod(newMethodDesc);
for (String interceptorClass : next.getInterceptorClasses()) {
newInterceptorBinding.appendInterceptorClass(interceptorClass);
}
newInterceptorBinding.setIsTotalOrdering(next.getIsTotalOrdering());
newInterceptorBinding.setExcludeDefaultInterceptors(next.getExcludeDefaultInterceptors());
newInterceptorBinding.setExcludeClassInterceptors(next.getExcludeClassInterceptors());
newBindings.add(newInterceptorBinding);
}
}
// check if it's a constructor
if (!isMethod && methodName.equals(ejbClass.getSimpleName())) {
// Constructor - will resolve via implicit comparison
newBindings.add(next);
continue;
}
} else {
newBindings.add(next);
}
}
bundleDesc.setInterceptorBindings(newBindings);
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor 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.EjbDescriptor in project Payara by payara.
the class EjbContainerServicesImpl method isRemoved.
public boolean isRemoved(Object ejbRef) {
EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef);
if (localObjectImpl == null) {
throw new UnsupportedOperationException("Invalid ejb ref");
}
Container container = localObjectImpl.getContainer();
EjbDescriptor ejbDesc = container.getEjbDescriptor();
boolean isStatefulBean = false;
if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
isStatefulBean = sessionDesc.isStateful();
}
if (!isStatefulBean) {
// stateless/singleton references via 299 will fail until bug is fixed.
return false;
// TODO reenable this per SessionObjectReference.isRemoved SPI
// throw new UnsupportedOperationException("ejbRef for ejb " +
// ejbDesc.getName() + " is not a stateful bean ");
}
boolean removed = false;
try {
((BaseContainer) container).checkExists(localObjectImpl);
} catch (Exception e) {
removed = true;
}
return removed;
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class EjbContainerServicesImpl method remove.
public void remove(Object ejbRef) {
EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef);
if (localObjectImpl == null) {
throw new UnsupportedOperationException("Invalid ejb ref");
}
Container container = localObjectImpl.getContainer();
EjbDescriptor ejbDesc = container.getEjbDescriptor();
boolean isStatefulBean = false;
if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
isStatefulBean = sessionDesc.isStateful();
}
if (!isStatefulBean) {
// stateless/singleton references via 299 could fail until bug is fixed.
return;
// TODO reenable this after bug is fixed
// throw new UnsupportedOperationException("ejbRef for ejb " +
// ejbDesc.getName() + " is not a stateful bean ");
}
try {
localObjectImpl.remove();
} catch (EJBException e) {
LogFacade.getLogger().log(Level.FINE, "EJBException during remove. ", e);
} catch (javax.ejb.RemoveException re) {
throw new NoSuchEJBException(re.getMessage(), re);
}
}
Aggregations