[jboss-svn-commits] JBL Code SVN: r36518 - in labs/jbossesb/branches/JBESB_4_9_CP/product: rosetta/src/org/jboss/internal/soa/esb/util/stax and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 13 08:25:38 EST 2011
Author: kevin.conner at jboss.com
Date: 2011-01-13 08:25:37 -0500 (Thu, 13 Jan 2011)
New Revision: 36518
Added:
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCache.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCacheResource.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountException.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxAttribute.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxCharacters.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxComment.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxDTD.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndDocument.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndElement.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityDeclaration.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityReference.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxLocation.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespace.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespaceContext.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNotationDeclaration.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxProcessingInstruction.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartDocument.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartElement.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxXMLEvent.java
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/util/
labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/util/ESBXMLEventStreamReader.java
Modified:
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/resources/soapui-client.sar.properties
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
Log:
cache soap wsdl/templating information: JBESB-3558
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCache.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCache.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCache.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,240 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+/**
+ * LRU Reference Count cache.
+ *
+ * Cache implementation which caches the most recent caches, allowing entries to
+ * be used by multiple users. Requests for entries are tracked and counted,
+ * returned to the cached set once no references remain.
+ */
+public class LRUReferenceCountCache<T, R extends LRUReferenceCountCacheResource<T>>
+{
+ /**
+ * The unused entries.
+ */
+ private final Map<String, R> cachedResources = new HashMap<String, R>();
+ /**
+ * The list of cached resource entries.
+ */
+ private final LinkedHashSet<String> cachedResourceInsertion = new LinkedHashSet<String>();
+ /**
+ * The active entries.
+ */
+ private final Map<String, LRUReferenceCountCacheEntry<T, R>> active = new HashMap<String, LRUReferenceCountCacheEntry<T, R>>();
+ /**
+ * The cache size.
+ */
+ private final int lruCacheSize;
+ /**
+ * The logger instance.
+ */
+ private final Logger logger = Logger.getLogger(getClass()) ;
+
+ public LRUReferenceCountCache(final int lruCacheSize)
+ {
+ this.lruCacheSize = lruCacheSize ;
+ }
+
+ public synchronized void clean()
+ {
+ cachedResourceInsertion.clear() ;
+ final Collection<R> cachedResource = cachedResources.values() ;
+ for(R resource: cachedResource)
+ {
+ closeResource(resource) ;
+ }
+ cachedResources.clear() ;
+ if (active.size() > 0)
+ {
+ logger.warn("Active entries in cache") ;
+ }
+ }
+
+ protected synchronized LRUReferenceCountCacheEntry<T, R> internalGet(final String resourceLocation)
+ {
+ final LRUReferenceCountCacheEntry<T, R> result ;
+ final LRUReferenceCountCacheEntry<T, R> activeEntry = active.get(resourceLocation) ;
+ if (activeEntry != null)
+ {
+ activeEntry.incCount() ;
+ result = activeEntry ;
+ }
+ else
+ {
+ final R cachedResource = cachedResources.remove(resourceLocation) ;
+ if (cachedResource != null)
+ {
+ cachedResourceInsertion.remove(resourceLocation) ;
+ final LRUReferenceCountCacheEntry<T, R> entry = new LRUReferenceCountCacheEntry<T, R>(cachedResource, resourceLocation) ;
+ active.put(resourceLocation, entry) ;
+ result = entry ;
+ }
+ else
+ {
+ result = null ;
+ }
+ }
+ return result ;
+ }
+
+ protected LRUReferenceCountCacheEntry<T, R> create(final String resourceLocation, R newResource)
+ {
+ final LRUReferenceCountCacheEntry<T, R> result ;
+ boolean close = false ;
+
+ synchronized (this)
+ {
+ final LRUReferenceCountCacheEntry<T, R> current = internalGet(resourceLocation) ;
+ if (current == null)
+ {
+ final LRUReferenceCountCacheEntry<T, R> newEntry = new LRUReferenceCountCacheEntry<T, R>(newResource, resourceLocation) ;
+ active.put(resourceLocation, newEntry) ;
+ result = newEntry ;
+ }
+ else
+ {
+ close = true ;
+ result = current ;
+ }
+ }
+ if (close)
+ {
+ closeResource(newResource) ;
+ }
+ else
+ {
+ checkExpired() ;
+ }
+ return result ;
+ }
+
+ public void release(final LRUReferenceCountCacheEntry<T, R> entry)
+ {
+ boolean cached = false ;
+ synchronized (this)
+ {
+ if (entry.decCount() == 0)
+ {
+ final String resourceLocation = entry.getResourceLocation() ;
+ cachedResources.put(resourceLocation, entry.getCacheResource()) ;
+ cachedResourceInsertion.add(resourceLocation) ;
+ cached = true ;
+ }
+ }
+ if (cached)
+ {
+ checkExpired() ;
+ }
+ }
+
+ private void checkExpired()
+ {
+ final List<R> expiredResources ;
+ synchronized (this)
+ {
+ final int activeSize = active.size() ;
+ final int cachedSize = cachedResourceInsertion.size() ;
+ final int expiredCount = (activeSize >= lruCacheSize ? cachedSize
+ : activeSize + cachedSize - lruCacheSize) ;
+ if (expiredCount > 0)
+ {
+ expiredResources = new ArrayList<R>(expiredCount) ;
+ final Iterator<String> iterator = cachedResourceInsertion.iterator() ;
+ for (int count = 0; count < expiredCount; count++)
+ {
+ final String expiredResourceLocation = iterator.next();
+ iterator.remove() ;
+ expiredResources.add(cachedResources.remove(expiredResourceLocation)) ;
+ }
+ }
+ else
+ {
+ expiredResources = null ;
+ }
+ }
+ if (expiredResources != null)
+ {
+ for (R resource : expiredResources)
+ {
+ closeResource(resource) ;
+ }
+ }
+ }
+
+ private void closeResource(final R resource)
+ {
+ try
+ {
+ resource.close() ;
+ }
+ catch (final Throwable th)
+ {
+ logger.warn("Unexpected exception cleaning resource", th) ;
+ }
+ }
+
+ public static final class LRUReferenceCountCacheEntry<T, R extends LRUReferenceCountCacheResource<T>>
+ {
+ private final R resource;
+ private final String resourceLocation;
+ private int count = 1;
+
+ LRUReferenceCountCacheEntry(final R resource, final String resourceLocation)
+ {
+ this.resource = resource ;
+ this.resourceLocation = resourceLocation ;
+ }
+
+ R getCacheResource()
+ {
+ return resource ;
+ }
+
+ public T getResource()
+ {
+ return resource.getInstance() ;
+ }
+
+ public String getResourceLocation()
+ {
+ return resourceLocation ;
+ }
+
+ private int incCount()
+ {
+ return ++count ;
+ }
+
+ private int decCount()
+ {
+ return --count ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCache.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCacheResource.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCacheResource.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCacheResource.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util;
+
+/**
+ * Resource type for cache.
+ */
+public class LRUReferenceCountCacheResource<T>
+{
+ private final T instance ;
+
+ protected LRUReferenceCountCacheResource(final T instance)
+ {
+ this.instance = instance ;
+ }
+
+ public T getInstance()
+ {
+ return instance ;
+ }
+
+ public void close()
+ throws LRUReferenceCountException
+ {
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountCacheResource.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountException.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountException.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountException.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util;
+
+/**
+ * Exception used for LRUReferenceCountCache
+ */
+public class LRUReferenceCountException extends Exception
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 4726344597058554887L;
+
+ /**
+ * Construct a default lru reference count exception.
+ */
+ public LRUReferenceCountException()
+ {
+ }
+
+ /**
+ * Construct a lru reference count exception with a specific message.
+ * @param message the associated message.
+ */
+ public LRUReferenceCountException(final String message)
+ {
+ super(message) ;
+ }
+
+ /**
+ * Construct a lru reference count exception with a specific cause.
+ * @param cause the associated cause.
+ */
+ public LRUReferenceCountException(final Throwable cause)
+ {
+ super(cause) ;
+ }
+
+ /**
+ * Construct a lru reference count exception with a specific message and cause.
+ * @param message the associated message.
+ * @param cause the associated cause.
+ */
+ public LRUReferenceCountException(final String message, final Throwable cause)
+ {
+ super(message, cause) ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUReferenceCountException.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxAttribute.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxAttribute.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxAttribute.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.Attribute;
+
+/**
+ * Cached event information for Attribute.
+ */
+public class ESBStaxAttribute extends ESBStaxXMLEvent implements Attribute
+{
+ private final String dtdType ;
+ private final QName name ;
+ private final String value ;
+ private final boolean specified ;
+
+ public ESBStaxAttribute(final Attribute attribute)
+ {
+ super(attribute) ;
+ dtdType = attribute.getDTDType() ;
+ name = attribute.getName() ;
+ value = attribute.getValue() ;
+ specified = attribute.isSpecified() ;
+ }
+
+ public String getDTDType()
+ {
+ return dtdType ;
+ }
+
+ public QName getName()
+ {
+ return name ;
+ }
+
+ public String getValue()
+ {
+ return value ;
+ }
+
+ public boolean isSpecified()
+ {
+ return specified ;
+ }
+
+ @Override
+ public boolean isAttribute()
+ {
+ return true ;
+ }
+
+ static List<Attribute> getAttributes(final Iterator<Attribute> attributes)
+ {
+ if (attributes == null)
+ {
+ return null ;
+ }
+ else if (attributes.hasNext())
+ {
+ final List<Attribute> result = new ArrayList<Attribute>() ;
+ do
+ {
+ result.add(new ESBStaxAttribute(attributes.next())) ;
+ }
+ while(attributes.hasNext()) ;
+ return result ;
+ }
+ else
+ {
+ return Collections.emptyList() ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxAttribute.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxCharacters.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxCharacters.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxCharacters.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import javax.xml.stream.events.Characters;
+
+/**
+ * Cached event information for Characters.
+ */
+public class ESBStaxCharacters extends ESBStaxXMLEvent implements Characters
+{
+ private final String data ;
+ private final boolean cdata ;
+ private boolean ignorableWhiteSpace ;
+ private boolean whiteSpace ;
+
+ public ESBStaxCharacters(final Characters characters)
+ {
+ super(characters) ;
+ data = characters.getData() ;
+ cdata = characters.isCData() ;
+ ignorableWhiteSpace = characters.isIgnorableWhiteSpace() ;
+ whiteSpace = characters.isWhiteSpace() ;
+ }
+
+ public String getData()
+ {
+ return data ;
+ }
+
+ public boolean isCData()
+ {
+ return cdata ;
+ }
+
+ public boolean isIgnorableWhiteSpace()
+ {
+ return ignorableWhiteSpace ;
+ }
+
+ public boolean isWhiteSpace()
+ {
+ return whiteSpace ;
+ }
+
+ @Override
+ public boolean isCharacters()
+ {
+ return true ;
+ }
+
+ @Override
+ public Characters asCharacters()
+ {
+ return this ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxCharacters.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxComment.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxComment.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxComment.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import javax.xml.stream.events.Comment;
+
+/**
+ * Cached event information for Comment.
+ */
+public class ESBStaxComment extends ESBStaxXMLEvent implements Comment
+{
+ private final String text ;
+
+ public ESBStaxComment(final Comment comment)
+ {
+ super(comment) ;
+ text = comment.getText() ;
+ }
+
+ public String getText()
+ {
+ return text ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxComment.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxDTD.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxDTD.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxDTD.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.List;
+
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.NotationDeclaration;
+
+/**
+ * Cached event information for DTD.
+ */
+public class ESBStaxDTD extends ESBStaxXMLEvent implements DTD
+{
+ private final String documentTypeDeclaration ;
+ private final List<EntityDeclaration> entities ;
+ private final List<NotationDeclaration> notations ;
+ private Object processedDTD ;
+
+ public ESBStaxDTD(final DTD dtd)
+ {
+ super(dtd) ;
+ documentTypeDeclaration = dtd.getDocumentTypeDeclaration() ;
+ entities = ESBStaxEntityDeclaration.getEntities(dtd.getEntities()) ;
+ notations = ESBStaxNotationDeclaration.getNotations(dtd.getNotations()) ;
+ processedDTD = dtd.getProcessedDTD() ;
+ }
+
+ public String getDocumentTypeDeclaration()
+ {
+ return documentTypeDeclaration ;
+ }
+
+ public List<EntityDeclaration> getEntities()
+ {
+ return entities ;
+ }
+
+ public List<NotationDeclaration> getNotations()
+ {
+ return notations ;
+ }
+
+ public Object getProcessedDTD()
+ {
+ return processedDTD ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxDTD.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndDocument.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndDocument.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndDocument.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import javax.xml.stream.events.EndDocument;
+
+/**
+ * Cached event information for EndDocument.
+ */
+public class ESBStaxEndDocument extends ESBStaxXMLEvent implements EndDocument
+{
+ public ESBStaxEndDocument(final EndDocument endDocument)
+ {
+ super(endDocument) ;
+ }
+
+ @Override
+ public boolean isEndDocument()
+ {
+ return true ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndDocument.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndElement.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndElement.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndElement.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.Namespace;
+
+/**
+ * Cached event information for EndElement.
+ */
+public class ESBStaxEndElement extends ESBStaxXMLEvent implements EndElement
+{
+ private final QName name ;
+ private final List<Namespace> namespaces ;
+
+ public ESBStaxEndElement(final EndElement endElement)
+ {
+ super(endElement) ;
+ name = endElement.getName() ;
+ namespaces = ESBStaxNamespace.getNamespaces(endElement.getNamespaces()) ;
+ }
+
+ public QName getName()
+ {
+ return name ;
+ }
+
+ public Iterator<Namespace> getNamespaces()
+ {
+ return namespaces.iterator() ;
+ }
+
+ @Override
+ public boolean isEndElement()
+ {
+ return true ;
+ }
+
+ @Override
+ public EndElement asEndElement()
+ {
+ return this ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEndElement.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityDeclaration.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityDeclaration.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityDeclaration.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.stream.events.EntityDeclaration;
+
+/**
+ * Cached event information for EntityDeclaration.
+ */
+public class ESBStaxEntityDeclaration extends ESBStaxXMLEvent implements EntityDeclaration
+{
+ private final String baseURI ;
+ private final String name ;
+ private final String notationName ;
+ private final String publicId ;
+ private final String replacementText ;
+ private final String systemId ;
+
+ public ESBStaxEntityDeclaration(final EntityDeclaration entityDeclaration)
+ {
+ super(entityDeclaration) ;
+ baseURI = entityDeclaration.getBaseURI() ;
+ name = entityDeclaration.getName() ;
+ notationName = entityDeclaration.getNotationName() ;
+ publicId = entityDeclaration.getPublicId() ;
+ replacementText = entityDeclaration.getReplacementText() ;
+ systemId = entityDeclaration.getSystemId() ;
+ }
+
+ public String getBaseURI()
+ {
+ return baseURI ;
+ }
+
+ public String getName()
+ {
+ return name ;
+ }
+
+ public String getNotationName()
+ {
+ return notationName ;
+ }
+
+ public String getPublicId()
+ {
+ return publicId ;
+ }
+
+ public String getReplacementText()
+ {
+ return replacementText ;
+ }
+
+ public String getSystemId()
+ {
+ return systemId ;
+ }
+
+ static List<EntityDeclaration> getEntities(final List<EntityDeclaration> entities)
+ {
+ if (entities == null)
+ {
+ return null ;
+ }
+ else if (entities.size() > 0)
+ {
+ final List<EntityDeclaration> result = new ArrayList<EntityDeclaration>() ;
+ for(EntityDeclaration entity: entities)
+ {
+ result.add(new ESBStaxEntityDeclaration(entity)) ;
+ }
+ return result ;
+ }
+ else
+ {
+ return Collections.emptyList() ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityDeclaration.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityReference.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityReference.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityReference.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.EntityReference;
+
+/**
+ * Cached event information for EntityReference.
+ */
+public class ESBStaxEntityReference extends ESBStaxXMLEvent implements EntityReference
+{
+ private final EntityDeclaration declaration ;
+ private final String name ;
+
+ public ESBStaxEntityReference(final EntityReference entityReference)
+ {
+ super(entityReference) ;
+
+ final EntityDeclaration declaration = entityReference.getDeclaration() ;
+ this.declaration = (declaration == null ? null : new ESBStaxEntityDeclaration(declaration)) ;
+ name = entityReference.getName() ;
+ }
+
+ public EntityDeclaration getDeclaration()
+ {
+ return declaration ;
+ }
+
+ public String getName()
+ {
+ return name ;
+ }
+
+ @Override
+ public boolean isEntityReference()
+ {
+ return true ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxEntityReference.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxLocation.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxLocation.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxLocation.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import javax.xml.stream.Location;
+
+/**
+ * Cached Location information for events..
+ */
+public class ESBStaxLocation implements Location
+{
+ private final int characterOffset ;
+ private final int columnNumber ;
+ private final int lineNumber ;
+ private final String publicId ;
+ private final String systemId ;
+
+ public ESBStaxLocation(final Location location)
+ {
+ characterOffset = location.getCharacterOffset() ;
+ columnNumber = location.getColumnNumber() ;
+ lineNumber = location.getLineNumber() ;
+ publicId = location.getPublicId() ;
+ systemId = location.getSystemId() ;
+ }
+
+ public int getCharacterOffset()
+ {
+ return characterOffset ;
+ }
+
+ public int getColumnNumber()
+ {
+ return columnNumber ;
+ }
+
+ public int getLineNumber()
+ {
+ return lineNumber ;
+ }
+
+ public String getPublicId()
+ {
+ return publicId ;
+ }
+
+ public String getSystemId()
+ {
+ return systemId ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxLocation.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespace.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespace.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespace.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.stream.events.Namespace;
+
+/**
+ * Cached event information for Namespace.
+ */
+public class ESBStaxNamespace extends ESBStaxAttribute implements Namespace
+{
+ private final String namespaceURI ;
+ private final String prefix ;
+ private final boolean defaultNamespaceDeclaration ;
+
+ public ESBStaxNamespace(final Namespace namespace)
+ {
+ super(namespace) ;
+ namespaceURI = namespace.getNamespaceURI() ;
+ prefix = namespace.getPrefix() ;
+ defaultNamespaceDeclaration = namespace.isDefaultNamespaceDeclaration() ;
+ }
+
+ public String getNamespaceURI()
+ {
+ return namespaceURI ;
+ }
+
+ public String getPrefix()
+ {
+ return prefix ;
+ }
+
+ public boolean isDefaultNamespaceDeclaration()
+ {
+ return defaultNamespaceDeclaration ;
+ }
+
+ @Override
+ public boolean isNamespace()
+ {
+ return true ;
+ }
+
+ static List<Namespace> getNamespaces(final Iterator<Namespace> namespaces)
+ {
+ if (namespaces == null)
+ {
+ return null ;
+ }
+ else if (namespaces.hasNext())
+ {
+ final List<Namespace> result = new ArrayList<Namespace>() ;
+ do
+ {
+ result.add(new ESBStaxNamespace(namespaces.next())) ;
+ }
+ while(namespaces.hasNext()) ;
+ return result ;
+ }
+ else
+ {
+ return Collections.emptyList() ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespace.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespaceContext.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespaceContext.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespaceContext.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.events.Namespace;
+
+/**
+ * NamespaceContext for events.
+ */
+public class ESBStaxNamespaceContext implements NamespaceContext
+{
+ private final Map<String, String> namespaceToPrefix ;
+ private final Map<String, String> prefixToNamespace ;
+
+ public ESBStaxNamespaceContext(final List<Namespace> namespaces)
+ {
+ final int size = (namespaces == null ? 0 : namespaces.size()) ;
+ if (size == 0)
+ {
+ namespaceToPrefix = Collections.emptyMap() ;
+ prefixToNamespace = Collections.emptyMap() ;
+ }
+ else
+ {
+ namespaceToPrefix = new HashMap<String, String>(size) ;
+ prefixToNamespace = new HashMap<String, String>(size) ;
+ for(Namespace namespace: namespaces)
+ {
+ final String prefix = namespace.getPrefix() ;
+ final String namespaceURI = namespace.getNamespaceURI() ;
+ namespaceToPrefix.put(namespaceURI, prefix) ;
+ prefixToNamespace.put(prefix, namespaceURI) ;
+ }
+ }
+ }
+
+ static NamespaceContext getNamespaceContext(final List<Namespace> namespaces)
+ {
+ if (namespaces == null)
+ {
+ return EMPTY_NAMESPACE_CONTEXT ;
+ }
+ else if (namespaces.size() > 0)
+ {
+ return new ESBStaxNamespaceContext(namespaces) ;
+ }
+ else
+ {
+ return EMPTY_NAMESPACE_CONTEXT ;
+ }
+ }
+
+ public String getNamespaceURI(final String prefix)
+ {
+ return normalize(prefixToNamespace.get(prefix), XMLConstants.NULL_NS_URI);
+ }
+
+ public String getPrefix(final String namespaceURI)
+ {
+ return normalize(namespaceToPrefix.get(namespaceURI), XMLConstants.DEFAULT_NS_PREFIX);
+ }
+
+ public Iterator<String> getPrefixes(final String namespaceURI)
+ {
+ final String prefix = namespaceToPrefix.get(namespaceURI) ;
+ if (prefix == null)
+ {
+ final List<String> emptyList = Collections.emptyList() ;
+ return emptyList.iterator() ;
+ }
+ else
+ {
+ return Arrays.asList(prefix).iterator() ;
+ }
+ }
+
+ private static String normalize(final String value, final String defaultValue)
+ {
+ return (value == null ? defaultValue : value) ;
+ }
+
+ private static final List<Namespace> EMPTY_NAMESPACES = Collections.emptyList() ;
+ private static final NamespaceContext EMPTY_NAMESPACE_CONTEXT = new ESBStaxNamespaceContext(EMPTY_NAMESPACES) ;
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNamespaceContext.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNotationDeclaration.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNotationDeclaration.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNotationDeclaration.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.stream.events.NotationDeclaration;
+
+/**
+ * Cached event information for NotationDeclaration.
+ */
+public class ESBStaxNotationDeclaration extends ESBStaxXMLEvent implements NotationDeclaration
+{
+ private final String name ;
+ private final String publicId ;
+ private final String systemId ;
+
+ public ESBStaxNotationDeclaration(final NotationDeclaration notationDeclaration)
+ {
+ super(notationDeclaration) ;
+ name = notationDeclaration.getName() ;
+ publicId = notationDeclaration.getPublicId() ;
+ systemId = notationDeclaration.getSystemId() ;
+ }
+
+ public String getName()
+ {
+ return name ;
+ }
+
+ public String getPublicId()
+ {
+ return publicId ;
+ }
+
+ public String getSystemId()
+ {
+ return systemId ;
+ }
+
+ static List<NotationDeclaration> getNotations(final List<NotationDeclaration> notations)
+ {
+ if (notations == null)
+ {
+ return null ;
+ }
+ else if (notations.size() > 0)
+ {
+ final List<NotationDeclaration> result = new ArrayList<NotationDeclaration>() ;
+ for(NotationDeclaration notation: notations)
+ {
+ result.add(new ESBStaxNotationDeclaration(notation)) ;
+ }
+ return result ;
+ }
+ else
+ {
+ return Collections.emptyList() ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxNotationDeclaration.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxProcessingInstruction.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxProcessingInstruction.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxProcessingInstruction.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import javax.xml.stream.events.ProcessingInstruction;
+
+/**
+ * Cached event information for ProcessingInstruction.
+ */
+public class ESBStaxProcessingInstruction extends ESBStaxXMLEvent implements ProcessingInstruction
+{
+ private final String data ;
+ private final String target ;
+
+ public ESBStaxProcessingInstruction(final ProcessingInstruction processingInstruction)
+ {
+ super(processingInstruction) ;
+ data = processingInstruction.getData() ;
+ target = processingInstruction.getTarget() ;
+ }
+
+ public String getData()
+ {
+ return data ;
+ }
+
+ public String getTarget()
+ {
+ return target ;
+ }
+
+ @Override
+ public boolean isProcessingInstruction()
+ {
+ return true ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxProcessingInstruction.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartDocument.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartDocument.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartDocument.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import javax.xml.stream.events.StartDocument;
+
+/**
+ * Cached event information for StartDocument.
+ */
+public class ESBStaxStartDocument extends ESBStaxXMLEvent implements StartDocument
+{
+ private final boolean encodingSet ;
+ private final String characterEncodingScheme ;
+ private final String systemId ;
+ private final String version ;
+ private final boolean standalone ;
+ private final boolean standaloneSet ;
+
+ public ESBStaxStartDocument(final StartDocument startDocument)
+ {
+ super(startDocument) ;
+ encodingSet = startDocument.encodingSet() ;
+ characterEncodingScheme = startDocument.getCharacterEncodingScheme() ;
+ systemId = startDocument.getSystemId() ;
+ version = startDocument.getVersion() ;
+ standalone = startDocument.isStandalone() ;
+ standaloneSet = startDocument.standaloneSet() ;
+ }
+
+ public boolean encodingSet()
+ {
+ return encodingSet ;
+ }
+
+ public String getCharacterEncodingScheme()
+ {
+ return characterEncodingScheme ;
+ }
+
+ public String getSystemId()
+ {
+ return systemId ;
+ }
+
+ public String getVersion()
+ {
+ return version ;
+ }
+
+ public boolean isStandalone()
+ {
+ return standalone ;
+ }
+
+ public boolean standaloneSet()
+ {
+ return standaloneSet ;
+ }
+
+ @Override
+ public boolean isStartDocument()
+ {
+ return true ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartDocument.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartElement.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartElement.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartElement.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+
+/**
+ * Cached event information for StartElement.
+ */
+public class ESBStaxStartElement extends ESBStaxXMLEvent implements StartElement
+{
+ private final QName name ;
+ private final List<Attribute> attributes ;
+ private final List<Namespace> namespaces ;
+ private final NamespaceContext namespaceContext ;
+
+ public ESBStaxStartElement(final StartElement startElement)
+ {
+ super(startElement) ;
+ name = startElement.getName() ;
+ attributes = ESBStaxAttribute.getAttributes(startElement.getAttributes()) ;
+ namespaces = ESBStaxNamespace.getNamespaces(startElement.getNamespaces()) ;
+ namespaceContext = ESBStaxNamespaceContext.getNamespaceContext(namespaces) ;
+ }
+
+ public Attribute getAttributeByName(final QName name)
+ {
+ for(Attribute attribute: attributes)
+ {
+ if (attribute.getName().equals(name))
+ {
+ return attribute ;
+ }
+ }
+ return null ;
+ }
+
+ public Iterator<Attribute> getAttributes()
+ {
+ return attributes.iterator() ;
+ }
+
+ public QName getName()
+ {
+ return name ;
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ return namespaceContext ;
+ }
+
+ public String getNamespaceURI(final String prefix)
+ {
+ return namespaceContext.getNamespaceURI(prefix) ;
+ }
+
+ public Iterator getNamespaces()
+ {
+ return namespaces.iterator() ;
+ }
+
+ @Override
+ public boolean isStartElement()
+ {
+ return true ;
+ }
+
+ @Override
+ public StartElement asStartElement()
+ {
+ return this ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxStartElement.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxXMLEvent.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxXMLEvent.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxXMLEvent.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,194 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.events;
+
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EndDocument;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.EntityReference;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Base cached event information for events.
+ */
+public class ESBStaxXMLEvent implements XMLEvent
+{
+ private final int eventType ;
+ private final Location location ;
+ private QName schemaType ;
+
+ protected ESBStaxXMLEvent(final XMLEvent event)
+ {
+ this.eventType = event.getEventType() ;
+ final Location location = event.getLocation() ;
+ this.location = (location == null ? null : new ESBStaxLocation(location)) ;
+ this.schemaType = event.getSchemaType() ;
+ }
+
+ public Characters asCharacters()
+ {
+ throw new ClassCastException("Cannot case to Characters") ;
+ }
+
+ public EndElement asEndElement()
+ {
+ throw new ClassCastException("Cannot case to EndElement") ;
+ }
+
+ public StartElement asStartElement()
+ {
+ throw new ClassCastException("Cannot case to StartElement") ;
+ }
+
+ public int getEventType()
+ {
+ return eventType ;
+ }
+
+ public Location getLocation()
+ {
+ return location ;
+ }
+
+ public QName getSchemaType()
+ {
+ return schemaType ;
+ }
+
+ public boolean isAttribute()
+ {
+ return false ;
+ }
+
+ public boolean isCharacters()
+ {
+ return false ;
+ }
+
+ public boolean isEndDocument()
+ {
+ return false ;
+ }
+
+ public boolean isEndElement()
+ {
+ return false ;
+ }
+
+ public boolean isEntityReference()
+ {
+ return false ;
+ }
+
+ public boolean isNamespace()
+ {
+ return false ;
+ }
+
+ public boolean isProcessingInstruction()
+ {
+ return false ;
+ }
+
+ public boolean isStartDocument()
+ {
+ return false ;
+ }
+
+ public boolean isStartElement()
+ {
+ return false ;
+ }
+
+ public void writeAsEncodedUnicode(final Writer writer)
+ throws XMLStreamException
+ {
+ }
+
+ public static List<XMLEvent> cloneStream(final XMLEventReader reader)
+ throws XMLStreamException
+ {
+ if (reader.hasNext())
+ {
+ final List<XMLEvent> events = new ArrayList<XMLEvent>() ;
+ do
+ {
+ events.add(cloneEvent(reader.nextEvent())) ;
+ }
+ while(reader.hasNext()) ;
+ return events ;
+ }
+ else
+ {
+ return Collections.emptyList() ;
+ }
+ }
+
+ public static XMLEvent cloneEvent(final XMLEvent event)
+ throws XMLStreamException
+ {
+ switch(event.getEventType())
+ {
+ case XMLStreamConstants.CDATA:
+ case XMLStreamConstants.CHARACTERS:
+ case XMLStreamConstants.SPACE:
+ return new ESBStaxCharacters(event.asCharacters()) ;
+
+ case XMLStreamConstants.COMMENT:
+ return new ESBStaxComment((Comment)event) ;
+
+ case XMLStreamConstants.DTD:
+ return new ESBStaxDTD((DTD)event) ;
+
+ case XMLStreamConstants.END_DOCUMENT:
+ return new ESBStaxEndDocument((EndDocument)event) ;
+
+ case XMLStreamConstants.END_ELEMENT:
+ return new ESBStaxEndElement(event.asEndElement()) ;
+
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ return new ESBStaxEntityReference((EntityReference)event) ;
+
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ return new ESBStaxProcessingInstruction((ProcessingInstruction)event) ;
+
+ case XMLStreamConstants.START_DOCUMENT:
+ return new ESBStaxStartDocument((StartDocument)event) ;
+
+ case XMLStreamConstants.START_ELEMENT:
+ return new ESBStaxStartElement(event.asStartElement()) ;
+ }
+
+ throw new XMLStreamException("Unrecognised event type: " + event.getEventType()) ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/events/ESBStaxXMLEvent.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/util/ESBXMLEventStreamReader.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/util/ESBXMLEventStreamReader.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/util/ESBXMLEventStreamReader.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.util.stax.util;
+
+import java.util.List;
+import java.util.ListIterator;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Implementation of XMLEventReader which replays a set of XMLEvents.
+ */
+public class ESBXMLEventStreamReader implements XMLEventReader
+{
+ private final ListIterator<XMLEvent> eventIter ;
+
+ public ESBXMLEventStreamReader(final List<XMLEvent> events)
+ {
+ eventIter = events.listIterator() ;
+ }
+
+ public Object next()
+ {
+ return nextEvent() ;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("No support for remove()") ;
+ }
+
+ public void close()
+ throws XMLStreamException
+ {
+ }
+
+ public String getElementText()
+ throws XMLStreamException
+ {
+ XMLEvent event = nextEvent() ;
+ if (!event.isStartElement())
+ {
+ throw new XMLStreamException("Expected start element, found event type " + event.getEventType()) ;
+ }
+ final StringBuffer sb = new StringBuffer() ;
+ while(hasNext())
+ {
+ event = nextEvent() ;
+ if (event.isStartElement())
+ {
+ throw new XMLStreamException("Unexpected nested start element") ;
+ }
+ else if (event.isCharacters())
+ {
+ sb.append(event.asCharacters().getData()) ;
+ }
+ else if (event.isEndElement())
+ {
+ return sb.toString() ;
+ }
+ }
+ throw new XMLStreamException("Unexpected end of Document");
+ }
+
+ public Object getProperty(final String property)
+ throws IllegalArgumentException
+ {
+ return null;
+ }
+
+ public boolean hasNext()
+ {
+ return eventIter.hasNext() ;
+ }
+
+ public XMLEvent nextEvent()
+ {
+ return eventIter.next() ;
+ }
+
+ public XMLEvent nextTag()
+ throws XMLStreamException
+ {
+ while(hasNext())
+ {
+ final XMLEvent event = nextEvent() ;
+ if (event.isCharacters() && !event.asCharacters().isWhiteSpace())
+ {
+ throw new XMLStreamException("Unexpected character content in stream") ;
+ }
+ if (event.isStartElement() || event.isEndElement())
+ {
+ return event ;
+ }
+ }
+ throw new XMLStreamException("End of document") ;
+ }
+
+ public XMLEvent peek()
+ throws XMLStreamException
+ {
+ final XMLEvent peak = eventIter.next();
+ eventIter.previous() ;
+ return peak ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/util/ESBXMLEventStreamReader.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2011-01-13 13:21:25 UTC (rev 36517)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -27,31 +27,29 @@
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import javax.wsdl.Binding;
import javax.wsdl.Definition;
import javax.wsdl.Import;
import javax.wsdl.Part;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
@@ -63,7 +61,12 @@
import org.apache.xmlbeans.XmlOptions;
import org.jboss.internal.soa.esb.soap.OGNLUtils;
import org.jboss.internal.soa.esb.util.ESBProperties;
+import org.jboss.internal.soa.esb.util.LRUReferenceCountCache;
+import org.jboss.internal.soa.esb.util.LRUReferenceCountCacheResource;
import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.LRUReferenceCountCache.LRUReferenceCountCacheEntry;
+import org.jboss.internal.soa.esb.util.stax.events.ESBStaxXMLEvent;
+import org.jboss.internal.soa.esb.util.stax.util.ESBXMLEventStreamReader;
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.dom.YADOMUtil;
@@ -86,6 +89,7 @@
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.support.soap.SoapMessageBuilder;
import com.eviware.soapui.impl.wsdl.support.xsd.SampleXmlUtil;
+import com.eviware.soapui.impl.wsdl.support.xsd.SchemaException;
import com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils;
import com.eviware.soapui.model.iface.MessagePart;
import com.eviware.soapui.model.iface.Operation;
@@ -99,13 +103,14 @@
*/
public class SoapUIClientService extends ServiceMBeanSupport implements SoapUIClientServiceMBean {
+ private static final String FAULT_PREFIX = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ + "<soapenv:Body><soapenv:Fault><faultcode>?</faultcode><faultstring>?</faultstring><detail>" ;
+ private static final String FAULT_SUFFIX = "</detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>" ;
+
private static final String IS_CLONE_ATTRIB = "is-clone";
private static Logger logger = Logger.getLogger(SoapUIClientService.class);
- private Map<String, WsdlInterface[]> wsdls = new HashMap<String, WsdlInterface[]>();
- private Map<String, Set<QName>> nillables = new HashMap<String, Set<QName>>();
- private DocumentBuilderFactory docBuilderFactory ;
- private SmooksCache smooksCache;
- private ESBProperties properties;
+ private final WsdlCache wsdlCache;
+ private final SmooksCache smooksCache;
private static final String SOAPUI_OPTIONAL_COMMENT = "Optional:";
private static final String REMOVE_POSTFIX = " to be removed";
private static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
@@ -140,12 +145,12 @@
* Public default constructor.
*/
public SoapUIClientService() throws ConfigurationException {
- properties = new ESBProperties("/soapui-client.sar.properties");
+ final ESBProperties properties = new ESBProperties("/soapui-client.sar.properties");
- docBuilderFactory = DocumentBuilderFactory.newInstance();
- docBuilderFactory.setNamespaceAware(true);
int smooksLRUCacheSize = properties.getIntProperty("smooks.lru.cache.size", 30);
smooksCache = new SmooksCache(smooksLRUCacheSize);
+ final int wsdlLRUCacheSize = properties.getIntProperty("wsdl.lru.cache.size", 30);
+ wsdlCache = new WsdlCache(wsdlLRUCacheSize);
}
protected void startService() throws Exception {
@@ -339,11 +344,18 @@
* @throws IOException Failed to load WSDL.
*/
public String buildRequest(String wsdl, String operation, String serviceName, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
- Operation operationInst = getOperation(wsdl, operation, serviceName, httpClientProps, true);
- String requestTemplate = operationInst.getRequestAt(0).getRequestContent();
- Set<QName> nils = nillables.get(wsdl);
-
- return buildSOAPMessage(requestTemplate, params, smooksResource, soapNs, nils);
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> wsdlEntry = wsdlCache.get(wsdl, httpClientProps) ;
+
+ try
+ {
+ final WsdlState state = wsdlEntry.getResource() ;
+ final XMLEventReader reader = state.getRequest(operation, serviceName, true, wsdl, httpClientProps) ;
+ return buildSOAPMessage(reader, params, smooksResource, soapNs, state.getNils());
+ }
+ finally
+ {
+ wsdlCache.release(wsdlEntry) ;
+ }
}
/**
@@ -364,48 +376,35 @@
* @throws SAXException Failed to parse the SOAP UI generated request message.
*/
public String buildResponse(String wsdl, String operation, String serviceName, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
- Operation operationInst = getOperation(wsdl, operation, serviceName, httpClientProps, true);
- WsdlOperation wsdlOperation = (WsdlOperation)operationInst;
- String responseTemplate = wsdlOperation.createResponse(true);
- Set<QName> nils = nillables.get(wsdl);
- return buildSOAPMessage(responseTemplate, params, smooksResource, soapNs, nils);
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> wsdlEntry = wsdlCache.get(wsdl, httpClientProps) ;
+
+ try
+ {
+ final WsdlState state = wsdlEntry.getResource() ;
+ final XMLEventReader reader = state.getResponse(operation, serviceName, true, wsdl, httpClientProps) ;
+ return buildSOAPMessage(reader, params, smooksResource, soapNs, state.getNils());
+ }
+ finally
+ {
+ wsdlCache.release(wsdlEntry) ;
+ }
}
public String buildFault(String wsdl, String operation, String serviceName, String faultName, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
- String faultDetail = null;
- Operation operationInst = getOperation(wsdl, operation, serviceName, httpClientProps, true);
- WsdlOperation wsdlOperation = (WsdlOperation)operationInst;
- MessagePart[] faultParts = wsdlOperation.getFaultParts();
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> wsdlEntry = wsdlCache.get(wsdl, httpClientProps) ;
params.put("Fault.faultcode","soapenv:server");
- SoapMessageBuilder soapMessageBuilder = wsdlOperation.getInterface().getMessageBuilder();
- String faultTemplate = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">"
- + "<soapenv:Body><soapenv:Fault><faultcode>?</faultcode><faultstring>?</faultstring><detail>";
- XmlObject detail = XmlObject.Factory.newInstance();
- for (int i = 0 ; i < faultParts.length; i++) {
- MessagePart.FaultPart faultPart = (MessagePart.FaultPart)faultParts[i];
- if (faultPart.getName().equalsIgnoreCase(faultName)) {
- SampleXmlUtil generator = new SampleXmlUtil( false );
- generator.setExampleContent( false );
- generator.setTypeComment( false );
- XmlCursor cursor = detail.newCursor();
- cursor.toFirstContentToken();
- generator.setTypeComment( true );
- generator.setIgnoreOptional(wsdlOperation.getInterface().getSettings().getBoolean( WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS ) );
- for( Part part : faultPart.getWsdlParts() ) {
- try {
- soapMessageBuilder.createElementForPart(part, cursor, generator);
- } catch (Exception e) {
- logger.error("Unable to create soap fualt template", e);
- }
- }
- }
+
+ try
+ {
+ final WsdlState state = wsdlEntry.getResource() ;
+ final XMLEventReader reader = state.getFault(operation, serviceName, faultName, true, wsdl, httpClientProps) ;
+ return buildSOAPMessage(reader, params, smooksResource, soapNs, state.getNils());
}
- faultTemplate = faultTemplate + detail.xmlText( new XmlOptions().setSaveAggressiveNamespaces().setSavePrettyPrint())
- + "</detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>";
- Set<QName> nils = nillables.get(wsdl);
- faultDetail = buildSOAPMessage(faultTemplate, params, smooksResource, soapNs, nils);
- return faultDetail;
+ finally
+ {
+ wsdlCache.release(wsdlEntry) ;
+ }
}
/**
@@ -417,13 +416,24 @@
* @throws IOException Failed to load WSDL.
*/
public String getEndpoint(String wsdl, String serviceName, Properties httpClientProps) throws IOException {
- if(serviceName != null) {
- WsdlInterface wsdlInterface = getServiceInterface(wsdl, serviceName, httpClientProps, true, true);
- return wsdlInterface.getEndpoints()[0];
- } else {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
- return wsdlInterfaces[0].getEndpoints()[0];
- }
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> wsdlEntry = wsdlCache.get(wsdl, httpClientProps) ;
+
+ try
+ {
+ final WsdlState state = wsdlEntry.getResource() ;
+ if(serviceName != null)
+ {
+ return state.getEndpoint(serviceName, true, true, wsdl, httpClientProps);
+ }
+ else
+ {
+ return state.getDefaultEndpoint() ;
+ }
+ }
+ finally
+ {
+ wsdlCache.release(wsdlEntry) ;
+ }
}
/**
@@ -435,13 +445,24 @@
* @throws IOException Failed to load WSDL.
*/
public String getContentType(String wsdl, String serviceName, Properties httpClientProps) throws IOException {
- if(serviceName != null) {
- WsdlInterface wsdlInterface = getServiceInterface(wsdl, serviceName, httpClientProps, true, true);
- return wsdlInterface.getSoapVersion().getContentType();
- } else {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
- return wsdlInterfaces[0].getSoapVersion().getContentType();
- }
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> wsdlEntry = wsdlCache.get(wsdl, httpClientProps) ;
+
+ try
+ {
+ final WsdlState state = wsdlEntry.getResource() ;
+ if(serviceName != null)
+ {
+ return state.getContentType(serviceName, true, true, wsdl, httpClientProps);
+ }
+ else
+ {
+ return state.getDefaultContentType() ;
+ }
+ }
+ finally
+ {
+ wsdlCache.release(wsdlEntry) ;
+ }
}
/**
@@ -461,49 +482,55 @@
* @throws SAXException Failed to parse the SOAP UI generated request message.
*/
public String mergeResponseTemplate(String wsdl, String operation, String serviceName, String response, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
- Operation operationInst = getOperation(wsdl, operation, serviceName, httpClientProps, true);
- WsdlOperation wsdlOperation = (WsdlOperation)operationInst;
- String responseTemplate = wsdlOperation.createResponse(true);
- return mergeSOAPMessage(responseTemplate, response, smooksResource, soapNs);
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> wsdlEntry = wsdlCache.get(wsdl, httpClientProps) ;
+
+ try
+ {
+ final WsdlState state = wsdlEntry.getResource() ;
+ final XMLEventReader reader = state.getResponse(operation, serviceName, true, wsdl, httpClientProps) ;
+ return (reader == null ? response : mergeSOAPMessage(reader, response, smooksResource, soapNs));
+ }
+ finally
+ {
+ wsdlCache.release(wsdlEntry) ;
+ }
}
- private WsdlInterface[] getWsdlInterfaces(String wsdl, Properties httpClientProps) throws IOException {
- try {
- WsdlInterface[] wsdlInterfaces = wsdls.get(wsdl);
- if (wsdlInterfaces == null) {
- WsdlProject wsdlProject = new WsdlProject();
- HttpClient httpClient = HttpClientFactory.createHttpClient(httpClientProps);
- Set<QName> nils = new HashSet<QName>();
+ WsdlOperationInfo getOperationInfo(final String wsdl, final String operationName , final String serviceName,
+ final Properties httpClientProps, final boolean refresh)
+ throws IOException
+ {
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> wsdlEntry = wsdlCache.get(wsdl, httpClientProps) ;
+
+ try
+ {
+ final WsdlState state = wsdlEntry.getResource() ;
+ final WsdlServiceInfo serviceInfo = state.getServiceInfo(serviceName, refresh, true, wsdl, httpClientProps) ;
+ return serviceInfo.getOperation(operationName) ;
+ }
+ finally
+ {
+ wsdlCache.release(wsdlEntry) ;
+ }
+ }
- try {
- EsbWsdlLoader loader = new EsbWsdlLoader(wsdl, httpClient);
- WsdlLoaderAspect.set(loader); // JBESB-3276
- wsdlInterfaces = wsdlProject.importWsdl(wsdl, true, loader);
- Map<String, XmlObject> schemas = SchemaUtils.getSchemas(wsdl, loader);
- Iterator keys = schemas.keySet().iterator();
- while (keys.hasNext()) {
- XmlObject schema = schemas.get(keys.next());
- String namespace = SchemaUtils.getTargetNamespace(schema);
- Document doc = getDocument(schema.toString());
- Element docRoot = doc.getDocumentElement();
- extractNillableElements(docRoot, nils, namespace);
- }
- } finally {
- WsdlLoaderAspect.unset(); // JBESB-3276
- HttpClientFactory.shutdown(httpClient);
- }
- nillables.put(wsdl, nils);
- wsdls.put(wsdl, wsdlInterfaces);
- }
- return wsdlInterfaces;
- } catch (Exception e) {
- IOException ioe = new IOException("Failed to import WSDL '" + wsdl + "'.");
- ioe.initCause(e);
- throw ioe;
+ static Set<QName> extractNillableElements(final String wsdl, final EsbWsdlLoader loader)
+ throws SchemaException, IOException
+ {
+ final Set<QName> nils = new HashSet<QName>() ;
+ Map<String, XmlObject> schemas = SchemaUtils.getSchemas(wsdl, loader);
+ Iterator keys = schemas.keySet().iterator();
+ while (keys.hasNext()) {
+ XmlObject schema = schemas.get(keys.next());
+ String namespace = SchemaUtils.getTargetNamespace(schema);
+ Document doc = getDocument(schema.toString());
+ Element docRoot = doc.getDocumentElement();
+ extractNillableElements(docRoot, nils, namespace);
}
+ return nils ;
}
-
- private void extractNillableElements(Element element, Set<QName> nils, String namespace) {
+
+ static void extractNillableElements(Element element, Set<QName> nils, String namespace) {
if (element != null
&& element.getLocalName()!= null
&& element.getLocalName().equals("element")
@@ -523,161 +550,9 @@
}
}
- protected Operation getOperation(String wsdl, String operationName, String serviceName, Properties httpClientProps, boolean refresh) throws IOException {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
+ private String buildSOAPMessage(XMLEventReader reader, Map params, String smooksResource, String soapNs, Set<QName> nils) throws IOException, SAXException {
+ Document messageDoc = getDocument(reader) ;
- for (WsdlInterface wsdlInterface : wsdlInterfaces) {
- List<Operation> operations = wsdlInterface.getOperations();
-
- for(Operation operation: operations) {
- if(operation.getName().equals(operationName)) {
- if(serviceName != null) {
- Definition definition;
- try {
- definition = wsdlInterface.getWsdlContext().getDefinition();
- } catch (Exception e) {
- IOException ioException = new IOException("Failed to get WsdlContext from WsdlInterface.");
- ioException.initCause(e);
- throw ioException;
- }
- QName serviceQName = getServiceName(wsdlInterface.getBindingName(), definition);
- if(serviceName != null && !serviceName.equals(serviceQName.toString())) {
- // Not the correct service... continue looking for the operation...
- continue;
- }
- }
-
- return operation;
- }
- }
- }
-
- if(refresh) {
- // Try clearing WSDL cache, WSDL may have updated
- wsdls.remove(wsdl);
- nillables.remove(wsdl);
- wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
-
- return getOperation(wsdl, operationName, serviceName, httpClientProps, false);
- }
-
- throw new UnsupportedOperationException("Operation '" + operationName + "' not supported by WSDL '" + wsdl + "'.");
- }
-
- private WsdlInterface getServiceInterface(String wsdl, String serviceName, Properties httpClientProps, boolean refresh, boolean fail) throws IOException {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
-
- for (WsdlInterface wsdlInterface : wsdlInterfaces) {
- Definition definition;
- try {
- definition = wsdlInterface.getWsdlContext().getDefinition();
- } catch (Exception e) {
- IOException ioException = new IOException("Failed to get WsdlContext from WsdlInterface.");
- ioException.initCause(e);
- throw ioException;
- }
- if(hasService(serviceName, definition)) {
- return wsdlInterface;
- }
-
- // Is it one of the imports...
- Map imports = definition.getImports();
- if(imports != null && !imports.isEmpty()) {
- for(Object importListObj : imports.values()) {
- if(importListObj instanceof List) {
- List<Import> importList = (List<Import>) importListObj;
- if(importList != null) {
- for(Import importInst : importList) {
- WsdlInterface importedInterface = getServiceInterface(importInst.getDefinition().getDocumentBaseURI(), serviceName, httpClientProps, true, false);
- if(importedInterface != null) {
- return importedInterface;
- }
- }
- }
- }
- }
- }
- }
-
- if(refresh) {
- // Try clearing WSDL cache, WSDL may have updated
- wsdls.remove(wsdl);
- nillables.remove(wsdl);
- wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
-
- return getServiceInterface(wsdl, serviceName, httpClientProps, false, fail);
- }
-
- if(fail) {
- throw new UnsupportedOperationException("Service by name '" + serviceName + "' not found on WSDL '" + wsdl + "'.");
- }
-
- return null;
- }
-
- private boolean hasService(String serviceName, Definition definition) {
-
- Map<Object, Service> services = definition.getServices();
-
- // Is it one of the services on this wsdl...
- if(services != null && !services.isEmpty()) {
- for(Service service : services.values()) {
- if(serviceName.equals(service.getQName().toString())) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private QName getServiceName(QName bindingQName, Definition definition) {
-
- try {
- Map<Object, Service> services = definition.getServices();
-
- // Is it one of the services on this wsdl...
- if(services != null && !services.isEmpty()) {
- for(Service service : services.values()) {
- Map<Object, Port> ports = service.getPorts();
- if(ports != null) {
- for(Port port : ports.values()) {
- Binding binding = port.getBinding();
- if(binding.getQName().equals(bindingQName)) {
- return service.getQName();
- }
- }
- }
- }
- }
-
- // Is it one of the services in one of the imported wsdls (if any)...
- Map imports = definition.getImports();
- if(imports != null && !imports.isEmpty()) {
- for(Object importListObj : imports.values()) {
- if(importListObj instanceof List) {
- List<Import> importList = (List<Import>) importListObj;
- if(importList != null) {
- for(Import importInst : importList) {
- QName serviceQName = getServiceName(bindingQName, importInst.getDefinition());
- if(serviceQName != null) {
- return serviceQName;
- }
- }
- }
- }
- }
- }
- } catch (Exception e) {
- logger.error("Error resolving service name associated with binding '" + bindingQName + "'.", e);
- }
-
- return null;
- }
-
- private String buildSOAPMessage(String soapMessageTemplate, Map params, String smooksResource, String soapNs, Set<QName> nils) throws IOException, SAXException {
- Document messageDoc = getDocument(soapMessageTemplate) ;
-
Element docRoot = messageDoc.getDocumentElement();
// Purposely not using log levels to output because I want to make
@@ -721,8 +596,8 @@
}
}
- private String mergeSOAPMessage(String soapMessageTemplate, String response, String smooksResource, String soapNs) throws IOException, SAXException {
- Document templateDoc = getDocument(soapMessageTemplate);
+ private String mergeSOAPMessage(XMLEventReader reader, String response, String smooksResource, String soapNs) throws IOException, SAXException {
+ Document templateDoc = getDocument(reader);
Element templateRoot = templateDoc.getDocumentElement();
Document messageDoc = getDocument(response);
@@ -811,8 +686,18 @@
}
}
- private Document getDocument(String soapMessageTemplate) throws IOException {
+ private static Document getDocument(final XMLEventReader reader) throws IOException {
try {
+ return XMLHelper.createDocument(reader) ;
+ } catch (final Exception ex) {
+ final IOException ioe = new IOException("Failed to deserialize the SOAP message template") ;
+ ioe.initCause(ex) ;
+ throw ioe ;
+ }
+ }
+
+ private static Document getDocument(String soapMessageTemplate) throws IOException {
+ try {
final XMLEventReader reader = XMLHelper.getXMLEventReader(new StringReader(soapMessageTemplate)) ;
return XMLHelper.createDocument(reader) ;
} catch (final Exception ex) {
@@ -836,10 +721,10 @@
private void applySmooksTransform(String smooksResource, Document messageDoc) throws IOException, SAXException {
if(smooksResource != null) {
- SmooksEntry smooksEntry = smooksCache.get(smooksResource);
+ LRUReferenceCountCacheEntry<Smooks, SmooksResource> smooksEntry = smooksCache.get(smooksResource);
try {
- final Smooks smooks = smooksEntry.getSmooks();
- smooks.filterSource(new DOMSource(messageDoc), new DOMResult());
+ final Smooks smooks = smooksEntry.getResource();
+ smooks.filterSource(new DOMSource(messageDoc), new DOMResult());
}
finally
{
@@ -893,13 +778,7 @@
// already have an entry for it...
clonePoint.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB, ognl + "[0]");
} else {
- // It's a collection and we need to do some cloning
- if(clonePoint != null) {
- // We already have one, so decrement by one...
- cloneCollectionTemplateElement(clonePoint, (collectionSize - 1), ognl, params);
- } else {
- logger.warn("Collection/array template element <" + element.getLocalName() + "> would appear to be invalid. It doesn't contain any child elements.");
- }
+ cloneCollectionTemplateElement(clonePoint, (collectionSize - 1), ognl, params);
}
}
}
@@ -1133,16 +1012,150 @@
return list;
}
- private synchronized DocumentBuilder getDocBuilder() throws IOException {
- try {
- return docBuilderFactory.newDocumentBuilder();
- } catch (final ParserConfigurationException pce) {
- final IOException ioe = new IOException("Could not create document builder") ;
- ioe.initCause(pce) ;
- throw ioe ;
+
+ private static WsdlOperationInfo getWsdlOperationInfo(final Operation operation)
+ throws XMLStreamException
+ {
+ final WsdlOperation wsdlOperation = (WsdlOperation)operation ;
+
+ final String requestTemplate = wsdlOperation.createRequest(true);
+ final XMLEventReader requestReader = XMLHelper.getXMLEventReader(new StringReader(requestTemplate)) ;
+ final List<XMLEvent> requestEvents = ESBStaxXMLEvent.cloneStream(requestReader) ;
+
+ final String responseTemplate = wsdlOperation.createResponse(true);
+ final List<XMLEvent> responseEvents ;
+ if (responseTemplate != null)
+ {
+ final XMLEventReader responseReader = XMLHelper.getXMLEventReader(new StringReader(responseTemplate)) ;
+ responseEvents = ESBStaxXMLEvent.cloneStream(responseReader) ;
}
+ else
+ {
+ responseEvents = Collections.emptyList() ;
+ }
+
+ final MessagePart[] faultParts = wsdlOperation.getFaultParts();
+ final Map<String, List<XMLEvent>> faultEventsMap = new HashMap<String, List<XMLEvent>>() ;
+
+ final SoapMessageBuilder soapMessageBuilder = wsdlOperation.getInterface().getMessageBuilder();
+ final XmlObject detail = XmlObject.Factory.newInstance();
+ for(MessagePart messagePart: faultParts)
+ {
+ final MessagePart.FaultPart faultPart = (MessagePart.FaultPart)messagePart ;
+ final String faultName = faultPart.getName() ;
+ final SampleXmlUtil generator = new SampleXmlUtil(false) ;
+ generator.setExampleContent(false) ;
+ generator.setTypeComment(false) ;
+ final XmlCursor cursor = detail.newCursor();
+ cursor.toFirstContentToken() ;
+ generator.setTypeComment(true) ;
+ generator.setIgnoreOptional(wsdlOperation.getInterface().getSettings().getBoolean( WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS ) );
+ for(Part part: faultPart.getWsdlParts())
+ {
+ try
+ {
+ soapMessageBuilder.createElementForPart(part, cursor, generator);
+ }
+ catch (final Exception ex)
+ {
+ throw new XMLStreamException("Unexpected exception creating fault template", ex) ;
+ }
+ }
+ final String faultTemplate = FAULT_PREFIX + detail.xmlText( new XmlOptions().setSaveAggressiveNamespaces().setSavePrettyPrint()) + FAULT_SUFFIX ;
+ final XMLEventReader faultReader = XMLHelper.getXMLEventReader(new StringReader(faultTemplate)) ;
+ final List<XMLEvent> faultEvents = ESBStaxXMLEvent.cloneStream(faultReader) ;
+ faultEventsMap.put(faultName, faultEvents) ;
+ }
+ return new WsdlOperationInfo(requestEvents, responseEvents,faultEventsMap) ;
}
-
+
+ private static Map<String, WsdlServiceInfo> getServiceInfoMap(final WsdlInterface[] wsdlInterfaces,
+ final Map<QName, Map<String, WsdlOperationInfo>> bindingToOperationInfo)
+ throws Exception
+ {
+ final Map<String, WsdlServiceInfo> serviceInfoMap = new HashMap<String, WsdlServiceInfo> () ;
+
+ final Set<String> processed = new HashSet<String>() ;
+
+ final Map<QName, WsdlInterface> bindingsToInterface = new HashMap<QName, WsdlInterface>() ;
+ for(WsdlInterface wsdlInterface: wsdlInterfaces)
+ {
+ bindingsToInterface.put(wsdlInterface.getBindingName(), wsdlInterface) ;
+ }
+
+ for(WsdlInterface wsdlInterface: wsdlInterfaces)
+ {
+ final Definition definition = wsdlInterface.getWsdlContext().getDefinition() ;
+ processDefinition(definition, processed, bindingToOperationInfo, bindingsToInterface, serviceInfoMap) ;
+ }
+ return serviceInfoMap ;
+ }
+
+ private static void processDefinition(final Definition definition, final Set<String> processed,
+ final Map<QName, Map<String, WsdlOperationInfo>> bindingToOperationInfo,
+ final Map<QName, WsdlInterface> bindingsToInterface,
+ final Map<String, WsdlServiceInfo> serviceInfoMap)
+ {
+ final String definitionLocation = definition.getDocumentBaseURI() ;
+ if (processed.add(definitionLocation))
+ {
+ final Map<?, Service> services = definition.getServices() ;
+ if (services != null)
+ {
+ for(Service service: services.values())
+ {
+ final Map<?, Port> ports = service.getPorts() ;
+ if (ports != null)
+ {
+ String endpoint = null ;
+ String contentType = null ;
+ boolean first = true ;
+ final Map<String, WsdlOperationInfo> operationInfoMap = new HashMap<String, WsdlOperationInfo>() ;
+
+ for(Port port: ports.values())
+ {
+ final QName bindingName = port.getBinding().getQName() ;
+ if (first)
+ {
+ first = false ;
+ final WsdlInterface bindingWsdlInterface = bindingsToInterface.get(bindingName) ;
+ endpoint = bindingWsdlInterface.getEndpoints()[0] ;
+ contentType = bindingWsdlInterface.getSoapVersion().getContentType() ;
+ }
+
+ final Map<String, WsdlOperationInfo> bindingOperationInfoMap = bindingToOperationInfo.get(bindingName) ;
+ for(Map.Entry<String, WsdlOperationInfo> entry: bindingOperationInfoMap.entrySet())
+ {
+ final String operationName = entry.getKey() ;
+ final WsdlOperationInfo operationInfo = entry.getValue() ;
+ final WsdlOperationInfo current = operationInfoMap.put(operationName, operationInfo) ;
+ if (current != null)
+ {
+ operationInfoMap.put(operationName, current) ;
+ }
+ }
+ }
+ final WsdlServiceInfo serviceInfo = new WsdlServiceInfo(endpoint, contentType, operationInfoMap) ;
+ final String serviceName = service.getQName().toString() ;
+ serviceInfoMap.put(serviceName, serviceInfo) ;
+ }
+ }
+ }
+ final Map<?, List<Import>> allImports = definition.getImports() ;
+ if (allImports != null)
+ {
+ for(List<Import> imports: allImports.values())
+ {
+ for(Import current: imports)
+ {
+ processDefinition(current.getDefinition(), processed,
+ bindingToOperationInfo, bindingsToInterface, serviceInfoMap) ;
+ }
+ }
+ }
+ }
+ }
+
public void setServerDataDir(final String datadir)
{
this.serverDataDir = datadir;
@@ -1153,175 +1166,452 @@
return serverDataDir;
}
- static final class SmooksCache
+ /**
+ * Wrapper class for smooks resource.
+ */
+ static class SmooksResource extends LRUReferenceCountCacheResource<Smooks>
{
+ SmooksResource(final Smooks smooks)
+ {
+ super(smooks) ;
+ }
+
+ public void close()
+ {
+ getInstance().close() ;
+ }
+ }
+
+ /**
+ * Smooks cache implementation.
+ */
+ static class SmooksCache extends LRUReferenceCountCache<Smooks, SmooksResource>
+ {
+ SmooksCache(final int lruCacheSize)
+ {
+ super(lruCacheSize);
+ }
+
+ public LRUReferenceCountCacheEntry<Smooks, SmooksResource> get(final String resourceLocation)
+ throws UnsupportedEncodingException, SAXException, IOException
+ {
+ final LRUReferenceCountCacheEntry<Smooks, SmooksResource> entry = internalGet(resourceLocation) ;
+ if (entry != null)
+ {
+ return entry ;
+ }
+ else
+ {
+ return create(resourceLocation, createResource(resourceLocation)) ;
+ }
+ }
+
+ protected SmooksResource createResource(final String resourceLocation)
+ throws UnsupportedEncodingException, SAXException, IOException
+ {
+ final Smooks smooks = new Smooks();
+ smooks.addConfigurations("smooks-resource", new ByteArrayInputStream(resourceLocation.getBytes("UTF-8")));
+ return new SmooksResource(smooks) ;
+ }
+ }
+
+ /**
+ * Cached operation information.
+ */
+ static class WsdlOperationInfo
+ {
/**
- * The unused entries.
+ * request event stream.
*/
- private final Map<String, Smooks> cachedResources = new HashMap<String, Smooks>();
+ private final List<XMLEvent> requestEvents ;
/**
- * The list of cached resource entries.
+ * response event stream.
*/
- private final LinkedList<String> cachedResourceInsertion = new LinkedList<String>();
+ private final List<XMLEvent> responseEvents ;
/**
- * The active entries.
+ * fault event streams.
*/
- private final Map<String, SmooksEntry> active = new HashMap<String, SmooksEntry>();
+ private final Map<String, List<XMLEvent>> faultEventsMap ;
+
+ WsdlOperationInfo(final List<XMLEvent> requestEvents, final List<XMLEvent> responseEvents,
+ final Map<String, List<XMLEvent>> faultEventsMap)
+ {
+ this.requestEvents = requestEvents ;
+ this.responseEvents = responseEvents ;
+ this.faultEventsMap = faultEventsMap ;
+ }
+
+ public List<XMLEvent> getRequestEvents()
+ {
+ return requestEvents ;
+ }
+
+ public List<XMLEvent> getResponseEvents()
+ {
+ return responseEvents ;
+ }
+
+ public List<XMLEvent> getFaultEvents(final String faultName)
+ {
+ return faultEventsMap.get(faultName) ;
+ }
+ }
+
+ /**
+ * Cached service info.
+ */
+ static class WsdlServiceInfo
+ {
/**
- * The cache size.
+ * First endpoint.
*/
- private final int smooksLRUCacheSize;
+ private final String endpoint ;
+ /**
+ * Content type for service.
+ */
+ private final String contentType ;
+ /**
+ * Cached operation information.
+ */
+ private final Map<String, WsdlOperationInfo> operationInfoMap ;
- public SmooksCache(final int smooksLRUCacheSize)
+ WsdlServiceInfo(final String endpoint, final String contentType, final Map<String, WsdlOperationInfo> operationInfoMap)
{
- this.smooksLRUCacheSize = smooksLRUCacheSize;
+ this.endpoint = endpoint ;
+ this.contentType = contentType ;
+ this.operationInfoMap = operationInfoMap ;
}
- public synchronized void clean() {
- cachedResourceInsertion.clear() ;
- final Collection<Smooks> cachedSmooks = cachedResources.values() ;
- for(Smooks smooks: cachedSmooks) {
- closeSmooks(smooks) ;
+ public String getEndpoint()
+ {
+ return endpoint ;
+ }
+
+ public String getContentType()
+ {
+ return contentType ;
+ }
+
+ public WsdlOperationInfo getOperation(final String operation)
+ {
+ return operationInfoMap.get(operation) ;
+ }
+ }
+
+ /**
+ * Internal WSDL state class to allow atomic swapping out during refresh operations.
+ */
+ static class WsdlInternalState
+ {
+ private final Set<QName> nils ;
+ private final Map<String, WsdlServiceInfo> serviceInfoMap ;
+ private final Map<String, WsdlOperationInfo> operationInfoMap = new HashMap<String, WsdlOperationInfo>() ;
+ private final String defaultContentType ;
+ private final String defaultEndpoint ;
+
+ public WsdlInternalState(final String wsdl, final Properties httpClientProps)
+ throws IOException
+ {
+ try {
+ final WsdlProject wsdlProject = new WsdlProject();
+ final HttpClient httpClient = HttpClientFactory.createHttpClient(httpClientProps);
+ try {
+ EsbWsdlLoader loader = new EsbWsdlLoader(wsdl, httpClient);
+ WsdlLoaderAspect.set(loader); // JBESB-3276
+ final WsdlInterface[] wsdlInterfaces = wsdlProject.importWsdl(wsdl, true, loader);
+ nils = extractNillableElements(wsdl, loader) ;
+
+ defaultContentType = wsdlInterfaces[0].getSoapVersion().getContentType() ;
+ defaultEndpoint = wsdlInterfaces[0].getEndpoints()[0] ;
+
+ final Map<QName, Map<String, WsdlOperationInfo>> bindingToOperationInfo = new HashMap<QName, Map<String, WsdlOperationInfo>>() ;
+ for(WsdlInterface wsdlInterface: wsdlInterfaces)
+ {
+ final Map<String, WsdlOperationInfo> bindingOperationInfoMap = new HashMap<String, WsdlOperationInfo>() ;
+ for (Operation operation: wsdlInterface.getOperations())
+ {
+ final String name = operation.getName() ;
+ // we cannot disambiguate further than name, so ignore subsequent ones
+ if (!bindingOperationInfoMap.containsKey(name))
+ {
+ final WsdlOperationInfo info = getWsdlOperationInfo(operation) ;
+ bindingOperationInfoMap.put(name, info) ;
+ final WsdlOperationInfo current = operationInfoMap.put(name, info) ;
+ // Restore first operation detail if already set
+ if (current != null)
+ {
+ operationInfoMap.put(name, current) ;
+ }
+ }
+ }
+ bindingToOperationInfo.put(wsdlInterface.getBindingName(), bindingOperationInfoMap) ;
+ }
+
+ serviceInfoMap = getServiceInfoMap(wsdlInterfaces, bindingToOperationInfo) ;
+ } finally {
+ WsdlLoaderAspect.unset(); // JBESB-3276
+ HttpClientFactory.shutdown(httpClient);
+ }
+ } catch (Exception e) {
+ IOException ioException = new IOException("Failed to create WSDL state.");
+ ioException.initCause(e);
+ throw ioException;
}
- cachedResources.clear() ;
- if (active.size() > 0) {
- logger.warn("Active smooks entries in cache") ;
+ }
+
+ public XMLEventReader getRequest(final String operation, final String serviceName)
+ {
+ final WsdlOperationInfo operationInfo = getOperationInfo(serviceName, operation) ;
+ if (operationInfo != null)
+ {
+ return new ESBXMLEventStreamReader(operationInfo.getRequestEvents()) ;
}
+ return null ;
}
- public SmooksEntry get(final String smooksResource)
- throws IOException, SAXException {
- final SmooksEntry smooks = internalGet(smooksResource);
- if (smooks != null) {
- return smooks;
- } else {
- return create(smooksResource);
+ public XMLEventReader getResponse(final String operation, final String serviceName)
+ {
+ final WsdlOperationInfo operationInfo = getOperationInfo(serviceName, operation) ;
+ if (operationInfo != null)
+ {
+ return new ESBXMLEventStreamReader(operationInfo.getResponseEvents()) ;
}
+ return null ;
}
- private synchronized SmooksEntry internalGet(final String smooksResource) {
- final SmooksEntry result;
- final SmooksEntry activeEntry = active.get(smooksResource);
- if (activeEntry != null) {
- activeEntry.incCount();
- result = activeEntry;
- } else {
- final Smooks smooks = (Smooks) cachedResources.remove(smooksResource);
- if (smooks != null) {
- cachedResourceInsertion.remove(smooksResource);
- final SmooksEntry entry = new SmooksEntry(smooks, smooksResource);
- active.put(smooksResource, entry);
- result = entry;
- } else {
- result = null;
+ public XMLEventReader getFault(final String faultName, final String operation, final String serviceName)
+ {
+ final WsdlOperationInfo operationInfo = getOperationInfo(serviceName, operation) ;
+ if (operationInfo != null)
+ {
+ final List<XMLEvent> events = operationInfo.getFaultEvents(faultName) ;
+ if (events != null)
+ {
+ return new ESBXMLEventStreamReader(events) ;
}
}
- return result;
+ return null ;
}
- private SmooksEntry create(final String smooksResource)
- throws IOException, SAXException {
- final SmooksEntry result;
- boolean close = false;
- final Smooks smooks = new Smooks();
- smooks.addConfigurations("smooks-resource", new ByteArrayInputStream(smooksResource.getBytes("UTF-8")));
- synchronized (this)
+ public String getDefaultContentType()
+ {
+ return defaultContentType ;
+ }
+
+ public String getDefaultEndpoint()
+ {
+ return defaultEndpoint ;
+ }
+
+ public WsdlOperationInfo getOperationInfo(final String serviceName, final String operation)
+ {
+ if (serviceName != null)
{
- final SmooksEntry current = internalGet(smooksResource);
- if (current == null) {
- final SmooksEntry newEntry = new SmooksEntry(smooks,
- smooksResource);
- active.put(smooksResource, newEntry);
- result = newEntry;
- } else {
- close = true;
- result = current;
+ final WsdlServiceInfo serviceInfo = getServiceInfo(serviceName) ;
+ if (serviceInfo != null)
+ {
+ return serviceInfo.getOperation(operation) ;
}
+ return null ;
}
- if (close) {
- closeSmooks(smooks);
- } else {
- checkExpired();
+ else
+ {
+ return operationInfoMap.get(operation) ;
}
- return result;
}
- public void release(final SmooksEntry smooksEntry) {
- boolean cached = false ;
- synchronized (this)
+ public WsdlServiceInfo getServiceInfo(final String serviceName)
+ {
+ return serviceInfoMap.get(serviceName) ;
+ }
+
+ public Set<QName> getNils()
+ {
+ return nils ;
+ }
+ }
+
+ /**
+ * WSDL state class supporting refresh of internal state.
+ */
+ static class WsdlState
+ {
+ private volatile WsdlInternalState state ;
+
+ WsdlState(final String wsdl, final Properties httpClientProps)
+ throws IOException
+ {
+ state = new WsdlInternalState(wsdl, httpClientProps) ;
+ }
+
+ public XMLEventReader getRequest(final String operation, final String serviceName,
+ final boolean refresh, final String wsdl, final Properties httpClientProps)
+ throws IOException
+ {
+ final XMLEventReader reader = state.getRequest(operation, serviceName) ;
+ if (reader != null)
{
- if (smooksEntry.decCount() == 0) {
- final String smooksResource = smooksEntry.getSmooksResource();
- cachedResources.put(smooksResource, smooksEntry.getSmooks());
- cachedResourceInsertion.addLast(smooksResource);
- cached = true ;
- }
+ return reader ;
}
- if (cached) {
- checkExpired();
+ else if (refresh)
+ {
+ state = new WsdlInternalState(wsdl, httpClientProps) ;
+ return getRequest(operation, serviceName, false, null, null) ;
}
+ else
+ {
+ throw new UnsupportedOperationException("Operation '" + operation + "' not found in service '" + serviceName + "' defined in WSDL '" + wsdl + "'.");
+ }
}
- private void checkExpired() {
- final List<Smooks> expiredSmooks;
- synchronized (this)
+ public XMLEventReader getResponse(final String operation, final String serviceName,
+ final boolean refresh, final String wsdl, final Properties httpClientProps)
+ throws IOException
+ {
+ final XMLEventReader reader = state.getResponse(operation, serviceName) ;
+ if (reader != null)
{
- final int activeSize = active.size();
- final int cachedSize = cachedResourceInsertion.size();
- final int expiredCount = (activeSize >= smooksLRUCacheSize ? cachedSize
- : activeSize + cachedSize - smooksLRUCacheSize);
- if (expiredCount > 0) {
- expiredSmooks = new ArrayList<Smooks>(expiredCount);
- for (int count = 0; count < expiredCount; count++) {
- final String expiredSmooksResource = cachedResourceInsertion.removeFirst();
- expiredSmooks.add((Smooks) cachedResources.remove(expiredSmooksResource));
- }
- } else {
- expiredSmooks = null;
- }
+ return (reader.hasNext() ? reader : null) ;
}
- if (expiredSmooks != null) {
- for (Smooks smooks : expiredSmooks) {
- closeSmooks(smooks);
- }
+ else if (refresh)
+ {
+ state = new WsdlInternalState(wsdl, httpClientProps) ;
+ return getResponse(operation, serviceName, false, null, null) ;
}
+ else
+ {
+ throw new UnsupportedOperationException("Operation '" + operation + "' not found in service '" + serviceName + "' defined in WSDL '" + wsdl + "'.");
+ }
}
- private void closeSmooks(final Smooks smooks) {
- try {
- smooks.close();
- } catch (final Throwable th) {
- logger.warn("Unexpected exception cleaning smooks resource", th);
+ public XMLEventReader getFault(final String operation, final String serviceName,
+ final String faultName, final boolean refresh, final String wsdl, final Properties httpClientProps)
+ throws IOException
+ {
+ final XMLEventReader reader = state.getFault(faultName, operation, serviceName) ;
+ if (reader != null)
+ {
+ return reader ;
}
+ else if (refresh)
+ {
+ state = new WsdlInternalState(wsdl, httpClientProps) ;
+ return getFault(operation, serviceName, faultName, false, null, null) ;
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Fault '" + faultName + "' not found in operation '" + operation + "' from service '" + serviceName + "' defined in WSDL '" + wsdl + "'.");
+ }
}
- }
- static final class SmooksEntry
- {
- private final Smooks smooks;
- private final String smooksResource;
- private int count = 1;
+ public String getDefaultContentType()
+ {
+ return state.getDefaultContentType() ;
+ }
- SmooksEntry(final Smooks smooks, final String smooksResource)
+ public String getContentType(final String serviceName, final boolean refresh, final boolean fail,
+ final String wsdl, final Properties httpClientProps)
+ throws IOException
{
- this.smooks = smooks;
- this.smooksResource = smooksResource;
+ final WsdlServiceInfo serviceInfo = getServiceInfo(serviceName, refresh, fail, wsdl, httpClientProps) ;
+ if (serviceInfo != null)
+ {
+ return serviceInfo.getContentType() ;
+ }
+ else
+ {
+ return null ;
+ }
}
- Smooks getSmooks() {
- return smooks;
+ public String getDefaultEndpoint()
+ {
+ return state.getDefaultEndpoint() ;
}
- String getSmooksResource() {
- return smooksResource;
+ public String getEndpoint(final String serviceName, final boolean refresh, final boolean fail,
+ final String wsdl, final Properties httpClientProps)
+ throws IOException
+ {
+ final WsdlServiceInfo serviceInfo = getServiceInfo(serviceName, refresh, fail, wsdl, httpClientProps) ;
+ if (serviceInfo != null)
+ {
+ return serviceInfo.getEndpoint() ;
+ }
+ else
+ {
+ return null ;
+ }
}
- int incCount() {
- return ++count;
+ public WsdlServiceInfo getServiceInfo(final String serviceName, final boolean refresh, final boolean fail, final String wsdl, final Properties httpClientProps)
+ throws IOException
+ {
+ final WsdlServiceInfo serviceInfo = state.getServiceInfo(serviceName) ;
+ if (serviceInfo != null)
+ {
+ return serviceInfo ;
+ }
+ else if (refresh)
+ {
+ state = new WsdlInternalState(wsdl, httpClientProps) ;
+ return getServiceInfo(serviceName, false, fail, wsdl, httpClientProps) ;
+ }
+ else if (fail)
+ {
+ throw new UnsupportedOperationException("Service '" + serviceName + "' not defined in WSDL '" + wsdl + "'.");
+ }
+ else
+ {
+ return null ;
+ }
}
- int decCount() {
- return --count;
+ public Set<QName> getNils()
+ {
+ return state.getNils() ;
}
}
+
+ /**
+ * Wrapper class for WSDL state resource.
+ */
+ static class WsdlResource extends LRUReferenceCountCacheResource<WsdlState>
+ {
+ WsdlResource(final WsdlState state)
+ {
+ super(state) ;
+ }
+ }
+
+ /**
+ * WSDL cache implementation.
+ */
+ static class WsdlCache extends LRUReferenceCountCache<WsdlState, WsdlResource>
+ {
+ WsdlCache(final int lruCacheSize)
+ {
+ super(lruCacheSize);
+ }
+
+ public LRUReferenceCountCacheEntry<WsdlState, WsdlResource> get(final String wsdl, final Properties httpProperties)
+ throws IOException
+ {
+ final LRUReferenceCountCacheEntry<WsdlState, WsdlResource> entry = internalGet(wsdl) ;
+ if (entry != null)
+ {
+ return entry ;
+ }
+ else
+ {
+ return create(wsdl, createResource(wsdl, httpProperties)) ;
+ }
+ }
+
+ protected WsdlResource createResource(final String wsdl, final Properties httpProperties)
+ throws IOException
+ {
+ return new WsdlResource(new WsdlState(wsdl, httpProperties)) ;
+ }
+ }
}
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/resources/soapui-client.sar.properties
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/resources/soapui-client.sar.properties 2011-01-13 13:21:25 UTC (rev 36517)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/main/resources/soapui-client.sar.properties 2011-01-13 13:25:37 UTC (rev 36518)
@@ -1,4 +1,8 @@
#####################################################################################
# Smooks instances are cached in an LRU cache.
#####################################################################################
-smooks.lru.cache.size=30
\ No newline at end of file
+smooks.lru.cache.size=30
+#####################################################################################
+# Wsdl information is cached in an LRU cache.
+#####################################################################################
+wsdl.lru.cache.size=30
\ No newline at end of file
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2011-01-13 13:21:25 UTC (rev 36517)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2011-01-13 13:25:37 UTC (rev 36518)
@@ -34,6 +34,7 @@
import junit.framework.TestCase;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.services.soapui.SoapUIClientService.WsdlOperationInfo;
import org.jboss.soa.esb.services.soapui.orderprocessing.Order;
import org.jboss.soa.esb.services.soapui.orderprocessing.LineItem;
import org.jboss.soa.esb.services.soapui.orderprocessing.ProcessOrderRequest;
@@ -170,9 +171,9 @@
properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
- Operation retailerBlast1 = mbean.getOperation(wsdlFile.toURI().toString(), "BlastOrder", "{http://docs.active-endpoints.com/activebpel/sample/wsdl/retailer/2006/04/Retailer.wsdl}RetailerService", properties, true);
- Operation retailerBlast2 = mbean.getOperation(wsdlFile.toURI().toString(), "BlastOrder", "{http://docs.active-endpoints.com/activebpel/sample/wsdl/retailer/2006/04/Retailer.wsdl}RetailerService", properties, true);
- Operation retailerBlast3 = mbean.getOperation(wsdlFile.toURI().toString(), "BlastOrder", "{http://docs.active-endpoints.com/activebpel/sample/wsdl/customer/2006/04/Customer.wsdl}CustomerService", properties, true);
+ WsdlOperationInfo retailerBlast1 = mbean.getOperationInfo(wsdlFile.toURI().toString(), "BlastOrder", "{http://docs.active-endpoints.com/activebpel/sample/wsdl/retailer/2006/04/Retailer.wsdl}RetailerService", properties, true);
+ WsdlOperationInfo retailerBlast2 = mbean.getOperationInfo(wsdlFile.toURI().toString(), "BlastOrder", "{http://docs.active-endpoints.com/activebpel/sample/wsdl/retailer/2006/04/Retailer.wsdl}RetailerService", properties, true);
+ WsdlOperationInfo retailerBlast3 = mbean.getOperationInfo(wsdlFile.toURI().toString(), "BlastOrder", "{http://docs.active-endpoints.com/activebpel/sample/wsdl/customer/2006/04/Customer.wsdl}CustomerService", properties, true);
assertTrue(retailerBlast1 == retailerBlast2);
assertFalse(retailerBlast2 == retailerBlast3);
More information about the jboss-svn-commits
mailing list