Package javolution.xml

Examples of javolution.xml.XMLObjectReader


     *
     * @param inputStream the input stream holding the xml configuration.
     */
    public static void read(InputStream inputStream) {
        try {
            XMLObjectReader reader = XMLObjectReader.newInstance(inputStream);
            XMLBinding binding = new XMLBinding() {
                protected XMLFormat getFormat(Class forClass) throws XMLStreamException  {
                    if (Configurable.class.isAssignableFrom(forClass))
                        return new ConfigurableXMLFormat();
                    return super.getFormat(forClass);
                }
            };
            binding.setAlias(Configurable.class, "Configurable");
            reader.setBinding(binding);
            // Reads and configures.
            reader.read("Configuration", FastTable.class);
        } catch (Exception ex) {
            LogContext.error(ex);
        }
    }
View Full Code Here


    return this.started;
  }

  @SuppressWarnings("unchecked")
  public void load() throws FileNotFoundException {
    XMLObjectReader reader = null;
    try {
      reader = XMLObjectReader.newInstance(new FileInputStream(persistFile.toString()));
      reader.setBinding(binding);

            try {
                this.connectDelay = reader.read(CONNECT_DELAY_PROP, Integer.class);
                this.workerThreads = reader.read(WORKER_THREADS_PROP, Integer.class);
                this.singleThread = reader.read(SINGLE_THREAD_PROP, Boolean.class);
            } catch (java.lang.NullPointerException npe) {
                // ignore.
                // For backward compatibility we can ignore if these values are not defined
            }     

      this.servers = reader.read(SERVERS, FastList.class);

      for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
        Server serverTemp = n.getValue();
        ((ServerImpl) serverTemp).setManagement(this);
        if (serverTemp.isStarted()) {
          try {
            ((ServerImpl) serverTemp).start();
          } catch (Exception e) {
            logger.error(String.format("Error while initiating Server=%s", serverTemp.getName()), e);
          }
        }
      }

      this.associations = reader.read(ASSOCIATIONS, AssociationMap.class);
      for (FastMap.Entry<String, Association> n = this.associations.head(), end = this.associations.tail(); (n = n.getNext()) != end;) {
        AssociationImpl associationTemp = (AssociationImpl) n.getValue();
        associationTemp.setManagement(this);
      }
View Full Code Here

     */

    protected final  JSSnapshot readFile(String importFileName, XMLBinding binding)
            throws SerializerException
    {
        XMLObjectReader reader = null;
        JSSnapshot snap = null;
        try
        {
            reader = XMLObjectReader.newInstance(new FileInputStream(
                    importFileName));
        } catch (Exception e)
        {
            throw new SerializerException(SerializerException.FILE_READER_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        }
        try
        {
            if (binding != null) reader.setBinding(binding);
            snap = (JSSnapshot) reader.read(this.getSerializerDataTag(),
                getSerializerDataClass());

        } catch (Exception e)
        {
            e.printStackTrace();
            new SerializerException(SerializerException.FILE_PROCESSING_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        } finally
        {
            /** ensure the reader is closed */
            try
            {
                logMe("*********closing up reader ********");
                reader.close();
            } catch (Exception e1)
            {
                logMe("Error in closing reader " + e1.getMessage());
                /**
                 * don't do anything with this exception - never let the bubble
View Full Code Here

     */

    protected final  JSSnapshot readFile(String importFileName, XMLBinding binding)
            throws SerializerException
    {
        XMLObjectReader reader = null;
        JSSnapshot snap = null;
        try
        {
            reader = XMLObjectReader.newInstance(new FileInputStream(
                    importFileName));
        } catch (Exception e)
        {
            throw new SerializerException(SerializerException.FILE_READER_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        }
        try
        {
            if (binding != null) reader.setBinding(binding);
            snap = (JSSnapshot) reader.read(this.getSerializerDataTag(),
                getSerializerDataClass());

        } catch (Exception e)
        {
            e.printStackTrace();
            new SerializerException(SerializerException.FILE_PROCESSING_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        } finally
        {
            /** ensure the reader is closed */
            try
            {
                logMe("*********closing up reader ********");
                reader.close();
            } catch (Exception e1)
            {
                logMe("Error in closing reader " + e1.getMessage());
                /**
                 * don't do anything with this exception - never let the bubble
View Full Code Here

      reader = new InputStreamReader(in);
    } else {
      reader = new InputStreamReader(in, encoding);
    }
   
      XMLObjectReader objectReader = XMLObjectReader.newInstance(reader);
      objectReader.setBinding(mBinding);
     
      try {
        return objectReader.read();
      } finally {
        objectReader.close();
      }
  }
View Full Code Here

     */

    protected final  JSSnapshot readFile(String importFileName, XMLBinding binding)
            throws SerializerException
    {
        XMLObjectReader reader = null;
        JSSnapshot snap = null;
        try
        {
            reader = XMLObjectReader.newInstance(new FileInputStream(
                    importFileName));
        } catch (Exception e)
        {
            throw new SerializerException(SerializerException.FILE_READER_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        }
        try
        {
            if (binding != null) reader.setBinding(binding);
            snap = (JSSnapshot) reader.read(this.getSerializerDataTag(),
                getSerializerDataClass());

        } catch (Exception e)
        {
            e.printStackTrace();
            new SerializerException(SerializerException.FILE_PROCESSING_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        } finally
        {
            /** ensure the reader is closed */
            try
            {
                logMe("*********closing up reader ********");
                reader.close();
            } catch (Exception e1)
            {
                logMe("Error in closing reader " + e1.getMessage());
                /**
                 * don't do anything with this exception - never let the bubble
View Full Code Here

   * @throws SerializerException
   */

  private ArrayList readOrderFile(String importFileName)
  {
    XMLObjectReader reader = null;

    XMLBinding binding = new XMLBinding();
    binding.setAlias(ArrayList.class, "ProcessOrder");
    binding.setAlias(JSGroup.class, "File");

    ArrayList snap = null;
    try
    {
      reader = XMLObjectReader.newInstance(new FileInputStream(
          importFileName));
    } catch (Exception e)
    {
      e.printStackTrace();
      return null;
    }
    try
    {
      reader.setBinding(binding);
      snap = (ArrayList) reader.read("ProcessOrder", ArrayList.class);

    } catch (Exception e)
    {
      e.printStackTrace();
    } finally
    {
      /** ensure the reader is closed */
      try
      {
        reader.close();
      } catch (Exception e1)
      {
        /**
         * don't do anything with this exception - never let the bubble
         * out of the finally block
View Full Code Here

   * @throws SerializerException
   */

  private ArrayList readOrderFile(String importFileName)
  {
    XMLObjectReader reader = null;

    XMLBinding binding = new XMLBinding();
    binding.setAlias(ArrayList.class, "ProcessOrder");
    binding.setAlias(JSGroup.class, "File");

    ArrayList snap = null;
    try
    {
      reader = XMLObjectReader.newInstance(new FileInputStream(
          importFileName));
    } catch (Exception e)
    {
      e.printStackTrace();
      return null;
    }
    try
    {
      reader.setBinding(binding);
      snap = (ArrayList) reader.read("ProcessOrder", ArrayList.class);

    } catch (Exception e)
    {
      e.printStackTrace();
    } finally
    {
      /** ensure the reader is closed */
      try
      {
        reader.close();
      } catch (Exception e1)
      {
        /**
         * don't do anything with this exception - never let the bubble
         * out of the finally block
View Full Code Here

     */

    protected final  JSSnapshot readFile(String importFileName, XMLBinding binding)
            throws SerializerException
    {
        XMLObjectReader reader = null;
        JSSnapshot snap = null;
        try
        {
            reader = XMLObjectReader.newInstance(new FileInputStream(
                    importFileName));
        } catch (Exception e)
        {
            throw new SerializerException(SerializerException.FILE_READER_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        }
        try
        {
            if (binding != null) reader.setBinding(binding);
            snap = (JSSnapshot) reader.read(this.getSerializerDataTag(),
                getSerializerDataClass());

        } catch (Exception e)
        {
            e.printStackTrace();
            new SerializerException(SerializerException.FILE_PROCESSING_ERROR
                    .create(new String[]
                    { importFileName, e.getMessage()}));
        } finally
        {
            /** ensure the reader is closed */
            try
            {
                logMe("*********closing up reader ********");
                reader.close();
            } catch (Exception e1)
            {
                logMe("Error in closing reader " + e1.getMessage());
                /**
                 * don't do anything with this exception - never let the bubble
View Full Code Here

        super("javolution xmlformat");
    }

  public MediaContent deserialize(byte[] array) throws Exception
  {
    XMLObjectReader reader = XMLObjectReader.newInstance(new ByteArrayInputStream(array)).setBinding(_binding);
    try {
      return reader.read("mc", MediaContent.class);
    } finally {
      reader.close();
    }
  }
View Full Code Here

TOP

Related Classes of javolution.xml.XMLObjectReader

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.