use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class AbstractInvocationHandler method invokeInternal.
public void invokeInternal(final Endpoint endpoint, final Invocation wsInvocation) throws Exception {
// prepare for invocation
onBeforeInvocation(wsInvocation);
// prepare invocation data
final ComponentView componentView = getComponentView();
Component component = componentView.getComponent();
// in case of @FactoryType annotation we don't need to go into EE interceptors
final boolean forceTargetBean = (wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null);
if (forceTargetBean) {
this.reference = new ManagedReference() {
public void release() {
}
public Object getInstance() {
return wsInvocation.getInvocationContext().getTargetBean();
}
};
if (component instanceof WSComponent) {
((WSComponent) component).setReference(reference);
}
}
final Method method = getComponentViewMethod(wsInvocation.getJavaMethod(), componentView.getViewMethods());
final InterceptorContext context = new InterceptorContext();
prepareForInvocation(context, wsInvocation);
context.setMethod(method);
context.setParameters(wsInvocation.getArgs());
context.putPrivateData(Component.class, component);
context.putPrivateData(ComponentView.class, componentView);
// pull in any XTS transaction
LocalTransactionContext.getCurrent().importProviderTransaction();
context.setTransaction(ContextTransactionManager.getInstance().getTransaction());
if (forceTargetBean) {
context.putPrivateData(ManagedReference.class, reference);
}
// invoke method
final Object retObj = componentView.invoke(context);
// set return value
wsInvocation.setReturnValue(retObj);
}
use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class EJBComponent method getEjbObjectType.
public Class<?> getEjbObjectType() {
if (ejbObjectViewServiceName == null) {
return null;
}
final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbObjectViewServiceName);
final ComponentView view = (ComponentView) serviceController.getValue();
return view.getViewClass();
}
use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class EJBComponent method createViewInstanceProxy.
protected <T> T createViewInstanceProxy(final Class<T> viewInterface, final Map<Object, Object> contextData, final ServiceName serviceName) {
final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(serviceName);
final ComponentView view = (ComponentView) serviceController.getValue();
final ManagedReference instance;
try {
if (WildFlySecurityManager.isChecking()) {
instance = WildFlySecurityManager.doUnchecked(new PrivilegedExceptionAction<ManagedReference>() {
@Override
public ManagedReference run() throws Exception {
return view.createInstance(contextData);
}
});
} else {
instance = view.createInstance(contextData);
}
} catch (Exception e) {
//TODO: do we need to let the exception propagate here?
throw new RuntimeException(e);
}
return viewInterface.cast(instance.getInstance());
}
use of org.jboss.as.ee.component.ComponentView in project wildfly by wildfly.
the class EJBComponent method getEJBHome.
public EJBHome getEJBHome() throws IllegalStateException {
if (ejbHomeViewServiceName == null) {
throw EjbLogger.ROOT_LOGGER.beanHomeInterfaceIsNull(getComponentName());
}
final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbHomeViewServiceName);
final ComponentView view = (ComponentView) serviceController.getValue();
final String locatorAppName = earApplicationName == null ? "" : earApplicationName;
return EJBClient.createProxy(createHomeLocator(view.getViewClass().asSubclass(EJBHome.class), locatorAppName, moduleName, getComponentName(), distinctName));
}
Aggregations