How to replace `JsonMarshaller` with `DynamoDBTypeConvertedJson` in aws-sdk 1.12.245? - aws-sdk

I am helping my team updating our service which is currently using some deprecated aws-sdk feature
some of our code is using JsonMarshaller :
public abstract class SomeTaskClass {
...
#DynamoDBMarshalling(marshallerClass = SomeExponentialRetryPolicyRecordMarshaller.class)
#DynamoDBAttribute(attributeName = "SomeExponentialRetryPolicy")
private SomeExponentialRetryPolicy exponentialRetryPolicy;
#DynamoDBMarshalling(marshallerClass = SomeLinearRetryPolicyRecordMarshaller.class)
#DynamoDBAttribute(attributeName = "someLinearRetryPolicy")
private SomeLinearRetryPolicy linearRetryPolicy;
static public class SomeExponentialRetryPolicyRecordMarshaller extends JsonMarshaller<ExponentialRetryPolicy> { }
static public class SomeLinearRetryPolicyRecordMarshaller extends JsonMarshaller<LinearRetryPolicy> { }
...
}
I have looked everywhere which I could, I don't find any good way to update these deprecated APIs, looking for suggestions here, any idea would be great

Related

How do I get proguard working with sjersey?

Trying to use Jersey with Scala, via a fork of SJersey, and obfuscating it with ProGuard.
I've got all of this stuff:
-keepattributes SourceFile,LineNumberTable,*Annotation*,EnclosingMethod,Signature,InnerClasses
and I'm doing this:
-keep public class com.example.*JsonSeralisedClasses {
public *;
}
but when I encode stuff with jersey nothing comes out!
Figured out eventually that SJersey doesn't use public methods, but introspects onto private fields, so one needs to do this:
-keep public class com.example.*JsonSeralisedClasses {
public protected private *;
}
See protected private is the difference.
Alernatively, you can annotate everything with #BeanProperty (which makes public accessors that are preserved using the original config).

LibGDX: addActor(Body body)

