diff --git a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java index 3b6a6d948e..7d077fcd27 100644 --- a/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java +++ b/cave/com.raytheon.uf.viz.core.maps/src/com/raytheon/uf/viz/core/maps/scales/MapScalesManager.java @@ -35,7 +35,6 @@ import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.exception.LocalizationException; 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.SingleTypeJAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -46,6 +45,7 @@ import com.raytheon.uf.viz.core.maps.scales.MapScales.MapScale; import com.raytheon.uf.viz.core.maps.scales.MapScales.PartId; import com.raytheon.uf.viz.core.procedures.Bundle; import com.raytheon.uf.viz.core.procedures.Procedure; +import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager; import com.raytheon.viz.ui.actions.LoadSerializedXml; /** @@ -56,9 +56,11 @@ import com.raytheon.viz.ui.actions.LoadSerializedXml; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Oct 8, 2013 mschenke Initial creation + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Oct 08, 2013 mschenke Initial creation + * Oct 22, 2013 2491 bsteffen Change from SerializationUtil to + * ProcedureXmlManager * * * @@ -119,13 +121,8 @@ public class MapScalesManager { this.displayName = displayName; this.partIds = new PartId[0]; this.scaleFile = null; - try { - this.bundleXml = SerializationUtil.getJaxbManager() - .marshalToXml(scaleBundle); - } catch (JAXBException e) { - throw new SerializationException( - "Error serializing bundle for scale, " + displayName); - } + this.bundleXml = ProcedureXmlManager.getInstance().marshal( + scaleBundle); } private void loadBundleXml() { @@ -146,10 +143,8 @@ public class MapScalesManager { if (bundleXml != null) { long t0 = System.currentTimeMillis(); try { - return (Bundle) SerializationUtil.getJaxbManager() - .unmarshalFromXml(bundleXml); - } catch (JAXBException e) { - throw new SerializationException(e); + return ProcedureXmlManager.getInstance().unmarshal( + Bundle.class, bundleXml); } finally { System.out.println("Time to create Bundle: " + (System.currentTimeMillis() - t0) + "ms"); 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 5f6ec90fa7..47222c2ab8 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF @@ -42,7 +42,8 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.common.python;bundle-version="1.12.1174", com.raytheon.uf.common.velocity;bundle-version="1.0.0", ch.qos.logback;bundle-version="1.0.13", - com.raytheon.uf.common.style;bundle-version="1.0.0" + com.raytheon.uf.common.style;bundle-version="1.0.0", + org.reflections;bundle-version="0.9.9" Bundle-ActivationPolicy: lazy Eclipse-BuddyPolicy: ext, registered, global Eclipse-RegisterBuddy: org.apache.velocity, com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status, com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.comm, ch.qos.logback diff --git a/cave/com.raytheon.uf.viz.core/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/cave/com.raytheon.uf.viz.core/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index aa203ed95e..0000000000 --- a/cave/com.raytheon.uf.viz.core/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,26 +0,0 @@ -com.raytheon.uf.viz.core.alerts.DataCubeAlertMessageParser -com.raytheon.uf.viz.core.drawables.ResourcePair -com.raytheon.uf.viz.core.procedures.Bundle -com.raytheon.uf.viz.core.procedures.Procedure -com.raytheon.uf.viz.core.map.MapDescriptor -com.raytheon.uf.viz.core.rsc.capabilities.BlendableCapability -com.raytheon.uf.viz.core.rsc.capabilities.BlendedCapability -com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability -com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability -com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability -com.raytheon.uf.viz.core.rsc.capabilities.GroupNamingCapability -com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability -com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability -com.raytheon.uf.viz.core.rsc.capabilities.ShadeableCapability -com.raytheon.uf.viz.core.rsc.capabilities.LabelableCapability -com.raytheon.uf.viz.core.rsc.capabilities.DensityCapability -com.raytheon.uf.viz.core.rsc.capabilities.DisplayTypeCapability -com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability -com.raytheon.uf.viz.core.rsc.capabilities.PointCapability -com.raytheon.uf.viz.core.rsc.capabilities.TimeMatchBasisCapability -com.raytheon.uf.viz.core.rsc.GenericResourceData -com.raytheon.uf.viz.core.rsc.ResourceList -com.raytheon.uf.viz.core.rsc.ResourceProperties -com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties -com.raytheon.uf.viz.core.rsc.LoadProperties - diff --git a/cave/com.raytheon.uf.viz.core/res/spring/viz.xml b/cave/com.raytheon.uf.viz.core/res/spring/viz.xml index d7b13a2cbf..641a4e5c2e 100644 --- a/cave/com.raytheon.uf.viz.core/res/spring/viz.xml +++ b/cave/com.raytheon.uf.viz.core/res/spring/viz.xml @@ -69,5 +69,7 @@ + + \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractTimeMatcher.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractTimeMatcher.java index f39c47d58b..cfcd4596cf 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractTimeMatcher.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractTimeMatcher.java @@ -24,7 +24,6 @@ import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; import com.raytheon.uf.viz.core.drawables.IDescriptor; @@ -39,9 +38,10 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 10, 2009            chammack     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------  -------- ----------- --------------------------
+ * Feb 10, 2009           chammack    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Remove ISerializableObject
  * 
  * 
* @@ -49,7 +49,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public abstract class AbstractTimeMatcher implements ISerializableObject { +public abstract class AbstractTimeMatcher { /** * Trigger the time matcher to update time information on this resource the diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/alerts/AbstractAlertMessageParser.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/alerts/AbstractAlertMessageParser.java index 9d7d9dc813..499380db0e 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/alerts/AbstractAlertMessageParser.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/alerts/AbstractAlertMessageParser.java @@ -19,7 +19,9 @@ **/ package com.raytheon.uf.viz.core.alerts; -import com.raytheon.uf.common.serialization.ISerializableObject; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; + import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; @@ -29,17 +31,18 @@ import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Sep 15, 2009            mschenke     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Sep 15, 2009           mschenke    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Remove ISerializableObject
  * 
  * 
* * @author mschenke * @version 1.0 */ - -public abstract class AbstractAlertMessageParser implements ISerializableObject { +@XmlAccessorType(XmlAccessType.NONE) +public abstract class AbstractAlertMessageParser { /** * Parse the alert message object into an object expected by the Resource diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/PerspectiveSpecificLoadProperties.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/PerspectiveSpecificLoadProperties.java index 4232d0fabc..a32b0f9879 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/PerspectiveSpecificLoadProperties.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/PerspectiveSpecificLoadProperties.java @@ -22,8 +22,6 @@ package com.raytheon.uf.viz.core.comm; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import com.raytheon.uf.common.serialization.ISerializableObject; - /** * Abstract Base Class for load properties that are specific to a perspective. * Use as nested properties in LoadProperties. @@ -31,9 +29,10 @@ import com.raytheon.uf.common.serialization.ISerializableObject; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jul 6, 2009            bgonzale     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Jul 06, 2009           bgonzale    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Remove ISerializableObject
  * 
  * 
* @@ -41,6 +40,5 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public abstract class PerspectiveSpecificLoadProperties implements - ISerializableObject { +public abstract class PerspectiveSpecificLoadProperties { } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/datastructure/LoopProperties.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/datastructure/LoopProperties.java index fdcd8715c4..f64f57fceb 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/datastructure/LoopProperties.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/datastructure/LoopProperties.java @@ -26,8 +26,6 @@ import javax.xml.bind.annotation.XmlElement; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; -import com.raytheon.uf.common.serialization.ISerializableObject; - /** * This class is a container for the loop properties * @@ -36,9 +34,10 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 30, 2007 randerso Initial Creation. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Aug 30, 2007 randerso Initial Creation. + * Oct 22, 2013 2491 bsteffen Remove ISerializableObject * * * @@ -47,7 +46,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * */ @XmlAccessorType(XmlAccessType.NONE) -public class LoopProperties implements ISerializableObject { +public class LoopProperties { public enum LoopMode { Forward, Backward, Cycle diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/AbstractRenderableDisplay.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/AbstractRenderableDisplay.java index bafa5f1f3d..28e577a598 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/AbstractRenderableDisplay.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/AbstractRenderableDisplay.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -33,7 +32,7 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.common.serialization.SerializationUtil; +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; @@ -46,6 +45,7 @@ import com.raytheon.uf.viz.core.IView; import com.raytheon.uf.viz.core.VizConstants; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.preferences.ColorFactory; +import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.IRefreshListener; import com.raytheon.uf.viz.core.rsc.IResourceGroup; @@ -63,10 +63,11 @@ import com.raytheon.uf.viz.core.rsc.ResourceList.RemoveListener; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 06, 2009            bgonzale     Initial creation
- * Jun 24, 2013   2140     randerso     Added paintResource method
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Feb 06, 2009           bgonzale    Initial creation
+ * Jun 24, 2013  2140     randerso    Added paintResource method
+ * Oct 22, 2013  2491     bsteffen    Switch clone to ProcedureXmlManager
  * 
  * 
* @@ -502,8 +503,9 @@ public abstract class AbstractRenderableDisplay implements IRenderableDisplay { @Override public IRenderableDisplay createNewDisplay() { try { - AbstractRenderableDisplay clonedDisplay = (AbstractRenderableDisplay) SerializationUtil - .unmarshalFromXml(SerializationUtil.marshalToXml(this)); + ProcedureXmlManager jaxb = ProcedureXmlManager.getInstance(); + AbstractRenderableDisplay clonedDisplay = jaxb.unmarshal( + AbstractRenderableDisplay.class, jaxb.marshal(this)); List rscsToRemove = new ArrayList(); for (ResourcePair rp : clonedDisplay.getDescriptor() .getResourceList()) { @@ -518,21 +520,23 @@ public abstract class AbstractRenderableDisplay implements IRenderableDisplay { } clonedDisplay.setExtent(this.getExtent().clone()); return clonedDisplay; - } catch (JAXBException e) { - e.printStackTrace(); + } catch (SerializationException e) { + statusHandler.handle(Priority.PROBLEM, + "Unable to create new display.", e); } return null; } public AbstractRenderableDisplay cloneDisplay() { try { - AbstractRenderableDisplay clonedDisplay = (AbstractRenderableDisplay) SerializationUtil - .unmarshalFromXml(SerializationUtil.marshalToXml(this)); + ProcedureXmlManager jaxb = ProcedureXmlManager.getInstance(); + AbstractRenderableDisplay clonedDisplay = jaxb.unmarshal( + AbstractRenderableDisplay.class, jaxb.marshal(this)); if (getExtent() != null) { clonedDisplay.setExtent(this.getExtent().clone()); } return clonedDisplay; - } catch (JAXBException e) { + } catch (SerializationException e) { statusHandler.handle(Priority.PROBLEM, "Error cloning renderable display", e); } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ResourcePair.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ResourcePair.java index 7a0e00e02d..ee24d538a9 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ResourcePair.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ResourcePair.java @@ -26,7 +26,6 @@ import javax.xml.bind.annotation.XmlType; import org.apache.commons.lang.Validate; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractResourceData; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; @@ -43,9 +42,10 @@ import com.raytheon.uf.viz.core.rsc.ResourceProperties; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Sep 5, 2007 chammack Initial Creation. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Sep 05, 2007 chammack Initial Creation. + * Oct 22, 2013 2491 bsteffen Remove ISerializableObject * * * @@ -54,7 +54,7 @@ import com.raytheon.uf.viz.core.rsc.ResourceProperties; */ @XmlAccessorType(XmlAccessType.NONE) @XmlType(name = "pair") -public class ResourcePair implements ISerializableObject { +public class ResourcePair { protected AbstractVizResource resource; diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/map/MapDescriptor.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/map/MapDescriptor.java index 8d7be07ca9..114a8e1762 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/map/MapDescriptor.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/map/MapDescriptor.java @@ -42,7 +42,6 @@ import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.TransformException; import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.core.IExtent; @@ -59,11 +58,13 @@ import com.vividsolutions.jts.geom.Envelope; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * 7/1/06 chammack Initial Creation. - * 1/12/09 randerso added getMapManager - * 10/22/09 #3348 bsteffen Moved getter/setters for numberOfFrames down to AbstractDescriptor + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jul 01, 2006 chammack Initial Creation. + * Jan 12, 2009 randerso added getMapManager + * Dec 22, 2009 3348 bsteffen Moved getter/setters for numberOfFrames down to AbstractDescriptor + * Oct 22, 2013 2491 bsteffen Remove ISerializableObject + * * * * @@ -73,8 +74,7 @@ import com.vividsolutions.jts.geom.Envelope; */ @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement -public class MapDescriptor extends AbstractDescriptor implements - IMapDescriptor, ISerializableObject { +public class MapDescriptor extends AbstractDescriptor implements IMapDescriptor { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(MapDescriptor.class); diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Bundle.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Bundle.java index 9b93f50fc3..de57c43229 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Bundle.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Bundle.java @@ -23,7 +23,6 @@ import java.io.File; import java.io.FileReader; import java.util.Map; -import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -31,8 +30,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import com.raytheon.uf.common.serialization.ISerializableObject; -import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.viz.core.VariableSubstitutionUtil; import com.raytheon.uf.viz.core.datastructure.LoopProperties; import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; @@ -45,9 +43,11 @@ import com.raytheon.uf.viz.core.exception.VizException; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 30, 2007 chammack Initial Creation. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Aug 30, 2007 chammack Initial Creation. + * Oct 22, 2013 2491 bsteffen Switch serialization to + * ProcedureXmlManager * * * @@ -56,7 +56,7 @@ import com.raytheon.uf.viz.core.exception.VizException; */ @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) -public class Bundle implements ISerializableObject { +public class Bundle { /** Contains the descriptors */ @XmlElement @@ -161,8 +161,8 @@ public class Bundle implements ISerializableObject { public String toXML() throws VizException { try { - return SerializationUtil.marshalToXml(this); - } catch (JAXBException e) { + return ProcedureXmlManager.getInstance().marshal(this); + } catch (SerializationException e) { throw new VizException(e); } } @@ -275,7 +275,8 @@ public class Bundle implements ISerializableObject { String substStr = VariableSubstitutionUtil.processVariables( bundleStr, variables); - Bundle b = (Bundle) SerializationUtil.unmarshalFromXml(substStr); + Bundle b = ProcedureXmlManager.getInstance().unmarshal( + Bundle.class, substStr); return b; } catch (Exception e) { diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Procedure.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Procedure.java index 66ba014a7c..a1c2da9b42 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Procedure.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/Procedure.java @@ -21,7 +21,6 @@ package com.raytheon.uf.viz.core.procedures; import java.io.File; -import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -32,8 +31,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.eclipse.ui.IMemento; -import com.raytheon.uf.common.serialization.ISerializableObject; -import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.viz.core.exception.VizException; /** @@ -46,9 +44,11 @@ import com.raytheon.uf.viz.core.exception.VizException; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Sep 5, 2007 chammack Initial Creation. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Sep 05, 2007 chammack Initial Creation. + * Oct 22, 2013 2491 bsteffen Switch serialization to + * ProcedureXmlManager * * * @@ -57,7 +57,7 @@ import com.raytheon.uf.viz.core.exception.VizException; */ @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) -public class Procedure implements ISerializableObject { +public class Procedure { @XmlAttribute private String perspective; @@ -110,27 +110,26 @@ public class Procedure implements ISerializableObject { public String toXML() throws VizException { try { - return SerializationUtil.marshalToXml(this); - } catch (JAXBException e) { + return ProcedureXmlManager.getInstance().marshal(this); + } catch (SerializationException e) { throw new VizException(e); } } public static Procedure loadProcedure(File fileName) throws VizException { try { - return (Procedure) SerializationUtil - .jaxbUnmarshalFromXmlFile(fileName.getAbsolutePath()); - } catch (Exception e) { - e.printStackTrace(); + return ProcedureXmlManager.getInstance().unmarshal( + Procedure.class, fileName); + } catch (SerializationException e) { throw new VizException(e); } } public static Procedure loadProcedure(String xml) throws VizException { try { - return (Procedure) SerializationUtil.unmarshalFromXml(xml); - } catch (Exception e) { - e.printStackTrace(); + return ProcedureXmlManager.getInstance().unmarshal( + Procedure.class, xml); + } catch (SerializationException e) { throw new VizException(e); } } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/ProcedureXmlManager.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/ProcedureXmlManager.java new file mode 100644 index 0000000000..b63080fdb4 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/ProcedureXmlManager.java @@ -0,0 +1,193 @@ +/** + * 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. + **/ +package com.raytheon.uf.viz.core.procedures; + +import java.io.File; +import java.util.Collection; + +import javax.xml.bind.JAXBException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; + +import com.raytheon.uf.common.serialization.JAXBManager; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.jaxb.JAXBClassLocator; +import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; +import com.raytheon.uf.viz.core.reflect.SubClassLocator; +import com.raytheon.uf.viz.core.rsc.ResourceGroup; + +/** + * Centralized class for handling xml mapping of {@link Procedure}s, + * {@link Bundle}s, {@link IRenderableDisplay}s, {@link ResourceGroup}s, and + * anything else that might appear in a procedure. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 18, 2013  2491     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class ProcedureXmlManager { + + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ProcedureXmlManager.class); + + private static ProcedureXmlManager instance; + + private final JAXBManager manager; + + /** + * Get the singleton instance. + * + * @return singleton ProcedureXmlManager + */ + public static synchronized ProcedureXmlManager getInstance() { + if (instance == null) { + instance = new ProcedureXmlManager(); + } + return instance; + } + + /** + * Start initializing singleton manager in a background thread. + * + * @return true + */ + public static boolean inititializeAsync() { + new Job("Preparing to parse procedure Xml.") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + getInstance(); + return Status.OK_STATUS; + } + + }.schedule(); + return true; + } + + private ProcedureXmlManager() { + this.manager = initManager(); + } + + private JAXBManager initManager() { + SubClassLocator locator = new SubClassLocator(); + Collection> classes = JAXBClassLocator.getJAXBClasses(locator, + Procedure.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; + + try { + return new JAXBManager(jaxbClasses); + } catch (JAXBException e) { + statusHandler.handle(Priority.PROBLEM, + ProcedureXmlManager.class.getSimpleName() + + " Failed to initialize.", e); + } + return null; + + } + + private JAXBManager getManager() throws SerializationException { + if (manager == null) { + throw new SerializationException( + ProcedureXmlManager.class.getSimpleName() + + " Failed to initialize."); + } + return manager; + } + + /** + * Transform an object to XML using the internal procedure context and all + * its registered classes. + * + * @param obj + * something to marshal + * @return XML in a String + * @throws SerializationException + */ + public String marshal(Object obj) throws SerializationException { + try { + return getManager().marshalToXml(obj); + } catch (JAXBException je) { + throw new SerializationException(je); + } + } + + /** + * Transform some xml in a String to an object of the specified class. + * + * @param clazz + * expected type of object + * @param xml + * string containing xml + * @return the object + * @throws SerializationException + */ + public T unmarshal(Class clazz, String xml) + throws SerializationException { + try { + return clazz.cast(getManager().unmarshalFromXml(xml)); + } catch (ClassCastException cce) { + throw new SerializationException(cce); + } catch (JAXBException je) { + throw new SerializationException(je); + } + } + + /** + * Transform some xml in a File to an object of the specified class. + * + * @param clazz + * expected type of object + * @param file + * file containing xml + * @return the object + * @throws SerializationException + */ + public T unmarshal(Class clazz, File file) + throws SerializationException { + return getManager().unmarshalFromXmlFile(clazz, file); + } + +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleClassCache.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleClassCache.java new file mode 100644 index 0000000000..ccabe8a9a7 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleClassCache.java @@ -0,0 +1,318 @@ +/** + * 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. + **/ +package com.raytheon.uf.viz.core.reflect; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Pattern; + +import org.osgi.framework.Bundle; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; + +/** + * Provides a file based cache of all types available for each installed plugin. + * Each type can either be a super class and all sub classes or an annotation + * class and all classes with that annotation. + * + * JAXB/XML was not used because it was 20x slower and every ms counts. + * + * The file format uses space separated fields. Each bundle is described on a + * Bundle line which includes the name, version, bundleId, and mod time. After a + * Bundle line there will be multiple "Type" lines, each describing one base + * class that has been searched within that bundle. When subclasses or annotated + * classes are found they will be appended to the type line, space separated. + * For must types/bundles there will be no subclasses but the type line is + * included so that the bundle is not rescanned and so the set of base classes + * can remain dynamic. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 21, 2013  2491     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class BundleClassCache { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(BundleClassCache.class); + + private static final String BUNDLE = "Bundle"; + + private static final String TYPE = "Type"; + + private static final char SEPERATOR = ' '; + + private static final Pattern SEPERATOR_SPLIT = Pattern.compile(" "); + + private final File file; + + private final Map pluginMap = new HashMap(); + + private boolean modified = false; + + /** + * Create a new cache using the provided file. If the file exists it is read + * in to prepopulate the cache. + * + * @param file + */ + public BundleClassCache(File file) { + this.file = file; + if (file.exists()) { + try { + BufferedReader r = new BufferedReader(new FileReader(file)); + PluginKey key = null; + SubTypeNameMap value = new SubTypeNameMap(); + + String line = r.readLine(); + while (line != null) { + line = line.trim(); + if (line.startsWith(BUNDLE)) { + key = new PluginKey(line); + value = new SubTypeNameMap(); + pluginMap.put(key, value); + } else if (line.startsWith(TYPE)) { + value.addType(line); + } + line = r.readLine(); + } + r.close(); + } catch (IOException e) { + statusHandler.handle(Priority.VERBOSE, e.getLocalizedMessage(), + e); + } + } + } + + /** + * Get all types in a bundles that extend the provided base class. + * + * @param bundle + * bundle to search + * @param baseClassName + * name of a base class + * @return names of all subclasses(possible empty), or null if the bundle + * does not have a cache entry for the base class. + */ + public String[] getTypes(Bundle bundle, String baseClassName) { + SubTypeNameMap map = pluginMap.get(new PluginKey(bundle)); + if (map == null) { + return null; + } + return map.getSubTypes(baseClassName); + } + + /** + * Add the type to the cache. + * + * @param bundle + * the bundle that was scanned. + * @param baseClassName + * name of base class + * @param subTypes + * all subtypes, can be length 0 but not null. + */ + public void putTypes(Bundle bundle, String baseClassName, String[] subTypes) { + modified = true; + PluginKey key = new PluginKey(bundle); + SubTypeNameMap map = pluginMap.get(key); + if (map == null) { + map = new SubTypeNameMap(); + pluginMap.put(key, map); + } + map.putSubTypes(baseClassName, subTypes); + } + + /** + * Peresist the contents of the cache to the file used during construction. + * If any {@link IOException}s occur they will be logged but not returned. + */ + public void save() { + if (modified) { + try { + File tmpFile = File.createTempFile("tmpClassCache", ".txt", + file.getParentFile()); + Writer w = new BufferedWriter(new FileWriter(tmpFile)); + for (Entry e : pluginMap.entrySet()) { + e.getKey().save(w); + e.getValue().save(w); + } + w.close(); + tmpFile.renameTo(file); + } catch (IOException e) { + statusHandler.handle(Priority.VERBOSE, e.getLocalizedMessage(), + e); + } + } + } + + /** + * Cache entry, containing all base/subtype mappings. + */ + private static class SubTypeNameMap { + private final Map typeMap = new HashMap(); + + public void addType(String line) { + String[] parts = SEPERATOR_SPLIT.split(line); + String base = parts[1]; + String[] subTypes = Arrays.copyOfRange(parts, 2, parts.length); + typeMap.put(base, subTypes); + } + + public String[] getSubTypes(String className) { + return typeMap.get(className); + } + + public void putSubTypes(String className, String[] subTypes) { + typeMap.put(className, subTypes); + } + + public void save(Writer w) throws IOException { + for (Entry e : typeMap.entrySet()) { + w.write(TYPE); + w.write(SEPERATOR); + w.write(e.getKey()); + for (String val : e.getValue()) { + w.write(SEPERATOR); + w.write(val); + } + w.write('\n'); + } + } + + } + + /** + * Key for uniquely identifing a plugin. + */ + private static class PluginKey { + + /* + * On development boxes the modtime changes every time CAVE is run, so + * it is not used in comparisons by default. + */ + private static final boolean useModTime = false; + + /* + * The unique ID is not strictly needed for comparisons since + * name/version should be unique already. It is kept in just in case + * there is an unaccounted for edge case. + */ + private static final boolean useUnique = true; + + private final String name; + + private final String version; + + private final long unique; + + private final long modTime; + + public PluginKey(String line) { + String[] split = SEPERATOR_SPLIT.split(line); + name = split[1]; + version = split[2]; + unique = Long.parseLong(split[3]); + modTime = Long.parseLong(split[4]); + } + + public PluginKey(Bundle bundle) { + name = bundle.getSymbolicName(); + version = bundle.getVersion().toString(); + unique = bundle.getBundleId(); + modTime = bundle.getLastModified(); + } + + public void save(Writer w) throws IOException { + w.write(BUNDLE); + w.write(SEPERATOR); + w.write(name); + w.write(SEPERATOR); + w.write(version); + w.write(SEPERATOR); + w.write(Long.toString(unique)); + w.write(SEPERATOR); + w.write(Long.toString(modTime)); + w.write('\n'); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + if (useModTime) + result = prime * result + (int) (modTime ^ (modTime >>> 32)); + if (useUnique) + result = prime * result + (int) (unique ^ (unique >>> 32)); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PluginKey other = (PluginKey) obj; + + if (useModTime) + if (modTime != other.modTime) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (useUnique) + if (unique != other.unique) + return false; + if (version == null) { + if (other.version != null) + return false; + } else if (!version.equals(other.version)) + return false; + return true; + } + + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java new file mode 100644 index 0000000000..e3e0f6a6ab --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java @@ -0,0 +1,79 @@ +/** + * 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. + **/ +package com.raytheon.uf.viz.core.reflect; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.Bundle; +import org.osgi.framework.wiring.BundleWiring; +import org.reflections.Reflections; +import org.reflections.scanners.Scanner; +import org.reflections.util.ConfigurationBuilder; + +/** + * Provides the capabilities of {@link Reflections} for a single OSGi + * {@link Bundle}. Uses Reflections internally but populates URL and CLassLoader + * from the Bundle. + * + * In the future this can be expanded to expose more of the {@link Reflections} + * capabilities. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 21, 2013  2491     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class BundleReflections { + + private Reflections reflections; + + public BundleReflections(Bundle bundle, Scanner scanner) throws IOException { + ConfigurationBuilder cb = new ConfigurationBuilder(); + BundleWiring bundleWiring = bundle.adapt(BundleWiring.class); + cb.addClassLoader(bundleWiring.getClassLoader()); + cb.addUrls(FileLocator.getBundleFile(bundle).toURI().toURL()); + cb.setScanners(scanner); + reflections = cb.build(); + } + + public Set> getSubTypesOf(final Class type) { + return reflections.getSubTypesOf(type); + } + + public Set> getSubTypesOf(Class... types) { + Set> subTypes = new HashSet>(); + for (Class type : types) { + subTypes.addAll(getSubTypesOf(type)); + } + return subTypes; + } +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java new file mode 100644 index 0000000000..a6b6e3ec1c --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java @@ -0,0 +1,305 @@ +/** + * 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. + **/ +package com.raytheon.uf.viz.core.reflect; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; + +import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; +import org.osgi.framework.wiring.BundleWiring; +import org.reflections.scanners.SubTypesScanner; + +import com.raytheon.uf.common.serialization.reflect.ISubClassLocator; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.core.Activator; + +/** + * Loads all subclasses of any class using all installed OSGi bundles and the + * Reflections package. Results are cached using a {@link BundleClassCache}. to + * save time on startup. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 18, 2013  2491     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class SubClassLocator implements ISubClassLocator { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(SubClassLocator.class); + + private static final String CACHE_FILENAME = "subclassCache.txt"; + + private static final Pattern COMMA_SPLIT = Pattern.compile("[,]"); + + private static final Pattern SEMICOLON_SPLIT = Pattern.compile("[;]"); + + private final Map reflectionLookup = new HashMap(); + + private final Map bundleLookup = new HashMap(); + + private final Map> requiredBundles = new HashMap>(); + + private final BundleClassCache cache; + + /** + * Create a new SubClassLocator. + */ + public SubClassLocator() { + Bundle[] bundles = Activator.getDefault().getBundle() + .getBundleContext().getBundles(); + for (Bundle b : bundles) { + bundleLookup.put(b.getSymbolicName(), b); + } + File stateDir = Activator.getDefault().getStateLocation().toFile(); + cache = new BundleClassCache(new File(stateDir, CACHE_FILENAME)); + } + + /** + * Locate all subclasses in all bundles of a given class + * + * @param base + * @return + */ + public Collection> locateSubClasses(Class base) { + Map>> recursiveClasses = new HashMap>>( + bundleLookup.size(), 1.0f); + Set> result = new HashSet>(512); + for (Bundle bundle : bundleLookup.values()) { + result.addAll(lookupRecursiveSubClasses(base, bundle, true, + recursiveClasses)); + } + return result; + } + + /** + * Store the cache to disk. + */ + public void save() { + cache.save(); + } + + /** + * The lookup must occur recursively because otherwise sub classes of sub + * classes of base types are not correctly located. + * + * @param base + * base class + * @param bundle + * bundle to search + * @param includeRequiredSubclasses + * when false only subclasses of base found in this bundle are + * returned, when true subclasses found in other bundles required + * by this bundle are also returned. + * @param recursiveClasses + * map of already searched bundles to avoid recursing the same + * bundles multiple time. + * @return the sub classes contained in the bundle. + */ + private Set> lookupRecursiveSubClasses(Class base, + Bundle bundle, boolean includeRequiredSubclasses, + Map>> recursiveClasses) { + String bundleName = bundle.getSymbolicName(); + if (bundleName.startsWith("org.eclipse")) { + /* + * org.eclipse.osgi has no class loader and must be skipped, + * skipping the rest of org.eclipse just saves time. + */ + return Collections.emptySet(); + } + + if (includeRequiredSubclasses) { + /* Short circut if we already did this. */ + Set> result = recursiveClasses.get(bundleName); + if (result != null) { + return result; + } + } + + String[] ownedNames = cache.getTypes(bundle, base.getName()); + if (ownedNames == null) { + Set> dependencies = getRequiredSubclasses(base, bundle, + recursiveClasses); + /* Must pass dependencies in so type heirarchy is complete. */ + Set> owned = loadSubClassesReflectively(bundle, dependencies); + /* populate the cache */ + ownedNames = new String[owned.size()]; + int index = 0; + for (Class clazz : owned) { + ownedNames[index++] = clazz.getName(); + } + cache.putTypes(bundle, base.getName(), ownedNames); + Set> all = new HashSet>(dependencies); + all.addAll(owned); + recursiveClasses.put(bundleName, all); + if (includeRequiredSubclasses) { + return all; + } else { + return owned; + } + } else { + Set> owned = loadClassesFromCache(bundle, + Arrays.asList(ownedNames)); + if (includeRequiredSubclasses) { + Set> dependencies = getRequiredSubclasses(base, + bundle, + recursiveClasses); + Set> all = new HashSet>(dependencies); + all.addAll(owned); + recursiveClasses.put(bundleName, all); + return all; + } else { + return owned; + } + } + } + + /** + * Locate all subclasses of base that are found in the bundles required by + * this bundle. + * + * @param base + * base class + * @param bundle + * bundle to search + * @param recursiveClasses + * map of already searched bundles to avoid recursing the same + * bundles multiple time. + * @return the sub classes contained in required bundles. + */ + private Set> getRequiredSubclasses(Class base, Bundle bundle, + Map>> recursiveClasses) { + Set> dependencies = new HashSet>(); + dependencies.add(base); + for (Bundle reqBundle : getRequiredBundles(bundle)) { + dependencies.addAll(lookupRecursiveSubClasses(base, reqBundle, + true, recursiveClasses)); + } + return dependencies; + } + + /** + * Load all subclasses of a set of classes that are found within a bundle. + * + * @param bundle + * bundle to search + * @param baseClasses + * all base classes + * @return + */ + private Set> loadSubClassesReflectively(Bundle bundle, + Collection> baseClasses) { + String bundleName = bundle.getSymbolicName(); + + try { + BundleReflections reflections = reflectionLookup.get(bundleName); + if (reflections == null) { + reflections = new BundleReflections(bundle, + new SubTypesScanner()); + reflectionLookup.put(bundleName, reflections); + } + return reflections.getSubTypesOf(baseClasses + .toArray(new Class[0])); + } catch (Throwable e) { + statusHandler.handle(Priority.PROBLEM, + "Error loading classes in bundle(" + bundleName + + "), some procedures may not load.", e); + } + return Collections.emptySet(); + } + + /** + * Load classes by name using a specific bundles class loader + * + * @param bundle + * the bundle to get a class loader from + * @param classNames + * names of classes to load. + * @return + */ + private Set> loadClassesFromCache(Bundle bundle, + Collection classNames) { + BundleWiring bundleWiring = bundle.adapt(BundleWiring.class); + ClassLoader loader = bundleWiring.getClassLoader(); + HashSet> result = new HashSet>(classNames.size(), + 1.0f); + for (String className : classNames) { + try { + result.add(Class.forName(className, false, loader)); + } catch (ClassNotFoundException e) { + statusHandler.handle(Priority.PROBLEM, "Error loading class(" + + className + "), some procedures may not load.", e); + } + } + return result; + } + + /** + * Parse bundle header to get all required bundles + * + * @param bundle + * the bundle + * @return bundles required by bundle. + */ + private List getRequiredBundles(Bundle bundle) { + String bundleName = bundle.getSymbolicName(); + List required = requiredBundles.get(bundle); + if (required == null) { + required = new ArrayList(); + String requiredBundlesHeader = bundle.getHeaders().get( + Constants.REQUIRE_BUNDLE); + if (requiredBundlesHeader != null) { + String[] requiredBundles = COMMA_SPLIT + .split(requiredBundlesHeader); + for (String requiredBundleName : requiredBundles) { + String[] nameParts = SEMICOLON_SPLIT + .split(requiredBundleName); + Bundle reqBundle = bundleLookup.get(nameParts[0]); + if (reqBundle != null) { + required.add(reqBundle); + } + } + } + requiredBundles.put(bundleName, required); + + } + return required; + } + +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractResourceData.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractResourceData.java index 4dce8ab51f..d5da59f4ea 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractResourceData.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractResourceData.java @@ -26,7 +26,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.exception.VizException; @@ -40,9 +39,11 @@ import com.raytheon.uf.viz.core.exception.VizException; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 2, 2009             chammack    Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Feb 02, 2009           chammack    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Remove ISerializableObject
+ * 
  * 
  * 
* @@ -50,7 +51,7 @@ import com.raytheon.uf.viz.core.exception.VizException; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public abstract class AbstractResourceData implements ISerializableObject { +public abstract class AbstractResourceData { /** The generator used to generate names for labels */ protected AbstractNameGenerator nameGenerator = null; diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/LoadProperties.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/LoadProperties.java index 48473caf50..a28afb1de6 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/LoadProperties.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/LoadProperties.java @@ -25,7 +25,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.viz.core.comm.PerspectiveSpecificLoadProperties; import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability; import com.raytheon.uf.viz.core.rsc.capabilities.Capabilities; @@ -39,10 +38,11 @@ import com.raytheon.uf.viz.core.rsc.capabilities.Capabilities; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 15, 2007 chammack Initial Creation. - * Feb 26, 2009 2032 jsanchez Added a loadWithoutData. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Aug 15, 2007 chammack Initial Creation. + * Feb 26, 2009 2032 jsanchez Added a loadWithoutData. + * Oct 22, 2013 2491 bsteffen Remove ISerializableObject * * * @@ -51,7 +51,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.Capabilities; */ @XmlType(name = "loadProperties") @XmlAccessorType(XmlAccessType.NONE) -public class LoadProperties implements ISerializableObject { +public class LoadProperties { private Capabilities capabilities; diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ProgressiveDisclosureProperties.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ProgressiveDisclosureProperties.java index cf2586a96b..40fe37b28c 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ProgressiveDisclosureProperties.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ProgressiveDisclosureProperties.java @@ -24,8 +24,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import com.raytheon.uf.common.serialization.ISerializableObject; - /** * Defines the progressive disclosure properties * @@ -33,9 +31,10 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * 7/30/07 randerso Initial Creation. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jul 30, 2007 randerso Initial Creation. + * Oct 22, 2013 2491 bsteffen Remove ISerializableObject * * * @@ -43,7 +42,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * */ @XmlAccessorType(XmlAccessType.NONE) -public class ProgressiveDisclosureProperties implements ISerializableObject { +public class ProgressiveDisclosureProperties { /** * Minimum display width in meters for the associated resource to be * displayed diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java index e7fb2b91ad..d6469b7dfe 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java @@ -36,7 +36,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import org.apache.commons.lang.Validate; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -55,11 +54,13 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Sep 5, 2007 chammack Initial Creation. - * Apr 9, 2009 1288 rjpeter Added iterator implementation to fix remove. - * Apr 24, 2013 1950 bsteffen Sort resources before instantiation. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Sep 05, 2007 chammack Initial Creation. + * Apr 09, 2009 1288 rjpeter Added iterator implementation to fix + * remove. + * Apr 24, 2013 1950 bsteffen Sort resources before instantiation. + * Oct 22, 2013 2491 bsteffen Remove ISerializableObject * * * @@ -67,8 +68,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability; * @version 1 */ @XmlAccessorType(XmlAccessType.NONE) -public class ResourceList extends CopyOnWriteArrayList implements - ISerializableObject { +public class ResourceList extends CopyOnWriteArrayList { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(ResourceList.class); diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceProperties.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceProperties.java index de24313ced..59194f1142 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceProperties.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceProperties.java @@ -25,7 +25,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.viz.core.rsc.RenderingOrderFactory.ResourceOrder; /** @@ -35,10 +34,11 @@ import com.raytheon.uf.viz.core.rsc.RenderingOrderFactory.ResourceOrder; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * 7/1/06 chammack Initial Creation. - * 3/5/08 2032 jsanchez Initialized pdProps. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jul 01, 2006 chammack Initial Creation. + * Mar 05, 2008 2032 jsanchez Initialized pdProps. + * Oct 22, 2013 2491 bsteffen Remove ISerializableObject * * * @@ -46,7 +46,7 @@ import com.raytheon.uf.viz.core.rsc.RenderingOrderFactory.ResourceOrder; * */ @XmlAccessorType(XmlAccessType.NONE) -public class ResourceProperties implements ISerializableObject { +public class ResourceProperties { /** is the layer isVisible */ @XmlAttribute diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/AbstractCapability.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/AbstractCapability.java index 0a1d2641f4..819f029f7d 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/AbstractCapability.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/capabilities/AbstractCapability.java @@ -22,7 +22,6 @@ package com.raytheon.uf.viz.core.rsc.capabilities; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.viz.core.rsc.AbstractResourceData; import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType; @@ -38,9 +37,11 @@ import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 2, 2009             chammack    Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Feb 02, 2009           chammack    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Remove ISerializableObject
+ * 
  * 
  * 
* @@ -48,7 +49,7 @@ import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public abstract class AbstractCapability implements ISerializableObject { +public abstract class AbstractCapability { /** * The resource pointer. Primarily useful for communication with the diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScale.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScale.java index e8cdcb5481..7c6c240b0a 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScale.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScale.java @@ -29,7 +29,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.adapters.UnitAdapter; import com.raytheon.uf.common.style.level.Level.LevelType; @@ -39,9 +38,10 @@ import com.raytheon.uf.common.style.level.Level.LevelType; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 6, 2009            mschenke     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Nov 06, 2009           mschenke    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Remove ISerializableObject
  * 
  * 
* @@ -49,7 +49,7 @@ import com.raytheon.uf.common.style.level.Level.LevelType; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public class HeightScale implements ISerializableObject { +public class HeightScale { @XmlAccessorType(XmlAccessType.NONE) public static enum ScaleType { diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScales.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScales.java index c4fc68f35c..cc76ace665 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScales.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/viz/core/slice/request/HeightScales.java @@ -33,20 +33,21 @@ import com.raytheon.uf.common.localization.ILocalizationFileObserver; 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.ISerializableObject; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; /** - * TODO Add Description + * Collection of {@link HeightScale} objects used by the volume browser and + * several height displays to scale verticle data. * *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 24, 2009            mschenke     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Nov 24, 2009           mschenke    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Remove ISerializableObject
  * 
  * 
* @@ -55,7 +56,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; */ @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement -public class HeightScales implements ISerializableObject { +public class HeightScales { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(HeightScales.class); diff --git a/cave/com.raytheon.uf.viz.cots.feature/feature.xml b/cave/com.raytheon.uf.viz.cots.feature/feature.xml index 49ad6fedea..65244a65cc 100644 --- a/cave/com.raytheon.uf.viz.cots.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.cots.feature/feature.xml @@ -81,10 +81,4 @@ install-size="0" version="0.0.0"/> - - diff --git a/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml b/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml index 77631409b2..6a7c73bc95 100644 --- a/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml +++ b/cave/com.raytheon.uf.viz.feature.alertviz/feature.xml @@ -308,6 +308,12 @@ version="0.0.0" unpack="false"/> + + * * SOFTWARE HISTORY - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Oct 8, 2009 mschenke Initial creation + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Oct 08, 2009 mschenke Initial creation + * Oct 22, 2013 2491 bsteffen Unmarshal with Bundle.unmarshalBundle. + * * * * @@ -58,22 +62,26 @@ public interface IInsetMapContainer { /** Utility class for loading the inset map from a bundle */ public static class InsetMapUtil { + + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(IInsetMapContainer.class); + public static IRenderableDisplay loadInsetMap( IRenderableDisplay parentDisplay) { File bundle = PathManagerFactory.getPathManager().getStaticFile( "insetmap" + File.separator + "inset.xml"); try { - Bundle b = (Bundle) SerializationUtil - .jaxbUnmarshalFromXmlFile(bundle.getAbsolutePath()); + Bundle b = Bundle.unmarshalBundle(bundle); InsetMapRenderableDisplay display = (InsetMapRenderableDisplay) b .getDisplays()[0]; - display.getDescriptor().getResourceList().instantiateResources( - display.getDescriptor(), true); + display.getDescriptor().getResourceList() + .instantiateResources(display.getDescriptor(), true); display.setExtent(new PixelExtent(0, 1000, 0, 1000)); display.setParentDisplay(parentDisplay); return display; - } catch (SerializationException e) { - e.printStackTrace(); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); } return null; } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/perspective/MPEPerspectiveManager.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/perspective/MPEPerspectiveManager.java index 2fa5d679a3..243201c797 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/perspective/MPEPerspectiveManager.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/perspective/MPEPerspectiveManager.java @@ -35,7 +35,6 @@ import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.DescriptorMap; @@ -47,6 +46,7 @@ import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.maps.MapManager; import com.raytheon.uf.viz.core.procedures.Bundle; +import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager; import com.raytheon.uf.viz.core.rsc.IInputHandler; import com.raytheon.viz.hydrocommon.actions.SetProjection; import com.raytheon.viz.mpe.ui.MPEDisplayManager; @@ -71,12 +71,14 @@ import com.vividsolutions.jts.geom.Coordinate; * *
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Aug 21, 2008            randerso     Initial creation
- * Feb 18, 2010  4111      snaples      Updated to support contexts
- * Apr 27, 2010            mschenke     refactor for common perspective switching
- * Jan 29, 2013  1550      mpduff       Add ability to preload maps on open.
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Aug 21, 2008           randerso    Initial creation
+ * Feb 18, 2010  4111     snaples     Updated to support contexts
+ * Apr 27, 2010           mschenke    refactor for common perspective switching
+ * Jan 29, 2013  1550     mpduff      Add ability to preload maps on open.
+ * Oct 22, 2013  2491     bsteffen    Switch serialization to 
+ *                                    ProcedureXmlManager
  * 
* * @author randerso @@ -120,68 +122,57 @@ public class MPEPerspectiveManager extends AbstractCAVEPerspectiveManager { public AbstractEditor openNewEditor() { try { // Unmarshal default bundle xml - Object unmarshalled = SerializationUtil.getJaxbManager() - .unmarshalFromXmlFile( - PathManagerFactory.getPathManager().getStaticFile( + Bundle b = ProcedureXmlManager.getInstance().unmarshal( + Bundle.class, + PathManagerFactory.getPathManager() + .getStaticFile( MPE + IPathManager.SEPARATOR + "default-bundle.xml")); - if (unmarshalled instanceof Bundle) { - // Load Bundle to perspective window in new editor - Bundle b = (Bundle) unmarshalled; - String editorId = b.getEditor(); - if (editorId != null) { - IRenderableDisplay[] displays = b.getDisplays(); - if (displays.length > 0) { - editorId = DescriptorMap.getEditorId(displays[0] - .getDescriptor().getClass().getName()); - AbstractEditor editor = UiUtil.createEditor( - perspectiveWindow, editorId, displays); - if (editor != null) { - initialize(editor); + // Load Bundle to perspective window in new editor + String editorId = b.getEditor(); + if (editorId != null) { + IRenderableDisplay[] displays = b.getDisplays(); + if (displays.length > 0) { + editorId = DescriptorMap.getEditorId(displays[0] + .getDescriptor().getClass().getName()); + AbstractEditor editor = UiUtil.createEditor( + perspectiveWindow, editorId, displays); + if (editor != null) { + initialize(editor); - String[] maps; + String[] maps; - // Get the maps configured for display at startup - String displayMaps = AppsDefaults.getInstance() - .getToken("mpe_display_maps", - "statesCounties"); + // Get the maps configured for display at startup + String displayMaps = AppsDefaults.getInstance() + .getToken("mpe_display_maps", "statesCounties"); - if (displayMaps.contains(",")) { - maps = displayMaps.split(","); - } else { - maps = new String[1]; - maps[0] = displayMaps; - } - - IDisplayPaneContainer currentEditor = EditorUtil - .getActiveVizContainer(); - MapManager mapMgr = MapManager - .getInstance((IMapDescriptor) currentEditor - .getActiveDisplayPane() - .getDescriptor()); - - // Load the configured maps - for (String map : maps) { - mapMgr.loadMapByBundleName(map.trim()); - } - - return editor; + if (displayMaps.contains(",")) { + maps = displayMaps.split(","); } else { - throw new VizException( - "Failed to open new editor on window"); + maps = new String[1]; + maps[0] = displayMaps; } + + IDisplayPaneContainer currentEditor = EditorUtil + .getActiveVizContainer(); + MapManager mapMgr = MapManager + .getInstance((IMapDescriptor) currentEditor + .getActiveDisplayPane().getDescriptor()); + + // Load the configured maps + for (String map : maps) { + mapMgr.loadMapByBundleName(map.trim()); + } + + return editor; } else { - throw new SerializationException( - "No displays to load found in MPE default bundle XML"); + throw new VizException( + "Failed to open new editor on window"); } + } else { + throw new SerializationException( + "No displays to load found in MPE default bundle XML"); } - } else { - throw new SerializationException( - "Unexpected type deserialied from mpe bundle file. Expected " - + Bundle.class.getSimpleName() - + ", got " - + (unmarshalled != null ? unmarshalled - .getClass().getSimpleName() : null)); } } catch (Exception e) { UFStatus.getHandler().handle(Priority.PROBLEM, diff --git a/cave/com.raytheon.viz.radar/build.properties b/cave/com.raytheon.viz.radar/build.properties index e5eb50c213..1bab865885 100644 --- a/cave/com.raytheon.viz.radar/build.properties +++ b/cave/com.raytheon.viz.radar/build.properties @@ -4,4 +4,5 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ config.xml,\ - localization/ + localization/,\ + res/ diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicResourceFactory.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicResourceFactory.java index 1765ebf003..2600bf7bfb 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicResourceFactory.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicResourceFactory.java @@ -19,21 +19,19 @@ **/ package com.raytheon.viz.radar.rsc.mosaic; -import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import com.raytheon.uf.common.serialization.SerializationUtil; +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; import com.raytheon.uf.viz.core.drawables.ResourcePair; +import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager; import com.raytheon.uf.viz.core.rsc.ResourceGroup; import com.raytheon.uf.viz.core.rsc.ResourceList; -import com.raytheon.uf.viz.core.status.StatusConstants; -import com.raytheon.viz.radar.Activator; /** * Use a base resource, a substitution key and a comma separated list of @@ -49,9 +47,11 @@ import com.raytheon.viz.radar.Activator; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Sep 29, 2010            bsteffen     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Sep 29, 2010           bsteffen    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Switch serialization to 
+ *                                    ProcedureXmlManager
  * 
  * 
* @@ -78,20 +78,22 @@ public class RadarMosaicResourceFactory extends AbstractMosaicResourceFactory { */ @Override public ResourceList getResourceList() { + ProcedureXmlManager jaxb = ProcedureXmlManager.getInstance(); + ResourceList resourceList = new ResourceList(); + // Put the base resource in a group so it can be serialized + ResourceGroup baseGroup = new ResourceGroup(); + baseGroup.getResourceList().add(resource); try { - ResourceList resourceList = new ResourceList(); - // Put the base resource in a group so it can be serialized - ResourceGroup baseGroup = new ResourceGroup(); - baseGroup.getResourceList().add(resource); - String baseXml = SerializationUtil.marshalToXml(baseGroup); + String baseXml = jaxb.marshal(baseGroup); resourceList.clear(); for (String icao : substitutionValues.split(",")) { String xml = baseXml.replace(substitutionKey, icao); - resourceList.add(((ResourceGroup) SerializationUtil - .unmarshalFromXml(xml)).getResourceList().get(0)); + resourceList.add(jaxb + .unmarshal(ResourceGroup.class, xml) + .getResourceList().get(0)); } return resourceList; - } catch (JAXBException e) { + } catch (SerializationException e) { statusHandler.handle(Priority.PROBLEM, e .getLocalizedMessage(), e); } diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/menu/SatBundleContributionItem.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/menu/SatBundleContributionItem.java index 52477dc5f8..45180b77d4 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/menu/SatBundleContributionItem.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/menu/SatBundleContributionItem.java @@ -24,15 +24,13 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Map; -import javax.xml.bind.JAXBException; - import org.eclipse.ui.IWorkbenchWindow; import org.geotools.coverage.grid.GeneralGridGeometry; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.menus.xml.CommonBundleMenuContribution; import com.raytheon.uf.common.menus.xml.VariableSubstitution; -import com.raytheon.uf.common.serialization.SerializationUtil; +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; @@ -47,6 +45,7 @@ import com.raytheon.uf.viz.core.globals.IGlobalChangedListener; import com.raytheon.uf.viz.core.globals.VizGlobalsManager; import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.procedures.Bundle; +import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.ResourceGroup; import com.raytheon.uf.viz.core.rsc.URICatalog; @@ -58,15 +57,19 @@ import com.raytheon.viz.ui.EditorUtil; /** * - * TODO Add Description + * Custom bundle contribution item for satellite so it has the ability to + * determine available times differently depending on scale by using a + * {@link SatBestResResourceData} to determine which resources are best to load. * *
  * 
  * SOFTWARE HISTORY
  * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Aug 26, 2011            bsteffen     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Aug 26, 2011           bsteffen    Initial creation
+ * Oct 22, 2013  2491     bsteffen    Switch serialization to 
+ *                                    ProcedureXmlManager
  * 
  * 
* @@ -102,8 +105,9 @@ public class SatBundleContributionItem extends BundleContributionItem { pair.setResourceData(resourceData); ResourceGroup group = new ResourceGroup(); group.getResourceList().add(pair); - String xml = SerializationUtil.marshalToXml(group); - group = (ResourceGroup) SerializationUtil.unmarshalFromXml(xml); + ProcedureXmlManager jaxb = ProcedureXmlManager.getInstance(); + String xml = jaxb.marshal(group); + group = jaxb.unmarshal(ResourceGroup.class, xml); resourceData = (AbstractRequestableResourceData) group .getResourceList().get(0).getResourceData(); // get the available times @@ -129,7 +133,7 @@ public class SatBundleContributionItem extends BundleContributionItem { } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - } catch (JAXBException e) { + } catch (SerializationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java index a985402c38..2557a733f6 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java @@ -35,10 +35,13 @@ import com.raytheon.viz.ui.panes.DrawCoordinatorJob; * *
  * SOFTWARE HISTORY
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 7/1/06                   chammack    Initial Creation.
- * Oct 27, 2009 #2354       bsteffen    Added preferences to ui plugin
+ * Date       	 Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Jul 01, 2006             chammack  Initial Creation.
+ * Oct 27, 2009  2354       bsteffen  Added preferences to ui plugin
+ * Oct 24, 2012  2491       bsteffen  Do not start DrawCoordinatorJob during
+ *                                    activation to allow activation before
+ *                                    localization is set.
  * 
  * 
  * 
@@ -67,7 +70,6 @@ public class UiPlugin extends AbstractUIPlugin { */ public void start(BundleContext context) throws Exception { super.start(context); - DrawCoordinatorJob.getInstance(); } /** diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/LoadSerializedXml.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/LoadSerializedXml.java index c2f738efdf..1b9c067a5a 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/LoadSerializedXml.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/LoadSerializedXml.java @@ -38,7 +38,6 @@ import org.eclipse.ui.internal.EditorAreaHelper; import org.eclipse.ui.internal.EditorReference; import org.eclipse.ui.internal.WorkbenchPage; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -49,6 +48,7 @@ import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.procedures.Bundle; import com.raytheon.uf.viz.core.procedures.Procedure; +import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager; import com.raytheon.viz.ui.BundleLoader; import com.raytheon.viz.ui.UiUtil; import com.raytheon.viz.ui.VizWorkbenchManager; @@ -60,10 +60,12 @@ import com.raytheon.viz.ui.editor.AbstractEditor; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Apr 6, 2010             mschenke    Initial creation
- * Mar 21, 2013 1638       mschenke    Added method to load procedure to window
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 06, 2010           mschenke    Initial creation
+ * Mar 21, 2013  1638     mschenke    Added method to load procedure to window
+ * Oct 22, 2013  2491     bsteffen    Switch serialization to
+ *                                    ProcedureXmlManager
  * 
  * 
* @@ -113,7 +115,8 @@ public class LoadSerializedXml extends AbstractHandler { public static Object deserialize(File fileName) { Object obj = null; try { - obj = SerializationUtil.jaxbUnmarshalFromXmlFile(fileName); + obj = ProcedureXmlManager.getInstance().unmarshal( + Object.class, fileName); } catch (Exception e) { String errMsg = "Error occurred during xml deserialization"; statusHandler.handle(Priority.CRITICAL, errMsg, e); diff --git a/cots/org.hibernate/.classpath b/cots/org.hibernate/.classpath index 783dbadf49..aeb471100d 100644 --- a/cots/org.hibernate/.classpath +++ b/cots/org.hibernate/.classpath @@ -3,7 +3,6 @@ - diff --git a/cots/org.hibernate/META-INF/MANIFEST.MF b/cots/org.hibernate/META-INF/MANIFEST.MF index e9f8a57777..362af709bf 100644 --- a/cots/org.hibernate/META-INF/MANIFEST.MF +++ b/cots/org.hibernate/META-INF/MANIFEST.MF @@ -6,7 +6,6 @@ Bundle-Version: 1.0.0.qualifier Bundle-ClassPath: hibernate-spatial-1.0.jar, hibernate-spatial-postgis-1.0.jar, hibernate3.5.6-Final.jar, - javassist-3.9.0.GA.jar, jta-1.1.jar Bundle-Vendor: Hibernate Export-Package: org.hibernate, @@ -184,4 +183,5 @@ Export-Package: org.hibernate, org.hibernatespatial.postgis, org.hibernatespatial.readers, org.hibernatespatial.spi -Require-Bundle: org.slf4j +Require-Bundle: org.slf4j, + org.javassist;bundle-version="3.9.0" diff --git a/cots/org.hibernate/build.properties b/cots/org.hibernate/build.properties index 131e6678ba..55b69f5a8e 100644 --- a/cots/org.hibernate/build.properties +++ b/cots/org.hibernate/build.properties @@ -2,5 +2,4 @@ bin.includes = META-INF/,\ hibernate-spatial-1.0.jar,\ hibernate-spatial-postgis-1.0.jar,\ hibernate3.5.6-Final.jar,\ - javassist-3.9.0.GA.jar,\ jta-1.1.jar diff --git a/cots/org.javassist/.classpath b/cots/org.javassist/.classpath new file mode 100644 index 0000000000..937d4cc568 --- /dev/null +++ b/cots/org.javassist/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/cots/org.javassist/.project b/cots/org.javassist/.project new file mode 100644 index 0000000000..d32d66355b --- /dev/null +++ b/cots/org.javassist/.project @@ -0,0 +1,28 @@ + + + org.javassist + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/cots/org.javassist/META-INF/MANIFEST.MF b/cots/org.javassist/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..cceab46e99 --- /dev/null +++ b/cots/org.javassist/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Javassist +Bundle-SymbolicName: org.javassist +Bundle-Version: 3.9.0.GA +Bundle-ClassPath: javassist-3.9.0.GA.jar +Export-Package: javassist, + javassist.bytecode, + javassist.bytecode.analysis, + javassist.bytecode.annotation, + javassist.bytecode.stackmap, + javassist.compiler, + javassist.compiler.ast, + javassist.convert, + javassist.expr, + javassist.runtime, + javassist.scopedpool, + javassist.tools, + javassist.tools.reflect, + javassist.tools.rmi, + javassist.tools.web, + javassist.util, + javassist.util.proxy +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/cots/org.javassist/build.properties b/cots/org.javassist/build.properties new file mode 100644 index 0000000000..68fa07cd56 --- /dev/null +++ b/cots/org.javassist/build.properties @@ -0,0 +1,2 @@ +bin.includes = META-INF/,\ + javassist-3.9.0.GA.jar diff --git a/cots/org.hibernate/javassist-3.9.0.GA.jar b/cots/org.javassist/javassist-3.9.0.GA.jar similarity index 100% rename from cots/org.hibernate/javassist-3.9.0.GA.jar rename to cots/org.javassist/javassist-3.9.0.GA.jar diff --git a/cots/org.reflections/META-INF/MANIFEST.MF b/cots/org.reflections/META-INF/MANIFEST.MF index 460ae67b86..41ab7b4d8b 100644 --- a/cots/org.reflections/META-INF/MANIFEST.MF +++ b/cots/org.reflections/META-INF/MANIFEST.MF @@ -11,3 +11,5 @@ Export-Package: org.reflections, org.reflections.util, org.reflections.vfs Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: com.google.guava;bundle-version="1.0.0", + org.javassist;bundle-version="3.9.0" diff --git a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml index 621ee766b4..a6a13646d4 100644 --- a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml @@ -277,6 +277,12 @@ install-size="0" version="0.0.0"/> + + + + diff --git a/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF index e54e2f2894..b2a3dbfb50 100644 --- a/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.serialization/META-INF/MANIFEST.MF @@ -16,5 +16,7 @@ Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.adapters, com.raytheon.uf.common.serialization.annotations, + com.raytheon.uf.common.serialization.jaxb, + com.raytheon.uf.common.serialization.reflect, com.raytheon.uf.common.serialization.thrift Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/jaxb/JAXBClassLocator.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/jaxb/JAXBClassLocator.java new file mode 100644 index 0000000000..93342b6d1f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/jaxb/JAXBClassLocator.java @@ -0,0 +1,193 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.serialization.jaxb; + +import java.io.File; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.raytheon.uf.common.serialization.reflect.ISubClassLocator; + +/** + * Locate all classes that can be used in a JAXB contexts. This class uses an + * {@link ISubClassLocator} to dynamically find all possible subtypes of every + * class used in a JAXB context. For most xml types this would be overkill but + * for some advanced types that allow dynamic class types with the xsi:type + * field this can be useful for building a complete context. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 22, 2013  2491     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class JAXBClassLocator { + + private ISubClassLocator locator; + + private Set> processed = new HashSet>(512); + + private List> included = new ArrayList>(512); + + private JAXBClassLocator(ISubClassLocator locator, Class rootClass) { + this.locator = locator; + processed.addAll(getBuiltinTypes()); + processClass(rootClass); + } + + private void processClass(Class clazz) { + if (!processed.add(clazz)) { + return; + } + if (clazz.isPrimitive() || clazz.isEnum() || clazz.isInterface()) { + return; + } + if (clazz.isArray()) { + processClass(clazz.getComponentType()); + return; + } + if (clazz.getName().contains("$") + && !clazz.isAnnotationPresent(XmlType.class)) { + return; + } + included.add(clazz); + Class zuper = clazz.getSuperclass(); + if (zuper == Object.class) { + /* Found a "base" class, search for subclasses */ + if (!Modifier.isFinal(clazz.getModifiers())) { + for (Class sub : locator.locateSubClasses(clazz)) { + processClass(sub); + } + } + } else { + processClass(zuper); + } + + for (Field field : clazz.getDeclaredFields()) { + processField(field); + } + for (Method method : clazz.getDeclaredMethods()) { + processMethod(method); + } + } + + private void processField(Field field) { + if (isXmlElement(field)) { + Class type = field.getType(); + if (Collection.class.isAssignableFrom(type)) { + handleCollectionType(field.getGenericType()); + } else { + processClass(field.getType()); + } + } + } + + private void processMethod(Method method) { + if (isXmlElement(method)) { + Class returnType = method.getReturnType(); + if (returnType != void.class) { + /* Getter */ + processClass(returnType); + } else if (Collection.class.isAssignableFrom(returnType)) { + handleCollectionType(method.getGenericReturnType()); + } else { + Class[] tp = method.getParameterTypes(); + if (tp.length == 1) { + /* Setter */ + if (Collection.class.isAssignableFrom(tp[0])) { + handleCollectionType(method.getGenericParameterTypes()[0]); + } else { + processClass(tp[0]); + } + } + } + } + } + + private void handleCollectionType(Type type) { + if (type instanceof ParameterizedType) { + ParameterizedType ptype = (ParameterizedType) type; + Type[] args = ptype.getActualTypeArguments(); + if (args.length == 1 && args[0] instanceof Class) { + processClass((Class) args[0]); + } + } else if (type instanceof Class) { + handleCollectionType(((Class) type).getGenericSuperclass()); + } + } + + private Collection> getResults() { + return included; + } + + private static boolean isXmlElement(AnnotatedElement element) { + return element.isAnnotationPresent(XmlElement.class) + && !element.isAnnotationPresent(XmlJavaTypeAdapter.class); + } + + /** + * A base set of classes for which we don't need to find subclasses or + * reflect on the fields. + * + * @return + */ + private static Collection> getBuiltinTypes() { + return Arrays.> asList(Boolean.class, Byte.class, Short.class, + Integer.class, Long.class, Float.class, Double.class, + String.class, Object.class, Class.class, File.class); + } + + /** + * Dynamically find all classes that can possibly appear in an xml document + * rooted in baseClass. + * + * @param locator + * used for finding subclasses + * @param rootClass + * the root cml object + * @return all classes that are can be in the xml. + */ + public static Collection> getJAXBClasses(ISubClassLocator locator, + Class baseClass) { + return new JAXBClassLocator(locator, baseClass).getResults(); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/reflect/ISubClassLocator.java b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/reflect/ISubClassLocator.java new file mode 100644 index 0000000000..c41c673d44 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.serialization/src/com/raytheon/uf/common/serialization/reflect/ISubClassLocator.java @@ -0,0 +1,53 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.serialization.reflect; + +import java.util.Collection; + +/** + * Interface indicating an object is capable of looking up subclassed based off + * of a known parent class. Generally this must be implemented using advanced + * reflection mechanisms that are heavily dependendant on the type of runtime + * and will ned to be different on edex and cave. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 23, 2013  2491     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public interface ISubClassLocator { + + /** + * Determine all subclasses of a given class. + * + * @param base + * a class + * @return all subclasses of base. + */ + public Collection> locateSubClasses(Class base); +} diff --git a/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml index 7443958454..966774685b 100644 --- a/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml @@ -189,10 +189,4 @@ install-size="0" version="0.0.0"/> - - diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF index e0497fa11a..6984f951dd 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF @@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.4.1", gov.noaa.nws.ncep.viz.common, gov.noaa.nws.ncep.viz.localization, gov.noaa.nws.ncep.viz.rsc.pgen;bundle-version="1.0.0", - com.raytheon.uf.common.sounding + com.raytheon.uf.common.sounding, + com.raytheon.viz.core.graphing Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: com.raytheon.edex.plugin.modelsounding.common, @@ -35,7 +36,6 @@ Import-Package: com.raytheon.edex.plugin.modelsounding.common, com.raytheon.uf.viz.d2d.core.time, com.raytheon.uf.viz.d2d.ui.perspectives, com.raytheon.uf.viz.sounding, - com.raytheon.viz.core.graphing, com.vividsolutions.jts.geom, gov.noaa.nws.ncep.common.dataplugin.ncuair, gov.noaa.nws.ncep.edex.common.ncinventory, diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpAbstractPaneDescriptor.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpAbstractPaneDescriptor.java index 606bee640f..2bbad12a99 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpAbstractPaneDescriptor.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpAbstractPaneDescriptor.java @@ -12,6 +12,8 @@ * ------- ------- -------- ----------- * 05/02/2012 229 Chin Chen Initial coding for multiple display panes implementation * 03/11/2013 972 Greg Hull rm paneNumber + * 03/11/2013 2491 bsteffen extend IDescriptor derictly for better serialization detection. + * * * @@ -32,10 +34,12 @@ import org.geotools.referencing.crs.DefaultEngineeringCRS; import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.datastructure.LoopProperties; +import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.viz.core.graphing.GraphDescriptor; @XmlAccessorType(XmlAccessType.NONE) -public class NsharpAbstractPaneDescriptor extends GraphDescriptor { +public class NsharpAbstractPaneDescriptor extends GraphDescriptor implements + IDescriptor { // @XmlElement // protected int paneNumber; diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/rsc/GridLoadProperties.java b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/rsc/GridLoadProperties.java deleted file mode 100644 index 615fefe508..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/rsc/GridLoadProperties.java +++ /dev/null @@ -1,125 +0,0 @@ -/***************************************************************************************** - * COPYRIGHT (c), 2008, RAYTHEON COMPANY - * ALL RIGHTS RESERVED, An Unpublished Work - * - * RAYTHEON PROPRIETARY - * If the end user is not the U.S. Government or any agency thereof, use - * or disclosure of data contained in this source code file is subject to - * the proprietary restrictions set forth in the Master Rights File. - * - * U.S. GOVERNMENT PURPOSE RIGHTS NOTICE - * If the end user is the U.S. Government or any agency thereof, this source - * code is provided to the U.S. Government with Government Purpose Rights. - * Use or disclosure of data contained in this source code file is subject to - * the "Government Purpose Rights" restriction in the Master Rights File. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * Use or disclosure of data contained in this source code file is subject to - * the export restrictions set forth in the Master Rights File. - ******************************************************************************************/ -package gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; - -import com.raytheon.uf.viz.core.rsc.DisplayType; -import com.raytheon.uf.viz.core.rsc.LoadProperties; - -/** - * Loads properties to have different display types (Image, Contour etc..) for - * grid data. - * - *
- * SOFTWARE HISTORY
- * Date           Ticket#    Engineer    Description
- * ------------   ---------- ----------- --------------------------
- * July 18, 2008   #1280     S. Manoj     Initial creation
- * 
- * 
- * - * @author smanoj - * @version 1.0 - */ -@XmlAccessorType(XmlAccessType.NONE) -public class GridLoadProperties extends LoadProperties { - - /** - * Display type for a grid data(Image, Contour etc...) - */ - @XmlAttribute - private DisplayType displayType; - - public GridLoadProperties() { - this.displayType = DisplayType.CONTOUR; - } - - /** - * Constructor - * - * @param displayType - */ - public GridLoadProperties(DisplayType displayType) { - this.displayType = displayType; - } - - /** - * Returns the display type. - * - * @return displayType - */ - public DisplayType getDisplayType() { - return displayType; - } - - /** - * Sets the display type. - * - * @param displayType - */ - public void setDisplayType(DisplayType displayType) { - this.displayType = displayType; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result - + ((displayType == null) ? 0 : displayType.hashCode()); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - GridLoadProperties other = (GridLoadProperties) obj; - if (displayType == null) { - if (other.displayType != null) { - return false; - } - } else if (!displayType.equals(other.displayType)) { - return false; - } - return true; - } - -} diff --git a/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/MANIFEST.MF index 111f0b57e3..eea1dd0915 100644 --- a/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/MANIFEST.MF @@ -14,15 +14,14 @@ Require-Bundle: org.eclipse.ui, gov.noaa.nws.ncep.viz.common;bundle-version="1.0.0", com.raytheon.uf.common.colormap;bundle-version="1.12.1174", gov.noaa.nws.ncep.viz.localization;bundle-version="1.0.0", - com.raytheon.uf.common.style;bundle-version="1.0.0" + com.raytheon.uf.common.style;bundle-version="1.0.0", + com.raytheon.viz.core.graphing;bundle-version="1.12.1174", + com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: gov.noaa.nws.ncep.viz.ui.display Import-Package: com.raytheon.uf.common.topo, - com.raytheon.uf.viz.core.maps, - com.raytheon.uf.viz.core.maps.display, com.raytheon.uf.viz.core.rsc.legend, - com.raytheon.viz.core.graphing, gov.noaa.nws.ncep.gempak.parameters.colorbar, javax.measure.unit, javax.vecmath