use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class EJBComponent method getEjbLocalObjectType.
public Class<?> getEjbLocalObjectType() {
if (ejbLocalObjectViewServiceName == null) {
return null;
}
final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbLocalObjectViewServiceName);
final ComponentView view = (ComponentView) serviceController.getValue();
return view.getViewClass();
}
use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class SessionBeanHomeInterceptorFactory method create.
@Override
public Interceptor create(final InterceptorFactoryContext context) {
return new Interceptor() {
@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
final ComponentView view = viewToCreate.getValue();
try {
INIT_METHOD.set(method);
INIT_PARAMETERS.set(context.getParameters());
final ManagedReference instance = view.createInstance();
return instance.getInstance();
} finally {
INIT_METHOD.remove();
INIT_PARAMETERS.remove();
}
}
};
}
use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class EjbIIOPTransactionInterceptor method processInvocation.
@Override
public Object processInvocation(final InterceptorContext invocation) throws Exception {
// Do we have a foreign transaction context?
Transaction tx = TxServerInterceptor.getCurrentTransaction();
if (tx instanceof ForeignTransaction) {
final EJBComponent component = (EJBComponent) invocation.getPrivateData(Component.class);
//for timer invocations there is no view, so the methodInf is attached directly
//to the context. Otherwise we retrieve it from the invoked view
MethodIntf methodIntf = invocation.getPrivateData(MethodIntf.class);
if (methodIntf == null) {
final ComponentView componentView = invocation.getPrivateData(ComponentView.class);
if (componentView != null) {
methodIntf = componentView.getPrivateData(MethodIntf.class);
} else {
methodIntf = MethodIntf.BEAN;
}
}
final TransactionAttributeType attr = component.getTransactionAttributeType(methodIntf, invocation.getMethod());
if (attr != TransactionAttributeType.NOT_SUPPORTED && attr != TransactionAttributeType.REQUIRES_NEW) {
throw EjbLogger.ROOT_LOGGER.transactionPropagationNotSupported();
}
}
return invocation.proceed();
}
use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class RegisterManagementEJBService method start.
@Override
public void start(StartContext context) throws StartException {
final DeploymentRepository repository = deploymentRepositoryValue.getValue();
moduleIdentifier = new DeploymentModuleIdentifier(APP_NAME, MODULE_NAME, DISTINCT_NAME);
final InjectedValue<ComponentView> injectedHomeView = new InjectedValue<ComponentView>();
injectedHomeView.setValue(new ImmediateValue<ComponentView>(new ManagementHomeEjbComponentView()));
final InjectedValue<ComponentView> injectedRemoteView = new InjectedValue<ComponentView>();
injectedRemoteView.setValue(new ImmediateValue<ComponentView>(new ManagementRemoteEjbComponentView(mbeanServerValue.getValue())));
Map<String, InjectedValue<ComponentView>> views = new HashMap<String, InjectedValue<ComponentView>>();
views.put(ManagementHome.class.getName(), injectedHomeView);
views.put(Management.class.getName(), injectedRemoteView);
final EjbDeploymentInformation ejb = new ManagementEjbDeploymentInformation(EJB_NAME, views, SecurityActions.getClassLoader(this.getClass()));
final ModuleDeployment deployment = new ModuleDeployment(moduleIdentifier, Collections.singletonMap(EJB_NAME, ejb));
repository.add(moduleIdentifier, deployment);
repository.startDeployment(moduleIdentifier);
doPrivileged((PrivilegedAction<Void>) () -> {
final ClassLoader classLoader = getClass().getClassLoader();
EJBClientContext.getContextManager().setClassLoaderDefault(classLoader, ejbClientContextValue.getValue().getClientContext());
Discovery.getContextManager().setClassLoaderDefault(classLoader, Discovery.create(associationServiceInjector.getValue().getLocalDiscoveryProvider()));
return null;
});
}
use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class SessionObjectReferenceImpl method getBusinessObject.
@Override
@SuppressWarnings({ "unchecked" })
public synchronized <S> S getBusinessObject(Class<S> businessInterfaceType) {
final String businessInterfaceName = businessInterfaceType.getName();
ManagedReference managedReference = null;
if (businessInterfaceToReference == null) {
businessInterfaceToReference = new HashMap<String, ManagedReference>();
} else {
managedReference = businessInterfaceToReference.get(businessInterfaceName);
}
if (managedReference == null) {
if (viewServices.containsKey(businessInterfaceType)) {
final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(viewServices.get(businessInterfaceType));
final ComponentView view = (ComponentView) serviceController.getValue();
try {
managedReference = view.createInstance();
businessInterfaceToReference.put(businessInterfaceType.getName(), managedReference);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
throw WeldLogger.ROOT_LOGGER.viewNotFoundOnEJB(businessInterfaceType.getName(), ejbName);
}
}
return (S) managedReference.getInstance();
}
Aggregations