I get a little bit confused by the tutorial at this site:
http://williammora.com/a-running-game-with-libgdx-part-2/
Why is it possible to give a body to the addActor method?
Can someone explain me this?
I thought I must give it some Actor.
private void setUpGround() {
ground = new Ground(WorldUtils.createGround(world));
addActor(ground);
}
private void setUpRunner() {
runner = new Runner(WorldUtils.createRunner(world));
addActor(runner);
}
Take again a look at the code. There is nowhere passed a Body object to the addActor method.
The only objects I see passed as parameters to the addActor method are runner & ground.
But those classes are extending the Actor class and not Body, see the code:
public class Runner extends GameActor { //..
and
public class Ground extends GameActor { //..
last not least the author of the code has defined the GameActor class like this:
public abstract class GameActor extends Actor { //..
==> you can see that those are subclasses of Actor and not Body. I hope it is clearer now.
BTW: if you use development environments like eclipse you can make use of the "Type Hierarchy" view!

Jaxb json missing brackets for one element array

I'm using JAXB/Jersey (1.3) to convert java to json in a REST API.
I read a lot about this problem, I tryed this solution, it work a half:
#XmlRootElement
public class ArrayWrapper
{
public List<String> list = new LinkedList<String>();
}
and my ContextResolver:
#Provider
public class JAXBContextResolver implements ContextResolver<JAXBContext> {
private JAXBContext context;
private Class[] types = {ArrayWrapper.class,Wrapper.class};
public JAXBContextResolver() throws Exception {
MappedBuilder builder = JSONConfiguration.mapped();
builder.arrays("list");
builder.rootUnwrapping(true);
this.context = new JSONJAXBContext(builder.build(), types);
}
ArrayWrapper aw=new ArrayWrapper();
aw.list.add("test");
I get {"list":["test"]} so it works but when I wrapp ArrayWrapper in an other class it don't work:
#XmlRootElement
public class Wrapper
{
public ArrayWrapper aw;
public Wrapper()
{
aw=new ArrayWrapper();
aw.list.add("test");
}
}
new Wrapper();
I get {"aw":{"list":"test"}}
Anyone know how to fix it?
I am not quite sure if you got it working so I am contributing my bit.
I also stumbled upon this issue recently. I found a post in stackoverflow that helped me, but even more helpful was this article (introducing Jackson might help).
I hope this helps you, too. For me it was a matter of 5 minutes to fix the issue.

Struts2 JSON Plugin With Annotations

I have a Struts2 Action Class configured via annotations. All of the "normal" methods that are annotated with #Action work fine.
However, I need to add a method into the action that returns JSON.
Here is a trimmed down version of my class (dao autowired with Spring):
#Namespace("featureClass")
// define success and input actions for class here
public class FeatureClassAction extends ActionSupport {
FeatureClassDao featureClassDao;
#Autowired
public setFeatureClassDao(FeatureClassDeao featureClassDao) {
this.featureClassDao = featureClassDao;
}
List<FeatureClass> featureClasses;
// snip normal actions
#Action("/featureClassesJSON")
#JSON
public String getFeatureClassesJSON() throws Exception {
featureClasses = featureClassDao.getAll();
return SUCCESS;
}
}
Can anyone assist? If I have to go the struts.xml route, that means moving all of my other actions (which work fine) into it.
I figured I would share the answer, since anyone else with the same problem would likely also face the silence.
I created two actions: FeatureClassAction and FeatureClassJsonAction. FeatureClassAction was annotated as such:
#ParentPackage("struts-default")
#Namespace("/featureClass")
public class FeatureClassAction extends ActionSupport {
FeatureClassJsonAction is annotated like this:
#ParentPackage("json-default")
#Namespace("/featureClass")
public class FeatureClassJsonAction extends ActionSupport {
The method in the JSON Action was annotated like this:
#Action(value="featureClassesJson", results = {
#Result(name="success", type="json")
})
public String getFeatureClassesJSON() throws Exception {
Hope it helps someone.

Mixin or Trait implementation in AS3?

I'm looking for ideas on how to implement a Mixin/Trait style system in AS3.
I want to be able to compose a number of classes together into a single object. Of course this is not a language level feature of AS3, but I'm hoping that there is maybe some way to do this using prototype based techniques or maybe some bytecode hacking that I believe AsMock uses to implement it's functionality.
An existing Java example is Qi4J where the user define interfaces that the Qi4j framework implements based on metadata tags and coding by convention.
Has anyone any ideas on how to get the Mixin/Trait concept working within AS3?
Zero solutions presented on this, so I looked into a few methods. There are ECMA script style mixins by adding methods defined on other objects to the base objects prototype. But this means that the advantages of static typing are gone.
I was looking for a solution that didn't sidestep the static type system. I knew that ASMock used bytecode injection to create proxy classes. I hacked around ASMock for the past few days and came up with a possible solution implemented by creating a class with composed classes (through bytecode injection).
From the users point of view this involves defining your object that uses mixins through many interfaces:
public interface Person extends RoomObject, Moveable
public interface RoomObject
{
function joinRoom(room:Room):void
function get room():Room
}
public interface Moveable
{
function moveTo(location:Point):void
function get location():Point
}
Then you define classes to represent these interfaces:
public class MoveableImpl implements Moveable
{
private var _location:Point = new Point()
public function get location():Point { return _location }
public function move(location:Point):void
{
_location = location.clone()
}
}
public class RoomObjectImpl implements RoomObject
{
private var _room:Room
public function get room():Room { return _room }
public function joinRoom(room:Room):void
{
_room = room
}
}
In a normal situation where you want to compose classes you would write:
public class PersonImpl implements Person
{
private var _roomObject:RoomObject = new RoomObjectImpl()
private var _moveable:Moveable = new MoveableImpl()
public function get room():Room { return _roomObject.room }
public function joinRoom(room:Room):void { _roomObject.joinRoom(room) }
public function get location():Point { return _moveable.location }
public function move(location:Point):void { _moveable.move(location) }
}
This is easily written using code due to it's regular layout. And that is exactly what my solution does, by injecting the equivilant bytecode into a new class. With this bytecode injection system we can create a Person object like so:
public class Main
{
private var mixinRepo:MixinRepository = new MixinRepository()
public function Main()
{
with(mixinRepo)
{
defineMixin(RoomObject, RoomObjectImpl) // associate interfaces with concreate classes
defineMixin(Moveable, MoveableImpl)
defineBase(Person)
prepare().completed.add(testMixins) // the injection is a async process, just liek in ASMock
}
}
private function testMixins():void
{
var person:Person = mixinRepo.create(Person)
var room:Room = new Room('room you can play in')
person.joinRoom(room)
trace('person.room:', person.room)
person.move(new Point(1, 2))
trace('person.location:', person.location)
}
}
At the moment this system is a proof of concept and is therefore very basic and brittle. But it shows that it is possible to come close to a Scala mixin/traits style system to AS3. I've made a github project to hold the code if anyone is interested in running the solution and poking around at how it was done.
A more complete example is given on the project wiki.
Look here, this works, mixes in methods and is simple.
http://github.com/specialunderwear/as3-mixin
o, and it works when you compile in as3 mode.
I found this one in Realaxy -- http://realaxy.com/