Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 09F199913 for ; Thu, 23 Feb 2012 12:54:05 +0000 (UTC) Received: (qmail 97037 invoked by uid 500); 23 Feb 2012 12:54:04 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 96985 invoked by uid 500); 23 Feb 2012 12:54:04 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 96976 invoked by uid 99); 23 Feb 2012 12:54:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Feb 2012 12:54:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Feb 2012 12:54:01 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5D4402388860; Thu, 23 Feb 2012 12:53:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1292785 - in /cxf/branches/2.4.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPBeanDefinitionParser.java Date: Thu, 23 Feb 2012 12:53:40 -0000 To: commits@cxf.apache.org From: ay@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120223125340.5D4402388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ay Date: Thu Feb 23 12:53:39 2012 New Revision: 1292785 URL: http://svn.apache.org/viewvc?rev=1292785&view=rev Log: Merged revisions 1292766 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes ................ r1292766 | ay | 2012-02-23 13:41:00 +0100 (Thu, 23 Feb 2012) | 9 lines Merged revisions 1292763 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1292763 | ay | 2012-02-23 13:22:19 +0100 (Thu, 23 Feb 2012) | 1 line [CXF-3993] WS-RM's blueprint configuration fails to parse RMAssertion entries (fix) ........ ................ Modified: cxf/branches/2.4.x-fixes/ (props changed) cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPBeanDefinitionParser.java Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Feb 23 12:53:39 2012 @@ -1,2 +1,2 @@ -/cxf/branches/2.5.x-fixes:1292373 -/cxf/trunk:1221366 +/cxf/branches/2.5.x-fixes:1292373,1292766 +/cxf/trunk:1221366,1292763 Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java?rev=1292785&r1=1292784&r2=1292785&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java (original) +++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java Thu Feb 23 12:53:39 2012 @@ -18,7 +18,14 @@ */ package org.apache.cxf.configuration.blueprint; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.logging.Logger; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; import javax.xml.namespace.QName; import org.w3c.dom.Attr; import org.w3c.dom.Element; @@ -33,8 +40,12 @@ import org.apache.aries.blueprint.mutabl import org.apache.aries.blueprint.mutable.MutableRefMetadata; import org.apache.aries.blueprint.mutable.MutableValueMetadata; import org.apache.cxf.bus.blueprint.BlueprintBus; +import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.common.util.PackageUtils; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.helpers.DOMUtils; +import org.apache.cxf.jaxb.JAXBContextCache; +import org.apache.cxf.jaxb.JAXBContextCache.CachedContextAndSchemas; import org.osgi.framework.Bundle; import org.osgi.service.blueprint.reflect.BeanMetadata; import org.osgi.service.blueprint.reflect.CollectionMetadata; @@ -49,6 +60,11 @@ public abstract class AbstractBPBeanDefi private static final String XMLNS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0"; private static final String COMPONENT_ID = "component-id"; + private static final Logger LOG = LogUtils.getL7dLogger(AbstractBPBeanDefinitionParser.class); + + private JAXBContext jaxbContext; + private Set> jaxbClasses; + protected boolean hasBusProperty() { return false; } @@ -274,4 +290,60 @@ public abstract class AbstractBPBeanDefi el = DOMUtils.getNextElement(el); } } + + protected void mapElementToJaxbProperty(ParserContext ctx, + MutableBeanMetadata bean, Element parent, + QName name, + String propertyName, + Class c) { + + Element data = DOMUtils.getFirstChildWithName(parent, name); + if (data == null) { + return; + } + + try { + Unmarshaller unmarshaller = getContext(c).createUnmarshaller(); + MutablePassThroughMetadata value = ctx.createMetadata(MutablePassThroughMetadata.class); + value.setObject(unmarshaller.unmarshal(data, c).getValue()); + bean.addProperty(propertyName, value); + } catch (JAXBException e) { + LOG.warning("Unable to parse property " + propertyName + " due to " + e); + } + } + + private synchronized JAXBContext getContext(Class cls) { + if (jaxbContext == null || jaxbClasses == null || !jaxbClasses.contains(cls)) { + try { + Set> tmp = new HashSet>(); + if (jaxbClasses != null) { + tmp.addAll(jaxbClasses); + } + JAXBContextCache.addPackage(tmp, PackageUtils.getPackageName(cls), + cls == null + ? getClass().getClassLoader() + : cls.getClassLoader()); + if (cls != null) { + boolean hasOf = false; + for (Class c : tmp) { + if (c.getPackage() == cls.getPackage() + && "ObjectFactory".equals(c.getSimpleName())) { + hasOf = true; + } + } + if (!hasOf) { + tmp.add(cls); + } + } + JAXBContextCache.scanPackages(tmp); + CachedContextAndSchemas ccs + = JAXBContextCache.getCachedContextAndSchemas(tmp, null, null, null, false); + jaxbClasses = ccs.getClasses(); + jaxbContext = ccs.getContext(); + } catch (JAXBException e) { + throw new RuntimeException(e); + } + } + return jaxbContext; + } } Modified: cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPBeanDefinitionParser.java?rev=1292785&r1=1292784&r2=1292785&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPBeanDefinitionParser.java (original) +++ cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/blueprint/RMBPBeanDefinitionParser.java Thu Feb 23 12:53:39 2012 @@ -19,25 +19,14 @@ package org.apache.cxf.ws.rm.blueprint; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Logger; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; import javax.xml.namespace.QName; import org.w3c.dom.Element; import org.apache.aries.blueprint.ParserContext; import org.apache.aries.blueprint.mutable.MutableBeanMetadata; -import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata; -import org.apache.cxf.common.logging.LogUtils; -import org.apache.cxf.common.util.PackageUtils; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser; -import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.ws.rm.RMManager; import org.apache.cxf.ws.rm.manager.DeliveryAssuranceType; import org.apache.cxf.ws.rm.manager.DestinationPolicyType; @@ -52,10 +41,6 @@ import org.osgi.service.blueprint.reflec public class RMBPBeanDefinitionParser extends AbstractBPBeanDefinitionParser { protected static final String RM_NS = "http://cxf.apache.org/ws/rm/manager"; - private static final Logger LOG = LogUtils.getL7dLogger(RMBPBeanDefinitionParser.class); - - private Map, JAXBContext> jaxbContexts = new HashMap, JAXBContext>(); - private Class beanClass; public RMBPBeanDefinitionParser(Class beanClass) { @@ -100,8 +85,6 @@ public class RMBPBeanDefinitionParser ex return bean; } - - @Override protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) { if ("store".equals(name)) { @@ -110,32 +93,4 @@ public class RMBPBeanDefinitionParser ex bean.addProperty("addressingNamespace", createValue(ctx, el.getTextContent())); } } - - protected void mapElementToJaxbProperty(ParserContext ctx, - MutableBeanMetadata bean, Element parent, - QName name, - String propertyName, - Class c) { - - Element data = DOMUtils.getFirstElement(parent); - - try { - Unmarshaller unmarshaller = getJAXBContext(c).createUnmarshaller(); - MutablePassThroughMetadata value = ctx.createMetadata(MutablePassThroughMetadata.class); - value.setObject(unmarshaller.unmarshal(data, c).getValue()); - bean.addProperty(propertyName, value); - } catch (JAXBException e) { - LOG.warning("Unable to parse property " + propertyName + " due to " + e); - } - } - - private synchronized JAXBContext getJAXBContext(Class c) throws JAXBException { - JAXBContext jaxbContext = jaxbContexts.get(c); - if (jaxbContext == null) { - jaxbContext = JAXBContext.newInstance(PackageUtils.getPackageName(c), - c.getClassLoader()); - jaxbContexts.put(c, jaxbContext); - } - return jaxbContext; - } }