Debian Codegraph @

jetty-infinispan/infinispan-common/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSerializationContextInitializer.java

raw
1 //
2 // ========================================================================
3 // Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
4 //
5 // This program and the accompanying materials are made available under the
6 // terms of the Eclipse Public License v. 2.0 which is available at
7 // https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
8 // which is available at https://www.apache.org/licenses/LICENSE-2.0.
9 //
10 // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
11 // ========================================================================
12 //
13
14 package org.eclipse.jetty.session.infinispan;
15
16 import java.io.UncheckedIOException;
17
18 import org.infinispan.protostream.FileDescriptorSource;
19 import org.infinispan.protostream.SerializationContext;
20 import org.infinispan.protostream.SerializationContextInitializer;
21
22 /**
23 * Set up the marshaller for InfinispanSessionData serialization
24 *
25 */
26 public class InfinispanSerializationContextInitializer implements SerializationContextInitializer
27 {
28 @Override
29 public String getProtoFileName()
30 {
31 return "session.proto";
32 }
33
34 @Override
35 public String getProtoFile() throws UncheckedIOException
36 {
37 return FileDescriptorSource.getResourceAsString(getClass(), "/" + getProtoFileName());
38 }
39
40 @Override
41 public void registerSchema(SerializationContext serCtx)
42 {
43 serCtx.registerProtoFiles(FileDescriptorSource.fromString(getProtoFileName(), getProtoFile()));
44 }
45
46 @Override
47 public void registerMarshallers(SerializationContext serCtx)
48 {
49 serCtx.registerMarshaller(new SessionDataMarshaller());
50 }
51 }