| @@ -0,0 +1,53 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ 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. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>org.wildfly</groupId> | ||
| <artifactId>wildfly-clustering-ee</artifactId> | ||
| <!-- | ||
| Maintain separation between the artifact id and the version to help prevent | ||
| merge conflicts between commits changing the GA and those changing the V. | ||
| --> | ||
| <version>17.0.0.Beta1-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>wildfly-clustering-ee-hotrod</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>WildFly: EE clustering - HotRod service provider</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>wildfly-clustering-ee-cache</artifactId> | ||
| <version>${project.parent.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.infinispan</groupId> | ||
| <artifactId>infinispan-client-hotrod</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * 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.ee.hotrod; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import org.infinispan.client.hotrod.RemoteCache; | ||
| import org.wildfly.clustering.ee.Mutator; | ||
|
|
||
| /** | ||
| * Mutates a given cache entry. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class RemoteCacheEntryMutator<K, V> implements Mutator { | ||
|
|
||
| private final RemoteCache<K, V> cache; | ||
| private final K id; | ||
| private final V value; | ||
|
|
||
| public RemoteCacheEntryMutator(RemoteCache<K, V> cache, Map.Entry<K, V> entry) { | ||
| this(cache, entry.getKey(), entry.getValue()); | ||
| } | ||
|
|
||
| public RemoteCacheEntryMutator(RemoteCache<K, V> cache, K id, V value) { | ||
| this.cache = cache; | ||
| this.id = id; | ||
| this.value = value; | ||
| } | ||
|
|
||
| @Override | ||
| public void mutate() { | ||
| this.cache.put(this.id, this.value); | ||
| } | ||
| } |
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * 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.ee.hotrod; | ||
|
|
||
| import org.infinispan.client.hotrod.configuration.Configuration; | ||
| import org.infinispan.client.hotrod.configuration.TransactionMode; | ||
| import org.wildfly.clustering.ee.cache.CacheProperties; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class RemoteCacheManagerProperties implements CacheProperties { | ||
|
|
||
| private final boolean transactional; | ||
|
|
||
| public RemoteCacheManagerProperties(Configuration configuration) { | ||
| this.transactional = configuration.transaction().transactionMode() != TransactionMode.NONE; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isLockOnRead() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isLockOnWrite() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isMarshalling() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isPersistent() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isTransactional() { | ||
| return this.transactional; | ||
| } | ||
| } |
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * 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.ee.hotrod.tx; | ||
|
|
||
| import org.infinispan.client.hotrod.RemoteCache; | ||
| import org.infinispan.client.hotrod.exceptions.HotRodClientException; | ||
| import org.wildfly.clustering.ee.cache.tx.TransactionalBatcher; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class HotRodBatcher extends TransactionalBatcher<HotRodClientException> { | ||
|
|
||
| public HotRodBatcher(RemoteCache<?, ?> cache) { | ||
| super(cache.getTransactionManager(), HotRodClientException::new); | ||
| } | ||
| } |
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * 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.ee.infinispan.tx; | ||
|
|
||
| import org.infinispan.Cache; | ||
| import org.infinispan.commons.CacheException; | ||
| import org.wildfly.clustering.ee.cache.tx.TransactionalBatcher; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class InfinispanBatcher extends TransactionalBatcher<CacheException> { | ||
|
|
||
| public InfinispanBatcher(Cache<?, ?> cache) { | ||
| super(cache.getAdvancedCache().getTransactionManager(), CacheException::new); | ||
| } | ||
| } |
| @@ -0,0 +1,54 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ 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. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>org.wildfly</groupId> | ||
| <artifactId>wildfly-clustering-infinispan</artifactId> | ||
| <!-- | ||
| Maintain separation between the artifact id and the version to help prevent | ||
| merge conflicts between commits changing the GA and those changing the V. | ||
| --> | ||
| <version>17.0.0.Beta1-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>wildfly-clustering-infinispan-client</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>WildFly: Infinispan Client SPI</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>wildfly-clustering-common</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.infinispan</groupId> | ||
| <artifactId>infinispan-client-hotrod</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * 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.infinispan.client; | ||
|
|
||
| import org.infinispan.client.hotrod.configuration.Configuration; | ||
| 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; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public enum InfinispanClientRequirement implements UnaryRequirement, UnaryServiceNameFactoryProvider { | ||
|
|
||
| REMOTE_CONTAINER("org.wildfly.clustering.infinispan.remote-cache-container", RemoteCacheContainer.class), | ||
| REMOTE_CONTAINER_CONFIGURATION("org.wildfly.clustering.infinispan.remote-cache-container-configuration", Configuration.class), | ||
| ; | ||
| private final String name; | ||
| private final Class<?> type; | ||
| private final UnaryServiceNameFactory factory = new UnaryRequirementServiceNameFactory(this); | ||
|
|
||
| InfinispanClientRequirement(String name, Class<?> type) { | ||
| this.name = name; | ||
| this.type = type; | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return this.name; | ||
| } | ||
|
|
||
| @Override | ||
| public Class<?> getType() { | ||
| return this.type; | ||
| } | ||
|
|
||
| @Override | ||
| public UnaryServiceNameFactory getServiceNameFactory() { | ||
| return this.factory; | ||
| } | ||
| } |
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * 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.infinispan.client; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Base type for cache keys. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class Key<I> { | ||
|
|
||
| private I id; | ||
|
|
||
| public Key(I id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public I getId() { | ||
| return this.id; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(this.getClass(), this.id); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object object) { | ||
| return this.getClass().equals(object.getClass()) && this.id.equals(((Key<?>) object).id); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.format("%s(%s)", this.getClass().getSimpleName(), this.id); | ||
| } | ||
| } |
| @@ -0,0 +1,67 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ JBoss, Home of Professional Open Source. | ||
| ~ Copyright 2010, 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. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>org.wildfly</groupId> | ||
| <artifactId>wildfly-clustering-web</artifactId> | ||
| <!-- | ||
| Maintain separation between the artifact id and the version to help prevent | ||
| merge conflicts between commits changing the GA and those changing the V. | ||
| --> | ||
| <version>17.0.0.Beta1-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>wildfly-clustering-web-cache</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>WildFly: Common abstractions for cache-based session manager implementations.</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>wildfly-clustering-ee-cache</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>wildfly-clustering-web-spi</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.kohsuke.metainf-services</groupId> | ||
| <artifactId>metainf-services</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>wildfly-clustering-marshalling-api</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>test</scope> | ||
| <classifier>tests</classifier> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * 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.cache.routing; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
|
|
||
| import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; | ||
| import org.wildfly.clustering.service.SupplierDependency; | ||
| import org.wildfly.clustering.web.routing.RoutingProvider; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class LocalRoutingProvider implements RoutingProvider { | ||
|
|
||
| @Override | ||
| public Collection<CapabilityServiceConfigurator> getServiceConfigurators(String serverName, SupplierDependency<String> route) { | ||
| return Collections.singleton(new LocalRouteServiceConfigurator(serverName, route)); | ||
| } | ||
| } |
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * 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.cache.session; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import javax.servlet.http.HttpSession; | ||
|
|
||
| /** | ||
| * An {@link HttpSession} whose attributes can be filtered. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public interface FilteringHttpSession extends HttpSession { | ||
| /** | ||
| * Returns the session attributes that are instances of the specified class. | ||
| * @return an map of session attribute names and values | ||
| */ | ||
| <T> Map<String, T> getAttributes(Class<T> targetClass); | ||
| } |
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * 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.cache.session; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import javax.servlet.ServletContext; | ||
| import javax.servlet.http.HttpSessionActivationListener; | ||
| import javax.servlet.http.HttpSessionEvent; | ||
|
|
||
| import org.wildfly.clustering.web.session.ImmutableSession; | ||
|
|
||
| /** | ||
| * Triggers activation events for all attributes of a session. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class ImmutableSessionActivationNotifier implements SessionActivationNotifier { | ||
|
|
||
| private final FilteringHttpSession session; | ||
|
|
||
| public ImmutableSessionActivationNotifier(ImmutableSession session, ServletContext context) { | ||
| this.session = new ImmutableFilteringHttpSession(session, context); | ||
| } | ||
|
|
||
| @Override | ||
| public void prePassivate() { | ||
| Map<String, HttpSessionActivationListener> listeners = this.session.getAttributes(HttpSessionActivationListener.class); | ||
| if (!listeners.isEmpty()) { | ||
| HttpSessionEvent event = new HttpSessionEvent(this.session); | ||
| for (HttpSessionActivationListener listener : listeners.values()) { | ||
| listener.sessionWillPassivate(event); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void postActivate() { | ||
| Map<String, HttpSessionActivationListener> listeners = this.session.getAttributes(HttpSessionActivationListener.class); | ||
| if (!listeners.isEmpty()) { | ||
| HttpSessionEvent event = new HttpSessionEvent(this.session); | ||
| for (HttpSessionActivationListener listener : listeners.values()) { | ||
| listener.sessionDidActivate(event); | ||
| } | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * 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.cache.session; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import javax.servlet.ServletContext; | ||
| import javax.servlet.http.HttpSessionBindingEvent; | ||
| import javax.servlet.http.HttpSessionBindingListener; | ||
|
|
||
| import org.wildfly.clustering.web.session.ImmutableSession; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class ImmutableSessionBindingNotifier implements SessionBindingNotifier { | ||
|
|
||
| private final FilteringHttpSession session; | ||
|
|
||
| public ImmutableSessionBindingNotifier(ImmutableSession session, ServletContext context) { | ||
| this.session = new ImmutableFilteringHttpSession(session, context); | ||
| } | ||
|
|
||
| @Override | ||
| public void unbound() { | ||
| Map<String, HttpSessionBindingListener> listeners = this.session.getAttributes(HttpSessionBindingListener.class); | ||
| if (!listeners.isEmpty()) { | ||
| for (Map.Entry<String, HttpSessionBindingListener> entry : listeners.entrySet()) { | ||
| HttpSessionBindingListener listener = entry.getValue(); | ||
| listener.valueUnbound(new HttpSessionBindingEvent(this.session, entry.getKey(), listener)); | ||
| } | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * 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.cache.session; | ||
|
|
||
| /** | ||
| * Notifies attributes of a session implementing {@link javax.servlet.http.HttpSessionActivationListener}. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public interface SessionActivationNotifier { | ||
|
|
||
| /** | ||
| * Notifies interested attributes that they will be passivated. | ||
| */ | ||
| void prePassivate(); | ||
|
|
||
| /** | ||
| * Notifies interested attributes that they are were activated. | ||
| */ | ||
| void postActivate(); | ||
| } |
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * 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.cache.session; | ||
|
|
||
| /** | ||
| * Notifies attributes of a session implementing {@link javax.servlet.http.HttpSessionBindingListener}. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public interface SessionBindingNotifier { | ||
|
|
||
| /** | ||
| * Notifies all attributes that they are being unbound from a given session. | ||
| */ | ||
| void unbound(); | ||
| } |