Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package edu.utn.frba.grupo5303.serverenviolibre.repository; import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.regions.Region; import com.amazonaws.regions.Regions; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; import edu.utn.frba.grupo5303.serverenviolibre.model.ImagenDynamo; import org.springframework.stereotype.Repository; /** * * @author flavio */ @Repository public class ImagenUsuarioDAODynamo implements ImagenUsuarioDAO { private static AmazonDynamoDBClient ddb; private DynamoDBMapper mapper; public ImagenUsuarioDAODynamo() { String regionName = "us-west-2"; Region region = Region.getRegion(Regions.fromName(regionName)); ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(20); ddb = new AmazonDynamoDBClient(new ProfileCredentialsProvider(), clientConfiguration); ddb.setRegion(region); mapper = new DynamoDBMapper(ddb); } @Override public void guardarImagenDeUsuario(ImagenDynamo imagen) { mapper.save(imagen); } @Override public ImagenDynamo getImagenDeUsuarioById(Integer id) { return mapper.load(ImagenDynamo.class, id); } @Override public void borrarImagen(ImagenDynamo imagen) { mapper.delete(imagen); } }