Merge "Issue #2361 move ebxml away from using SerializationUtil for XML processing" into development
Former-commit-id:eb504de3a0
[formerly1ac6a4ea18
] [formerly7156ac5d4f
] [formerlyeb504de3a0
[formerly1ac6a4ea18
] [formerly7156ac5d4f
] [formerly6fac918395
[formerly7156ac5d4f
[formerly 84226cbd63d12c6c1624dfc1dd72b42360d0e54d]]]] Former-commit-id:6fac918395
Former-commit-id:064fa413cf
[formerly8c3eb7612c
] [formerly 9d0ec1d71c57a9298742cd4dc01ef04de0897694 [formerlyb5d457f566
]] Former-commit-id: 0bbda3dbc6008120f19a0673634c1f1625090efe [formerly7691a13fec
] Former-commit-id:a3cb4309d1
This commit is contained in:
commit
2d337c30bb
8 changed files with 171 additions and 87 deletions
|
@ -23,8 +23,8 @@ import static com.raytheon.uf.common.registry.ebxml.encoder.RegistryEncoders.Typ
|
|||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.EbxmlJaxbManager;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
|
||||
/**
|
||||
* A {@link StringBasedEncoder} implementation that uses JAXB. Package-private
|
||||
|
@ -38,6 +38,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 07, 2012 1102 djohnson Initial creation
|
||||
* Jun 03, 2013 2038 djohnson Add equals/hashcode.
|
||||
* Oct 31, 2013 2361 njensen Use specific JAXBManager instead of SerializationUtil
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -60,7 +61,7 @@ class JaxbEncoder extends StringBasedEncoder {
|
|||
@Override
|
||||
Object decodeContent(String content) throws SerializationException {
|
||||
try {
|
||||
return SerializationUtil.unmarshalFromXml(Object.class, content);
|
||||
return EbxmlJaxbManager.getJaxbManager().unmarshalFromXml(content);
|
||||
} catch (JAXBException e) {
|
||||
throw new SerializationException("Unable to decode the object!", e);
|
||||
}
|
||||
|
@ -72,7 +73,8 @@ class JaxbEncoder extends StringBasedEncoder {
|
|||
@Override
|
||||
String encodeContent(Object objectToEncode) throws SerializationException {
|
||||
try {
|
||||
return new String(SerializationUtil.marshalToXml(objectToEncode));
|
||||
return new String(EbxmlJaxbManager.getJaxbManager().marshalToXml(
|
||||
objectToEncode));
|
||||
} catch (JAXBException e) {
|
||||
throw new SerializationException("Unable to encode the object!", e);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ Require-Bundle: javax.persistence;bundle-version="1.0.0",
|
|||
com.raytheon.uf.edex.database;bundle-version="1.0.0",
|
||||
org.apache.commons.cxf;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.util;bundle-version="1.12.1174"
|
||||
com.raytheon.uf.common.util;bundle-version="1.12.1174",
|
||||
org.reflections;bundle-version="0.9.9"
|
||||
Export-Package: com.raytheon.uf.common.registry,
|
||||
com.raytheon.uf.common.registry.schemas.ebxml.util,
|
||||
com.raytheon.uf.common.registry.schemas.ebxml.util.annotations,
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
oasis.names.tc.ebxml.regrep.xsd.lcm.v4.ObjectFactory
|
||||
oasis.names.tc.ebxml.regrep.xsd.query.v4.ObjectFactory
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectFactory
|
||||
oasis.names.tc.ebxml.regrep.xsd.rs.v4.ObjectFactory
|
||||
oasis.names.tc.ebxml.regrep.xsd.spi.v4.ObjectFactory
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ActionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.AnyValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.AssociationType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.AuditableEventType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.BooleanValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationNodeType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationSchemeType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.CollectionValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.DateTimeValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.DeliveryInfoType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.DurationValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.EmailAddressType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.EntryType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalIdentifierType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExternalLinkType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExtrinsicObjectType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.FederationType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.FloatValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.IntegerValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.InternationalStringType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.InternationalStringValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.LocalizedStringType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.MapType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.MapValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.NotificationType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefListType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectRefType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ParameterType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.PersonNameType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.PersonType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.PostalAddressType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryDefinitionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryExpressionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryPackageType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.RoleType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ServiceBindingType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ServiceEndpointType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ServiceInterfaceType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ServiceType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.SimpleLinkType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringQueryExpressionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.TaxonomyElementType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.TelephoneNumberType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.ValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.VocabularyTermType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.VocabularyTermValueType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.WorkflowActionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.XMLQueryExpressionType
|
||||
oasis.names.tc.ebxml.regrep.xsd.rim.v4.DynamicObjectRefType
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* 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.registry.schemas.ebxml.util;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.TypeAnnotationsScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
|
||||
/**
|
||||
* A JAXB Manager for transforming EBXML objects to/from XML.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 30, 2013 2361 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EbxmlJaxbManager {
|
||||
|
||||
private static JAXBManager jaxb;
|
||||
|
||||
/**
|
||||
* Uses reflections to scan for ebxml datadelivery registry classes that can
|
||||
* be transformed to/from xml, and then adds in the ebxml object factories.
|
||||
*
|
||||
* @return the classes it found without any duplicates
|
||||
*/
|
||||
private static Class<?>[] getClasses() {
|
||||
String[] packageNames = new String[] {
|
||||
"com.raytheon.uf.common.datadelivery.registry" };
|
||||
|
||||
long t0 = System.currentTimeMillis();
|
||||
ConfigurationBuilder cb = new ConfigurationBuilder();
|
||||
for (String pkg : packageNames) {
|
||||
cb.addUrls(ClasspathHelper.forPackage(pkg));
|
||||
}
|
||||
cb.setScanners(new TypeAnnotationsScanner());
|
||||
// the call to build() will do the actual scanning so the separate
|
||||
// calls to getTypesAnnotatedWith(class, false) will not slow it down
|
||||
Reflections reflecs = cb.build();
|
||||
Set<Class<?>> set = reflecs.getTypesAnnotatedWith(
|
||||
XmlAccessorType.class, false);
|
||||
set.addAll(reflecs.getTypesAnnotatedWith(XmlRegistry.class, false));
|
||||
long t1 = System.currentTimeMillis();
|
||||
System.out.println("Found " + set.size() + " classes for ebxml in "
|
||||
+ (t1 - t0) + " ms");
|
||||
|
||||
set.add(oasis.names.tc.ebxml.regrep.xsd.lcm.v4.ObjectFactory.class);
|
||||
set.add(oasis.names.tc.ebxml.regrep.xsd.query.v4.ObjectFactory.class);
|
||||
set.add(oasis.names.tc.ebxml.regrep.xsd.rim.v4.ObjectFactory.class);
|
||||
set.add(oasis.names.tc.ebxml.regrep.xsd.rs.v4.ObjectFactory.class);
|
||||
set.add(oasis.names.tc.ebxml.regrep.xsd.spi.v4.ObjectFactory.class);
|
||||
|
||||
return set.toArray(new Class[0]);
|
||||
}
|
||||
|
||||
public static synchronized JAXBManager getJaxbManager()
|
||||
throws JAXBException {
|
||||
if (jaxb == null) {
|
||||
jaxb = new JAXBManager(getClasses());
|
||||
}
|
||||
return jaxb;
|
||||
}
|
||||
|
||||
private EbxmlJaxbManager() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,23 @@
|
|||
/**
|
||||
* 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.registry.schemas.ebxml.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -11,8 +31,21 @@ import javax.xml.datatype.XMLGregorianCalendar;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
|
||||
/**
|
||||
* A serialized type
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* --/--/---- Initial creation
|
||||
* Oct 31, 2013 2361 njensen Use specific JAXBManager instead of SerializationUtil
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
public class SerializedType implements UserType {
|
||||
|
||||
/** Stored as a varchar in the databse */
|
||||
|
@ -60,7 +93,7 @@ public class SerializedType implements UserType {
|
|||
|
||||
if (obj != null) {
|
||||
try {
|
||||
return SerializationUtil.getJaxbManager().unmarshalFromXml(obj);
|
||||
return EbxmlJaxbManager.getJaxbManager().unmarshalFromXml(obj);
|
||||
} catch (Exception e) {
|
||||
throw new HibernateException("Error retrieving AnyType data", e);
|
||||
}
|
||||
|
@ -77,7 +110,7 @@ public class SerializedType implements UserType {
|
|||
} else {
|
||||
try {
|
||||
;
|
||||
statement.setString(index, SerializationUtil.getJaxbManager()
|
||||
statement.setString(index, EbxmlJaxbManager.getJaxbManager()
|
||||
.marshalToXml(value));
|
||||
} catch (Exception e) {
|
||||
throw new HibernateException("Error storing AnyType data", e);
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.util.Map;
|
|||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
|
||||
|
@ -57,8 +59,8 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.EbxmlJaxbManager;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
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.util.ReflectionUtil;
|
||||
|
@ -79,13 +81,14 @@ import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 2/9/2012 184 bphillip Initial Coding
|
||||
* 3/18/2013 1082 bphillip Changed to use transactional boundaries and spring injection
|
||||
* 4/9/2013 1802 bphillip Changed submitObjects method call from submitObjectsInternal
|
||||
* Apr 15, 2013 1693 djohnson Use a strategy to verify the database is up to date.
|
||||
* 4/9/2013 1802 bphillip Changed submitObjects method call from submitObjectsInternal
|
||||
* Apr 15, 2013 1693 djohnson Use a strategy to verify the database is up to date.
|
||||
* Apr 30, 2013 1960 djohnson Extend the generalized DbInit.
|
||||
* 5/21/2013 2022 bphillip Using TransactionTemplate for database initialization
|
||||
* May 29, 2013 1650 djohnson Reference LifecycleManager as interface type.
|
||||
* Jun 24, 2013 2106 djohnson Invoke registry initialized listeners in their own transaction so
|
||||
* 5/21/2013 2022 bphillip Using TransactionTemplate for database initialization
|
||||
* May 29, 2013 1650 djohnson Reference LifecycleManager as interface type.
|
||||
* Jun 24, 2013 2106 djohnson Invoke registry initialized listeners in their own transaction so
|
||||
* they can't fail the ebxml schema creation/population.
|
||||
* Nov 01, 2013 2361 njensen Use EbxmlJaxbManager instead of SerializationUtil
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -162,9 +165,15 @@ public class DbInit extends com.raytheon.uf.edex.database.init.DbInit implements
|
|||
statusHandler.info("Populating RegRep database from file: "
|
||||
+ fileList[i].getName());
|
||||
|
||||
SubmitObjectsRequest obj = SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(SubmitObjectsRequest.class,
|
||||
fileList[i]);
|
||||
SubmitObjectsRequest obj = null;
|
||||
try {
|
||||
obj = EbxmlJaxbManager.getJaxbManager().unmarshalFromXmlFile(
|
||||
SubmitObjectsRequest.class, fileList[i]);
|
||||
} catch (JAXBException e) {
|
||||
throw new SerializationException(
|
||||
"Error unmarshalling from file: "
|
||||
+ fileList[i].getPath(), e);
|
||||
}
|
||||
|
||||
// Ensure an owner is assigned
|
||||
for (RegistryObjectType regObject : obj.getRegistryObjectList()
|
||||
|
|
|
@ -35,7 +35,8 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 29, 2012 bphillip Initial creation
|
||||
* Feb 29, 2012 bphillip Initial creation
|
||||
* Oct 31, 2013 2361 njensen Use specific JAXBManager instead of SerializationUtil
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
|
|
@ -25,8 +25,7 @@ import java.util.Map;
|
|||
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.registry.schemas.ebxml.util.EbxmlJaxbManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
|
@ -83,9 +82,9 @@ public class AdhocQueryExpressionManager {
|
|||
|
||||
AdhocQueryExpression obj = null;
|
||||
try {
|
||||
obj = (AdhocQueryExpression) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(fileList[i]);
|
||||
} catch (SerializationException e) {
|
||||
obj = EbxmlJaxbManager.getJaxbManager().unmarshalFromXmlFile(
|
||||
AdhocQueryExpression.class, fileList[i]);
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Error getting predefined adhoc queries.",
|
||||
e);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue