Issue #2361 Moved to private JAXB
Former-commit-id: facfc8287c3826ca9764b7be336cc332b5567a94
This commit is contained in:
parent
15aed68c02
commit
33a0890d31
3 changed files with 46 additions and 94 deletions
|
@ -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;
|
||||
|
@ -54,6 +61,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,6 +156,7 @@ public class HarvesterConfigurationManager {
|
|||
|
||||
/**
|
||||
* Get this harvester configuration File
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
|
@ -131,11 +165,12 @@ public class HarvesterConfigurationManager {
|
|||
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;
|
||||
|
@ -144,15 +179,16 @@ public class HarvesterConfigurationManager {
|
|||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 23, 2013 2361 dhladky Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue