diff --git a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF index 47222c2ab8..a3561a026f 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Core Plug-in Bundle-SymbolicName: com.raytheon.uf.viz.core;singleton:=true -Bundle-Version: 1.12.1174.qualifier +Bundle-Version: 1.13.0.qualifier Bundle-Activator: com.raytheon.uf.viz.core.Activator Bundle-Vendor: Raytheon Require-Bundle: org.eclipse.ui, @@ -77,6 +77,7 @@ Export-Package: com.raytheon.uf.viz.core, com.raytheon.uf.viz.core.notification.observers, com.raytheon.uf.viz.core.preferences, com.raytheon.uf.viz.core.procedures, + com.raytheon.uf.viz.core.reflect, com.raytheon.uf.viz.core.requests, com.raytheon.uf.viz.core.rsc, com.raytheon.uf.viz.core.rsc.capabilities, diff --git a/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF index fda659921f..1d5205be98 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF @@ -10,6 +10,7 @@ Require-Bundle: org.apache.batik;bundle-version="1.6.0", org.eclipse.ui, org.eclipse.core.runtime, com.raytheon.viz.core, + com.raytheon.uf.viz.core, com.raytheon.viz.ui, javax.measure;bundle-version="1.0.0", org.apache.commons.lang, diff --git a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java index a14e41e0b3..897ffaa727 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java +++ b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java @@ -1,7 +1,5 @@ package gov.noaa.nws.ncep.viz.resources.manager; -import gov.noaa.nws.ncep.viz.common.area.PredefinedArea; -import gov.noaa.nws.ncep.viz.common.area.PredefinedAreaFactory; import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor; import gov.noaa.nws.ncep.viz.common.display.INatlCntrsPaneManager; import gov.noaa.nws.ncep.viz.common.display.INatlCntrsRenderableDisplay; @@ -21,6 +19,7 @@ import gov.noaa.nws.ncep.viz.ui.display.NcPaneLayout; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.util.Collection; import java.util.Map; import javax.xml.bind.JAXBException; @@ -32,14 +31,16 @@ import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.jaxb.JAXBClassLocator; +import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.VariableSubstitutionUtil; import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.reflect.SubClassLocator; import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.viz.ui.editor.AbstractEditor; @@ -62,7 +63,8 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * 11/25/12 #630 Greg Hull getDefaultRBD() * 02/22/10 #972 Greg Hull created from old RbdBundle * 05/14/13 #862 Greg Hull implement INatlCntrsPaneManager - * + * 10/29/13 #2491 bsteffen Use custom JAXB context instead of SerializationUtil. + * * * * @author ghull @@ -71,7 +73,9 @@ import com.raytheon.viz.ui.editor.AbstractEditor; @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public abstract class AbstractRBD - implements INatlCntrsPaneManager, ISerializableObject, Comparable> { + implements INatlCntrsPaneManager, Comparable> { + + private static JAXBManager jaxb; @XmlElement protected NcDisplayType displayType = NcDisplayType.NMAP_DISPLAY; @@ -259,7 +263,7 @@ public abstract class AbstractRBD File tempRbdFile = File.createTempFile("tempRBD-", ".xml"); - SerializationUtil.jaxbMarshalToXmlFile( rbdBndl, + getJaxbManager().marshalToXmlFile(rbdBndl, tempRbdFile.getAbsolutePath() ); AbstractRBD clonedRbd = getRbd( tempRbdFile ); @@ -289,6 +293,8 @@ public abstract class AbstractRBD } catch (SerializationException e) { throw new VizException( e ); + } catch (JAXBException e) { + throw new VizException(e); } catch (VizException e) { throw new VizException("Error loading rbd "+rbdBndl.rbdName+" :"+e.getMessage() ); } catch (IOException e) { // from createTempFile @@ -396,7 +402,7 @@ public abstract class AbstractRBD public String toXML() throws VizException { try { - return SerializationUtil.marshalToXml(this); + return getJaxbManager().marshalToXml(this); } catch (JAXBException e) { throw new VizException(e); } @@ -588,7 +594,7 @@ public abstract class AbstractRBD String substStr = VariableSubstitutionUtil.processVariables( bundleStr, variables); - Object xmlObj = SerializationUtil.unmarshalFromXml(substStr); + Object xmlObj = getJaxbManager().unmarshalFromXml(substStr); if (!(xmlObj instanceof AbstractRBD)) { System.out.println("Unmarshalled rbd file is not a valid RBD?"); return null; @@ -660,6 +666,36 @@ public abstract class AbstractRBD } } + /** + * Builds and returns a JAXB manager which has the ability to + * marshal/unmarshall all AbstractRBD types. + * + * @return a JAXBManager to use for marshalling/unmarshalling RBDs. + * @throws JAXBException + * if there are illegal JAXB annotations. + */ + public static synchronized JAXBManager getJaxbManager() + throws JAXBException { + if (jaxb == null) { + SubClassLocator locator = new SubClassLocator(); + Collection> classes = JAXBClassLocator.getJAXBClasses( + locator, AbstractRBD.class); + locator.save(); + + Class[] jaxbClasses = new Class[classes.size() + 1]; + classes.toArray(jaxbClasses); + /* + * Add JaxbDummyObject at the begining so properties are loaded + * correctly + */ + jaxbClasses[jaxbClasses.length - 1] = jaxbClasses[0]; + jaxbClasses[0] = JaxbDummyObject.class; + + jaxb = new JAXBManager(jaxbClasses); + } + return jaxb; + } + public NCTimeMatcher getTimeMatcher() { if (timeMatcher == null) { timeMatcher = (NCTimeMatcher) displays[0].getDescriptor() diff --git a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java index d9cb7f756f..1103ac2264 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java +++ b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java @@ -6,26 +6,20 @@ import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData; import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsResourceData; import gov.noaa.nws.ncep.viz.resources.INatlCntrsResourceData; -import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; -import java.io.IOException; import java.util.HashMap; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.viz.core.VariableSubstitutionUtil; -import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.procedures.Bundle; import com.raytheon.uf.viz.core.rsc.ResourceGroup; import com.raytheon.uf.viz.core.rsc.ResourceList; /** - * Class used by the content providers for Resources and Overlays. This stores the - * instantiated Resource Bundle Templates first with the default attributes and - * additionally stores later changes to the attributes. + * Class used by the content providers for Resources and Overlays. This stores + * the instantiated Resource Bundle Templates first with the default attributes + * and additionally stores later changes to the attributes. * *
  * SOFTWARE HISTORY
@@ -43,10 +37,11 @@ import com.raytheon.uf.viz.core.rsc.ResourceList;
  * 08/23/10     #273        Greg Hull       isVisible()
  * 11/17/11     #518        Greg Hull       set dfltFrameTimes (GDATTIM)
  * 02/10/13     #972        Greg Hull       getSupportedDisplayTypes
- *   
+ * 10/29/13     #2491       bsteffen        Use AbstratRBD JAXBManager instead of SerializationUtil.
+ * 
  * 
* - * @author + * @author * @version 1 */ @@ -187,7 +182,7 @@ public class ResourceFactory { ResourceList bndl_rscs = null; - Object rg = SerializationUtil.unmarshalFromXml(substStr); + Object rg = AbstractRBD.getJaxbManager().unmarshalFromXml(substStr); if( !(rg instanceof ResourceGroup) ) { throw new VizException("Resource Bundle template has unexpected class. (not ResourceGroup)");