use of org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData in project wildfly by wildfly.
the class AbstractDeploymentUnitProcessor method processDeploymentDescriptor.
protected void processDeploymentDescriptor(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
// find the EJB jar metadata and start processing it
final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetaData == null) {
return;
}
final SimpleSet<String> annotatedEJBs;
if (appclient) {
final List<ComponentDescription> additionalComponents = deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS);
annotatedEJBs = new SimpleSet<String>() {
@Override
public boolean contains(Object o) {
for (final ComponentDescription component : additionalComponents) {
if (component.getComponentName().equals(o)) {
return true;
}
}
return false;
}
};
} else {
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
annotatedEJBs = new SimpleSet<String>() {
@Override
public boolean contains(Object o) {
return ejbJarDescription.hasComponent((String) o);
}
};
}
// process EJBs
final EnterpriseBeansMetaData ejbs = ejbJarMetaData.getEnterpriseBeans();
if (ejbs != null && !ejbs.isEmpty()) {
for (final EnterpriseBeanMetaData ejb : ejbs) {
final String beanName = ejb.getName();
// the important bit is to skip already processed EJBs via annotations
if (annotatedEJBs.contains(beanName)) {
continue;
}
processBeanMetaData(deploymentUnit, ejb);
}
}
EjbDeploymentMarker.mark(deploymentUnit);
}
use of org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData in project wildfly by wildfly.
the class AbstractEjbXmlDescriptorProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
// get the deployment unit
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
// find the Jakarta Enterprise Beans jar metadata and start processing it
EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetaData == null) {
return;
}
// process Jakarta Enterprise Beans
EnterpriseBeansMetaData ejbs = ejbJarMetaData.getEnterpriseBeans();
if (ejbs != null && !ejbs.isEmpty()) {
for (EnterpriseBeanMetaData ejb : ejbs) {
if (this.getMetaDataType().isInstance(ejb)) {
this.processBeanMetaData((T) ejb, phaseContext);
}
}
}
}
use of org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData in project wildfly by wildfly.
the class DeploymentDescriptorMethodProcessor method handleSessionBean.
private void handleSessionBean(final EJBComponentDescription component, final Module module, final DeploymentReflectionIndex reflectionIndex) throws ClassNotFoundException, DeploymentUnitProcessingException {
if (component.getDescriptorData() == null) {
return;
}
final Class<?> componentClass = ClassLoadingUtils.loadClass(component.getComponentClassName(), module);
final EnterpriseBeanMetaData metaData = component.getDescriptorData();
AroundInvokesMetaData aroundInvokes = null;
if (metaData instanceof SessionBeanMetaData) {
aroundInvokes = ((SessionBeanMetaData) metaData).getAroundInvokes();
} else if (metaData instanceof MessageDrivenBeanMetaData) {
aroundInvokes = ((MessageDrivenBeanMetaData) metaData).getAroundInvokes();
}
if (aroundInvokes != null) {
for (AroundInvokeMetaData aroundInvoke : aroundInvokes) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
String methodName = aroundInvoke.getMethodName();
MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class);
builder.setAroundInvoke(methodIdentifier);
if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(aroundInvoke.getClassName(), builder.build());
}
}
}
// post-construct(s) of the interceptor configured (if any) in the deployment descriptor
LifecycleCallbacksMetaData postConstructs = metaData.getPostConstructs();
if (postConstructs != null) {
for (LifecycleCallbackMetaData postConstruct : postConstructs) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
String methodName = postConstruct.getMethodName();
MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPostConstruct(methodIdentifier);
if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(postConstruct.getClassName(), builder.build());
}
}
}
// pre-destroy(s) of the interceptor configured (if any) in the deployment descriptor
final LifecycleCallbacksMetaData preDestroys = metaData.getPreDestroys();
if (preDestroys != null) {
for (final LifecycleCallbackMetaData preDestroy : preDestroys) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
final String methodName = preDestroy.getMethodName();
final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPreDestroy(methodIdentifier);
if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(preDestroy.getClassName(), builder.build());
}
}
}
if (component.isStateful()) {
final SessionBeanMetaData sessionBeanMetadata = (SessionBeanMetaData) metaData;
// pre-passivate(s) of the interceptor configured (if any) in the deployment descriptor
final LifecycleCallbacksMetaData prePassivates = sessionBeanMetadata.getPrePassivates();
if (prePassivates != null) {
for (final LifecycleCallbackMetaData prePassivate : prePassivates) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
final String methodName = prePassivate.getMethodName();
final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPrePassivate(methodIdentifier);
if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(prePassivate.getClassName(), builder.build());
}
}
}
final LifecycleCallbacksMetaData postActivates = sessionBeanMetadata.getPostActivates();
if (postActivates != null) {
for (final LifecycleCallbackMetaData postActivate : postActivates) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
final String methodName = postActivate.getMethodName();
final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPostActivate(methodIdentifier);
if (postActivate.getClassName() == null || postActivate.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(postActivate.getClassName(), builder.build());
}
}
}
}
}
use of org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData in project wildfly by wildfly.
the class TimerMethodMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {
final EnterpriseBeanMetaData descriptorData = description.getDescriptorData();
if (descriptorData != null && (description.isSession() || description.isMessageDriven())) {
assert descriptorData instanceof ITimeoutTarget : descriptorData + " is not an ITimeoutTarget";
ITimeoutTarget target = (ITimeoutTarget) descriptorData;
if (target.getTimeoutMethod() != null) {
parseTimeoutMethod(target, description, componentClass, deploymentReflectionIndex);
}
parseScheduleMethods(descriptorData, description, componentClass, deploymentReflectionIndex);
}
// or the method specified in the deployment descriptor
if (TimedObject.class.isAssignableFrom(componentClass)) {
Class<?> c = componentClass;
while (c != null && c != Object.class) {
final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(c);
// TimedObject takes precedence
Method method = index.getMethod(Void.TYPE, "ejbTimeout", javax.ejb.Timer.class);
if (method != null) {
final Method otherMethod = description.getTimeoutMethod();
if (otherMethod != null && !otherMethod.equals(method)) {
throw EjbLogger.ROOT_LOGGER.invalidEjbEntityTimeout("3.1 18.2.5.3", componentClass);
}
description.setTimeoutMethod(method);
break;
}
c = c.getSuperclass();
}
}
}
use of org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData in project wildfly by wildfly.
the class TransactionManagementMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
final EnterpriseBeanMetaData beanMetaData = componentConfiguration.getDescriptorData();
if (componentConfiguration.isEntity() || beanMetaData == null) {
return;
}
final TransactionManagementType type = componentConfiguration.getDescriptorData().getTransactionType();
if (type != null) {
componentConfiguration.setTransactionManagementType(type);
}
}
Aggregations