use of org.jboss.metadata.ejb.spec.SessionBean31MetaData in project wildfly by wildfly.
the class InitMethodMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription description) throws DeploymentUnitProcessingException {
// first look for old school ejbCreate methods
// we are only looking on the bean class, not sure if that is correct or not
Class<?> clazz = componentClass;
while (clazz != Object.class && clazz != null) {
final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(clazz);
for (Method method : (Iterable<Method>) index.getMethods()) {
// it will be overridden below
if (method.getName().startsWith("ejbCreate") && !description.getInitMethods().containsKey(method)) {
description.addInitMethod(method, null);
}
}
clazz = clazz.getSuperclass();
}
SessionBeanMetaData data = description.getDescriptorData();
if (data instanceof SessionBean31MetaData) {
SessionBean31MetaData metaData = (SessionBean31MetaData) data;
final InitMethodsMetaData inits = metaData.getInitMethods();
if (inits != null) {
for (InitMethodMetaData method : inits) {
Method beanMethod = MethodResolutionUtils.resolveMethod(method.getBeanMethod(), componentClass, deploymentReflectionIndex);
if (method.getCreateMethod() != null) {
description.addInitMethod(beanMethod, method.getCreateMethod().getMethodName());
} else {
description.addInitMethod(beanMethod, null);
}
}
}
}
}
use of org.jboss.metadata.ejb.spec.SessionBean31MetaData in project wildfly by wildfly.
the class SessionBeanXmlDescriptorProcessor method processBeanMetaData.
/**
* Processes the passed {@link org.jboss.metadata.ejb.spec.SessionBeanMetaData} and creates appropriate {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} out of it.
* The {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} is then added to the {@link org.jboss.as.ee.component.EEModuleDescription module description} available
* in the deployment unit of the passed {@link DeploymentPhaseContext phaseContext}
*
* @param sessionBean The session bean metadata
* @param phaseContext
* @throws DeploymentUnitProcessingException
*/
@Override
protected void processBeanMetaData(final SessionBeanMetaData sessionBean, final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
// get the module description
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final String beanName = sessionBean.getName();
ComponentDescription bean = moduleDescription.getComponentByName(beanName);
if (appclient && bean == null) {
for (final ComponentDescription component : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
if (component.getComponentName().equals(beanName)) {
bean = component;
break;
}
}
}
if (!(bean instanceof SessionBeanComponentDescription)) {
// if this is a GenericBeanMetadata it may actually represent an MDB
return;
}
SessionBeanComponentDescription sessionBeanDescription = (SessionBeanComponentDescription) bean;
sessionBeanDescription.setDeploymentDescriptorEnvironment(new DeploymentDescriptorEnvironment("java:comp/env/", sessionBean));
// mapped-name
sessionBeanDescription.setMappedName(sessionBean.getMappedName());
// local business interface views
final BusinessLocalsMetaData businessLocals = sessionBean.getBusinessLocals();
if (businessLocals != null && !businessLocals.isEmpty()) {
sessionBeanDescription.addLocalBusinessInterfaceViews(businessLocals);
}
final String local = sessionBean.getLocal();
if (local != null) {
sessionBeanDescription.addEjbLocalObjectView(local);
}
final String remote = sessionBean.getRemote();
if (remote != null) {
sessionBeanDescription.addEjbObjectView(remote);
}
// remote business interface views
final BusinessRemotesMetaData businessRemotes = sessionBean.getBusinessRemotes();
if (businessRemotes != null && !businessRemotes.isEmpty()) {
sessionBeanDescription.addRemoteBusinessInterfaceViews(businessRemotes);
}
// process Enterprise Beans 3.1 specific session bean description
if (sessionBean instanceof SessionBean31MetaData) {
this.processSessionBean31((SessionBean31MetaData) sessionBean, sessionBeanDescription);
}
}
use of org.jboss.metadata.ejb.spec.SessionBean31MetaData in project wildfly by wildfly.
the class AsynchronousMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException {
final SessionBeanMetaData data = description.getDescriptorData();
final boolean elytronSecurityDomain = description.getSecurityDomainServiceName() != null;
if (data instanceof SessionBean31MetaData) {
final SessionBean31MetaData sessionBeanData = (SessionBean31MetaData) data;
final AsyncMethodsMetaData async = sessionBeanData.getAsyncMethods();
if (async != null) {
for (AsyncMethodMetaData method : async) {
final Collection<Method> methods = MethodResolutionUtils.resolveMethods(method.getMethodName(), method.getMethodParams(), componentClass, deploymentReflectionIndex);
for (final Method m : methods) {
description.addAsynchronousMethod(MethodIdentifier.getIdentifierForMethod(m));
}
}
}
}
if (!description.getAsynchronousClasses().isEmpty() || !description.getAsynchronousMethods().isEmpty()) {
// setup a dependency on the executor service
description.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
configuration.getCreateDependencies().add(new DependencyConfigurator<SessionBeanComponentCreateService>() {
@Override
public void configureDependency(final ServiceBuilder<?> serviceBuilder, final SessionBeanComponentCreateService service) throws DeploymentUnitProcessingException {
serviceBuilder.addDependency(asynchronousThreadPoolService, ExecutorService.class, service.getAsyncExecutorService());
}
});
}
});
for (final ViewDescription view : description.getViews()) {
final EJBViewDescription ejbView = (EJBViewDescription) view;
ejbView.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription();
for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
// we need the component method to get the correct declaring class
final Method componentMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentClass, method);
if (componentMethod != null) {
if (componentDescription.getAsynchronousClasses().contains(componentMethod.getDeclaringClass().getName())) {
addAsyncInterceptor(configuration, method, elytronSecurityDomain);
configuration.addAsyncMethod(method);
} else {
MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method);
if (componentDescription.getAsynchronousMethods().contains(id)) {
addAsyncInterceptor(configuration, method, elytronSecurityDomain);
configuration.addAsyncMethod(method);
}
}
}
}
}
});
}
}
}
use of org.jboss.metadata.ejb.spec.SessionBean31MetaData in project wildfly by wildfly.
the class EjbConcurrencyMergingProcessor method handleDeploymentDescriptor.
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
if (componentConfiguration.getDescriptorData() == null) {
return;
}
SessionBeanMetaData sessionBeanMetaData = componentConfiguration.getDescriptorData();
if (sessionBeanMetaData instanceof SessionBean31MetaData) {
SessionBean31MetaData descriptor = (SessionBean31MetaData) sessionBeanMetaData;
// handle lock
if (descriptor.getLockType() != null) {
componentConfiguration.setBeanLevelLockType(componentConfiguration.getEJBClassName(), descriptor.getLockType());
}
// handle access timeout
if (descriptor.getAccessTimeout() != null) {
componentConfiguration.setBeanLevelAccessTimeout(componentConfiguration.getEJBClassName(), new AccessTimeoutDetails(descriptor.getAccessTimeout().getTimeout(), descriptor.getAccessTimeout().getUnit()));
}
final ConcurrentMethodsMetaData methods = descriptor.getConcurrentMethods();
if (methods != null) {
for (final ConcurrentMethodMetaData method : methods) {
final Method realMethod = resolveMethod(deploymentReflectionIndex, componentClass, componentClass, method.getMethod());
final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(realMethod);
if (method.getLockType() != null) {
componentConfiguration.setLockType(method.getLockType(), methodIdentifier);
}
if (method.getAccessTimeout() != null) {
componentConfiguration.setAccessTimeout(new AccessTimeoutDetails(method.getAccessTimeout().getTimeout(), method.getAccessTimeout().getUnit()), methodIdentifier);
}
}
}
}
}
Aggregations