-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Default Serializer via a Factory method
Thus it is configurable from outside which Serializer and with which configuration is actually used as default.
- Loading branch information
Marcus Thiesen
committed
Jan 17, 2014
1 parent
b2715e8
commit f1f9f0a
Showing
5 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...src/main/java/de/javakaffee/web/msm/serializer/kryo/CompatibleFieldSerializerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2014 Marcus Thiesen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package de.javakaffee.web.msm.serializer.kryo; | ||
|
||
import com.esotericsoftware.kryo.Kryo; | ||
import com.esotericsoftware.kryo.Serializer; | ||
import com.esotericsoftware.kryo.serialize.CompatibleFieldSerializer; | ||
|
||
/** | ||
* Default Serializer Factory that creates a {@link CompatibleFieldSerializer} | ||
* | ||
* @author Marcus Thiesen ([email protected]) (initial creation) | ||
*/ | ||
public class CompatibleFieldSerializerFactory implements KryoDefaultSerializerFactory { | ||
|
||
@Override | ||
public Serializer newDefaultSerializer( Kryo kryo, Class<?> type ) { | ||
return new CompatibleFieldSerializer( kryo, type ); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...zer/src/main/java/de/javakaffee/web/msm/serializer/kryo/KryoDefaultSerializerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2014 Marcus Thiesen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package de.javakaffee.web.msm.serializer.kryo; | ||
|
||
import com.esotericsoftware.kryo.Kryo; | ||
import com.esotericsoftware.kryo.Serializer; | ||
|
||
/** | ||
* Interface for creating default Serializers for Kryo. | ||
* | ||
* @author Marcus Thiesen ([email protected]) (initial creation) | ||
*/ | ||
public interface KryoDefaultSerializerFactory { | ||
|
||
/** | ||
* Should return the Serializer used by Kryo when | ||
* {@link Kryo#newDefaultSerializer} is called. | ||
*/ | ||
public Serializer newDefaultSerializer( Kryo kryo, Class<?> type ); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../src/main/java/de/javakaffee/web/msm/serializer/kryo/ReferenceFieldSerializerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2014 Marcus Thiesen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package de.javakaffee.web.msm.serializer.kryo; | ||
|
||
import com.esotericsoftware.kryo.Kryo; | ||
import com.esotericsoftware.kryo.Serializer; | ||
import com.esotericsoftware.kryo.serialize.ReferenceFieldSerializer; | ||
|
||
/** | ||
* Default Serializer used by memcached-session-manager. | ||
* Creates a {@link ReferenceFieldSerializer} which does not ignores synthetic fields. | ||
* | ||
* @author Marcus Thiesen ([email protected]) (initial creation) | ||
*/ | ||
public class ReferenceFieldSerializerFactory implements KryoDefaultSerializerFactory { | ||
|
||
@Override | ||
public Serializer newDefaultSerializer( final Kryo kryo, final Class<?> type ) { | ||
final ReferenceFieldSerializer result = new ReferenceFieldSerializer( kryo, type ); | ||
result.setIgnoreSyntheticFields( false ); | ||
return result; | ||
} | ||
|
||
} |