Package org.xmlBlaster.contrib.dbwriter

Examples of org.xmlBlaster.contrib.dbwriter.DbWriter


      if (readerInfo != null && writerInfo != null && readerInfo == writerInfo)
         throw new Exception("ReplicationAgent.init: the info objects are the same instance. This will lead to problems. Check your code and make sure they are separate instances");
      if (writerInfo != null) {
         log.info("setUp: Instantiating DbWriter");
         GlobalInfo.setStrippedHostname(writerInfo, GlobalInfo.UPPER_CASE);
         this.dbWriter = new DbWriter();
         this.dbWriter.init(writerInfo);
         slaveName = "client/" + writerInfo.get("mom.loginName", "DbWriter/session/1");
      }
      startDbWatcher(readerInfo);
   }
View Full Code Here


     
      String initialFilesLocation = this.info.get("replication.initialFilesLocation", "${user.home}/tmp");
      XmlScriptParser xmlScriptParser = new XmlScriptParser();
      xmlScriptParser.init(new Global(), null, null);

      DbWriter dbWriter = (DbWriter)this.info.getObject("org.xmlBlaster.contrib.dbwriter.DbWriter");
      if (dbWriter == null)
         throw new Exception("The DbWriter is not set in the info");
     
      File dirWhereToStore = ReplManagerPlugin.checkExistance(initialFilesLocation);
      File subDir = new File(dirWhereToStore, subDirName);
      if (!subDir.exists()) {
         String txt = "directory '" + subDir.getAbsolutePath() + "' does not exist";
         log.severe(txt);
         throw new Exception(txt);
      }
      if (!subDir.isDirectory()) {
         String txt = "file '" + subDir.getAbsolutePath() + "' is not a directory";
         log.severe(txt);
         throw new Exception(txt);
      }
     
      String[] files = subDir.list();
      log.info("retreiving '" + files.length + "' manual transferred data files from directory '" + subDir.getAbsolutePath() + "'");
      // alphabetical order guarantees correct sequence.
      TreeSet set = new TreeSet();
      for (int i=0; i < files.length; i++)
         set.add(files[i]);
      files = (String[])set.toArray(new String[set.size()]);
     
      for (int i=0; i < files.length; i++) {
         File file = new File(subDir, files[i]);
         if (!file.exists())
            throw new Exception("The entry nr. '" + i + "': file '" + file.getAbsolutePath() + "' does not exist");
         if (!file.isFile())
            throw new Exception("The entry nr. '" + i + "': file '" + file.getAbsolutePath() + "' is not a file");

         FileInputStream fis = new FileInputStream(file);
         MsgInfo[] msgInfos = xmlScriptParser.parse(fis);
         log.info("Processing entry " + i + " of " + files.length + ": '" + file.getAbsoluteFile() + "' which has " + msgInfos.length + "' msg");
         for (int j=0; j < msgInfos.length; j++) {
            MsgUnitRaw[] messages = msgInfos[j].getMessageArr();
            for (int k=0; k < messages.length; k++) {
               MsgUnit msgUnit = new MsgUnit(new Global(), messages[k].getKey(), messages[k].getContent(), messages[k].getQos());
               // MsgUnit msgUnit = (MsgUnit)messages[k].getMsgUnit();
               if (msgUnit == null)
                  throw new Exception("The message unit for '" + file.getAbsoluteFile() + "' is null");
               if (msgUnit.getQosData() == null)
                  throw new Exception("The qos for message unit of '" + file.getAbsoluteFile() + "' is null");
               Map subMap = msgUnit.getQosData().getClientProperties();
               byte[] subContent = msgUnit.getContent();
               dbWriter.update(topic, new ByteArrayInputStream(subContent), subMap);
            }
         }
      }
   }
View Full Code Here

      }
   }

   private I_DbSpecific getDbSpecific() {
      assertTrue("The agent must not be null", this.agent != null);
      DbWriter writer = this.agent.getDbWriter();
      assertTrue("The writer must not be null", writer != null);
      I_Info tmpInfo = writer.getInfo();
      assertTrue("The writer info must not be null", tmpInfo != null);

      String dbSpecificClass = tmpInfo.get("replication.dbSpecific.class", "org.xmlBlaster.contrib.replication.impl.SpecificOracle");
      I_DbSpecific dbSpecific = (I_DbSpecific)tmpInfo.getObject(dbSpecificClass + ".object");
      assertTrue("The dbSpecific for the writer must not be null", dbSpecific != null);
View Full Code Here

      return ret;
   }

   private I_DbSpecific getDbSpecific() {
      assertTrue("The agent must not be null", this.agent != null);
      DbWriter writer = this.agent.getDbWriter();
      assertTrue("The writer must not be null", writer != null);
      I_Info tmpInfo = writer.getInfo();
      assertTrue("The writer info must not be null", tmpInfo != null);

      String dbSpecificClass = tmpInfo.get("replication.dbSpecific.class", "org.xmlBlaster.contrib.replication.impl.SpecificOracle");
      I_DbSpecific dbSpecific = (I_DbSpecific)tmpInfo.getObject(dbSpecificClass + ".object");
      assertTrue("The dbSpecific for the writer must not be null", dbSpecific != null);
View Full Code Here

TOP

Related Classes of org.xmlBlaster.contrib.dbwriter.DbWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.