Created
December 16, 2016 15:50
-
-
Save xdcrafts/da7b01fff3ec0cd0d3530f39fdb390dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.thumbtack.flower.spring.example.Authenticator | |
import net.thumbtack.flower.spring.example.LoggingMiddleware | |
import net.thumbtack.flower.spring.example.Receiver | |
import net.thumbtack.flower.spring.example.User | |
import net.thumbtack.flower.spring.example.email.EmailAuthorizer | |
import net.thumbtack.flower.spring.example.email.EmailRequestValidator | |
import net.thumbtack.flower.spring.example.email.EmailSender | |
import net.thumbtack.flower.spring.example.sms.SmsAuthorizer | |
import net.thumbtack.flower.spring.example.sms.SmsRequestValidator | |
import net.thumbtack.flower.spring.example.sms.SmsSender | |
import net.thumtack.flower.spring.impl.DefaultActionFactory | |
import net.thumtack.flower.spring.impl.DefaultFeature | |
import net.thumtack.flower.spring.impl.extensions.KeywordExtensionFactory | |
import net.thumtack.flower.spring.impl.flows.BasicSyncFlowFactory | |
import net.thumtack.flower.spring.impl.switches.KeywordSwitchFactory | |
beans { | |
// --------------------------------------- Simple spring beans --------------------------------------- | |
authenticator Authenticator, ["secret-admin": new User("admin", "admin@example.com", "adminpwd", ["sms", "email"]), | |
"sms-only-user": new User("sms-only-user", "sms-only-user@example.com", "smsonlyuserpwd", ["sms"]), | |
"email-only-user": new User("email-only-user", "email-only-user@example.com", "emailonlyuserpwd", ["email"])] | |
emailRequestValidator EmailRequestValidator | |
emailAuthorizer EmailAuthorizer | |
emailSender EmailSender | |
smsReqiestValidator SmsRequestValidator | |
smsAuthorizer SmsAuthorizer | |
smsSender SmsSender | |
receiver Receiver | |
// --------------------------------------- Middleware --------------------------------------- | |
loggingMiddleware LoggingMiddleware | |
// --------------------------------------- Actions --------------------------------------- | |
authenticatorAction DefaultActionFactory, "authenticator::authenticate", [loggingMiddleware] | |
switcher KeywordSwitchFactory, "request.type" | |
emailRequestValidatorAction DefaultActionFactory, "emailRequestValidator::validate" | |
emailAuthorizerAction DefaultActionFactory, "emailAuthorizer::authorize" | |
emailSenderAction DefaultActionFactory, "emailSender::send" | |
smsReqiestValidatorAction DefaultActionFactory, "emailRequestValidator::validate" | |
smsAuthorizerAction DefaultActionFactory, "smsAuthorizer::authorize" | |
smsSenderAction DefaultActionFactory, "smsSender::send" | |
receiverAction DefaultActionFactory, "receiver::receive" | |
// --------------------------------------- Flows --------------------------------------- | |
mainFlow BasicSyncFlowFactory, [authenticatorAction, switcher, receiverAction] | |
emailFlow BasicSyncFlowFactory, [emailAuthorizerAction, emailRequestValidatorAction, emailSenderAction] | |
smsFlow BasicSyncFlowFactory, [smsAuthorizerAction, smsReqiestValidatorAction, smsSenderAction] | |
// --------------------------------------- Extensions --------------------------------------- | |
emailExtension KeywordExtensionFactory, "email", emailFlow | |
smsExtension KeywordExtensionFactory, "sms", smsFlow | |
// --------------------------------------- Features --------------------------------------- | |
emailFeature DefaultFeature, true, [emailExtension: "switcher"] | |
smsFeature DefaultFeature, true, [smsExtension: "switcher"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment