All Downloads are FREE. Search and download functionalities are using the official Maven repository.

restx.security.SecurityModuleFactoryMachine Maven / Gradle / Ivy

There is a newer version: 1.2.0-rc2
Show newest version
package restx.security;

import com.google.common.collect.ImmutableSet;
import restx.factory.*;
import restx.security.SecurityModule;


@Machine
public class SecurityModuleFactoryMachine extends DefaultFactoryMachine {
    private static final SecurityModule module = new SecurityModule();

    public SecurityModuleFactoryMachine() {
        super(100, new MachineEngine[] {
            new StdMachineEngine(Name.of(java.lang.String.class, "restx.activation::restx.security.RestxSessionBareFilter::RestxSessionBareFilter"), 100, BoundlessComponentBox.FACTORY) {
        
                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return new BillOfMaterials(ImmutableSet.>of(
        
                    ));
                }

                @Override
                public java.lang.String doNewComponent(SatisfiedBOM satisfiedBOM) {
	                    return module.disableBareFilter(
	        
	                    );
                }
            },
            new StdMachineEngine(Name.of(restx.security.Sessions.class, "Sessions"), 100, BoundlessComponentBox.FACTORY) {
        private final Factory.Query settings = Factory.Query.byClass(restx.security.SecurityModule.SecuritySettings.class).mandatory();
                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return new BillOfMaterials(ImmutableSet.>of(
        settings
                    ));
                }

                @Override
                public restx.security.Sessions doNewComponent(SatisfiedBOM satisfiedBOM) {
	                    return module.session(
	        satisfiedBOM.getOne(settings).get().getComponent()
	                    );
                }
            },
            new StdMachineEngine(Name.of(restx.factory.AutoStartable.class, "startSessions"), 100, BoundlessComponentBox.FACTORY) {
        private final Factory.Query sessions = Factory.Query.byName(Name.of(restx.security.Sessions.class, "Sessions")).mandatory();
                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return new BillOfMaterials(ImmutableSet.>of(
        sessions
                    ));
                }

                @Override
                public restx.factory.AutoStartable doNewComponent(SatisfiedBOM satisfiedBOM) {
	                    return module.startSessions(
	        satisfiedBOM.getOne(sessions).get().getComponent()
	                    );
                }
            },
            new StdMachineEngine(Name.of(restx.security.SecurityModule.SecuritySettings.class, "securitySettings"), 100, BoundlessComponentBox.FACTORY) {
        private final Factory.Query config = Factory.Query.byClass(restx.common.RestxConfig.class).mandatory();
                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return new BillOfMaterials(ImmutableSet.>of(
        config
                    ));
                }

                @Override
                public restx.security.SecurityModule.SecuritySettings doNewComponent(SatisfiedBOM satisfiedBOM) {
	                    return module.securitySettings(
	        satisfiedBOM.getOne(config).get().getComponent()
	                    );
                }
            },
            new StdMachineEngine(Name.of(restx.security.RestxSession.Definition.EntryCacheManager.class, "EntryCacheManager"), 100, BoundlessComponentBox.FACTORY) {
        
                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return new BillOfMaterials(ImmutableSet.>of(
        
                    ));
                }

                @Override
                public restx.security.RestxSession.Definition.EntryCacheManager doNewComponent(SatisfiedBOM satisfiedBOM) {
	                    return module.guavaCacheManager(
	        
	                    );
                }
            },

            new StdMachineEngine(
                    Name.of(FactoryMachine.class, "productionNotFoundHandlerproductionNotFoundHandlerConditional"), 0, BoundlessComponentBox.FACTORY) {
                private Factory.Query query = Factory.Query.byName(Name.of(String.class, "restx.mode")).optional();

                @Override
                protected FactoryMachine doNewComponent(SatisfiedBOM satisfiedBOM) {
                    if (satisfiedBOM.getOne(query).isPresent()
                            && satisfiedBOM.getOne(query).get().getComponent().equals("prod")) {
                        return new SingleNameFactoryMachine(100000,
                                        new StdMachineEngine(
                                                Name.of(restx.RestxRoute.class, "productionNotFoundHandler"),
                                                100000, BoundlessComponentBox.FACTORY) {
                                            

                                            @Override
                                            public BillOfMaterials getBillOfMaterial() {
                                                return new BillOfMaterials(ImmutableSet.>of(
                                                    
                                                ));
                                            }

                                            @Override
                                            protected restx.RestxRoute doNewComponent(SatisfiedBOM satisfiedBOM) {
                                                    return module.productionNotFoundHandler(
                                                
                                                    );
                                            }
                                        });
                    } else {
                        return NoopFactoryMachine.INSTANCE;
                    }
                }

                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return BillOfMaterials.of(query);
                }
            },
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy