repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/SessionGranularity.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy; /** * Enumerates the session granularity values. * @author Paul Ferraro */ public enum SessionGranularity { SESSION(SessionAttributePersistenceStrategy.COARSE), ATTRIBUTE(SessionAttributePersistenceStrategy.FINE), ; private final SessionAttributePersistenceStrategy strategy; SessionGranularity(SessionAttributePersistenceStrategy strategy) { this.strategy = strategy; } public SessionAttributePersistenceStrategy getAttributePersistenceStrategy() { return this.strategy; } }
1,681
35.565217
82
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/SSOManagementServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.controller.PathAddress; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.web.service.sso.DistributableSSOManagementProvider; /** * Abstract service configurator for single sign-on management providers. * @author Paul Ferraro */ public abstract class SSOManagementServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Supplier<DistributableSSOManagementProvider> { public SSOManagementServiceConfigurator(PathAddress address) { super(SSOManagementResourceDefinition.Capability.SSO_MANAGEMENT_PROVIDER, address); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<DistributableSSOManagementProvider> provider = builder.provides(name); Service service = Service.newInstance(provider, this.get()); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
2,520
43.22807
179
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/LocalAffinityServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import org.jboss.as.controller.PathAddress; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; import org.wildfly.extension.clustering.web.routing.LocalRouteLocatorServiceConfiguratorFactory; /** * @author Paul Ferraro */ public class LocalAffinityServiceConfigurator<C> extends AffinityServiceConfigurator<C> { public LocalAffinityServiceConfigurator(PathAddress address) { super(LocalAffinityResourceDefinition.Capability.AFFINITY, address); } @Override public RouteLocatorServiceConfiguratorFactory<C> get() { return new LocalRouteLocatorServiceConfiguratorFactory<>(); } }
1,728
39.209302
96
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/JBossMarshallingVersion.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.io.Externalizable; import java.io.Serializable; import java.util.function.Function; import org.jboss.marshalling.MarshallingConfiguration; import org.jboss.marshalling.ModularClassResolver; import org.jboss.modules.Module; import org.wildfly.clustering.marshalling.jboss.DynamicClassTable; import org.wildfly.clustering.marshalling.jboss.DynamicExternalizerObjectTable; import org.wildfly.clustering.marshalling.jboss.SimpleClassTable; /** * @author Paul Ferraro */ public enum JBossMarshallingVersion implements Function<Module, MarshallingConfiguration> { VERSION_1() { @Override public MarshallingConfiguration apply(Module module) { MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setClassTable(new SimpleClassTable(Serializable.class, Externalizable.class)); return config; } }, VERSION_2() { @Override public MarshallingConfiguration apply(Module module) { MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setClassTable(new SimpleClassTable(Serializable.class, Externalizable.class)); config.setObjectTable(new DynamicExternalizerObjectTable(module.getClassLoader())); return config; } }, VERSION_3() { @Override public MarshallingConfiguration apply(Module module) { MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setClassTable(new DynamicClassTable(module.getClassLoader())); config.setObjectTable(new DynamicExternalizerObjectTable(module.getClassLoader())); return config; } }, ; static final JBossMarshallingVersion CURRENT = VERSION_3; }
3,140
42.027397
97
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/SessionManagementResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.AttributeAccess.Flag; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.clustering.service.UnaryRequirement; import org.wildfly.clustering.web.service.WebProviderRequirement; import org.wildfly.clustering.web.service.WebRequirement; /** * Base definition for session management resources. * @author Paul Ferraro */ public class SessionManagementResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { enum Capability implements CapabilityProvider, UnaryOperator<RuntimeCapability.Builder<Void>> { SESSION_MANAGEMENT_PROVIDER(WebProviderRequirement.SESSION_MANAGEMENT_PROVIDER), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(UnaryRequirement requirement) { this.capability = new UnaryRequirementCapability(requirement, this); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } @Override public RuntimeCapability.Builder<Void> apply(RuntimeCapability.Builder<Void> builder) { return builder.setDynamicNameMapper(UnaryCapabilityNameResolver.DEFAULT) .addRequirements(WebRequirement.ROUTING_PROVIDER.getName()); } } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { GRANULARITY("granularity", ModelType.STRING, null) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(EnumValidator.create(SessionGranularity.class)); } }, MARSHALLER("marshaller", ModelType.STRING, new ModelNode(SessionMarshallerFactory.JBOSS.name())) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(EnumValidator.create(SessionMarshallerFactory.class)); } } ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(defaultValue == null) .setDefaultValue(defaultValue) .setFlags(Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory factory; public SessionManagementResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory factory) { super(path, DistributableWebExtension.SUBSYSTEM_RESOLVER.createChildResolver(path, PathElement.pathElement("session-management"))); this.configurator = configurator; this.factory = factory; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addAttributes(Attribute.class) .addCapabilities(Capability.class) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this.factory); new SimpleResourceRegistrar(descriptor, handler).register(registration); new NoAffinityResourceDefinition().register(registration); new LocalAffinityResourceDefinition().register(registration); return registration; } }
6,139
45.515152
158
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/HotRodSessionManagementResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess.Flag; import org.jboss.dmr.ModelType; import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement; /** * @author Paul Ferraro */ public class HotRodSessionManagementResourceDefinition extends SessionManagementResourceDefinition { static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); static PathElement pathElement(String name) { return PathElement.pathElement("hotrod-session-management", name); } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { REMOTE_CACHE_CONTAINER("remote-cache-container", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(false) .setRequired(true) .setCapabilityReference(new CapabilityReference(Capability.SESSION_MANAGEMENT_PROVIDER, InfinispanClientRequirement.REMOTE_CONTAINER)) ; } }, CACHE_CONFIGURATION("cache-configuration", ModelType.STRING), ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setFlags(Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder; } } HotRodSessionManagementResourceDefinition() { super(WILDCARD_PATH, new SimpleResourceDescriptorConfigurator<>(Attribute.class), HotRodSessionManagementServiceConfigurator::new); } }
3,524
41.46988
158
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/PrimaryOwnerAffinityResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.EnumSet; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.capability.RuntimeCapability; import org.wildfly.clustering.service.UnaryRequirement; import org.wildfly.clustering.web.service.WebProviderRequirement; import org.wildfly.clustering.web.service.WebRequirement; /** * @author Paul Ferraro */ public class PrimaryOwnerAffinityResourceDefinition extends AffinityResourceDefinition { static final PathElement PATH = pathElement("primary-owner"); enum Capability implements CapabilityProvider, UnaryOperator<RuntimeCapability.Builder<Void>> { AFFINITY(WebProviderRequirement.AFFINITY), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(UnaryRequirement requirement) { this.capability = new UnaryRequirementCapability(requirement, this); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } @Override public RuntimeCapability.Builder<Void> apply(RuntimeCapability.Builder<Void> builder) { return builder.setAllowMultipleRegistrations(true) .setDynamicNameMapper(UnaryCapabilityNameResolver.PARENT) .addRequirements(WebRequirement.INFINISPAN_ROUTING_PROVIDER.getName()); } } static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return descriptor.addCapabilities(Capability.class); } } PrimaryOwnerAffinityResourceDefinition() { super(PATH, EnumSet.allOf(Capability.class), new ResourceDescriptorConfigurator(), PrimaryOwnerAffinityServiceConfigurator::new); } }
3,233
40.461538
137
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/DistributableWebExtensionTransformerRegistration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.EnumSet; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.transform.ExtensionTransformerRegistration; import org.jboss.as.controller.transform.SubsystemTransformerRegistration; import org.jboss.as.controller.transform.description.TransformationDescription; import org.kohsuke.MetaInfServices; /** * Registers transformers for the distributable-web subsystem. * @author Paul Ferraro */ @MetaInfServices(ExtensionTransformerRegistration.class) public class DistributableWebExtensionTransformerRegistration implements ExtensionTransformerRegistration { @Override public String getSubsystemName() { return DistributableWebExtension.SUBSYSTEM_NAME; } @Override public void registerTransformers(SubsystemTransformerRegistration registration) { // Register transformers for all but the current model for (DistributableWebSubsystemModel model : EnumSet.complementOf(EnumSet.of(DistributableWebSubsystemModel.CURRENT))) { ModelVersion version = model.getVersion(); TransformationDescription transformation = new DistributableWebResourceTransformer().apply(version).build(); TransformationDescription.Tools.register(transformation, registration, version); } } }
2,366
42.036364
127
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/HotRodSSOManagementServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import static org.wildfly.extension.clustering.web.HotRodSSOManagementResourceDefinition.Attribute.*; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.web.service.sso.DistributableSSOManagementProvider; import org.wildfly.extension.clustering.web.sso.hotrod.HotRodSSOManagementConfiguration; import org.wildfly.extension.clustering.web.sso.hotrod.HotRodSSOManagementProvider; /** * @author Paul Ferraro */ public class HotRodSSOManagementServiceConfigurator extends SSOManagementServiceConfigurator implements HotRodSSOManagementConfiguration { private volatile String containerName; private volatile String configurationName; public HotRodSSOManagementServiceConfigurator(PathAddress address) { super(address); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.containerName = REMOTE_CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); this.configurationName = CACHE_CONFIGURATION.resolveModelAttribute(context, model).asStringOrNull(); return this; } @Override public DistributableSSOManagementProvider get() { return new HotRodSSOManagementProvider(this); } @Override public String getContainerName() { return this.containerName; } @Override public String getConfigurationName() { return this.configurationName; } }
2,737
38.114286
138
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/InfinispanRoutingProviderServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import static org.wildfly.extension.clustering.web.InfinispanRoutingProviderResourceDefinition.Attribute.CACHE; import static org.wildfly.extension.clustering.web.InfinispanRoutingProviderResourceDefinition.Attribute.CACHE_CONTAINER; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.web.service.routing.RoutingProvider; import org.wildfly.extension.clustering.web.routing.infinispan.InfinispanRoutingConfiguration; import org.wildfly.extension.clustering.web.routing.infinispan.InfinispanRoutingProvider; /** * Service configurator for the Infinispan routing provider. * @author Paul Ferraro */ public class InfinispanRoutingProviderServiceConfigurator extends RoutingProviderServiceConfigurator implements InfinispanRoutingConfiguration { private volatile String containerName; private volatile String cacheName; public InfinispanRoutingProviderServiceConfigurator(PathAddress address) { super(address, InfinispanRoutingProviderResourceDefinition.Capability.INFINISPAN_ROUTING_PROVIDER.getServiceName(address)); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.containerName = CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); this.cacheName = CACHE.resolveModelAttribute(context, model).asStringOrNull(); return super.configure(context, model); } @Override public RoutingProvider get() { return new InfinispanRoutingProvider(this); } @Override public String getContainerName() { return this.containerName; } @Override public String getCacheName() { return this.cacheName; } @Override public void accept(ConfigurationBuilder builder) { // Use configuration as is } }
3,175
39.717949
144
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/RoutingProviderResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.RequirementCapability; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.wildfly.clustering.service.Requirement; import org.wildfly.clustering.web.service.WebRequirement; /** * Base definition for routing provider resources. * @author Paul Ferraro */ public class RoutingProviderResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static PathElement pathElement(String value) { return PathElement.pathElement("routing", value); } enum Capability implements CapabilityProvider, UnaryOperator<RuntimeCapability.Builder<Void>> { ROUTING_PROVIDER(WebRequirement.ROUTING_PROVIDER), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(Requirement requirement) { this.capability = new RequirementCapability(requirement); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } @Override public RuntimeCapability.Builder<Void> apply(RuntimeCapability.Builder<Void> builder) { return builder.setAllowMultipleRegistrations(true); } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory serviceConfiguratorFactory; RoutingProviderResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory serviceConfiguratorFactory) { super(path, DistributableWebExtension.SUBSYSTEM_RESOLVER.createChildResolver(pathElement(PathElement.WILDCARD_VALUE), path)); this.configurator = configurator; this.serviceConfiguratorFactory = serviceConfiguratorFactory; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addCapabilities(Capability.class) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this.serviceConfiguratorFactory); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
4,151
44.626374
168
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/HotRodSSOManagementResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess.Flag; import org.jboss.dmr.ModelType; import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement; /** * @author Paul Ferraro */ public class HotRodSSOManagementResourceDefinition extends SSOManagementResourceDefinition { static final PathElement WILDCARD_PATH = PathElement.pathElement("hotrod-single-sign-on-management"); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { REMOTE_CACHE_CONTAINER("remote-cache-container", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(false) .setRequired(true) .setCapabilityReference(new CapabilityReference(Capability.SSO_MANAGEMENT_PROVIDER, InfinispanClientRequirement.REMOTE_CONTAINER)) ; } }, CACHE_CONFIGURATION("cache-configuration", ModelType.STRING), ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setFlags(Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder; } } HotRodSSOManagementResourceDefinition() { super(WILDCARD_PATH, new SimpleResourceDescriptorConfigurator<>(Attribute.class), HotRodSSOManagementServiceConfigurator::new); } }
3,392
41.4125
154
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/LocalAffinityResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.EnumSet; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.capability.RuntimeCapability; import org.wildfly.clustering.service.UnaryRequirement; import org.wildfly.clustering.web.service.WebProviderRequirement; import org.wildfly.clustering.web.service.WebRequirement; /** * @author Paul Ferraro */ public class LocalAffinityResourceDefinition extends AffinityResourceDefinition { static final PathElement PATH = pathElement("local"); enum Capability implements CapabilityProvider, UnaryOperator<RuntimeCapability.Builder<Void>> { AFFINITY(WebProviderRequirement.AFFINITY), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(UnaryRequirement requirement) { this.capability = new UnaryRequirementCapability(requirement, this); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } @Override public RuntimeCapability.Builder<Void> apply(RuntimeCapability.Builder<Void> builder) { return builder.setAllowMultipleRegistrations(true) .setDynamicNameMapper(UnaryCapabilityNameResolver.PARENT) .addRequirements(WebRequirement.ROUTING_PROVIDER.getName()); } } static class ResourceDescriptorConfigurator implements UnaryOperator<ResourceDescriptor> { @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return descriptor.addCapabilities(Capability.class); } } LocalAffinityResourceDefinition() { super(PATH, EnumSet.allOf(Capability.class), new ResourceDescriptorConfigurator(), LocalAffinityServiceConfigurator::new); } }
3,193
39.948718
130
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/SSOManagementResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.wildfly.clustering.service.UnaryRequirement; import org.wildfly.clustering.web.service.WebProviderRequirement; /** * Base definition for single sign-on management resources. * @author Paul Ferraro */ public class SSOManagementResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { enum Capability implements CapabilityProvider { SSO_MANAGEMENT_PROVIDER(WebProviderRequirement.SSO_MANAGEMENT_PROVIDER), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(UnaryRequirement requirement) { this.capability = new UnaryRequirementCapability(requirement); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory serviceConfiguratorFactory; SSOManagementResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory serviceConfiguratorFactory) { super(path, DistributableWebExtension.SUBSYSTEM_RESOLVER.createChildResolver(path)); this.configurator = configurator; this.serviceConfiguratorFactory = serviceConfiguratorFactory; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addCapabilities(Capability.class) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this.serviceConfiguratorFactory); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
3,751
45.320988
166
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/InfinispanSessionManagementServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import static org.wildfly.extension.clustering.web.InfinispanSessionManagementResourceDefinition.Attribute.CACHE; import static org.wildfly.extension.clustering.web.InfinispanSessionManagementResourceDefinition.Attribute.CACHE_CONTAINER; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.extension.clustering.web.session.infinispan.InfinispanSessionManagementProvider; /** * Service configurator for Infinispan session management providers. * @author Paul Ferraro */ public class InfinispanSessionManagementServiceConfigurator extends SessionManagementServiceConfigurator<InfinispanSessionManagementConfiguration<DeploymentUnit>> implements InfinispanSessionManagementConfiguration<DeploymentUnit> { private volatile String containerName; private volatile String cacheName; public InfinispanSessionManagementServiceConfigurator(PathAddress address) { super(address); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.containerName = CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); this.cacheName = CACHE.resolveModelAttribute(context, model).asStringOrNull(); return super.configure(context, model); } @Override public DistributableSessionManagementProvider<InfinispanSessionManagementConfiguration<DeploymentUnit>> get() { return new InfinispanSessionManagementProvider(this, this.getRouteLocatorServiceConfiguratorFactory()); } @Override public String getContainerName() { return this.containerName; } @Override public String getCacheName() { return this.cacheName; } }
3,222
43.150685
232
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/SessionManagementResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.BiConsumer; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class SessionManagementResourceTransformer implements BiConsumer<ModelVersion, ResourceTransformationDescriptionBuilder> { @Override public void accept(ModelVersion version, ResourceTransformationDescriptionBuilder builder) { if (DistributableWebSubsystemModel.VERSION_3_0_0.requiresTransformation(version)) { builder.getAttributeBuilder() .setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, SessionManagementResourceDefinition.Attribute.MARSHALLER.getName()) .addRejectCheck(RejectAttributeChecker.DEFINED, SessionManagementResourceDefinition.Attribute.MARSHALLER.getName()) .end(); } } }
2,135
44.446809
138
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/AffinityServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.clustering.controller.Capability; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.controller.PathAddress; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; /** * @author Paul Ferraro */ public abstract class AffinityServiceConfigurator<C> extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Supplier<RouteLocatorServiceConfiguratorFactory<C>> { public AffinityServiceConfigurator(Capability capability, PathAddress address) { super(capability, address); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<RouteLocatorServiceConfiguratorFactory<C>> factory = builder.provides(name); Service service = Service.newInstance(factory, this.get()); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
2,480
42.526316
184
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/sso/hotrod/HotRodSSOManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.sso.hotrod; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.web.service.sso.DistributableSSOManagementProvider; /** * @author Paul Ferraro */ public class HotRodSSOManagementProvider implements DistributableSSOManagementProvider { private final HotRodSSOManagementConfiguration configuration; public HotRodSSOManagementProvider(HotRodSSOManagementConfiguration configuration) { this.configuration = configuration; } @Override public CapabilityServiceConfigurator getServiceConfigurator(String name) { return new HotRodSSOManagerFactoryServiceConfigurator<>(this.configuration, name); } }
1,759
39
90
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/sso/hotrod/HotRodSSOManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.sso.hotrod; import org.wildfly.clustering.ee.hotrod.RemoteCacheConfiguration; /** * @author Paul Ferraro */ public interface HotRodSSOManagementConfiguration extends RemoteCacheConfiguration { }
1,269
37.484848
84
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/sso/hotrod/HotRodSSOManagerFactoryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.sso.hotrod; import java.util.function.Consumer; import org.infinispan.client.hotrod.DefaultTemplate; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.configuration.NearCacheMode; import org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder; import org.infinispan.client.hotrod.configuration.TransactionMode; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.infinispan.client.service.RemoteCacheServiceConfigurator; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.hotrod.sso.HotRodSSOManagerFactory; import org.wildfly.clustering.web.hotrod.sso.HotRodSSOManagerFactoryConfiguration; import org.wildfly.clustering.web.sso.SSOManagerFactory; /** * @author Paul Ferraro */ public class HotRodSSOManagerFactoryServiceConfigurator<A, D, S> extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, HotRodSSOManagerFactoryConfiguration { private final String name; private final HotRodSSOManagementConfiguration config; private final CapabilityServiceConfigurator configurator; private volatile SupplierDependency<RemoteCache<?, ?>> cache; public HotRodSSOManagerFactoryServiceConfigurator(HotRodSSOManagementConfiguration config, String name) { super(ServiceName.JBOSS.append("clustering", "sso", name)); this.name = name; this.config = config; String configurationName = this.config.getConfigurationName(); String templateName = (configurationName != null) ? configurationName : DefaultTemplate.DIST_SYNC.getTemplateName(); this.configurator = new RemoteCacheServiceConfigurator<>(this.getServiceName().append("cache"), this.config.getContainerName(), this.name, new Consumer<RemoteCacheConfigurationBuilder>() { @Override public void accept(RemoteCacheConfigurationBuilder builder) { builder.forceReturnValues(false).nearCacheMode(NearCacheMode.INVALIDATED).templateName(templateName).transactionMode(TransactionMode.NONE); } }); } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { this.cache = new ServiceSupplierDependency<>(this.configurator.configure(support).getServiceName()); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { this.configurator.build(target).install(); ServiceBuilder<?> builder = target.addService(this.getServiceName()); Consumer<SSOManagerFactory<A, D, S, TransactionBatch>> factory = this.cache.register(builder).provides(this.getServiceName()); Service service = Service.newInstance(factory, new HotRodSSOManagerFactory<>(this)); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } @SuppressWarnings("unchecked") @Override public <K, V> RemoteCache<K, V> getRemoteCache() { return (RemoteCache<K, V>) this.cache.get(); } }
4,663
47.082474
196
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/sso/infinispan/InfinispanSSOManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.sso.infinispan; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.web.service.sso.DistributableSSOManagementProvider; /** * An Infinispan cache-based {@link DistributableSSOManagementProvider}. * @author Paul Ferraro */ public class InfinispanSSOManagementProvider implements DistributableSSOManagementProvider { private final InfinispanSSOManagementConfiguration configuration; public InfinispanSSOManagementProvider(InfinispanSSOManagementConfiguration configuration) { this.configuration = configuration; } @Override public CapabilityServiceConfigurator getServiceConfigurator(String name) { return new InfinispanSSOManagerFactoryServiceConfigurator<>(this.configuration, name); } }
1,856
40.266667
96
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/sso/infinispan/InfinispanSSOManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.sso.infinispan; import org.wildfly.clustering.ee.infinispan.InfinispanCacheConfiguration; /** * Configuration of an Infinispan single sign-on management provider. * @author Paul Ferraro */ public interface InfinispanSSOManagementConfiguration extends InfinispanCacheConfiguration { }
1,358
40.181818
92
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/sso/infinispan/InfinispanLegacySSOManagementProviderFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.sso.infinispan; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.web.service.sso.DistributableSSOManagementProvider; import org.wildfly.clustering.web.service.sso.LegacySSOManagementProviderFactory; /** * @author Paul Ferraro */ @MetaInfServices(LegacySSOManagementProviderFactory.class) public class InfinispanLegacySSOManagementProviderFactory implements LegacySSOManagementProviderFactory, InfinispanSSOManagementConfiguration { @Override public DistributableSSOManagementProvider createSSOManagementProvider() { return new InfinispanSSOManagementProvider(this); } @Override public String getContainerName() { return "web"; } @Override public String getCacheName() { return null; } }
1,840
35.82
143
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/sso/infinispan/InfinispanSSOManagerFactoryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.sso.infinispan; import java.util.function.Consumer; import java.util.function.Supplier; import org.infinispan.Cache; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.infinispan.affinity.KeyAffinityServiceFactory; import org.wildfly.clustering.infinispan.service.CacheServiceConfigurator; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanRequirement; import org.wildfly.clustering.infinispan.service.TemplateConfigurationServiceConfigurator; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.infinispan.sso.InfinispanSSOManagerFactory; import org.wildfly.clustering.web.infinispan.sso.InfinispanSSOManagerFactoryConfiguration; import org.wildfly.clustering.web.sso.SSOManagerFactory; public class InfinispanSSOManagerFactoryServiceConfigurator<A, D, S> extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, InfinispanSSOManagerFactoryConfiguration { private final String name; private final String containerName; private final String cacheName; private volatile ServiceConfigurator configurationConfigurator; private volatile ServiceConfigurator cacheConfigurator; private volatile SupplierDependency<KeyAffinityServiceFactory> affinityFactory; @SuppressWarnings("rawtypes") private volatile Supplier<Cache> cache; public InfinispanSSOManagerFactoryServiceConfigurator(InfinispanSSOManagementConfiguration config, String name) { super(ServiceName.JBOSS.append("clustering", "sso", name)); this.name = name; this.containerName = config.getContainerName(); this.cacheName = config.getCacheName(); } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { this.configurationConfigurator = new TemplateConfigurationServiceConfigurator(InfinispanCacheRequirement.CONFIGURATION.getServiceName(support, this.containerName, this.name), this.containerName, this.name, this.cacheName).configure(support); this.cacheConfigurator = new CacheServiceConfigurator<>(InfinispanCacheRequirement.CACHE.getServiceName(support, this.containerName, this.name), this.containerName, this.name).configure(support); this.affinityFactory = new ServiceSupplierDependency<>(InfinispanRequirement.KEY_AFFINITY_FACTORY.getServiceName(support, this.containerName)); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { this.configurationConfigurator.build(target).install(); this.cacheConfigurator.build(target).install(); ServiceBuilder<?> builder = target.addService(this.getServiceName()); Consumer<SSOManagerFactory<A, D, S, TransactionBatch>> factory = this.affinityFactory.register(builder).provides(this.getServiceName()); this.cache = builder.requires(this.cacheConfigurator.getServiceName()); Service service = Service.newInstance(factory, new InfinispanSSOManagerFactory<>(this)); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } @Override public <K, V> Cache<K, V> getCache() { return this.cache.get(); } @Override public KeyAffinityServiceFactory getKeyAffinityServiceFactory() { return this.affinityFactory.get(); } }
5,028
49.29
249
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/MutableRankedRoutingConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import org.wildfly.clustering.web.infinispan.routing.RankedRoutingConfiguration; import org.wildfly.extension.clustering.web.RankedAffinityResourceDefinition; /** * @author Paul Ferraro */ public class MutableRankedRoutingConfiguration implements RankedRoutingConfiguration { private String delimter = RankedAffinityResourceDefinition.Attribute.DELIMITER.getDefinition().getDefaultValue().asString(); private int maxRoutes = RankedAffinityResourceDefinition.Attribute.MAX_ROUTES.getDefinition().getDefaultValue().asInt(); @Override public String getDelimiter() { return this.delimter; } public void setDelimiter(String delimiter) { this.delimter = delimiter; } @Override public int getMaxRoutes() { return this.maxRoutes; } public void setMaxRoutes(int maxRoutes) { this.maxRoutes = maxRoutes; } }
1,968
35.462963
128
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/MutableSessionManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.function.Function; import java.util.function.UnaryOperator; import org.jboss.as.server.deployment.DeploymentUnit; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy; import org.wildfly.extension.clustering.web.SessionGranularity; import org.wildfly.extension.clustering.web.SessionMarshallerFactory; /** * @author Paul Ferraro */ public class MutableSessionManagementConfiguration implements DistributableSessionManagementConfiguration<DeploymentUnit>, UnaryOperator<String> { private final UnaryOperator<String> replacer; private SessionGranularity granularity; private Function<DeploymentUnit, ByteBufferMarshaller> marshallerFactory = SessionMarshallerFactory.JBOSS; MutableSessionManagementConfiguration(UnaryOperator<String> replacer) { this.replacer = replacer; } @Override public SessionAttributePersistenceStrategy getAttributePersistenceStrategy() { return (this.granularity != null) ? this.granularity.getAttributePersistenceStrategy() : null; } @Override public Function<DeploymentUnit, ByteBufferMarshaller> getMarshallerFactory() { return this.marshallerFactory; } public void setSessionGranularity(String value) { this.granularity = SessionGranularity.valueOf(this.replacer.apply(value)); } public void setMarshallerFactory(String value) { this.marshallerFactory = SessionMarshallerFactory.valueOf(this.replacer.apply(value)); } @Override public String apply(String value) { return this.replacer.apply(value); } }
2,841
38.472222
146
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentDependencyProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.Collections; import java.util.List; import java.util.function.Consumer; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.server.deployment.AttachmentKey; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.as.web.common.WarMetaData; import org.jboss.as.web.session.SharedSessionManagerConfig; import org.jboss.logging.Logger; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.web.service.WebProviderRequirement; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; /** * {@link DeploymentUnitProcessor} that establishes the requisite {@link DistributableSessionManagementProvider} dependency * for distributable web and shared session deployments. * @author Paul Ferraro */ public class DistributableWebDeploymentDependencyProcessor implements DeploymentUnitProcessor { public static final AttachmentKey<DistributableWebDeploymentConfiguration> CONFIGURATION_KEY = AttachmentKey.create(DistributableWebDeploymentConfiguration.class); private static final Logger LOGGER = Logger.getLogger(DistributableWebDeploymentDependencyProcessor.class); @Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { DeploymentUnit unit = context.getDeploymentUnit(); WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY); SharedSessionManagerConfig sharedConfig = unit.getAttachment(SharedSessionManagerConfig.ATTACHMENT_KEY); if (((warMetaData != null) && (warMetaData.getMergedJBossWebMetaData() != null && warMetaData.getMergedJBossWebMetaData().getDistributable() != null)) || ((sharedConfig != null) && sharedConfig.isDistributable())) { CapabilityServiceSupport support = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); DistributableWebDeploymentConfiguration config = unit.getAttachment(CONFIGURATION_KEY); String name = (config != null) ? config.getSessionManagementName() : null; DistributableSessionManagementProvider<? extends DistributableSessionManagementConfiguration<DeploymentUnit>> management = (name == null) && (config != null) ? config.getSessionManagement() : null; List<String> immutableClasses = (config != null) ? config.getImmutableClasses() : Collections.emptyList(); for (String immutableClass : immutableClasses) { unit.addToAttachmentList(DistributableSessionManagementProvider.IMMUTABILITY_ATTACHMENT_KEY, immutableClass); } if (management != null) { LOGGER.debugf("%s will use a deployment-specific distributable session management provider", unit.getName()); ServiceTarget target = context.getServiceTarget(); DeploymentUnit parentUnit = unit.getParent(); String deploymentName = (parentUnit != null) ? parentUnit.getName() + "." + unit.getName() : unit.getName(); ServiceName serviceName = WebProviderRequirement.SESSION_MANAGEMENT_PROVIDER.getServiceName(support, deploymentName); ServiceBuilder<?> builder = target.addService(serviceName); Consumer<DistributableSessionManagementProvider<? extends DistributableSessionManagementConfiguration<DeploymentUnit>>> injector = builder.provides(serviceName); Service service = Service.newInstance(injector, management); builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND).install(); context.addDependency(serviceName, DistributableSessionManagementProvider.ATTACHMENT_KEY); } else { if (name != null) { LOGGER.debugf("%s will use the '%s' distributable session management provider", unit.getName(), name); } else { LOGGER.debugf("%s will use the default distributable session management provider", unit.getName()); } context.addDependency(WebProviderRequirement.SESSION_MANAGEMENT_PROVIDER.getServiceName(support, name), DistributableSessionManagementProvider.ATTACHMENT_KEY); } } } @Override public void undeploy(DeploymentUnit unit) { unit.removeAttachment(DistributableSessionManagementProvider.IMMUTABILITY_ATTACHMENT_KEY); } }
6,012
55.726415
223
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentParsingProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.EnumSet; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.jboss.as.controller.xml.XMLElementSchema; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.as.server.logging.ServerLogger; import org.jboss.staxmapper.XMLMapper; import org.jboss.vfs.VirtualFile; /** * {@link DeploymentUnitProcessor} that parses a standalone distributable-web deployment descriptor. * @author Paul Ferraro */ public class DistributableWebDeploymentParsingProcessor implements DeploymentUnitProcessor { private static final String DISTRIBUTABLE_WEB_DEPLOYMENT_DESCRIPTOR = "WEB-INF/distributable-web.xml"; private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance(); private final XMLMapper mapper = XMLElementSchema.createXMLMapper(EnumSet.allOf(DistributableWebDeploymentSchema.class)); @Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { DeploymentUnit unit = context.getDeploymentUnit(); if (!unit.hasAttachment(DistributableWebDeploymentDependencyProcessor.CONFIGURATION_KEY)) { VirtualFile file = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot().getChild(DISTRIBUTABLE_WEB_DEPLOYMENT_DESCRIPTOR); if (file.exists()) { try { unit.putAttachment(DistributableWebDeploymentDependencyProcessor.CONFIGURATION_KEY, this.parse(unit, file.getPhysicalFile())); } catch (IOException e) { throw new DeploymentUnitProcessingException(e); } } } } @Override public void undeploy(DeploymentUnit unit) { unit.removeAttachment(DistributableWebDeploymentDependencyProcessor.CONFIGURATION_KEY); } private DistributableWebDeploymentConfiguration parse(DeploymentUnit unit, File file) throws DeploymentUnitProcessingException { try (FileReader reader = new FileReader(file)) { XMLStreamReader xmlReader = XML_INPUT_FACTORY.createXMLStreamReader(reader); try { MutableDistributableWebDeploymentConfiguration config = new MutableDistributableWebDeploymentConfiguration(unit); this.mapper.parseDocument(config, xmlReader); return config; } finally { xmlReader.close(); } } catch (XMLStreamException e) { throw ServerLogger.ROOT_LOGGER.errorLoadingDeploymentStructureFile(file.getPath(), e); } catch (FileNotFoundException e) { throw ServerLogger.ROOT_LOGGER.deploymentStructureFileNotFound(file); } catch (IOException e) { throw ServerLogger.ROOT_LOGGER.deploymentStructureFileNotFound(file); } } }
4,314
44.421053
146
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/MutableHotRodSessionManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.function.UnaryOperator; import org.jboss.as.server.deployment.DeploymentUnit; import org.wildfly.extension.clustering.web.session.hotrod.HotRodSessionManagementConfiguration; /** * @author Paul Ferraro */ public class MutableHotRodSessionManagementConfiguration extends MutableSessionManagementConfiguration implements HotRodSessionManagementConfiguration<DeploymentUnit> { private volatile String containerName; private volatile String configurationName; /** * Constructs a new HotRod session management configuration. * @param replacer a property replacer */ public MutableHotRodSessionManagementConfiguration(UnaryOperator<String> replacer) { super(replacer); } @Override public String getContainerName() { return this.containerName; } public void setContainerName(String containerName) { this.containerName = containerName; } @Override public String getConfigurationName() { return this.configurationName; } public void setConfigurationName(String configurationName) { this.configurationName = configurationName; } }
2,245
34.09375
168
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.List; import org.jboss.as.server.deployment.DeploymentUnit; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; /** * Configuration of a distributable web deployment. * @author Paul Ferraro */ public interface DistributableWebDeploymentConfiguration { /** * References the name of a session management provider. * @return a session management provider name */ String getSessionManagementName(); /** * Returns a deployment-specific session management provider. * @return a session management provider */ DistributableSessionManagementProvider<? extends DistributableSessionManagementConfiguration<DeploymentUnit>> getSessionManagement(); /** * Returns a list of immutable session attribute classes. * @return a list of class names */ List<String> getImmutableClasses(); }
2,071
37.37037
137
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/MutableDistributableWebDeploymentConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.function.Consumer; import java.util.function.UnaryOperator; import org.jboss.as.ee.structure.JBossDescriptorPropertyReplacement; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.metadata.property.PropertyReplacer; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; /** * @author Paul Ferraro */ public class MutableDistributableWebDeploymentConfiguration implements DistributableWebDeploymentConfiguration, UnaryOperator<String>, Consumer<String> { private final List<String> immutableClasses = new LinkedList<>(); private final PropertyReplacer replacer; private String managementName; private DistributableSessionManagementProvider<? extends DistributableSessionManagementConfiguration<DeploymentUnit>> management; public MutableDistributableWebDeploymentConfiguration(PropertyReplacer replacer) { this.replacer = replacer; } public MutableDistributableWebDeploymentConfiguration(DeploymentUnit unit) { this(JBossDescriptorPropertyReplacement.propertyReplacer(unit)); } @Override public DistributableSessionManagementProvider<? extends DistributableSessionManagementConfiguration<DeploymentUnit>> getSessionManagement() { return this.management; } public void setSessionManagement(DistributableSessionManagementProvider<? extends DistributableSessionManagementConfiguration<DeploymentUnit>> management) { this.management = management; } @Override public String getSessionManagementName() { return this.managementName; } public void setSessionManagementName(String value) { this.managementName = this.apply(value); } @Override public List<String> getImmutableClasses() { return Collections.unmodifiableList(this.immutableClasses); } @Override public void accept(String className) { this.immutableClasses.add(className); } @Override public String apply(String value) { return this.replacer.replaceProperties(value); } }
3,344
36.58427
160
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.controller.capability.CapabilityServiceSupport.NoSuchCapabilityException; import org.jboss.as.jsf.deployment.JsfVersionMarker; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.as.server.deployment.module.ModuleDependency; import org.jboss.as.server.deployment.module.ModuleSpecification; import org.jboss.as.weld.Capabilities; import org.jboss.as.weld.WeldCapability; import org.jboss.modules.Module; import org.jboss.modules.ModuleLoader; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; import org.wildfly.extension.clustering.web.SessionMarshallerFactory; /** * {@link DeploymentUnitProcessor} that attaches any configured {@link DistributableSessionManagementProvider} to the deployment unit. * @author Paul Ferraro */ public class DistributableWebDeploymentProcessor implements DeploymentUnitProcessor { private static final String WEB_API = "org.wildfly.clustering.web.api"; private static final String MARSHALLING_API = "org.wildfly.clustering.marshalling.api"; private static final String PROTOSTREAM = "org.infinispan.protostream"; private static final String EL_EXPRESSLY = "org.wildfly.clustering.el.expressly"; private static final String WELD_CORE = "org.wildfly.clustering.weld.core"; private static final String WELD_EJB = "org.wildfly.clustering.weld.ejb"; private static final String WELD_WEB = "org.wildfly.clustering.weld.web"; private static final String FACES_MOJARRA = "org.wildfly.clustering.faces.mojarra"; private static final String UNDERTOW = "org.wildfly.clustering.web.undertow"; @Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { DeploymentUnit unit = context.getDeploymentUnit(); DistributableSessionManagementProvider<DistributableSessionManagementConfiguration<DeploymentUnit>> provider = context.getAttachment(DistributableSessionManagementProvider.ATTACHMENT_KEY); if (provider != null) { unit.putAttachment(DistributableSessionManagementProvider.ATTACHMENT_KEY, provider); ModuleSpecification specification = unit.getAttachment(Attachments.MODULE_SPECIFICATION); ModuleLoader loader = Module.getBootModuleLoader(); specification.addSystemDependency(new ModuleDependency(loader, WEB_API, false, false, false, false)); if (provider.getSessionManagementConfiguration().getMarshallerFactory() == SessionMarshallerFactory.PROTOSTREAM) { specification.addSystemDependency(new ModuleDependency(loader, PROTOSTREAM, false, false, false, false)); specification.addSystemDependency(new ModuleDependency(loader, UNDERTOW, false, false, true, false)); CapabilityServiceSupport support = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); if (support.hasCapability(Capabilities.WELD_CAPABILITY_NAME)) { try { WeldCapability weldCapability = support.getCapabilityRuntimeAPI(Capabilities.WELD_CAPABILITY_NAME, WeldCapability.class); if (weldCapability.isPartOfWeldDeployment(unit)) { specification.addSystemDependency(new ModuleDependency(loader, EL_EXPRESSLY, false, false, true, false)); specification.addSystemDependency(new ModuleDependency(loader, WELD_CORE, false, false, true, false)); specification.addSystemDependency(new ModuleDependency(loader, WELD_EJB, false, false, true, false)); specification.addSystemDependency(new ModuleDependency(loader, WELD_WEB, false, false, true, false)); } } catch (NoSuchCapabilityException e) { throw new IllegalStateException(e); } } } else { specification.addSystemDependency(new ModuleDependency(loader, MARSHALLING_API, false, false, false, false)); } if (JsfVersionMarker.getVersion(unit).equals(JsfVersionMarker.JSF_4_0)) { specification.addSystemDependency(new ModuleDependency(loader, EL_EXPRESSLY, false, false, true, false)); specification.addSystemDependency(new ModuleDependency(loader, FACES_MOJARRA, false, false, true, false)); } } } @Override public void undeploy(DeploymentUnit unit) { unit.removeAttachment(DistributableSessionManagementProvider.ATTACHMENT_KEY); } }
6,097
57.07619
196
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/MutableInfinispanSessionManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.function.UnaryOperator; import org.jboss.as.server.deployment.DeploymentUnit; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration; /** * @author Paul Ferraro */ public class MutableInfinispanSessionManagementConfiguration extends MutableSessionManagementConfiguration implements InfinispanSessionManagementConfiguration<DeploymentUnit> { private String containerName; private String cacheName; public MutableInfinispanSessionManagementConfiguration(UnaryOperator<String> replacer) { super(replacer); } @Override public String getContainerName() { return this.containerName; } @Override public String getCacheName() { return this.cacheName; } public void setContainerName(String containerName) { this.containerName = this.apply(containerName); } public void setCacheName(String cacheName) { this.cacheName = this.apply(cacheName); } }
2,081
33.7
176
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentSchema.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.List; import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.xml.IntVersionSchema; import org.jboss.as.controller.xml.VersionedNamespace; import org.jboss.as.controller.xml.XMLElementSchema; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.jbossallxml.JBossAllSchema; import org.jboss.staxmapper.IntVersion; import org.jboss.staxmapper.XMLExtendedStreamReader; /** * Enumerate the schema versions of the distibutable-web deployment descriptor. * @author Paul Ferraro */ public enum DistributableWebDeploymentSchema implements XMLElementSchema<DistributableWebDeploymentSchema, MutableDistributableWebDeploymentConfiguration>, JBossAllSchema<DistributableWebDeploymentSchema, DistributableWebDeploymentConfiguration> { VERSION_1_0(1, 0), VERSION_2_0(2, 0), VERSION_3_0(3, 0), ; private final VersionedNamespace<IntVersion, DistributableWebDeploymentSchema> namespace; DistributableWebDeploymentSchema(int major, int minor) { this.namespace = IntVersionSchema.createURN(List.of(IntVersionSchema.JBOSS_IDENTIFIER, this.getLocalName()), new IntVersion(major, minor)); } @Override public String getLocalName() { return "distributable-web"; } @Override public VersionedNamespace<IntVersion, DistributableWebDeploymentSchema> getNamespace() { return this.namespace; } @Override public void readElement(XMLExtendedStreamReader reader, MutableDistributableWebDeploymentConfiguration configuration) throws XMLStreamException { new DistributableWebDeploymentXMLReader(this).readElement(reader, configuration); } @Override public DistributableWebDeploymentConfiguration parse(XMLExtendedStreamReader reader, DeploymentUnit unit) throws XMLStreamException { MutableDistributableWebDeploymentConfiguration configuration = new MutableDistributableWebDeploymentConfiguration(unit); this.readElement(reader, configuration); return configuration; } }
3,139
40.866667
247
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentXMLReader.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.deployment; import java.util.Arrays; import java.util.Set; import java.util.TreeSet; import java.util.function.Consumer; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.parsing.ParseUtils; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLExtendedStreamReader; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; import org.wildfly.extension.clustering.web.routing.LocalRouteLocatorServiceConfiguratorFactory; import org.wildfly.extension.clustering.web.routing.NullRouteLocatorServiceConfiguratorFactory; import org.wildfly.extension.clustering.web.routing.infinispan.PrimaryOwnerRouteLocatorServiceConfiguratorFactory; import org.wildfly.extension.clustering.web.routing.infinispan.RankedRouteLocatorServiceConfiguratorFactory; import org.wildfly.extension.clustering.web.session.hotrod.HotRodSessionManagementProvider; import org.wildfly.extension.clustering.web.session.infinispan.InfinispanSessionManagementProvider; /** * Parser for both jboss-all.xml distributable-web namespace parsing its standalone deployment descriptor counterpart. * @author Paul Ferraro */ public class DistributableWebDeploymentXMLReader implements XMLElementReader<MutableDistributableWebDeploymentConfiguration> { private static final String SESSION_MANAGEMENT = "session-management"; private static final String NAME = "name"; private static final String HOTROD_SESSION_MANAGEMENT = "hotrod-session-management"; private static final String INFINISPAN_SESSION_MANAGEMENT = "infinispan-session-management"; private static final String REMOTE_CACHE_CONTAINER = "remote-cache-container"; private static final String CACHE_CONFIGURATION = "cache-configuration"; private static final String CACHE_CONTAINER = "cache-container"; private static final String CACHE = "cache"; private static final String GRANULARITY = "granularity"; private static final String MARSHALLER = "marshaller"; private static final String NO_AFFINITY = "no-affinity"; private static final String LOCAL_AFFINITY = "local-affinity"; private static final String PRIMARY_OWNER_AFFINITY = "primary-owner-affinity"; private static final String RANKED_AFFINITY = "ranked-affinity"; private static final String DELIMITER = "delimiter"; private static final String MAX_ROUTES = "max-routes"; private static final String IMMUTABLE_CLASS = "immutable-class"; private final DistributableWebDeploymentSchema schema; public DistributableWebDeploymentXMLReader(DistributableWebDeploymentSchema schema) { this.schema = schema; } @Override public void readElement(XMLExtendedStreamReader reader, MutableDistributableWebDeploymentConfiguration configuration) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); Set<String> names = new TreeSet<>(); names.add(SESSION_MANAGEMENT); names.add(HOTROD_SESSION_MANAGEMENT); names.add(INFINISPAN_SESSION_MANAGEMENT); if (!reader.hasNext() || reader.nextTag() == XMLStreamConstants.END_ELEMENT) { throw ParseUtils.missingOneOf(reader, names); } switch (reader.getLocalName()) { case SESSION_MANAGEMENT: { this.readSessionManagement(reader, configuration); break; } case HOTROD_SESSION_MANAGEMENT: { MutableHotRodSessionManagementConfiguration config = new MutableHotRodSessionManagementConfiguration(configuration); configuration.setSessionManagement(new HotRodSessionManagementProvider(config)); this.readHotRodSessionManagement(reader, config); break; } case INFINISPAN_SESSION_MANAGEMENT: { MutableInfinispanSessionManagementConfiguration config = new MutableInfinispanSessionManagementConfiguration(configuration); RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> factory = this.readInfinispanSessionManagement(reader, config, configuration); configuration.setSessionManagement(new InfinispanSessionManagementProvider(config, factory)); break; } default: { throw ParseUtils.unexpectedElement(reader, names); } } if (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { throw ParseUtils.unexpectedElement(reader); } } private void readSessionManagement(XMLExtendedStreamReader reader, MutableDistributableWebDeploymentConfiguration configuration) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); ++i) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); switch (name) { case NAME: { configuration.setSessionManagementName(value); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } this.readImmutability(reader, configuration); } @SuppressWarnings("static-method") private void readSessionManagementAttribute(XMLExtendedStreamReader reader, int index, MutableSessionManagementConfiguration configuration) throws XMLStreamException { String value = reader.getAttributeValue(index); switch (reader.getAttributeLocalName(index)) { case GRANULARITY: { try { configuration.setSessionGranularity(value); } catch (IllegalArgumentException e) { throw ParseUtils.invalidAttributeValue(reader, index); } break; } case MARSHALLER: { try { configuration.setMarshallerFactory(value); } catch (IllegalArgumentException e) { throw ParseUtils.invalidAttributeValue(reader, index); } break; } default: { throw ParseUtils.unexpectedAttribute(reader, index); } } } private RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> readInfinispanSessionManagement(XMLExtendedStreamReader reader, MutableInfinispanSessionManagementConfiguration configuration, Consumer<String> accumulator) throws XMLStreamException { Set<String> required = new TreeSet<>(Arrays.asList(CACHE_CONTAINER, GRANULARITY)); for (int i = 0; i < reader.getAttributeCount(); ++i) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); required.remove(name); switch (name) { case CACHE_CONTAINER: { configuration.setContainerName(value); break; } case CACHE: { configuration.setCacheName(value); break; } default: { this.readSessionManagementAttribute(reader, i, configuration); } } } if (!required.isEmpty()) { ParseUtils.requireAttributes(reader, required.toArray(new String[required.size()])); } RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> affinityFactory = this.readInfinispanAffinity(reader); this.readImmutability(reader, accumulator); return affinityFactory; } private RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> readInfinispanAffinity(XMLExtendedStreamReader reader) throws XMLStreamException { if (!reader.hasNext() || reader.nextTag() == XMLStreamConstants.END_ELEMENT) { throw ParseUtils.missingRequiredElement(reader, new TreeSet<>(Arrays.asList(NO_AFFINITY, LOCAL_AFFINITY, PRIMARY_OWNER_AFFINITY))); } switch (reader.getLocalName()) { case PRIMARY_OWNER_AFFINITY: { ParseUtils.requireNoContent(reader); return new PrimaryOwnerRouteLocatorServiceConfiguratorFactory<>(); } case RANKED_AFFINITY: { if (this.schema.since(DistributableWebDeploymentSchema.VERSION_2_0)) { MutableRankedRoutingConfiguration config = new MutableRankedRoutingConfiguration(); for (int i = 0; i < reader.getAttributeCount(); ++i) { String value = reader.getAttributeValue(i); switch (reader.getAttributeLocalName(i)) { case DELIMITER: { config.setDelimiter(value); break; } case MAX_ROUTES: { config.setMaxRoutes(Integer.parseInt(value)); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); return new RankedRouteLocatorServiceConfiguratorFactory<>(config); } } default: { return this.readAffinity(reader); } } } private RouteLocatorServiceConfiguratorFactory<DistributableSessionManagementConfiguration<DeploymentUnit>> readHotRodSessionManagement(XMLExtendedStreamReader reader, MutableHotRodSessionManagementConfiguration configuration) throws XMLStreamException { Set<String> required = new TreeSet<>(Arrays.asList(REMOTE_CACHE_CONTAINER, GRANULARITY)); for (int i = 0; i < reader.getAttributeCount(); ++i) { String localName = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); required.remove(localName); switch (localName) { case REMOTE_CACHE_CONTAINER: { configuration.setContainerName(value); break; } case CACHE_CONFIGURATION: { configuration.setConfigurationName(value); break; } default: { this.readSessionManagementAttribute(reader, i, configuration); } } } if (!required.isEmpty()) { ParseUtils.requireAttributes(reader, required.toArray(new String[required.size()])); } if (!reader.hasNext() || reader.nextTag() == XMLStreamConstants.END_ELEMENT) { throw ParseUtils.missingRequiredElement(reader, new TreeSet<>(Arrays.asList(NO_AFFINITY, LOCAL_AFFINITY))); } return this.readAffinity(reader); } @SuppressWarnings("static-method") private <C> RouteLocatorServiceConfiguratorFactory<C> readAffinity(XMLExtendedStreamReader reader) throws XMLStreamException { switch (reader.getLocalName()) { case NO_AFFINITY: { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); return new NullRouteLocatorServiceConfiguratorFactory<>(); } case LOCAL_AFFINITY: { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); return new LocalRouteLocatorServiceConfiguratorFactory<>(); } default: { throw ParseUtils.unexpectedElement(reader); } } } @SuppressWarnings("static-method") private void readImmutability(XMLExtendedStreamReader reader, Consumer<String> accumulator) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (reader.getLocalName()) { case IMMUTABLE_CLASS: { ParseUtils.requireNoAttributes(reader); accumulator.accept(reader.getElementText()); break; } default: { throw ParseUtils.unexpectedElement(reader); } } } } }
14,008
44.33657
293
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/session/hotrod/HotRodSessionManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.session.hotrod; import org.wildfly.clustering.ee.hotrod.RemoteCacheConfiguration; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; /** * Configuration of an {@link InfinispanSessionManagementProvider}. * @author Paul Ferraro */ public interface HotRodSessionManagementConfiguration<M> extends DistributableSessionManagementConfiguration<M>, RemoteCacheConfiguration { }
1,482
42.617647
139
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/session/hotrod/HotRodSessionManagerFactoryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.session.hotrod; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.infinispan.client.hotrod.DefaultTemplate; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.configuration.NearCacheMode; import org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder; import org.infinispan.client.hotrod.configuration.TransactionMode; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.clustering.function.Consumers; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ee.Immutability; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.infinispan.client.service.RemoteCacheServiceConfigurator; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.LocalContextFactory; import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactory; import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactoryConfiguration; import org.wildfly.clustering.web.hotrod.session.SessionManagerNearCacheFactory; import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy; import org.wildfly.clustering.web.session.SessionManagerFactory; import org.wildfly.clustering.web.session.SessionManagerFactoryConfiguration; import org.wildfly.clustering.web.session.SpecificationProvider; /** * @param <S> the HttpSession specification type * @param <SC> the ServletContext specification type * @param <AL> the HttpSessionAttributeListener specification type * @param <MC> the marshalling context type * @param <LC> the local context type * @author Paul Ferraro */ public class HotRodSessionManagerFactoryServiceConfigurator<S, SC, AL, LC> extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, HotRodSessionManagerFactoryConfiguration<S, SC, AL, LC>, Supplier<SessionManagerFactory<SC, LC, TransactionBatch>> { private final HotRodSessionManagementConfiguration<DeploymentUnit> configuration; private final SessionManagerFactoryConfiguration<S, SC, AL, LC> factoryConfiguration; private volatile ServiceConfigurator cacheConfigurator; @SuppressWarnings("rawtypes") private volatile SupplierDependency<RemoteCache> cache; public HotRodSessionManagerFactoryServiceConfigurator(HotRodSessionManagementConfiguration<DeploymentUnit> configuration, SessionManagerFactoryConfiguration<S, SC, AL, LC> factoryConfiguration) { super(ServiceName.JBOSS.append("clustering", "web", factoryConfiguration.getDeploymentName())); this.configuration = configuration; this.factoryConfiguration = factoryConfiguration; } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { Integer maxActiveSessions = this.getMaxActiveSessions(); NearCacheMode mode = (maxActiveSessions == null) || (maxActiveSessions == 0) ? NearCacheMode.DISABLED : NearCacheMode.INVALIDATED; String configurationName = this.configuration.getConfigurationName(); String templateName = (configurationName != null) ? configurationName : DefaultTemplate.DIST_SYNC.getTemplateName(); SessionAttributePersistenceStrategy strategy = this.getAttributePersistenceStrategy(); this.cacheConfigurator = new RemoteCacheServiceConfigurator<>(this.getServiceName().append("cache"), this.configuration.getContainerName(), this.getDeploymentName(), new Consumer<RemoteCacheConfigurationBuilder>() { @Override public void accept(RemoteCacheConfigurationBuilder builder) { builder.forceReturnValues(false).nearCacheMode(mode).templateName(templateName).transactionMode(TransactionMode.NONE).nearCacheFactory(new SessionManagerNearCacheFactory(maxActiveSessions, strategy)); } }).configure(support); this.cache = new ServiceSupplierDependency<>(this.cacheConfigurator.getServiceName()); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { this.cacheConfigurator.build(target).install(); ServiceBuilder<?> builder = target.addService(this.getServiceName()); Consumer<SessionManagerFactory<SC, LC, TransactionBatch>> factory = this.cache.register(builder).provides(this.getServiceName()); Service service = new FunctionalService<>(factory, Function.identity(), this, Consumers.close()); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } @Override public SessionManagerFactory<SC, LC, TransactionBatch> get() { return new HotRodSessionManagerFactory<>(this); } @Override public SessionAttributePersistenceStrategy getAttributePersistenceStrategy() { return this.factoryConfiguration.getAttributePersistenceStrategy(); } @Override public ByteBufferMarshaller getMarshaller() { return this.factoryConfiguration.getMarshaller(); } @Override public Integer getMaxActiveSessions() { return this.factoryConfiguration.getMaxActiveSessions(); } @Override public LocalContextFactory<LC> getLocalContextFactory() { return this.factoryConfiguration.getLocalContextFactory(); } @Override public String getServerName() { return this.factoryConfiguration.getServerName(); } @Override public String getDeploymentName() { return this.factoryConfiguration.getDeploymentName(); } @Override public Immutability getImmutability() { return this.factoryConfiguration.getImmutability(); } @Override public <K, V> RemoteCache<K, V> getCache() { return this.cache.get(); } @Override public SpecificationProvider<S, SC, AL> getSpecificationProvider() { return this.factoryConfiguration.getSpecificationProvider(); } }
7,639
46.453416
268
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/session/hotrod/HotRodSessionManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.session.hotrod; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.server.deployment.DeploymentUnit; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.session.SessionManagerFactoryConfiguration; import org.wildfly.extension.clustering.web.routing.LocalRouteLocatorServiceConfigurator; /** * @author Paul Ferraro */ public class HotRodSessionManagementProvider implements DistributableSessionManagementProvider<HotRodSessionManagementConfiguration<DeploymentUnit>> { private final HotRodSessionManagementConfiguration<DeploymentUnit> configuration; public HotRodSessionManagementProvider(HotRodSessionManagementConfiguration<DeploymentUnit> configuration) { this.configuration = configuration; } @Override public <S, SC, AL, LC> CapabilityServiceConfigurator getSessionManagerFactoryServiceConfigurator(SessionManagerFactoryConfiguration<S, SC, AL, LC> config) { return new HotRodSessionManagerFactoryServiceConfigurator<>(this.configuration, config); } @Override public CapabilityServiceConfigurator getRouteLocatorServiceConfigurator(WebDeploymentConfiguration configuration) { return new LocalRouteLocatorServiceConfigurator(configuration); } @Override public HotRodSessionManagementConfiguration<DeploymentUnit> getSessionManagementConfiguration() { return this.configuration; } }
2,620
44.189655
160
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/session/infinispan/InfinispanSessionManagerFactoryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.session.infinispan; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.infinispan.Cache; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.ExpirationConfiguration; import org.infinispan.configuration.cache.StorageType; import org.infinispan.eviction.EvictionStrategy; import org.infinispan.remoting.transport.Address; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.clustering.controller.CompositeServiceBuilder; import org.jboss.as.clustering.function.Consumers; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ee.Immutability; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.infinispan.affinity.KeyAffinityServiceFactory; import org.wildfly.clustering.infinispan.container.DataContainerConfigurationBuilder; import org.wildfly.clustering.infinispan.service.CacheServiceConfigurator; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanRequirement; import org.wildfly.clustering.infinispan.service.TemplateConfigurationServiceConfigurator; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.server.NodeFactory; import org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory; import org.wildfly.clustering.server.service.ClusteringCacheRequirement; import org.wildfly.clustering.server.service.ClusteringRequirement; import org.wildfly.clustering.server.service.ProvidedCacheServiceConfigurator; import org.wildfly.clustering.server.service.group.DistributedCacheGroupServiceConfiguratorProvider; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.LocalContextFactory; import org.wildfly.clustering.web.infinispan.logging.InfinispanWebLogger; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagerFactory; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagerFactoryConfiguration; import org.wildfly.clustering.web.infinispan.session.SessionCreationMetaDataKey; import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy; import org.wildfly.clustering.web.session.SessionManagerFactory; import org.wildfly.clustering.web.session.SessionManagerFactoryConfiguration; import org.wildfly.clustering.web.session.SpecificationProvider; /** * @param <S> the HttpSession specification type * @param <SC> the ServletContext specification type * @param <AL> the HttpSessionAttributeListener specification type * @param <LC> the local context type * @author Paul Ferraro */ public class InfinispanSessionManagerFactoryServiceConfigurator<S, SC, AL, LC> extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, InfinispanSessionManagerFactoryConfiguration<S, SC, AL, LC>, Supplier<SessionManagerFactory<SC, LC, TransactionBatch>>, Consumer<ConfigurationBuilder> { private final InfinispanSessionManagementConfiguration<DeploymentUnit> configuration; private final SessionManagerFactoryConfiguration<S, SC, AL, LC> factoryConfiguration; private volatile ServiceConfigurator configurationConfigurator; private volatile ServiceConfigurator cacheConfigurator; private volatile ServiceConfigurator groupConfigurator; private volatile SupplierDependency<NodeFactory<Address>> group; private volatile SupplierDependency<KeyAffinityServiceFactory> affinityFactory; private volatile SupplierDependency<CommandDispatcherFactory> dispatcherFactory; @SuppressWarnings("rawtypes") private volatile Supplier<Cache> cache; public InfinispanSessionManagerFactoryServiceConfigurator(InfinispanSessionManagementConfiguration<DeploymentUnit> configuration, SessionManagerFactoryConfiguration<S, SC, AL, LC> factoryConfiguration) { super(ServiceName.JBOSS.append("clustering", "web", factoryConfiguration.getDeploymentName())); this.configuration = configuration; this.factoryConfiguration = factoryConfiguration; } @Override public SessionManagerFactory<SC, LC, TransactionBatch> get() { return new InfinispanSessionManagerFactory<>(this); } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { String containerName = this.configuration.getContainerName(); String cacheName = this.configuration.getCacheName(); String deploymentName = this.factoryConfiguration.getDeploymentName(); this.configurationConfigurator = new TemplateConfigurationServiceConfigurator(InfinispanCacheRequirement.CONFIGURATION.getServiceName(support, containerName, deploymentName), containerName, deploymentName, cacheName, this).configure(support); this.cacheConfigurator = new CacheServiceConfigurator<>(InfinispanCacheRequirement.CACHE.getServiceName(support, containerName, deploymentName), containerName, deploymentName).configure(support); this.groupConfigurator = new ProvidedCacheServiceConfigurator<>(DistributedCacheGroupServiceConfiguratorProvider.class, this.configuration.getContainerName(), this.factoryConfiguration.getDeploymentName()).configure(support); this.affinityFactory = new ServiceSupplierDependency<>(InfinispanRequirement.KEY_AFFINITY_FACTORY.getServiceName(support, containerName)); this.dispatcherFactory = new ServiceSupplierDependency<>(ClusteringRequirement.COMMAND_DISPATCHER_FACTORY.getServiceName(support, containerName)); this.group = new ServiceSupplierDependency<>(ClusteringCacheRequirement.GROUP.getServiceName(support, containerName, deploymentName)); return this; } @Override public void accept(ConfigurationBuilder builder) { // Ensure expiration is not enabled on cache ExpirationConfiguration expiration = builder.expiration().create(); if ((expiration.lifespan() >= 0) || (expiration.maxIdle() >= 0)) { builder.expiration().lifespan(-1).maxIdle(-1); InfinispanWebLogger.ROOT_LOGGER.expirationDisabled(InfinispanCacheRequirement.CONFIGURATION.resolve(this.configuration.getContainerName(), this.configuration.getCacheName())); } Integer size = this.factoryConfiguration.getMaxActiveSessions(); EvictionStrategy strategy = (size != null) ? EvictionStrategy.REMOVE : EvictionStrategy.NONE; builder.memory().storage(StorageType.HEAP) .whenFull(strategy) .maxCount((size != null) ? size.longValue() : 0) ; if (strategy.isEnabled()) { // Only evict creation meta-data entries // We will cascade eviction to the remaining entries for a given session builder.addModule(DataContainerConfigurationBuilder.class).evictable(SessionCreationMetaDataKey.class::isInstance); } } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceBuilder<?> configurationBuilder = this.configurationConfigurator.build(target); ServiceBuilder<?> cacheBuilder = this.cacheConfigurator.build(target); ServiceBuilder<?> groupBuilder = this.groupConfigurator.build(target); ServiceBuilder<?> builder = target.addService(this.getServiceName()); Consumer<SessionManagerFactory<SC, LC, TransactionBatch>> factory = new CompositeDependency(this.group, this.affinityFactory, this.dispatcherFactory).register(builder).provides(this.getServiceName()); this.cache = builder.requires(this.cacheConfigurator.getServiceName()); Service service = new FunctionalService<>(factory, Function.identity(), this, Consumers.close()); return new CompositeServiceBuilder<>(List.of(configurationBuilder, cacheBuilder, groupBuilder, builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND))); } @Override public <K, V> Cache<K, V> getCache() { return this.cache.get(); } @Override public KeyAffinityServiceFactory getKeyAffinityServiceFactory() { return this.affinityFactory.get(); } @Override public CommandDispatcherFactory getCommandDispatcherFactory() { return this.dispatcherFactory.get(); } @Override public NodeFactory<Address> getMemberFactory() { return this.group.get(); } @Override public SessionAttributePersistenceStrategy getAttributePersistenceStrategy() { return this.factoryConfiguration.getAttributePersistenceStrategy(); } @Override public ByteBufferMarshaller getMarshaller() { return this.factoryConfiguration.getMarshaller(); } @Override public Integer getMaxActiveSessions() { return this.factoryConfiguration.getMaxActiveSessions(); } @Override public String getServerName() { return this.factoryConfiguration.getServerName(); } @Override public String getDeploymentName() { return this.factoryConfiguration.getDeploymentName(); } @Override public LocalContextFactory<LC> getLocalContextFactory() { return this.factoryConfiguration.getLocalContextFactory(); } @Override public Immutability getImmutability() { return this.factoryConfiguration.getImmutability(); } @Override public SpecificationProvider<S, SC, AL> getSpecificationProvider() { return this.factoryConfiguration.getSpecificationProvider(); } }
11,339
50.545455
307
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/session/infinispan/InfinispanSessionManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.session.infinispan; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.server.deployment.DeploymentUnit; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.session.SessionManagerFactoryConfiguration; /** * An Infinispan cache-based {@link DistributableSessionManagementProvider}. * @author Paul Ferraro */ public class InfinispanSessionManagementProvider implements DistributableSessionManagementProvider<InfinispanSessionManagementConfiguration<DeploymentUnit>> { private final InfinispanSessionManagementConfiguration<DeploymentUnit> configuration; private final RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> factory; public InfinispanSessionManagementProvider(InfinispanSessionManagementConfiguration<DeploymentUnit> configuration, RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> factory) { this.configuration = configuration; this.factory = factory; } @Override public <S, SC, AL, LC> CapabilityServiceConfigurator getSessionManagerFactoryServiceConfigurator(SessionManagerFactoryConfiguration<S, SC, AL, LC> config) { return new InfinispanSessionManagerFactoryServiceConfigurator<>(this.configuration, config); } @Override public CapabilityServiceConfigurator getRouteLocatorServiceConfigurator(WebDeploymentConfiguration config) { return this.factory.createRouteLocatorServiceConfigurator(this.configuration, config); } @Override public InfinispanSessionManagementConfiguration<DeploymentUnit> getSessionManagementConfiguration() { return this.configuration; } public RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> getRouteLocatorServiceConfiguratorFactory() { return this.factory; } }
3,292
48.893939
226
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/session/infinispan/InfinispanLegacySessionManagementProviderFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.session.infinispan; import java.io.Externalizable; import java.io.Serializable; import java.util.function.Function; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.ServiceNameFactory; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.marshalling.MarshallingConfiguration; import org.jboss.marshalling.ModularClassResolver; import org.jboss.metadata.web.jboss.ReplicationConfig; import org.jboss.metadata.web.jboss.ReplicationGranularity; import org.jboss.modules.Module; import org.jboss.msc.service.ServiceName; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.jboss.DynamicExternalizerObjectTable; import org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller; import org.wildfly.clustering.marshalling.jboss.SimpleClassTable; import org.wildfly.clustering.marshalling.jboss.SimpleMarshallingConfigurationRepository; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration; import org.wildfly.clustering.web.service.WebRequirement; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.service.session.LegacySessionManagementProviderFactory; import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy; import org.wildfly.extension.clustering.web.routing.LocalRouteLocatorServiceConfigurator; import org.wildfly.extension.clustering.web.routing.infinispan.PrimaryOwnerRouteLocatorServiceConfigurator; /** * @author Paul Ferraro */ @MetaInfServices(LegacySessionManagementProviderFactory.class) @Deprecated public class InfinispanLegacySessionManagementProviderFactory implements LegacySessionManagementProviderFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>>, Function<DeploymentUnit, ByteBufferMarshaller> { private enum JBossMarshallingVersion implements Function<Module, MarshallingConfiguration> { VERSION_1() { @Override public MarshallingConfiguration apply(Module module) { MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setClassTable(new SimpleClassTable(Serializable.class, Externalizable.class)); return config; } }, VERSION_2() { @Override public MarshallingConfiguration apply(Module module) { MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setClassTable(new SimpleClassTable(Serializable.class, Externalizable.class)); config.setObjectTable(new DynamicExternalizerObjectTable(module.getClassLoader())); return config; } }, ; static final JBossMarshallingVersion CURRENT = VERSION_2; } @Override public DistributableSessionManagementProvider<InfinispanSessionManagementConfiguration<DeploymentUnit>> createSessionManagerProvider(DeploymentUnit unit, ReplicationConfig config) { // Determine container and cache names using legacy logic String replicationConfigCacheName = (config != null) ? config.getCacheName() : null; ServiceName replicationConfigServiceName = ServiceNameFactory.parseServiceName((replicationConfigCacheName != null) ? replicationConfigCacheName : "web"); ServiceName baseReplicationConfigServiceName = ServiceName.JBOSS.append("infinispan"); if (!baseReplicationConfigServiceName.isParentOf(replicationConfigServiceName)) { replicationConfigServiceName = baseReplicationConfigServiceName.append(replicationConfigServiceName); } String containerName = ((replicationConfigServiceName.length() > 3) ? replicationConfigServiceName.getParent() : replicationConfigServiceName).getSimpleName(); String cacheName = (replicationConfigServiceName.length() > 3) ? replicationConfigServiceName.getSimpleName() : null; InfinispanSessionManagementConfiguration<DeploymentUnit> configuration = new InfinispanSessionManagementConfiguration<>() { @Override public String getContainerName() { return containerName; } @Override public String getCacheName() { return cacheName; } @Override public SessionAttributePersistenceStrategy getAttributePersistenceStrategy() { ReplicationGranularity granularity = (config != null) ? config.getReplicationGranularity() : null; return (granularity == ReplicationGranularity.ATTRIBUTE) ? SessionAttributePersistenceStrategy.FINE : SessionAttributePersistenceStrategy.COARSE; } @Override public Function<DeploymentUnit, ByteBufferMarshaller> getMarshallerFactory() { // Legacy session management was hard-coded to use JBoss Marshalling return InfinispanLegacySessionManagementProviderFactory.this; } }; return new InfinispanSessionManagementProvider(configuration, new LegacyRouteLocatorServiceConfiguratorFactory(unit)); } @Override public ByteBufferMarshaller apply(DeploymentUnit unit) { Module module = unit.getAttachment(Attachments.MODULE); return new JBossByteBufferMarshaller(new SimpleMarshallingConfigurationRepository(JBossMarshallingVersion.class, JBossMarshallingVersion.CURRENT, module), module.getClassLoader()); } private static class LegacyRouteLocatorServiceConfiguratorFactory implements RouteLocatorServiceConfiguratorFactory<InfinispanSessionManagementConfiguration<DeploymentUnit>> { private final DeploymentUnit unit; LegacyRouteLocatorServiceConfiguratorFactory(DeploymentUnit unit) { this.unit = unit; } @Override public CapabilityServiceConfigurator createRouteLocatorServiceConfigurator(InfinispanSessionManagementConfiguration<DeploymentUnit> configuration, WebDeploymentConfiguration deploymentConfiguration) { CapabilityServiceSupport support = this.unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); // Legacy session management was hard-coded to use primary owner routing // Detect case where distributable-web subsystem exists, but configuration is not compatible with legacy deployment and thus local routing is required boolean forceLocalRouting = support.hasCapability(WebRequirement.ROUTING_PROVIDER.getName()) && !support.hasCapability(WebRequirement.INFINISPAN_ROUTING_PROVIDER.getName()); return forceLocalRouting ? new LocalRouteLocatorServiceConfigurator(deploymentConfiguration) : new PrimaryOwnerRouteLocatorServiceConfigurator(configuration, deploymentConfiguration); } } }
8,467
56.216216
219
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/LocalRouteLocatorServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.cache.routing.LocalRouteLocator; import org.wildfly.clustering.web.routing.RouteLocator; import org.wildfly.clustering.web.service.WebDeploymentRequirement; /** * Configures a service providing a local route locator. * @author Paul Ferraro */ public class LocalRouteLocatorServiceConfigurator extends RouteLocatorServiceNameProvider implements CapabilityServiceConfigurator, Supplier<RouteLocator> { private final WebDeploymentConfiguration deploymentConfiguration; private volatile SupplierDependency<String> route; public LocalRouteLocatorServiceConfigurator(WebDeploymentConfiguration deploymentConfiguration) { super(deploymentConfiguration); this.deploymentConfiguration = deploymentConfiguration; } @Override public RouteLocator get() { return new LocalRouteLocator(this.route.get()); } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { this.route = new ServiceSupplierDependency<>(WebDeploymentRequirement.LOCAL_ROUTE.getServiceName(support, this.deploymentConfiguration.getServerName())); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<RouteLocator> locator = this.route.register(builder).provides(name); Service service = new FunctionalService<>(locator, Function.identity(), this); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
3,467
42.35
161
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/LocalRouteLocatorServiceConfiguratorFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; /** * Factory for creating a service configurator for a local route locator. * @author Paul Ferraro */ public class LocalRouteLocatorServiceConfiguratorFactory<C> implements RouteLocatorServiceConfiguratorFactory<C> { @Override public CapabilityServiceConfigurator createRouteLocatorServiceConfigurator(C configuration, WebDeploymentConfiguration deploymentConfiguration) { return new LocalRouteLocatorServiceConfigurator(deploymentConfiguration); } }
1,781
43.55
149
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/LocalRouteServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing; import java.util.function.Consumer; import java.util.function.Function; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.ServiceNameFactory; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.service.WebDeploymentRequirement; /** * @author Paul Ferraro */ public class LocalRouteServiceConfigurator extends SimpleServiceNameProvider implements CapabilityServiceConfigurator { private final SupplierDependency<String> route; public LocalRouteServiceConfigurator(String serverName, SupplierDependency<String> route) { super(ServiceNameFactory.parseServiceName(WebDeploymentRequirement.LOCAL_ROUTE.getName()).append(serverName)); this.route = route; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceBuilder<?> builder = target.addService(this.getServiceName()); Consumer<String> route = this.route.register(builder).provides(this.getServiceName()); Service service = new FunctionalService<>(route, Function.identity(), this.route); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
2,587
42.864407
119
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/LocalRoutingProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing; import java.util.Collections; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.service.routing.RoutingProvider; /** * @author Paul Ferraro */ public class LocalRoutingProvider implements RoutingProvider { @Override public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String serverName, SupplierDependency<String> route) { return Collections.singleton(new LocalRouteServiceConfigurator(serverName, route)); } }
1,649
39.243902
129
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/RouteLocatorServiceNameProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing; import org.jboss.as.controller.ServiceNameFactory; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.service.WebDeploymentRequirement; /** * Service name provider for a route locator service. * @author Paul Ferraro */ public class RouteLocatorServiceNameProvider extends SimpleServiceNameProvider { public RouteLocatorServiceNameProvider(WebDeploymentConfiguration configuration) { super(ServiceNameFactory.parseServiceName(WebDeploymentRequirement.ROUTE_LOCATOR.getName()).append(configuration.getDeploymentName())); } }
1,733
42.35
143
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/NullRouteLocatorServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing; import java.util.function.Consumer; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.cache.routing.NullRouteLocator; import org.wildfly.clustering.web.routing.RouteLocator; /** * Configures a service providing a null route locator. * @author Paul Ferraro */ public class NullRouteLocatorServiceConfigurator extends RouteLocatorServiceNameProvider implements CapabilityServiceConfigurator { public NullRouteLocatorServiceConfigurator(WebDeploymentConfiguration deploymentConfiguration) { super(deploymentConfiguration); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<RouteLocator> locator = builder.provides(name); Service service = Service.newInstance(locator, new NullRouteLocator()); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
2,383
41.571429
131
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/NullRouteLocatorServiceConfiguratorFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; /** * Factory for creating a service configurator for a null route locator. * @author Paul Ferraro */ public class NullRouteLocatorServiceConfiguratorFactory<C> implements RouteLocatorServiceConfiguratorFactory<C> { @Override public CapabilityServiceConfigurator createRouteLocatorServiceConfigurator(C configuration, WebDeploymentConfiguration deploymentConfiguration) { return new NullRouteLocatorServiceConfigurator(deploymentConfiguration); } }
1,778
43.475
149
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/RankedRouteLocatorServiceConfiguratorFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.ee.infinispan.InfinispanCacheConfiguration; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.infinispan.routing.RankedRoutingConfiguration; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; /** * Factory for creating a service configurator for a ranked route locator. * @author Paul Ferraro */ public class RankedRouteLocatorServiceConfiguratorFactory<C extends InfinispanCacheConfiguration> implements RouteLocatorServiceConfiguratorFactory<C> { private final RankedRoutingConfiguration config; public RankedRouteLocatorServiceConfiguratorFactory(RankedRoutingConfiguration config) { this.config = config; } @Override public CapabilityServiceConfigurator createRouteLocatorServiceConfigurator(C configuration, WebDeploymentConfiguration deploymentConfiguration) { return new RankedRouteLocatorServiceConfigurator(configuration, deploymentConfiguration, this.config); } public RankedRoutingConfiguration getConfiguration() { return this.config; } }
2,293
43.115385
152
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/InfinispanLegacyRoutingProviderFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import org.infinispan.commons.configuration.attributes.AttributeSet; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.ClusteringConfiguration; import org.infinispan.configuration.cache.ClusteringConfigurationBuilder; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.StateTransferConfiguration; import org.infinispan.configuration.cache.StateTransferConfigurationBuilder; import org.infinispan.configuration.cache.StorageType; import org.infinispan.eviction.EvictionStrategy; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.infinispan.configuration.ConfigurationBuilderAttributesAccessor; import org.wildfly.clustering.infinispan.container.DataContainerConfigurationBuilder; import org.wildfly.clustering.web.service.routing.LegacyRoutingProviderFactory; import org.wildfly.clustering.web.service.routing.RoutingProvider; /** * Legacy affinity provider using hard coded values from WF14 and earlier. * @author Paul Ferraro */ @Deprecated @MetaInfServices(LegacyRoutingProviderFactory.class) public class InfinispanLegacyRoutingProviderFactory implements LegacyRoutingProviderFactory, InfinispanRoutingConfiguration { @Override public RoutingProvider createRoutingProvider() { return new InfinispanRoutingProvider(this); } @Override public String getContainerName() { return "web"; } @Override public String getCacheName() { return null; } @Override public void accept(ConfigurationBuilder builder) { ClusteringConfigurationBuilder clustering = builder.clustering(); CacheMode mode = clustering.cacheMode(); clustering.cacheMode(mode.needsStateTransfer() ? CacheMode.REPL_SYNC : CacheMode.LOCAL); clustering.l1().disable(); // Workaround for ISPN-8722 AttributeSet attributes = ConfigurationBuilderAttributesAccessor.INSTANCE.apply(clustering); attributes.attribute(ClusteringConfiguration.BIAS_ACQUISITION).reset(); attributes.attribute(ClusteringConfiguration.BIAS_LIFESPAN).reset(); attributes.attribute(ClusteringConfiguration.INVALIDATION_BATCH_SIZE).reset(); // Ensure we use the default data container builder.addModule(DataContainerConfigurationBuilder.class).evictable(null); // Disable expiration builder.expiration().lifespan(-1).maxIdle(-1); // Disable eviction builder.memory().storage(StorageType.HEAP).maxCount(-1).whenFull(EvictionStrategy.NONE); builder.persistence().clearStores(); StateTransferConfigurationBuilder stateTransfer = clustering.stateTransfer().fetchInMemoryState(mode.needsStateTransfer()); attributes = ConfigurationBuilderAttributesAccessor.INSTANCE.apply(stateTransfer); attributes.attribute(StateTransferConfiguration.AWAIT_INITIAL_TRANSFER).reset(); attributes.attribute(StateTransferConfiguration.TIMEOUT).reset(); } }
4,107
46.218391
131
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/PrimaryOwnerRouteLocatorServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.infinispan.Cache; import org.infinispan.remoting.transport.Address; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ee.infinispan.GroupedKey; import org.wildfly.clustering.ee.infinispan.InfinispanCacheConfiguration; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.registry.Registry; import org.wildfly.clustering.server.NodeFactory; import org.wildfly.clustering.server.service.ClusteringCacheRequirement; import org.wildfly.clustering.service.AsyncServiceConfigurator; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.infinispan.routing.PrimaryOwnerRouteLocator; import org.wildfly.clustering.web.infinispan.routing.PrimaryOwnerRouteLocatorConfiguration; import org.wildfly.clustering.web.routing.RouteLocator; import org.wildfly.extension.clustering.web.routing.RouteLocatorServiceNameProvider; /** * Configures a service providing a primary owner route locator. * @author Paul Ferraro */ public class PrimaryOwnerRouteLocatorServiceConfigurator extends RouteLocatorServiceNameProvider implements CapabilityServiceConfigurator, PrimaryOwnerRouteLocatorConfiguration, Supplier<RouteLocator> { private final InfinispanCacheConfiguration configuration; private final WebDeploymentConfiguration deploymentConfiguration; private volatile SupplierDependency<Registry<String, Void>> registry; private volatile SupplierDependency<Cache<GroupedKey<String>, ?>> cache; private volatile SupplierDependency<NodeFactory<Address>> factory; public PrimaryOwnerRouteLocatorServiceConfigurator(InfinispanCacheConfiguration configuration, WebDeploymentConfiguration deploymentConfiguration) { super(deploymentConfiguration); this.configuration = configuration; this.deploymentConfiguration = deploymentConfiguration; } @Override public RouteLocator get() { return new PrimaryOwnerRouteLocator(this); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = new AsyncServiceConfigurator(name).build(target); Consumer<RouteLocator> locator = new CompositeDependency(this.registry, this.cache, this.factory).register(builder).provides(name); Service service = new FunctionalService<>(locator, Function.identity(), this); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { this.registry = new ServiceSupplierDependency<>(ClusteringCacheRequirement.REGISTRY.getServiceName(support, this.configuration.getContainerName(), this.deploymentConfiguration.getServerName())); this.factory = new ServiceSupplierDependency<>(ClusteringCacheRequirement.GROUP.getServiceName(support, this.configuration.getContainerName(), this.deploymentConfiguration.getServerName())); this.cache = new ServiceSupplierDependency<>(InfinispanCacheRequirement.CACHE.getServiceName(support, this.configuration.getContainerName(), this.deploymentConfiguration.getDeploymentName())); return this; } @Override public Registry<String, Void> getRegistry() { return this.registry.get(); } @Override public Cache<GroupedKey<String>, ?> getCache() { return this.cache.get(); } @Override public NodeFactory<Address> getMemberFactory() { return this.factory.get(); } }
5,396
47.1875
202
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/RankedRouteLocatorServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import org.wildfly.clustering.ee.infinispan.InfinispanCacheConfiguration; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.infinispan.routing.RankedRouteLocator; import org.wildfly.clustering.web.infinispan.routing.RankedRouteLocatorConfiguration; import org.wildfly.clustering.web.infinispan.routing.RankedRoutingConfiguration; import org.wildfly.clustering.web.routing.RouteLocator; /** * Configures a service providing a ranked route locator. * @author Paul Ferraro */ public class RankedRouteLocatorServiceConfigurator extends PrimaryOwnerRouteLocatorServiceConfigurator implements RankedRouteLocatorConfiguration { private final RankedRoutingConfiguration config; public RankedRouteLocatorServiceConfigurator(InfinispanCacheConfiguration configuration, WebDeploymentConfiguration deploymentConfiguration, RankedRoutingConfiguration routeConfiguration) { super(configuration, deploymentConfiguration); this.config = routeConfiguration; } @Override public RouteLocator get() { return new RankedRouteLocator(this); } @Override public String getDelimiter() { return this.config.getDelimiter(); } @Override public int getMaxRoutes() { return this.config.getMaxRoutes(); } }
2,408
39.15
193
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/InfinispanRoutingConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import java.util.function.Consumer; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.wildfly.clustering.ee.infinispan.InfinispanCacheConfiguration; /** * Configuration of an Infinispan routing provider * @author Paul Ferraro */ public interface InfinispanRoutingConfiguration extends InfinispanCacheConfiguration, Consumer<ConfigurationBuilder> { }
1,470
39.861111
118
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/InfinispanRoutingProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import java.util.List; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.ServiceNameFactory; import org.wildfly.clustering.infinispan.service.CacheServiceConfigurator; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.TemplateConfigurationServiceConfigurator; import org.wildfly.clustering.server.service.ProvidedCacheServiceConfigurator; import org.wildfly.clustering.server.service.group.DistributedCacheGroupServiceConfiguratorProvider; import org.wildfly.clustering.server.service.registry.DistributedRegistryServiceConfiguratorProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.service.routing.RoutingProvider; import org.wildfly.extension.clustering.web.routing.LocalRouteServiceConfigurator; /** * Routing provider backed by an Infinispan cache. * @author Paul Ferraro */ public class InfinispanRoutingProvider implements RoutingProvider { private final InfinispanRoutingConfiguration config; public InfinispanRoutingProvider(InfinispanRoutingConfiguration config) { this.config = config; } @Override public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String serverName, SupplierDependency<String> route) { String containerName = this.config.getContainerName(); String cacheName = this.config.getCacheName(); CapabilityServiceConfigurator localRouteConfigurator = new LocalRouteServiceConfigurator(serverName, route); CapabilityServiceConfigurator registryEntryConfigurator = new RouteRegistryEntryProviderServiceConfigurator(containerName, serverName); CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(containerName, serverName), containerName, serverName, cacheName, this.config); CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(containerName, serverName), containerName, serverName); CapabilityServiceConfigurator groupConfigurator = new ProvidedCacheServiceConfigurator<>(DistributedCacheGroupServiceConfiguratorProvider.class, containerName, serverName); CapabilityServiceConfigurator registryConfigurator = new ProvidedCacheServiceConfigurator<>(DistributedRegistryServiceConfiguratorProvider.class, containerName, serverName); return List.of(localRouteConfigurator, registryEntryConfigurator, configurationConfigurator, cacheConfigurator, registryConfigurator, groupConfigurator); } }
3,872
58.584615
285
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/RouteRegistryEntryProviderServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.ServiceNameFactory; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.server.service.ClusteringCacheRequirement; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.clustering.web.infinispan.routing.RouteRegistryEntry; import org.wildfly.clustering.web.service.WebDeploymentRequirement; /** * Service that provides the {@link Map.Entry} for the routing {@link org.wildfly.clustering.registry.Registry}. * @author Paul Ferraro */ public class RouteRegistryEntryProviderServiceConfigurator extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, Function<String, Map.Entry<String, Void>> { private final SupplierDependency<String> route; public RouteRegistryEntryProviderServiceConfigurator(String containerName, String serverName) { super(ServiceNameFactory.parseServiceName(ClusteringCacheRequirement.REGISTRY_ENTRY.getName()).append(containerName, serverName)); this.route = new ServiceSupplierDependency<>(ServiceNameFactory.parseServiceName(WebDeploymentRequirement.LOCAL_ROUTE.getName()).append(serverName)); } @Override public Map.Entry<String, Void> apply(String route) { return new RouteRegistryEntry(route); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<Map.Entry<String, Void>> entry = this.route.register(builder).provides(name); Service service = new FunctionalService<>(entry, this, this.route); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
3,341
46.070423
178
java
null
wildfly-main/clustering/web/extension/src/main/java/org/wildfly/extension/clustering/web/routing/infinispan/PrimaryOwnerRouteLocatorServiceConfiguratorFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.extension.clustering.web.routing.infinispan; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.ee.infinispan.InfinispanCacheConfiguration; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; /** * Factory for creating a service configurator for a primary owner route locator. * @author Paul Ferraro */ public class PrimaryOwnerRouteLocatorServiceConfiguratorFactory<C extends InfinispanCacheConfiguration> implements RouteLocatorServiceConfiguratorFactory<C> { @Override public CapabilityServiceConfigurator createRouteLocatorServiceConfigurator(C configuration, WebDeploymentConfiguration deploymentConfiguration) { return new PrimaryOwnerRouteLocatorServiceConfigurator(configuration, deploymentConfiguration); } }
1,940
46.341463
158
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/WebDefaultProviderRequirement.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service; import org.jboss.as.clustering.controller.RequirementServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactoryProvider; import org.wildfly.clustering.service.Requirement; import org.wildfly.clustering.web.service.routing.RouteLocatorServiceConfiguratorFactory; import org.wildfly.clustering.web.service.session.DistributableSessionManagementProvider; import org.wildfly.clustering.web.service.sso.DistributableSSOManagementProvider; /** * @author Paul Ferraro */ public enum WebDefaultProviderRequirement implements Requirement, ServiceNameFactoryProvider { SESSION_MANAGEMENT_PROVIDER("org.wildfly.clustering.web.default-session-management-provider", DistributableSessionManagementProvider.class), SSO_MANAGEMENT_PROVIDER("org.wildfly.clustering.web.default-single-sign-on-management-provider", DistributableSSOManagementProvider.class), AFFINITY("org.wildfly.clustering.web.default-session-affinity", RouteLocatorServiceConfiguratorFactory.class), ; private final String name; private final Class<?> type; private final ServiceNameFactory factory; WebDefaultProviderRequirement(String name, Class<?> type) { this.name = name; this.type = type; this.factory = new RequirementServiceNameFactory(this); } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } @Override public ServiceNameFactory getServiceNameFactory() { return this.factory; } }
2,686
39.712121
144
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/WebProviderRequirement.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service; import org.jboss.as.clustering.controller.DefaultableUnaryServiceNameFactoryProvider; import org.jboss.as.clustering.controller.ServiceNameFactory; import org.jboss.as.clustering.controller.UnaryRequirementServiceNameFactory; import org.jboss.as.clustering.controller.UnaryServiceNameFactory; import org.wildfly.clustering.service.DefaultableUnaryRequirement; import org.wildfly.clustering.service.Requirement; /** * @author Paul Ferraro */ public enum WebProviderRequirement implements DefaultableUnaryRequirement, DefaultableUnaryServiceNameFactoryProvider { SESSION_MANAGEMENT_PROVIDER("org.wildfly.clustering.web.session-management-provider", WebDefaultProviderRequirement.SESSION_MANAGEMENT_PROVIDER), SSO_MANAGEMENT_PROVIDER("org.wildfly.clustering.web.single-sign-on-management-provider", WebDefaultProviderRequirement.SSO_MANAGEMENT_PROVIDER), AFFINITY("org.wildfly.clustering.web.session-affinity", WebDefaultProviderRequirement.AFFINITY), ; private final String name; private final UnaryServiceNameFactory factory; private final WebDefaultProviderRequirement defaultRequirement; WebProviderRequirement(String name, WebDefaultProviderRequirement defaultRequirement) { this.name = name; this.factory = new UnaryRequirementServiceNameFactory(this); this.defaultRequirement = defaultRequirement; } @Override public String getName() { return this.name; } @Override public UnaryServiceNameFactory getServiceNameFactory() { return this.factory; } @Override public ServiceNameFactory getDefaultServiceNameFactory() { return this.defaultRequirement; } @Override public Requirement getDefaultRequirement() { return this.defaultRequirement; } }
2,861
39.885714
149
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/WebDeploymentRequirement.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service; import org.jboss.as.clustering.controller.UnaryRequirementServiceNameFactory; import org.jboss.as.clustering.controller.UnaryServiceNameFactory; import org.jboss.as.clustering.controller.UnaryServiceNameFactoryProvider; import org.wildfly.clustering.service.UnaryRequirement; import org.wildfly.clustering.web.routing.RouteLocator; import org.wildfly.clustering.web.session.SessionManagerFactory; import org.wildfly.clustering.web.sso.SSOManagerFactory; /** * @author Paul Ferraro */ public enum WebDeploymentRequirement implements UnaryRequirement, UnaryServiceNameFactoryProvider { LOCAL_ROUTE("org.wildfly.clustering.web.local-route", String.class), ROUTE_LOCATOR("org.wildfly.clustering.web.route-locator", RouteLocator.class), SESSION_MANAGER_FACTORY("org.wildfly.clustering.web.session-manager-factory", SessionManagerFactory.class), SSO_MANAGER_FACTORY("org.wildfly.clustering.web.single-sign-on-manager-factory", SSOManagerFactory.class), ; private final String name; private final Class<?> type; private final UnaryServiceNameFactory factory; WebDeploymentRequirement(String name, Class<?> type) { this.name = name; this.type = type; this.factory = new UnaryRequirementServiceNameFactory(this); } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } @Override public UnaryServiceNameFactory getServiceNameFactory() { return this.factory; } }
2,612
38
111
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/WebRequirement.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service; import org.jboss.as.clustering.controller.RequirementServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactoryProvider; import org.wildfly.clustering.service.Requirement; import org.wildfly.clustering.web.service.routing.RoutingProvider; /** * Defines capability names common to a web container. * @author Paul Ferraro */ public enum WebRequirement implements Requirement, ServiceNameFactoryProvider { ROUTING_PROVIDER("org.wildfly.clustering.web.routing-provider", RoutingProvider.class), INFINISPAN_ROUTING_PROVIDER("org.wildfly.clustering.web.infinispan-routing-provider", RoutingProvider.class), ; private final String name; private final Class<?> type; private final ServiceNameFactory factory; WebRequirement(String name, Class<?> type) { this.name = name; this.type = type; this.factory = new RequirementServiceNameFactory(this); } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } @Override public ServiceNameFactory getServiceNameFactory() { return this.factory; } }
2,318
35.234375
113
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/sso/LegacySSOManagementProviderFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service.sso; /** * @author Paul Ferraro */ public interface LegacySSOManagementProviderFactory { DistributableSSOManagementProvider createSSOManagementProvider(); }
1,231
38.741935
70
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/sso/DistributableSSOManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service.sso; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; /** * @author Paul Ferraro */ public interface DistributableSSOManagementProvider { CapabilityServiceConfigurator getServiceConfigurator(String name); }
1,306
38.606061
72
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/session/LegacySessionManagementProviderFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service.session; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.metadata.web.jboss.ReplicationConfig; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; /** * @author Paul Ferraro */ @Deprecated public interface LegacySessionManagementProviderFactory<C extends DistributableSessionManagementConfiguration<DeploymentUnit>> { DistributableSessionManagementProvider<C> createSessionManagerProvider(DeploymentUnit unit, ReplicationConfig config); }
1,572
42.694444
128
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/session/DistributableSessionManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service.session; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.server.deployment.AttachmentKey; import org.jboss.as.server.deployment.AttachmentList; import org.jboss.as.server.deployment.DeploymentUnit; import org.wildfly.clustering.web.WebDeploymentConfiguration; import org.wildfly.clustering.web.session.DistributableSessionManagementConfiguration; import org.wildfly.clustering.web.session.SessionManagerFactoryConfiguration; /** * A distributable session management provider. * @author Paul Ferraro */ public interface DistributableSessionManagementProvider<C extends DistributableSessionManagementConfiguration<DeploymentUnit>> { AttachmentKey<DistributableSessionManagementProvider<DistributableSessionManagementConfiguration<DeploymentUnit>>> ATTACHMENT_KEY = AttachmentKey.create(DistributableSessionManagementProvider.class); AttachmentKey<AttachmentList<String>> IMMUTABILITY_ATTACHMENT_KEY = AttachmentKey.createList(String.class); /** * Returns a {@link CapabilityServiceConfigurator} used to configure a service providing a {@link org.wildfly.clustering.web.session.SessionManagerFactory}. * @param <S> the HttpSession specification type * @param <SC> the ServletContext specification type * @param <AL> the HttpSessionAttributeListener specification type * @param <LC> the local context type * @param configuration the configuration of the session manager factory * @return a service configurator */ <S, SC, AL, LC> CapabilityServiceConfigurator getSessionManagerFactoryServiceConfigurator(SessionManagerFactoryConfiguration<S, SC, AL, LC> configuration); /** * Returns a {@link CapabilityServiceConfigurator} used to configure a service providing a {@link org.wildfly.clustering.web.routing.RouteLocator}. * @param configuration the configuration of a deployment * @return a service configurator */ CapabilityServiceConfigurator getRouteLocatorServiceConfigurator(WebDeploymentConfiguration configuration); C getSessionManagementConfiguration(); }
3,167
50.934426
203
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/routing/LegacyRoutingProviderFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service.routing; /** * Creates a legacy routing provider. * @author Paul Ferraro */ @Deprecated public interface LegacyRoutingProviderFactory { RoutingProvider createRoutingProvider(); }
1,254
37.030303
70
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/routing/RouteLocatorServiceConfiguratorFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service.routing; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.web.WebDeploymentConfiguration; /** * Factory for creating a service configurator for a route locator. * @author Paul Ferraro */ public interface RouteLocatorServiceConfiguratorFactory<C> { CapabilityServiceConfigurator createRouteLocatorServiceConfigurator(C configuration, WebDeploymentConfiguration deploymentConfiguration); }
1,518
42.4
141
java
null
wildfly-main/clustering/web/service/src/main/java/org/wildfly/clustering/web/service/routing/RoutingProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.service.routing; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.wildfly.clustering.service.SupplierDependency; /** * Defines a routing provider. * @author Paul Ferraro */ public interface RoutingProvider { /** * Builds the server dependencies to be made available to every deployment. * @param serverName the name of the server * @param route the distinct route of the server * @return a service builder */ Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String serverName, SupplierDependency<String> route); }
1,662
38.595238
121
java
null
wildfly-main/clustering/web/container/src/main/java/org/wildfly/clustering/web/container/WebDeploymentConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.container; /** * Defines the configuration of a web deployment. * @author Paul Ferraro */ public interface WebDeploymentConfiguration { /** * Returns the target server name of this deployment * @return a server name */ String getServerName(); /** * Returns the name of this deployment * @return a deployment name */ String getDeploymentName(); }
1,457
32.906977
70
java
null
wildfly-main/clustering/web/container/src/main/java/org/wildfly/clustering/web/container/SessionManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.container; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.msc.service.ServiceName; /** * Container-specific session management provider for a deployment. * @author Paul Ferraro */ public interface SessionManagementProvider { /** * Returns a set of configurators for services providing a container-specific session manager factory. * @param name the service name of the session manager factory service * @param configuration the configuration of the session manager factory * @return a number of service configurators */ Iterable<CapabilityServiceConfigurator> getSessionManagerFactoryServiceConfigurators(ServiceName name, SessionManagerFactoryConfiguration configuration); /** * Returns set of configurators for services providing container-specific session affinity logic. * @param name the service name of the session affinity service * @param configuration the configuration of the deployment * @return a number of service configurators */ Iterable<CapabilityServiceConfigurator> getSessionAffinityServiceConfigurators(ServiceName name, WebDeploymentConfiguration configuration); }
2,261
44.24
157
java
null
wildfly-main/clustering/web/container/src/main/java/org/wildfly/clustering/web/container/SecurityDomainSingleSignOnManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.container; import java.util.function.Supplier; /** * Defines the container configuration for security domain-based single sign-on management. * @author Paul Ferraro */ public interface SecurityDomainSingleSignOnManagementConfiguration { /** * Returns the name of the associated security domain * @return a security domain name */ String getSecurityDomainName(); /** * Returns the identifier generator to be used for generating single sign-on identifiers. * @return an identifier generator */ Supplier<String> getIdentifierGenerator(); }
1,648
36.477273
93
java
null
wildfly-main/clustering/web/container/src/main/java/org/wildfly/clustering/web/container/SessionManagerFactoryConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.container; import java.time.Duration; import org.jboss.as.server.deployment.DeploymentUnit; /** * Defines the container configuration for a session manager factory of a deployment. * @author Paul Ferraro */ public interface SessionManagerFactoryConfiguration extends WebDeploymentConfiguration { /** * Returns the maximum number of sessions that should be active at any given time. * @return a positive integer; or null if there should be no limit to the number of active sessions. */ Integer getMaxActiveSessions(); /** * Returns the default session timeout. * @return the duration after which sessions will timeout. */ Duration getDefaultSessionTimeout(); /** * The deployment unit with which this session manager factory is to be associated. * @return a deployment unit */ DeploymentUnit getDeploymentUnit(); }
1,950
36.519231
104
java
null
wildfly-main/clustering/web/container/src/main/java/org/wildfly/clustering/web/container/SecurityDomainSingleSignOnManagementProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.container; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.msc.service.ServiceName; /** * Container-specific single sign-on management provider for a security domain. * @author Paul Ferraro */ public interface SecurityDomainSingleSignOnManagementProvider { /** * Returns a configurator for a service providing container-specific single sign-on management for a security domain. * @param name the service name of the single sign-on management * @param configuration the configuration of the security domain's single sign-on management * @return a configurator for a service providing a container-specific single sign-on management */ CapabilityServiceConfigurator getServiceConfigurator(ServiceName name, SecurityDomainSingleSignOnManagementConfiguration configuration); }
1,912
44.547619
140
java
null
wildfly-main/clustering/web/spi/src/test/java/org/wildfly/clustering/web/session/IdentifierSerializerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Random; import java.util.UUID; import java.util.function.Supplier; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.spi.Marshaller; import org.wildfly.clustering.web.IdentifierMarshaller; import io.undertow.server.session.SecureRandomSessionIdGenerator; /** * Unit test for {@link IdentifierMarshaller}. * * @author Paul Ferraro */ public class IdentifierSerializerTestCase { @Test public void testString() throws IOException { test(IdentifierMarshaller.ISO_LATIN_1, () -> UUID.randomUUID().toString()); } @Test public void testBase64() throws IOException { io.undertow.server.session.SessionIdGenerator generator = new SecureRandomSessionIdGenerator(); test(IdentifierMarshaller.BASE64, () -> generator.createSessionId()); } @Test public void testHex() throws IOException { test(IdentifierMarshaller.HEX, () -> { // Adapted from org.apache.catalina.util.StandardSessionIdGenerator byte[] buffer = new byte[16]; int sessionIdLength = 16; // Render the result as a String of hexadecimal digits StringBuilder builder = new StringBuilder(2 * sessionIdLength); int resultLenBytes = 0; Random random = new Random(System.currentTimeMillis()); while (resultLenBytes < sessionIdLength) { random.nextBytes(buffer); for (int j = 0; j < buffer.length && resultLenBytes < sessionIdLength; j++) { byte b1 = (byte) ((buffer[j] & 0xf0) >> 4); byte b2 = (byte) (buffer[j] & 0x0f); if (b1 < 10) builder.append((char) ('0' + b1)); else builder.append((char) ('A' + (b1 - 10))); if (b2 < 10) builder.append((char) ('0' + b2)); else builder.append((char) ('A' + (b2 - 10))); resultLenBytes++; } } return builder.toString(); }); } private static void test(Marshaller<String, ByteBuffer> marshaller, Supplier<String> generator) throws IOException { for (int i = 0; i < 100; ++i) { String id = generator.get(); ByteBuffer buffer = marshaller.write(id); Assert.assertEquals(id, marshaller.read(buffer)); } } }
3,623
36.360825
120
java
null
wildfly-main/clustering/web/spi/src/test/java/org/wildfly/clustering/web/session/SessionAttributeImmutabilityTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import static org.junit.Assert.assertTrue; import java.util.AbstractMap; import java.util.Collections; import java.util.EnumSet; import org.junit.Test; import org.wildfly.clustering.ee.Immutability; import org.wildfly.clustering.ee.immutable.CompositeImmutability; import org.wildfly.clustering.ee.immutable.DefaultImmutability; import org.wildfly.clustering.ee.immutable.DefaultImmutabilityTestCase; import org.wildfly.clustering.web.annotation.Immutable; import org.wildfly.common.iteration.CompositeIterable; /** * @author Paul Ferraro */ public class SessionAttributeImmutabilityTestCase extends DefaultImmutabilityTestCase { @Override @Test public void test() throws Exception { this.test(new CompositeImmutability(new CompositeIterable<>(EnumSet.allOf(DefaultImmutability.class), EnumSet.allOf(SessionAttributeImmutability.class)))); } @Override protected void test(Immutability immutability) throws Exception { ImmutableObject immutableObject = new ImmutableObject(); assertTrue(immutability.test(new ImmutableObject())); assertTrue(immutability.test(Collections.singleton(immutableObject))); assertTrue(immutability.test(Collections.singletonList(immutableObject))); assertTrue(immutability.test(Collections.singletonMap("1", immutableObject))); assertTrue(immutability.test(new AbstractMap.SimpleImmutableEntry<>("1", immutableObject))); } @Immutable static class ImmutableObject { } }
2,569
38.538462
163
java
null
wildfly-main/clustering/web/spi/src/test/java/org/wildfly/clustering/web/session/oob/OOBSessionTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session.oob; import static org.mockito.Mockito.*; import java.time.Duration; import java.time.Instant; import java.util.Collections; import java.util.Set; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.ee.Batch; import org.wildfly.clustering.ee.Batcher; import org.wildfly.clustering.web.session.ImmutableSession; import org.wildfly.clustering.web.session.ImmutableSessionAttributes; import org.wildfly.clustering.web.session.ImmutableSessionMetaData; import org.wildfly.clustering.web.session.Session; import org.wildfly.clustering.web.session.SessionAttributes; import org.wildfly.clustering.web.session.SessionManager; import org.wildfly.clustering.web.session.SessionMetaData; /** * Unit test for {@link OOBSession}. * @author Paul Ferraro */ public class OOBSessionTestCase { private final SessionManager<Object, Batch> manager = mock(SessionManager.class); private final String id = "ABC123"; private final Object localContext = new Object(); private final Session<Object> session = new OOBSession<>(this.manager, this.id, this.localContext); @Test public void getId() { Assert.assertSame(this.id, this.session.getId()); } @Test public void isValid() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertFalse(this.session.isValid()); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); when(this.manager.readSession(this.id)).thenReturn(session); Assert.assertTrue(this.session.isValid()); verify(batch).close(); } @Test public void getMetaData() { SessionMetaData metaData = this.session.getMetaData(); Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, metaData::getCreationTime); verify(batch).close(); } @Test public void getAttributes() { SessionAttributes attributes = this.session.getAttributes(); Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, attributes::getAttributeNames); verify(batch).close(); } @Test public void invalidate() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.findSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session::invalidate); verify(batch).close(); reset(batch); Session<Object> session = mock(Session.class); when(this.manager.findSession(this.id)).thenReturn(session); this.session.invalidate(); verify(session).invalidate(); verify(session).close(); verify(batch).close(); } @Test public void isNew() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::isNew); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class); boolean expected = true; when(this.manager.readSession(this.id)).thenReturn(session); when(session.getMetaData()).thenReturn(metaData); when(metaData.isNew()).thenReturn(expected); boolean result = this.session.getMetaData().isNew(); Assert.assertEquals(expected, result); verify(batch).close(); } @Test public void isExpired() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::isExpired); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class); boolean expected = true; when(this.manager.readSession(this.id)).thenReturn(session); when(session.getMetaData()).thenReturn(metaData); when(metaData.isExpired()).thenReturn(expected); boolean result = this.session.getMetaData().isExpired(); Assert.assertEquals(expected, result); verify(batch).close(); } @Test public void getCreationTime() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::getCreationTime); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class); Instant expected = Instant.now(); when(this.manager.readSession(this.id)).thenReturn(session); when(session.getMetaData()).thenReturn(metaData); when(metaData.getCreationTime()).thenReturn(expected); Instant result = this.session.getMetaData().getCreationTime(); Assert.assertSame(expected, result); verify(batch).close(); } @Test public void getLastAccessStartTime() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::getLastAccessStartTime); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class); Instant expected = Instant.now(); when(this.manager.readSession(this.id)).thenReturn(session); when(session.getMetaData()).thenReturn(metaData); when(metaData.getLastAccessStartTime()).thenReturn(expected); Instant result = this.session.getMetaData().getLastAccessStartTime(); Assert.assertSame(expected, result); verify(batch).close(); } @Test public void getLastAccessEndTime() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::getLastAccessTime); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class); Instant expected = Instant.now(); when(this.manager.readSession(this.id)).thenReturn(session); when(session.getMetaData()).thenReturn(metaData); when(metaData.getLastAccessTime()).thenReturn(expected); Instant result = this.session.getMetaData().getLastAccessTime(); Assert.assertSame(expected, result); verify(batch).close(); } @Test public void getMaxInactiveInterval() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::getTimeout); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class); Duration expected = Duration.ZERO; when(this.manager.readSession(this.id)).thenReturn(session); when(session.getMetaData()).thenReturn(metaData); when(metaData.getTimeout()).thenReturn(expected); Duration result = this.session.getMetaData().getTimeout(); Assert.assertSame(expected, result); verify(batch).close(); } @Test public void setLastAccess() { Assert.assertThrows(IllegalStateException.class, () -> this.session.getMetaData().setLastAccess(Instant.now(), Instant.now())); } @Test public void setMaxInactiveInterval() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); Duration duration = Duration.ZERO; when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.findSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, () -> this.session.getMetaData().setMaxInactiveInterval(duration)); verify(batch).close(); reset(batch); Session<Object> session = mock(Session.class); SessionMetaData metaData = mock(SessionMetaData.class); when(this.manager.findSession(this.id)).thenReturn(session); when(session.getMetaData()).thenReturn(metaData); this.session.getMetaData().setMaxInactiveInterval(duration); verify(metaData).setMaxInactiveInterval(duration); verify(session).close(); verify(batch).close(); } @Test public void getAttributeNames() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, this.session.getAttributes()::getAttributeNames); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionAttributes attributes = mock(ImmutableSessionAttributes.class); Set<String> expected = Collections.singleton("foo"); when(this.manager.readSession(this.id)).thenReturn(session); when(session.getAttributes()).thenReturn(attributes); when(attributes.getAttributeNames()).thenReturn(expected); Set<String> result = this.session.getAttributes().getAttributeNames(); Assert.assertSame(expected, result); verify(batch).close(); } @Test public void getAttribute() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); String attributeName = "foo"; when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.readSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, () -> this.session.getAttributes().getAttribute(attributeName)); verify(batch).close(); reset(batch); ImmutableSession session = mock(ImmutableSession.class); ImmutableSessionAttributes attributes = mock(ImmutableSessionAttributes.class); Object expected = new Object(); when(this.manager.readSession(this.id)).thenReturn(session); when(session.getAttributes()).thenReturn(attributes); when(attributes.getAttribute(attributeName)).thenReturn(expected); Object result = this.session.getAttributes().getAttribute(attributeName); Assert.assertSame(expected, result); verify(batch).close(); } @Test public void setAttribute() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); String attributeName = "foo"; Object attributeValue = "bar"; when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.findSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, () -> this.session.getAttributes().setAttribute(attributeName, attributeValue)); verify(batch).close(); reset(batch); Session<Object> session = mock(Session.class); SessionAttributes attributes = mock(SessionAttributes.class); Object expected = new Object(); when(this.manager.findSession(this.id)).thenReturn(session); when(session.getAttributes()).thenReturn(attributes); when(attributes.setAttribute(attributeName, attributeValue)).thenReturn(expected); Object result = this.session.getAttributes().setAttribute(attributeName, attributeValue); Assert.assertSame(expected, result); verify(session).close(); verify(batch).close(); } @Test public void removeAttribute() { Batcher<Batch> batcher = mock(Batcher.class); Batch batch = mock(Batch.class); String attributeName = "foo"; when(this.manager.getBatcher()).thenReturn(batcher); when(batcher.createBatch()).thenReturn(batch); when(this.manager.findSession(this.id)).thenReturn(null); Assert.assertThrows(IllegalStateException.class, () -> this.session.getAttributes().removeAttribute(attributeName)); verify(batch).close(); reset(batch); Session<Object> session = mock(Session.class); SessionAttributes attributes = mock(SessionAttributes.class); Object expected = new Object(); when(this.manager.findSession(this.id)).thenReturn(session); when(session.getAttributes()).thenReturn(attributes); when(attributes.removeAttribute(attributeName)).thenReturn(expected); Object result = this.session.getAttributes().removeAttribute(attributeName); Assert.assertSame(expected, result); verify(session).close(); verify(batch).close(); } }
16,431
34.111111
137
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/WebDeploymentConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web; import org.wildfly.clustering.ee.DeploymentConfiguration; /** * Encapsulates the configuration of a web deployment. * @author Paul Ferraro */ public interface WebDeploymentConfiguration extends DeploymentConfiguration { /** * Returns the target server name of this deployment * @return a server name */ String getServerName(); }
1,418
35.384615
77
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/IdentifierMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web; import java.nio.ByteBuffer; import org.wildfly.clustering.marshalling.spi.Marshaller; /** * @author Paul Ferraro */ public interface IdentifierMarshallerProvider { Marshaller<String, ByteBuffer> getMarshaller(); }
1,283
35.685714
70
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/LocalContextFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web; /** * Create a local context. * The local context is a mutable object that will *not* replicate to other nodes. * @author Paul Ferraro */ public interface LocalContextFactory<L> { L createLocalContext(); }
1,274
38.84375
82
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/IdentifierMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Base64; import org.wildfly.clustering.marshalling.spi.Marshaller; /** * Strategies for externalizing a session identifier. * @author Paul Ferraro */ public enum IdentifierMarshaller implements Marshaller<String, ByteBuffer> { ISO_LATIN_1() { @Override public String read(ByteBuffer buffer) throws IOException { int offset = buffer.arrayOffset(); int length = buffer.limit() - offset; return new String(buffer.array(), offset, length, StandardCharsets.ISO_8859_1); } @Override public ByteBuffer write(String value) throws IOException { return ByteBuffer.wrap(value.getBytes(StandardCharsets.ISO_8859_1)); } @Override public boolean validate(String id) { return true; } }, /** * Specific optimization for Base64-encoded identifiers (e.g. Undertow). */ BASE64() { @Override public String read(ByteBuffer buffer) throws IOException { return ISO_LATIN_1.read(Base64.getUrlEncoder().encode(buffer)); } @Override public ByteBuffer write(String value) throws IOException { return Base64.getUrlDecoder().decode(ISO_LATIN_1.write(value)); } }, /** * Specific optimization for hex-encoded identifiers (e.g. Tomcat). */ HEX() { @Override public String read(ByteBuffer buffer) throws IOException { int offset = buffer.arrayOffset(); int length = buffer.limit() - offset; StringBuilder builder = new StringBuilder(length * 2); while (buffer.hasRemaining()) { byte b = buffer.get(); builder.append(Character.toUpperCase(Character.forDigit((b >> 4) & 0xf, 16))); builder.append(Character.toUpperCase(Character.forDigit(b & 0xf, 16))); } return builder.toString(); } @Override public ByteBuffer write(String value) throws IOException { if (value.length() % 2 != 0) { throw new IllegalArgumentException(value); } byte[] bytes = new byte[value.length() / 2]; for (int i = 0; i < bytes.length; ++i) { int index = i * 2; int high = Character.digit(value.charAt(index), 16) << 4; int low = Character.digit(value.charAt(index + 1), 16); bytes[i] = (byte) (high + low); } return ByteBuffer.wrap(bytes); } }, ; @Override public boolean isMarshallable(Object object) { return object instanceof String; } /** * Indicates whether or not the specified identifier is valid for this serializer. * @param id an identifier * @return true, if the specified identifier is valid, false otherwise. */ public boolean validate(String id) { try { this.write(id); return true; } catch (IOException | IllegalArgumentException e) { return false; } } }
4,288
34.155738
94
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/sso/SSOManagerFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.sso; import org.wildfly.clustering.ee.Batch; /** * Factory for creating SSO manager instances. * @param <A> authentication type * @param <D> deployment type * @param <S> session type * @param <B> batch type */ public interface SSOManagerFactory<A, D, S, B extends Batch> { /** * Creates a new SSO manager using the specified configuration. * @param <L> local context type * @param config a SSO manager configuration * @return a new SSO manager */ <L> SSOManager<A, D, S, L, B> createSSOManager(SSOManagerConfiguration<L> config); }
1,631
37.857143
86
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/sso/SSOManagerConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.sso; import java.util.function.Supplier; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.web.LocalContextFactory; /** * @author Paul Ferraro * @param <L> local context type */ public interface SSOManagerConfiguration<L> { Supplier<String> getIdentifierFactory(); ByteBufferMarshaller getMarshaller(); LocalContextFactory<L> getLocalContextFactory(); }
1,479
36.948718
70
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/sso/Sessions.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.sso; import java.util.Set; /** * Represents the sessions per deployment for which a given user is authenticated. * @author Paul Ferraro * @param <D> deployment identifier type * @param <S> session identifier type */ public interface Sessions<D, S> { /** * Returns the set of web applications for which the current user is authenticated. * @return a set of web applications. */ Set<D> getDeployments(); /** * Returns the corresponding session identifier for the specified web application. * @param application * @return */ S getSession(D deployment); /** * Removes the specified web application from the set of authenticated web applications. * @param application */ S removeSession(D deployment); /** * Adds the specified web application and session identifier to the registry of authenticated web applications. * @param deployment a web application * @param session a session * @return true, if the session was added, false it already exists */ boolean addSession(D deployment, S session); }
2,168
35.15
115
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/sso/SSOManager.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.sso; import java.util.function.Supplier; import org.wildfly.clustering.ee.Batch; import org.wildfly.clustering.ee.Batcher; import org.wildfly.clustering.ee.Restartable; /** * The SSO equivalent of a session manager. * @author Paul Ferraro * @param <A> the authentication identity type * @param <D> the deployment identifier type * @param <S> the session identifier type * @param <L> the local context type * @param <B> the batch type */ public interface SSOManager<A, D, S, L, B extends Batch> extends Restartable { /** * Creates a new single sign on entry. * @param ssoId a unique SSO identifier * @return a new SSO. */ SSO<A, D, S, L> createSSO(String ssoId, A authentication); /** * Returns the single sign on entry identified by the specified identifier. * @param ssoId a unique SSO identifier * @return an existing SSO, or null, if no SSO was found */ SSO<A, D, S, L> findSSO(String ssoId); /** * Searches for the sessions of the single sign on entry containing the specified session. * @param sessionId a unique session identifier * @return an existing sessions of an SSO, or null, if no SSO was found */ Sessions<D, S> findSessionsContaining(S session); /** * A mechanism for starting/stopping a batch. * @return a batching mechanism. */ Batcher<B> getBatcher(); /** * Returns the identifier factory of this SSO manager. * @return an identifier factory */ Supplier<String> getIdentifierFactory(); }
2,609
34.753425
94
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/sso/SSO.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.sso; /** * Represents a single sign on entry for a user. * @author Paul Ferraro * @param <A> the authentication identity type * @param <D> the deployment identifier type * @param <S> the session identifier type * @param <L> the local context type */ public interface SSO<A, D, S, L> { /** * A unique identifier for this SSO. * @return a unique identifier */ String getId(); /** * Returns the authentication for this SSO. * @return an authentication. */ A getAuthentication(); /** * Returns the session for which the user is authenticated. * @return */ Sessions<D, S> getSessions(); /** * Invalidates this SSO. */ void invalidate(); /** * The local context of this SSO. * The local context is *not* replicated to other nodes in the cluster. * @return a local context. */ L getLocalContext(); }
1,978
30.412698
75
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/ImmutableSession.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; /** * Represents an immutable view of a web session. * @author Paul Ferraro */ public interface ImmutableSession { /** * Specifies this session's unique identifier. * @return a unique identifier for this session. */ String getId(); /** * Indicates whether or not this session is valid. * @return true, if this session is valid, false otherwise */ boolean isValid(); /** * Returns this session's meta data. * @return this session's meta data * @throws IllegalStateException if this session is invalid */ ImmutableSessionMetaData getMetaData(); /** * Returns this session's attributes. * @return this session's attributes * @throws IllegalStateException if this session is invalid */ ImmutableSessionAttributes getAttributes(); }
1,904
33.636364
70
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionAttributeImmutability.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import org.wildfly.clustering.ee.Immutability; import org.wildfly.clustering.ee.immutable.AnnotationImmutability; import org.wildfly.clustering.web.annotation.Immutable; /** * Session attribute immutability tests. * @author Paul Ferraro */ public enum SessionAttributeImmutability implements Immutability { ANNOTATION(new AnnotationImmutability(Immutable.class)), ; private final Immutability immutability; SessionAttributeImmutability(Immutability immutability) { this.immutability = immutability; } @Override public boolean test(Object object) { return this.immutability.test(object); } }
1,715
34.75
70
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/InactiveSessionStatistics.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.time.Duration; /** * Statistics for inactive sessions. * @author Paul Ferraro */ public interface InactiveSessionStatistics { /** * @return The number of expired sessions */ long getExpiredSessionCount(); /** * @return The longest a session has been alive, as a time duration */ Duration getMaxSessionLifetime(); /** * @return The average session lifetime, as a time duration */ Duration getMeanSessionLifetime(); }
1,558
31.479167
71
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/DistributableSessionManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.util.function.Function; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; /** * Encapsulates the configuration of a session management provider. * @author Paul Ferraro * @param <M> the marshaller factory context */ public interface DistributableSessionManagementConfiguration<M> { SessionAttributePersistenceStrategy getAttributePersistenceStrategy(); Function<M, ByteBufferMarshaller> getMarshallerFactory(); }
1,527
37.2
74
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/ImmutableSessionMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.time.Instant; import org.wildfly.clustering.ee.expiration.ExpirationMetaData; /** * Abstraction for immutable meta information about a web session. * @author Paul Ferraro */ public interface ImmutableSessionMetaData extends ExpirationMetaData { /** * Indicates whether or not this session was created by the current thread. * @return true, if this session is new, false otherwise */ default boolean isNew() { return this.getCreationTime().equals(this.getLastAccessStartTime()); } /** * Returns the time this session was created. * @return the time this session was created */ Instant getCreationTime(); /** * Returns the start time of the last request to access this session. * @return the start time of the last request to access this session. */ Instant getLastAccessStartTime(); }
1,953
35.185185
79
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionAttributePersistenceStrategy.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; /** * @author Paul Ferraro */ public enum SessionAttributePersistenceStrategy { COARSE, FINE }
1,169
38
70
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/HttpSessionFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; /** * Factory for creating HttpSession specification implementations * @param <S> the specification type for the HttpSession * @param <C> the specification type for the ServletContext * @author Paul Ferraro */ public interface HttpSessionFactory<S, C> { /** * Create an HttpSession specification implementation for the specified session and servlet context. * @param session a session * @param context a servlet context * @return a HttpSession specification implementation */ S createHttpSession(ImmutableSession session, C context); }
1,643
40.1
104
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/ActiveSessionStatistics.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; /** * Statistics for active sessions. * @author Paul Ferraro */ public interface ActiveSessionStatistics { /** * @return The number of active sessions */ long getActiveSessionCount(); }
1,277
34.5
70
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionManagerFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import org.wildfly.clustering.ee.Batch; /** * A factory for creating a session manager. * @param <SC> the ServletContext specification type * @param <LC> the local context type * @param <B> the batch type * @author Paul Ferraro */ public interface SessionManagerFactory<SC, LC, B extends Batch> extends AutoCloseable { /** * Create as session manager using the specified context and identifier factory. * @param context a session context * @param idFactory a session identifier factory * @return a new session manager */ SessionManager<LC, B> createSessionManager(SessionManagerConfiguration<SC> configuration); @Override void close(); }
1,755
38.022222
94
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.time.Duration; import java.time.Instant; /** * Abstraction for meta information about a web session. * @author Paul Ferraro */ public interface SessionMetaData extends ImmutableSessionMetaData { /** * Sets the time this session was last accessed. * @param the start time of the last request * @param the end time of the last request */ void setLastAccess(Instant startTime, Instant endTime); /** * Set the time interval as a duration, after which this session will expire. * @param duration a time duration */ void setMaxInactiveInterval(Duration duration); }
1,696
36.711111
81
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionAttributes.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; /** * Exposes accesses to the attributes of a session. * @author Paul Ferraro */ public interface SessionAttributes extends ImmutableSessionAttributes { /** * Removes the specified attribute. * @param name a unique attribute name * @return the removed attribute value, or null if the attribute does not exist. */ Object removeAttribute(String name); /** * Sets the specified attribute to the specified value. * @param name a unique attribute name * @param value the attribute value * @return the old attribute value, or null if the attribute did not previously exist. */ Object setAttribute(String name, Object value); }
1,754
38.886364
90
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionManagerFactoryConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import org.wildfly.clustering.ee.Immutability; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.web.LocalContextFactory; import org.wildfly.clustering.web.WebDeploymentConfiguration; /** * Encapsulates the configuration of a session manager. * @param <S> the HttpSession specification type * @param <SC> the ServletContext specification type * @param <AL> the HttpSessionAttributeListener specification type * @param <MC> the marshalling context type * @param <LC> the local context type * @author Paul Ferraro */ public interface SessionManagerFactoryConfiguration<S, SC, AL, LC> extends WebDeploymentConfiguration { Integer getMaxActiveSessions(); ByteBufferMarshaller getMarshaller(); LocalContextFactory<LC> getLocalContextFactory(); Immutability getImmutability(); SpecificationProvider<S, SC, AL> getSpecificationProvider(); SessionAttributePersistenceStrategy getAttributePersistenceStrategy(); }
2,060
38.634615
103
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SpecificationProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; /** * Provides servlet specification behavior for a container-agnostic distributed session manager. * @author Paul Ferraro */ public interface SpecificationProvider<S, C, AL> extends HttpSessionActivationListenerProvider<S, C, AL> { }
1,308
39.90625
106
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionManagerConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.util.function.Supplier; import org.wildfly.clustering.ee.expiration.ExpirationConfiguration; /** * Encapsulates the configuration of a session manager. * @author Paul Ferraro * @param <SC> the servlet context type */ public interface SessionManagerConfiguration<SC> extends ExpirationConfiguration<ImmutableSession> { SC getServletContext(); Supplier<String> getIdentifierFactory(); }
1,478
40.083333
100
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/HttpSessionActivationListenerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.util.function.Consumer; /** * Provides specification behavior for session activation listeners. * @param <S> the specification type for the HttpSession * @param <C> the specification type for the ServletContext * @param <L> the specification type for the HttpSessionActivationListener * @author Paul Ferraro */ public interface HttpSessionActivationListenerProvider<S, C, L> extends HttpSessionFactory<S, C> { /** * Returns the HttpSessionActivationListener specification interface. * @return the HttpSessionActivationListener specification interface */ Class<L> getHttpSessionActivationListenerClass(); /** * Creates a pre-passivate notifier for the specified listener. * @param listener the specification listener * @return a consumer for a session */ Consumer<S> prePassivateNotifier(L listener); /** * Creates a post-activate notifier for the specified listener. * @param listener the specification listener * @return a consumer for a session */ Consumer<S> postActivateNotifier(L listener); /** * Creates a specification implementation with the specified pre-passivate and post-activate logic. * @param prePassivate a pre-passivate event consumer for a session * @param postActivate a post-activate event consumer for a session * @return a specification listener implementation */ L createListener(Consumer<S> prePassivate, Consumer<S> postActivate); }
2,561
39.666667
103
java
null
wildfly-main/clustering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionManager.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.web.session; import java.time.Duration; import java.util.Set; import java.util.function.Supplier; import org.wildfly.clustering.ee.Batch; import org.wildfly.clustering.ee.Batcher; import org.wildfly.clustering.ee.Restartable; /** * SPI for a distributable session manager. * @param <L> the local context type * @param <B> the batch type * @author Paul Ferraro */ public interface SessionManager<L, B extends Batch> extends Restartable, ActiveSessionStatistics { /** * Returns the session with the specified identifier, or null if none exists. * Sessions returned by this method must be closed via {@link Session#close()}. * This method is intended to be invoked within the context of a batch. * @param id a session identifier * @return an existing web session, or null if none exists */ Session<L> findSession(String id); /** * Creates a session using the specified identifier. * Sessions returned by this method must be closed via {@link Session#close()}. * This method is intended to be invoked within the context of a batch. * @param id a session identifier * @return a new web session, or null if a session with the specified identifier already exists. */ Session<L> createSession(String id); /** * Exposes the batching mechanism used by this session manager. * @return a batcher. */ Batcher<B> getBatcher(); /** * Returns the identifiers of those sessions that are active on this node. * @return a set of session identifiers. */ Set<String> getActiveSessions(); /** * Returns the identifiers of all sessions on this node, including both active and passive sessions. * @return a set of session identifiers. */ Set<String> getLocalSessions(); /** * Returns a read-only view of the session with the specified identifier. * This method is intended to be invoked within the context of a batch * @param id a unique session identifier * @return a read-only session or null if none exists */ ImmutableSession readSession(String id); /** * The maximum duration of time to wait for the completion of requests before the session manager can be stopped. * @return a duration */ Duration getStopTimeout(); /** * Returns the identifier factory of this session manager. * @return an identifier factory */ Supplier<String> getIdentifierFactory(); }
3,532
35.802083
117
java