@Override
  public void callTimeout(final TimerImpl timer, final Method timeoutMethod) throws Exception {
    final Interceptor interceptor;
    synchronized (this) {
      if (!started) {
        // this can happen if an invocation has been triggered as the deployment is shutting down
        throw EjbLogger.ROOT_LOGGER.timerInvocationFailedDueToInvokerNotBeingStarted();
      }
      interceptor = timeoutInterceptors.get(timeoutMethod);
    }
    if (interceptor == null) {
      throw EjbLogger.ROOT_LOGGER.failToInvokeTimeout(timeoutMethod);
    }
    final InterceptorContext context = new InterceptorContext();
    context.setContextData(new HashMap<String, Object>());
    context.setMethod(timeoutMethod);
    if (timeoutMethod.getParameterTypes().length == 0) {
      context.setParameters(new Object[0]);
    } else {
      final Object[] params = new Object[1];
      params[0] = timer;
      context.setParameters(params);
    }
    context.setTimer(timer);

    if (timer.getPrimaryKey() != null) {
      context.putPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, timer.getPrimaryKey());
    }
    context.putPrivateData(Component.class, ejbComponent.getValue());
    context.putPrivateData(MethodIntf.class, MethodIntf.TIMER);
    context.putPrivateData(InvocationType.class, InvocationType.TIMER);
    interceptor.processInvocation(context);
  }
  /**
   * Invokes WS endpoint.
   *
   * @param endpoint WS endpoint
   * @param wsInvocation web service invocation
   * @throws Exception if any error occurs
   */
  public void invoke(final Endpoint endpoint, final Invocation wsInvocation) throws Exception {
    try {
      // prepare for invocation
      onBeforeInvocation(wsInvocation);
      // prepare invocation data
      final ComponentView componentView = getComponentView();
      Component component = componentView.getComponent();
      // for spring integration and @FactoryType is annotated we don't need to go into ee's
      // interceptors
      if (wsInvocation.getInvocationContext().getTargetBean() != null
              && (endpoint.getProperty("SpringBus") != null)
          || wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null) {
        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);
      if (wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null) {
        context.putPrivateData(ManagedReference.class, reference);
      }
      // invoke method
      final Object retObj = componentView.invoke(context);
      // set return value
      wsInvocation.setReturnValue(retObj);
    } catch (Throwable t) {
      handleInvocationException(t);
    } finally {
      onAfterInvocation(wsInvocation);
    }
  }
Esempio n. 3
0
 private void prepareInterceptorContext(
     final SkeletonStrategy op, final Object[] params, final InterceptorContext interceptorContext)
     throws IOException, ClassNotFoundException {
   if (!home) {
     if (componentView.getComponent() instanceof StatefulSessionComponent) {
       final SessionID sessionID = (SessionID) unmarshalIdentifier();
       interceptorContext.putPrivateData(SessionID.class, sessionID);
     } else if (componentView.getComponent() instanceof EntityBeanComponent) {
       final Object pk = unmarshalIdentifier();
       interceptorContext.putPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, pk);
     }
   }
   interceptorContext.setContextData(new HashMap<String, Object>());
   interceptorContext.setParameters(params);
   interceptorContext.setMethod(op.getMethod());
   interceptorContext.putPrivateData(ComponentView.class, componentView);
   interceptorContext.putPrivateData(Component.class, componentView.getComponent());
 }
Esempio n. 4
0
 public void invokeTimeoutMethod(final Method method, final Timer timer) {
   final Interceptor interceptor = timeoutInterceptors.get(method);
   if (interceptor == null) {
     throw MESSAGES.failToCallTimeOutMethod(method);
   }
   try {
     InterceptorContext context = prepareInterceptorContext();
     context.setMethod(method);
     context.setTimer(timer);
     context.setTarget(getInstance());
     final Object[] params;
     if (method.getParameterTypes().length == 1) {
       params = new Object[1];
       params[0] = timer;
     } else {
       params = EMPTY_OBJECT_ARRAY;
     }
     context.setParameters(params);
     interceptor.processInvocation(context);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }