Author: tcunning Date: Wed Sep 23 16:12:52 2009 New Revision: 818152 URL: http://svn.apache.org/viewvc?rev=818152&view=rev Log: SCOUT-91 Cache the JAXBContext in a hash and pass it out rather than getting a newInstance every time.
Added: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/JAXBContextUtil.java Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java Added: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/JAXBContextUtil.java URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/JAXBContextUtil.java?rev=818152&view=auto ============================================================================== --- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/JAXBContextUtil.java (added) +++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/JAXBContextUtil.java Wed Sep 23 16:12:52 2009 @@ -0,0 +1,34 @@ +package org.apache.ws.scout.registry; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class JAXBContextUtil { + + public static final String UDDI_V2_VERSION = "2.0"; + public static final String UDDI_V3_VERSION = "3.0"; + + private static Log log = LogFactory.getLog(JAXBContextUtil.class); + private static final Map<String, JAXBContext> JAXBContexts = new HashMap<String, JAXBContext>(); + + static { + try { + JAXBContexts.put(UDDI_V2_VERSION, JAXBContext.newInstance(new Class[] {org.apache.ws.scout.model.uddi.v2.ObjectFactory.class})); + JAXBContexts.put(UDDI_V3_VERSION, JAXBContext.newInstance(new Class[] {org.uddi.api_v3.ObjectFactory.class})); + } catch (JAXBException e) { + log.error("Initialization of JAXBMarshaller failed:" + e, e); + throw new ExceptionInInitializerError(e); + } + } + + public static JAXBContext getContext(String uddiVersion) { + return JAXBContexts.get(uddiVersion); + } + +} Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java?rev=818152&r1=818151&r2=818152&view=diff ============================================================================== --- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java (original) +++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java Wed Sep 23 16:12:52 2009 @@ -226,8 +226,8 @@ try { - JAXBContext context = JAXBContext.newInstance(new Class[] {ObjectFactory.class}); - JAXBContext v3context = JAXBContext.newInstance(new Class[] {org.uddi.api_v3.ObjectFactory.class}); + JAXBContext context = JAXBContextUtil.getContext(JAXBContextUtil.UDDI_V2_VERSION); + JAXBContext v3context = JAXBContextUtil.getContext(JAXBContextUtil.UDDI_V3_VERSION); if ("3.0".equals(uddiVer)) { this.unmarshaller = v3context.createUnmarshaller(); } else { Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java?rev=818152&r1=818151&r2=818152&view=diff ============================================================================== --- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java (original) +++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java Wed Sep 23 16:12:52 2009 @@ -186,8 +186,8 @@ try { - JAXBContext context = JAXBContext.newInstance(new Class[] {ObjectFactory.class}); - JAXBContext v3context = JAXBContext.newInstance(new Class[] {org.uddi.api_v3.ObjectFactory.class}); + JAXBContext context = JAXBContextUtil.getContext(JAXBContextUtil.UDDI_V2_VERSION); + JAXBContext v3context = JAXBContextUtil.getContext(JAXBContextUtil.UDDI_V3_VERSION); if ("3.0".equals(uddiVer)) { this.unmarshaller = v3context.createUnmarshaller(); } else { --------------------------------------------------------------------- To unsubscribe, e-mail: scout-dev-unsubscr...@ws.apache.org For additional commands, e-mail: scout-dev-h...@ws.apache.org