use of org.jboss.as.ejb3.component.stateful.StatefulComponentDescription in project wildfly by wildfly.
the class SessionBeanComponentDescriptionFactory method processSessionBeans.
private void processSessionBeans(final DeploymentUnit deploymentUnit, final List<AnnotationInstance> sessionBeanAnnotations, final SessionBeanComponentDescription.SessionBeanType annotatedSessionBeanType) {
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName();
PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
// process these session bean annotations and create component descriptions out of it
for (final AnnotationInstance sessionBeanAnnotation : sessionBeanAnnotations) {
final AnnotationTarget target = sessionBeanAnnotation.target();
if (!(target instanceof ClassInfo)) {
// Let's just WARN and move on. No need to throw an error
EjbLogger.DEPLOYMENT_LOGGER.warn(EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(sessionBeanAnnotation.name().toString(), target).getMessage());
continue;
}
final ClassInfo sessionBeanClassInfo = (ClassInfo) target;
// skip if it's not a valid class for session bean
if (!assertSessionBeanClassValidity(sessionBeanClassInfo)) {
continue;
}
final String ejbName = sessionBeanClassInfo.name().local();
final AnnotationValue nameValue = sessionBeanAnnotation.value("name");
final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString());
final SessionBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, SessionBeanMetaData.class);
final SessionBeanComponentDescription.SessionBeanType sessionBeanType;
final String beanClassName;
if (beanMetaData != null) {
beanClassName = override(sessionBeanClassInfo.name().toString(), beanMetaData.getEjbClass());
sessionBeanType = override(annotatedSessionBeanType, descriptionOf(((SessionBeanMetaData) beanMetaData).getSessionType()));
} else {
beanClassName = sessionBeanClassInfo.name().toString();
sessionBeanType = annotatedSessionBeanType;
}
final SessionBeanComponentDescription sessionBeanDescription;
switch(sessionBeanType) {
case STATELESS:
sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, beanMetaData, defaultSlsbPoolAvailable);
break;
case STATEFUL:
sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, beanMetaData);
// If passivation is disabled for the SFSB, either via annotation or via DD, then setup the component
// description appropriately
final boolean passivationCapableAnnotationValue = sessionBeanAnnotation.value("passivationCapable") == null ? true : sessionBeanAnnotation.value("passivationCapable").asBoolean();
final Boolean passivationCapableDeploymentDescriptorValue;
if ((beanMetaData instanceof SessionBean32MetaData)) {
passivationCapableDeploymentDescriptorValue = ((SessionBean32MetaData) beanMetaData).isPassivationCapable();
} else {
passivationCapableDeploymentDescriptorValue = null;
}
final boolean passivationApplicable = override(passivationCapableDeploymentDescriptorValue, passivationCapableAnnotationValue);
((StatefulComponentDescription) sessionBeanDescription).setPassivationApplicable(passivationApplicable);
break;
case SINGLETON:
if (sessionBeanClassInfo.interfaceNames().contains(SESSION_BEAN_INTERFACE)) {
EjbLogger.ROOT_LOGGER.singletonCantImplementSessionBean(beanClassName);
}
sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, beanMetaData);
break;
default:
throw EjbLogger.ROOT_LOGGER.unknownSessionBeanType(sessionBeanType.name());
}
addComponent(deploymentUnit, sessionBeanDescription);
final AnnotationValue mappedNameValue = sessionBeanAnnotation.value("mappedName");
if (mappedNameValue != null && !mappedNameValue.asString().isEmpty()) {
EjbLogger.ROOT_LOGGER.mappedNameNotSupported(mappedNameValue != null ? mappedNameValue.asString() : "", ejbName);
}
}
EjbDeploymentMarker.mark(deploymentUnit);
}
use of org.jboss.as.ejb3.component.stateful.StatefulComponentDescription in project wildfly by wildfly.
the class StatefulSessionBeanRuntimeHandler method executeReadAttribute.
@Override
protected void executeReadAttribute(String attributeName, OperationContext context, StatefulSessionComponent component, PathAddress address) {
final StatefulComponentDescription componentDescription = (StatefulComponentDescription) component.getComponentDescription();
final ModelNode result = context.getResult();
if (STATEFUL_TIMEOUT.getName().equals(attributeName)) {
final StatefulTimeoutInfo statefulTimeout = componentDescription.getStatefulTimeout();
if (statefulTimeout != null) {
result.set(statefulTimeout.getValue() + ' ' + statefulTimeout.getTimeUnit().toString());
}
} else if (AFTER_BEGIN_METHOD.getName().equals(attributeName)) {
final Method afterBeginMethod = component.getAfterBeginMethod();
if (afterBeginMethod != null) {
result.set(afterBeginMethod.toString());
}
} else if (BEFORE_COMPLETION_METHOD.getName().equals(attributeName)) {
final Method beforeCompletionMethod = component.getBeforeCompletionMethod();
if (beforeCompletionMethod != null) {
result.set(beforeCompletionMethod.toString());
}
} else if (AFTER_COMPLETION_METHOD.getName().equals(attributeName)) {
final Method afterCompletionMethod = component.getAfterCompletionMethod();
if (afterCompletionMethod != null) {
result.set(afterCompletionMethod.toString());
}
} else if (PASSIVATION_CAPABLE.getName().equals(attributeName)) {
result.set(componentDescription.isPassivationApplicable());
} else if (REMOVE_METHODS.getName().equals(attributeName)) {
final Collection<StatefulComponentDescription.StatefulRemoveMethod> removeMethods = componentDescription.getRemoveMethods();
for (StatefulComponentDescription.StatefulRemoveMethod removeMethod : removeMethods) {
ModelNode removeMethodNode = result.add();
final ModelNode beanMethodNode = removeMethodNode.get(BEAN_METHOD.getName());
final MethodIdentifier methodIdentifier = removeMethod.getMethodIdentifier();
beanMethodNode.set(methodIdentifier.getReturnType() + ' ' + methodIdentifier.getName() + '(' + String.join(", ", methodIdentifier.getParameterTypes()) + ')');
final ModelNode retainIfExceptionNode = removeMethodNode.get(RETAIN_IF_EXCEPTION.getName());
retainIfExceptionNode.set(removeMethod.getRetainIfException());
}
} else {
super.executeReadAttribute(attributeName, context, component, address);
}
// TODO expose the cache
}
use of org.jboss.as.ejb3.component.stateful.StatefulComponentDescription in project wildfly by wildfly.
the class EjbComponentIntegrator method integrate.
@Override
public boolean integrate(ServiceName beanManagerServiceName, ComponentConfiguration configuration, ComponentDescription description, ServiceBuilder<?> weldComponentServiceBuilder, Supplier<ServiceName> bindingServiceNameSupplier, DefaultInterceptorIntegrationAction integrationAction, ComponentInterceptorSupport interceptorSupport) {
if (description instanceof EJBComponentDescription) {
ServiceName bindingServiceName = bindingServiceNameSupplier.get();
integrationAction.perform(bindingServiceName);
if (description.isPassivationApplicable()) {
configuration.addPrePassivateInterceptor(factory(InterceptionType.PRE_PASSIVATE, weldComponentServiceBuilder, bindingServiceName, interceptorSupport), InterceptorOrder.ComponentPassivation.CDI_INTERCEPTORS);
configuration.addPostActivateInterceptor(factory(InterceptionType.POST_ACTIVATE, weldComponentServiceBuilder, bindingServiceName, interceptorSupport), InterceptorOrder.ComponentPassivation.CDI_INTERCEPTORS);
}
if (description instanceof StatefulComponentDescription) {
// add a context key for weld interceptor replication
configuration.getInterceptorContextKeys().add(SerializedCdiInterceptorsKey.class);
}
return true;
} else if (description instanceof ManagedBeanComponentDescription) {
integrationAction.perform(bindingServiceNameSupplier.get());
return true;
}
return false;
}
Aggregations