Guest User

ReverseMapping workaround

a guest
Dec 12th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static Map<Class<?>, String> runReverseMapping(JDBCConfiguration jconf) {
  2.         String hookId = UUID.randomUUID().toString();
  3.  
  4.         jconf.setId(hookId);
  5.  
  6.         //>-cc (customizerClass) is how we get the ReverseMappingTool instance later on
  7.         Options rmOpts = new Options();
  8.         String argString = String.format(... "-cc %s" ..., //
  9.                 HookPropertiesReverseCustomizer.class.getName());
  10.         rmOpts.setFromCmdLine(StringUtils.split(argString, " "));
  11.  
  12.         try {
  13.             ReverseMappingTool.run(jconf, new String[0], rmOpts);
  14.         } catch (Exception e) {
  15.             // e.printStackTrace();
  16.         }
  17.  
  18.         ReverseMappingTool gotTool = HookPropertiesReverseCustomizer.popTool(hookId);
  19. ...
  20. }
  21.  
  22. ---------------------------------------------
  23.  
  24. public class HookPropertiesReverseCustomizer extends PropertiesReverseCustomizer {
  25.     private static Map<String, ReverseMappingTool> idToTool = new HashMap<>();
  26.  
  27.     @Override
  28.     public void setTool(ReverseMappingTool tool) {
  29.         super.setTool(tool);
  30.         idToTool.put(tool.getConfiguration().getId(), tool);
  31.     }
  32.  
  33.     public static ReverseMappingTool popTool(String id) {
  34.         return idToTool.remove(id);
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment