SHARE
TWEET

lc

a guest Feb 8th, 2010 220 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class DataServiceCalledByUIPresenterOrSomething {
  2.         public DAO nsaDao;
  3.  
  4.         public StupidTransferObject loadLeakedUFOData(Id ufoId) {
  5.                
  6.                 BusinessObjectInterface businessObject = nsaDao.loadBusinessObject(ufoId);
  7.                 return (StupidTransferObject) businessObject.createSecureTransferObject(StupidTransferObject.class);
  8.         }
  9. }
  10.  
  11. public class NSABusinessObjectImpl implements TransferObjectEnabled {
  12.        
  13.         private String totally;
  14.  
  15.         private String secret;
  16.  
  17.         private String data;
  18.        
  19.         public TransferObject createSecureTransferObject(Class transferObjectClass) {
  20.                
  21.                 // do this better with reflection and/or dependency injection via a map of factories
  22.                 // implementation depends on how harcoded it should be, this is just for demo purposes
  23.                 // want it easy return a save map or list of clones or whatever you need, TOs are not everything mho :P
  24.                
  25.                 if(StupidTransferObject instanceOf transferObjectClass) {
  26.                        
  27.                         StupidTransferObject propaganda = new StupidTransferObject();
  28.  
  29.                         propanda.some =  fuckUpDataSoNobodyWillUnderstand(totally);
  30.                         propanda.truth =  fuckUpDataSoNobodyWillUnderstand(secret);
  31.                         propanda.forTheMasses =  fuckUpDataSoNobodyWillUnderstand(data);
  32.  
  33.                         return propaganda;
  34.                 } else if(AnotherStupidTransferObject instanceOf transferObjectClass) {
  35.                         //...
  36.                 } else {
  37.                         throw new InvalidRequestRuntimeException("No no no no! :P ");
  38.                 }
  39.         }
  40.        
  41.         private String fuckUpDataSoNobodyWillUnderstand(String data) {
  42.                 // fuck up the data...
  43.                
  44.                 // return a clone of the truth
  45.                 return fuckedUp.clone();
  46.         }
  47. }
  48.  
  49. public class StupidTransferObject implements TransferObject {
  50.        
  51.         public String some;
  52.  
  53.         public String truth;
  54.  
  55.         public String forTheMasses;
  56. }
  57.  
  58.  
  59. //interfaces
  60.  
  61. public Interface TransferObject {
  62.        
  63.         // marker
  64. }
  65.  
  66. public Interface TransferObjectEnabled {
  67.        
  68.         TransferObject createSecureTransferObject(Class transferObjectClass);
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top