Skip to content

Refactor executeUpdate() to use Action pattern #220

@rrobetti

Description

@rrobetti

Refactor: ExecuteUpdate Action Pattern

Summary

Refactor the executeUpdate() method in StatementServiceImpl to follow the Action pattern, extracting the logic into a dedicated ExecuteUpdateAction class.


Context

As part of the ongoing refactoring of StatementServiceImpl (a 2,528-line "God class"), we are extracting each public method into focused Action classes.

  • Reference Implementation: The connect() method (see PR #XXX) serves as the template for this transition.

Task Details

Extract the executeUpdate() logic from the service layer into a standalone action.

  • Source Location: StatementServiceImpl.executeUpdate() (line ~757)
  • Target Class: org.openjproxy.grpc.server.action.statement.ExecuteUpdateAction
  • Complexity: Medium (Est. 100-120 lines). Involves statement preparation, parameter binding, execution, and result processing.

Implementation Steps

  1. Create Action: Implement ExecuteUpdateAction using Action<StatementRequest, OpResult>.
  2. Extract Logic: Move the core logic from StatementServiceImpl to the new class.
  3. Modularize: Consider creating ExecuteUpdateInternalAction if logic reuse is required.
  4. State Management: Update the method to utilize context.getSessionManager() and other shared state components.
  5. Delegate: Update the original service method to delegate calls:
    public void executeUpdate(StatementRequest request, StreamObserver<OpResult> responseObserver) {
        new ExecuteUpdateAction(actionContext).execute(request, responseObserver);
    }
  6. Verify: Compile and execute the test suite.

Reference & Resources

Resource Path/Link
Migration Guide ../documents/designs/STATEMENTSERVICE_ACTION_PATTERN_MIGRATION.md
Reference PR PR #XXX (Connect Method)
Target Package org.openjproxy.grpc.server.action.statement

Acceptance Criteria

  • ExecuteUpdateAction class created.
  • Logic successfully removed from StatementServiceImpl.
  • Helper action (ExecuteUpdateInternalAction) created if architectural complexity requires it.
  • StatementServiceImpl.executeUpdate() correctly delegates to the new action.
  • Project compiles without errors.
  • All existing functional tests pass.
  • Zero functional changes confirmed (pure refactoring).

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions