/** * Classes derived from {@link AbstractCustomAction} can override this method to initialize the {@link CustomAction}. * @throws Exception if there is any error in initializing the custom action */ @TransactionPolicy(TransactionControl.IMPLICIT) protected void initialize() throws Exception { // No-op by default }
private static TransactionControl getTransactionControl(Class<?> cls, String methodName, Class<?>[] params) { try { Method method = cls.getDeclaredMethod(methodName, params); TransactionPolicy annotation = method.getAnnotation(TransactionPolicy.class); if (annotation != null) { return annotation.value(); } } catch (NoSuchMethodException e) { // this class does not have the method, that is ok } return null; }
/** * Classes derived from {@link AbstractSpark} can override this method to initialize the {@link Spark}. * {@link SparkClientContext} will be available in this method using {@link AbstractSpark#getContext}. * @throws Exception if there is any error in initializing the Spark */ @TransactionPolicy(TransactionControl.IMPLICIT) protected void initialize() throws Exception { // do nothing by default }
private static TransactionControl getTransactionControl(Class<?> cls, String methodName, Class<?>[] params) { try { Method method = cls.getDeclaredMethod(methodName, params); TransactionPolicy annotation = method.getAnnotation(TransactionPolicy.class); if (annotation != null) { return annotation.value(); } } catch (NoSuchMethodException e) { // this class does not have the method, that is ok } return null; }
@Override @TransactionPolicy(TransactionControl.IMPLICIT) public void destroy() { // do nothing by default }
@Override @TransactionPolicy(TransactionControl.IMPLICIT) public void destroy() { // Do nothing }
/** * Destroy is the last thing that gets called before the program is * shutdown. So, if there are any cleanups then they can be specified here. */ @TransactionPolicy(TransactionControl.IMPLICIT) void destroy(); }
/** * Classes derived from {@link AbstractCondition} can override this method to destroy the {@link Condition}. */ @Override @TransactionPolicy(TransactionControl.IMPLICIT) public void destroy() { }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void initialize(WorkerContext context) throws Exception { this.context = context; }
/** * This method is called when the http service is about to shutdown. * Cleanup job can be done in this method. */ @TransactionPolicy(TransactionControl.EXPLICIT) @Override void destroy(); }
@Override @TransactionPolicy(TransactionControl.IMPLICIT) public void initialize(WorkflowContext context) throws Exception { this.context = context; }
/** * Classes derived from {@link AbstractMapReduce} can override this method to destroy the {@link MapReduce}. */ @Override @TransactionPolicy(TransactionControl.IMPLICIT) public void destroy() { // do nothing by default }
/** * This method is called when the http service is about to shutdown. * Cleanup job can be done in this method. */ @TransactionPolicy(TransactionControl.EXPLICIT) @Override void destroy(); }
/** * This method is called when the http service is about to shutdown. * Cleanup job can be done in this method. */ @TransactionPolicy(TransactionControl.EXPLICIT) @Override void destroy(); }
/** * This method will get invoked after the last chunk of data is sent. It is always * executed inside a single transaction unless annotated with {@link TransactionPolicy(TransactionControl}. * * @throws Exception if there is any error */ @TransactionPolicy(TransactionControl.IMPLICIT) public abstract void onFinish() throws Exception;
/** * Invoked whenever an instance of this HttpServiceHandler is destroyed. This may happen * when the service is shut down, or when a handler instance expires due to inactivity. */ @Override @TransactionPolicy(TransactionControl.IMPLICIT) void destroy(); }
/** * This method is invoked when the end of the request body is reached. It must use the given * {@link HttpServiceResponder} to send the response in order to complete the HTTP call. This method is * always executed inside a single transaction unless annotated with * {@link TransactionPolicy(TransactionControl}. * * @param responder a {@link HttpServiceResponder} for sending response * @throws Exception if there is any error */ @TransactionPolicy(TransactionControl.IMPLICIT) public abstract void onFinish(HttpServiceResponder responder) throws Exception;
/** * Initializes a Program. * <p> * This method will be called only once per {@link co.cask.cdap.api.ProgramLifecycle} instance. * </p> * @param context An instance of {@link RuntimeContext} * @throws Exception If there is any error during initialization. */ @TransactionPolicy(TransactionControl.IMPLICIT) void initialize(T context) throws Exception;
/** * Destroy the {@code Worker}. * * Note that unlike most program types, this method is not called within an implicit transaction, * but instead it can start its own transactions using {@link WorkerContext#execute(TxRunnable)}. */ @Override @TransactionPolicy(TransactionControl.EXPLICIT) void destroy();
/** * Classes derived from {@link AbstractMapReduce} can override this method to initialize the {@link MapReduce}. * {@link MapReduceContext} will be available in this method using {@link AbstractMapReduce#getContext}. * @throws Exception if there is any error in initializing the MapReduce */ @TransactionPolicy(TransactionControl.IMPLICIT) protected void initialize() throws Exception { // do nothing by default }