From 33a0890d310f71afcf045305081b419dd3527f29 Mon Sep 17 00:00:00 2001 From: Dave Hladky Date: Tue, 29 Oct 2013 13:45:05 -0500 Subject: [PATCH] Issue #2361 Moved to private JAXB Former-commit-id: facfc8287c3826ca9764b7be336cc332b5567a94 --- .../HarvesterConfigurationManager.java | 56 ++++++++++--- .../harvester/HarvesterJaxbManager.java | 82 ------------------- .../harvester/crawler/Crawler.java | 2 - 3 files changed, 46 insertions(+), 94 deletions(-) delete mode 100644 edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java index 170a3b72eb..3c72740961 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java @@ -24,9 +24,16 @@ import java.io.File; import java.util.Arrays; import java.util.List; +import javax.xml.bind.JAXBException; + +import com.raytheon.uf.common.datadelivery.registry.Connection; +import com.raytheon.uf.common.datadelivery.registry.Provider; +import com.raytheon.uf.common.datadelivery.registry.ProviderType; +import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -53,6 +60,32 @@ public class HarvesterConfigurationManager { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(HarvesterConfigurationManager.class); + + private static final Class[] clazzess = new Class[] { + HarvesterConfig.class, Provider.class, Connection.class, + ProviderType.class, ServiceType.class, Agent.class, + CrawlAgent.class, OGCAgent.class, ConfigLayer.class }; + + private static JAXBManager jaxb = null; + + /** + * marshall and unmarshall harvester objects + * + * @return + */ + private static JAXBManager getJaxb() { + + if (jaxb == null) { + try { + jaxb = new JAXBManager(clazzess); + + } catch (JAXBException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); + } + } + return jaxb; + } /** * Gets site and base level configs for harvesters @@ -123,36 +156,39 @@ public class HarvesterConfigurationManager { /** * Get this harvester configuration File + * * @param file * @return */ public static HarvesterConfig getHarvesterFile(File file) { - + HarvesterConfig config = null; - + try { - config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file); + config = getJaxb() + .unmarshalFromXmlFile(HarvesterConfig.class, file); } catch (SerializationException e) { statusHandler.handle(Priority.ERROR, - "Can't deserialize harvester config at " - + file.getPath(), e); + "Can't deserialize harvester config at " + file.getPath(), + e); } - + return config; } - + /** * Writes the harvester config files + * * @param config * @param file */ public static void setHarvesterFile(HarvesterConfig config, File file) { try { - HarvesterJaxbManager.getJaxb().marshalToXmlFile(config, - file.getAbsolutePath()); + getJaxb().marshalToXmlFile(config, file.getAbsolutePath()); } catch (SerializationException e) { - statusHandler.handle(Priority.ERROR, "Couldn't write Harvester Config file.", e); + statusHandler.handle(Priority.ERROR, + "Couldn't write Harvester Config file.", e); } } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java deleted file mode 100644 index 45a78baab0..0000000000 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.raytheon.uf.common.datadelivery.harvester; - -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -import javax.xml.bind.JAXBException; - -import com.raytheon.uf.common.datadelivery.registry.Connection; -import com.raytheon.uf.common.datadelivery.registry.Provider; -import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType; -import com.raytheon.uf.common.datadelivery.registry.ProviderType; -import com.raytheon.uf.common.serialization.JAXBManager; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -/** - * JAXB for Harvester - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 23, 2013 2361       dhladky     Initial creation
- * 
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public class HarvesterJaxbManager { - - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(HarvesterJaxbManager.class); - - private static Class[] clazzess = new Class[] { - HarvesterConfig.class, Provider.class, Connection.class, - ProviderType.class, ServiceType.class, Agent.class, - CrawlAgent.class, OGCAgent.class, ConfigLayer.class }; - - private JAXBManager jaxb = null; - - private static HarvesterJaxbManager instance = new HarvesterJaxbManager(); - - /** - * marshall and unmarshall harvester objects - * - * @return - */ - public static JAXBManager getJaxb() { - - if (instance.jaxb == null) { - try { - instance.jaxb = new JAXBManager(clazzess); - - } catch (JAXBException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); - } - } - return instance.jaxb; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java index a5d8aa879e..fb8263eaec 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java @@ -17,9 +17,7 @@ import com.raytheon.uf.common.comm.ProxyConfiguration; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; -import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.datadelivery.registry.Collection; -import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority;