Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to WildFly 21.0.0.Final #8

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ The following is a sample `/WEB-INF/applicationContext.xml`:
<context:annotation-config/>

<bean class="org.wildfly.clustering.web.spring.hotrod.annotation.HotRodHttpSessionConfiguration">
<property name="properties">
<props>
<prop key="infinispan.client.hotrod.server_list">127.0.0.1:11222</prop>
</props>
</property>
<property name="persistenceStrategy">
<value type="org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy">FINE</value>
</property>
<property name="maxActiveSessions">1000</property>
<property name="properties">
<props>
<prop key="infinispan.client.hotrod.server_list">127.0.0.1:11222</prop>
</props>
</property>
<property name="granularity">
<value type="org.wildfly.clustering.web.spring.SessionPersistenceGranularity">SESSION</value>
</property>
<property name="marshallerFactory">
<value type="org.wildfly.clustering.web.spring.SessionMarshallerFactory">PROTOSTREAM</value>
</property>
<property name="maxActiveSessions">1000</property>
</bean>
</beans>

Expand All @@ -117,9 +120,10 @@ The following is a sample `/WEB-INF/applicationContext.xml`:

|Property|Description|
|:---|:---|
|configurationName|Defines the server-side configuration template from which a deployment cache is created on the server. If undefined, the configuration of the server's default cache will be used.|
|persistenceStrategy|Defines how a session is mapped to entries in the cache. "COARSE" will store all attributes of a session in a single cache entry. "FINE" will store each session attribute in a separate cache entry. Default is "COARSE".|
|maxActiveSessions|Defines the maximum number of sessions to retain in the near cache. Default is boundless. A value of 0 will disable the near cache.|
|templateName|Defines the server-side configuration template from which a deployment cache is created on the server. Default is `org.infinispan.DIST_SYNC`.|
|granularity|Defines how a session is mapped to entries in the cache. Supported granularities are enumerated by the `org.wildfly.clustering.web.spring.SessionPersistenceGranularity` enum. `SESSION` will store all attributes of a session in a single cache entry, while `ATTRIBUTE` will store each session attribute in a separate cache entry. Default is `SESSION`.|
|maxActiveSessions|Defines the maximum number of sessions to retain in the near cache. Default is limitless. A value of 0 will disable the near cache.|
|marshallerFactory|Specifies the marshaller used to serialize and deserialize session attributes. Supported marshallers are enumerated by the `org.wildfly.clustering.web.spring.SessionMarshallerFactory` enum and include: `JAVA`, `JBOSS`, `PROTOSTREAM`. Default marshaller is `JBOSS`.|

#### HotRod properties

Expand Down
36 changes: 29 additions & 7 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@
<name>Distributed session management for Spring Session: Core integration</name>

<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
Expand All @@ -50,25 +62,35 @@
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-clustering-web-cache</artifactId>
<artifactId>wildfly-clustering-marshalling-jboss</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-clustering-marshalling-protostream</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-clustering-web-cache</artifactId>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-server-testdriver-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-server-testdriver-junit4</artifactId>
<groupId>org.infinispan.protostream</groupId>
<artifactId>protostream-processor</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.marshalling.jdk;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

/**
* A {@link ClassResolver} that resolves classes against a given class loader.
* @author Paul Ferraro
*/
public class ClassLoaderResolver implements ClassResolver {

private final ClassLoader loader;

public ClassLoaderResolver(ClassLoader loader) {
this.loader = loader;
}

@Override
public void annotateClass(ObjectOutput output, Class<?> targetClass) throws IOException {
// Do nothing
}

@Override
public Class<?> resolveClass(ObjectInput input, String className) throws IOException, ClassNotFoundException {
return this.loader.loadClass(className);
}

@Override
public ClassLoader getClassLoader() {
return this.loader;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.marshalling.jdk;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

/**
* Annotates a resolves {@link Class} instances to/from an object stream.
* @author Paul Ferraro
*/
public interface ClassResolver {

void annotateClass(ObjectOutput output, Class<?> targetClass) throws IOException;

Class<?> resolveClass(ObjectInput input, String className) throws IOException, ClassNotFoundException;

ClassLoader getClassLoader();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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.marshalling.jdk;

import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidClassException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.OutputStream;
import java.io.Serializable;

import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller;

/**
* A {@link ByteBufferMarshaller} based on Java serialization.
*
* @author Paul Ferraro
*/
public class JavaByteBufferMarshaller implements ByteBufferMarshaller {
private final ClassResolver resolver;

public JavaByteBufferMarshaller(ClassResolver resolver) {
this.resolver = resolver;
}

@Override
public boolean isMarshallable(Object object) {
return (object == null) || object instanceof Serializable;
}

@Override
public Object readFrom(InputStream in) throws IOException {
try (ObjectInput input = new ObjectInputStream(in, this.resolver)) {
return input.readObject();
} catch (ClassNotFoundException e) {
InvalidClassException exception = new InvalidClassException(e.getMessage());
exception.initCause(e);
throw exception;
}
}

@Override
public void writeTo(OutputStream out, Object object) throws IOException {
try (ObjectOutput output = new ObjectOutputStream(out, this.resolver)) {
output.writeObject(object);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.marshalling.jdk;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectStreamClass;
import java.lang.reflect.Proxy;

/**
* An {@link java.io.ObjectInputStream} that resolves classes using a given {@link ClassResolver}.
* @author Paul Ferraro
*/
public class ObjectInputStream extends java.io.ObjectInputStream {

private final ClassResolver resolver;

public ObjectInputStream(InputStream input, ClassResolver resolver) throws IOException {
super(input);
this.resolver = resolver;
}

@Override
protected Class<?> resolveClass(ObjectStreamClass description) throws IOException, ClassNotFoundException {
return this.resolver.resolveClass(this, description.getName());
}

@Override
protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
Class<?>[] interfaceClasses = new Class<?>[interfaces.length];
for (int i = 0; i < interfaces.length; ++i) {
interfaceClasses[i] = this.resolver.resolveClass(this, interfaces[i]);
}
try {
return Proxy.getProxyClass(this.resolver.getClassLoader(), interfaceClasses);
} catch (IllegalArgumentException e) {
throw new ClassNotFoundException(null, e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.marshalling.jdk;

import java.io.IOException;
import java.io.OutputStream;

/**
* An {@link java.io.ObjectInputStream} that annotates classes using a given {@link ClassResolver}.
* @author Paul Ferraro
*/
public class ObjectOutputStream extends java.io.ObjectOutputStream {

private final ClassResolver resolver;

public ObjectOutputStream(OutputStream output, ClassResolver resolver) throws IOException {
super(output);
this.resolver = resolver;
}

@Override
protected void annotateClass(Class<?> targetClass) throws IOException {
this.resolver.annotateClass(this, targetClass);
}

@Override
protected void annotateProxyClass(Class<?> proxyClass) throws IOException {
this.resolver.annotateClass(this, proxyClass);
}
}
Loading