diff --git a/core/pom.xml b/core/pom.xml index d5df10e..a56b3d1 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -79,8 +79,11 @@ wsdl4j wsdl4j - + org.smooks + smooks-core + + net.jcip diff --git a/core/src/main/java/org/jboss/wise/core/client/WSDynamicClient.java b/core/src/main/java/org/jboss/wise/core/client/WSDynamicClient.java index 49e7e4a..47d62fd 100644 --- a/core/src/main/java/org/jboss/wise/core/client/WSDynamicClient.java +++ b/core/src/main/java/org/jboss/wise/core/client/WSDynamicClient.java @@ -24,7 +24,8 @@ import net.jcip.annotations.ThreadSafe; import org.jboss.wise.core.wsextensions.EnablerDelegate; -import org.milyn.Smooks; +import org.smooks.Smooks; + /** * This is the Wise core class responsible to invoke the JAX-WS tools that handles wsdl retrieval & parsing. It is used to diff --git a/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java b/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java index 46afd38..894275c 100644 --- a/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java +++ b/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java @@ -30,7 +30,8 @@ import org.jboss.wise.core.exception.WiseRuntimeException; import org.jboss.wise.core.wsextensions.EnablerDelegate; import org.jboss.wise.core.wsextensions.EnablerDelegateProvider; -import org.milyn.Smooks; +import org.smooks.Smooks; + /** * This is the Wise core, i.e. the JAX-WS client that handles wsdl retrieval & parsing, invocations, etc. diff --git a/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java b/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java index aa9095c..19b53a4 100644 --- a/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java +++ b/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java @@ -49,18 +49,18 @@ import org.jboss.wise.core.client.WSDynamicClient; import org.jboss.wise.core.exception.WiseRuntimeException; import org.jboss.wise.core.mapper.SmooksMapper; -import org.milyn.Smooks; -import org.milyn.SmooksUtil; -import org.milyn.cdr.SmooksResourceConfiguration; -import org.milyn.cdr.SmooksResourceConfigurationList; -import org.milyn.cdr.XMLConfigDigester; -import org.milyn.container.ExecutionContext; -import org.milyn.event.report.HtmlReportGenerator; -import org.milyn.javabean.context.BeanContext; -import org.milyn.profile.DefaultProfileSet; -import org.milyn.profile.ProfileStore; -import org.milyn.profile.UnknownProfileMemberException; -import org.milyn.resource.URIResourceLocator; +import org.smooks.Smooks; +import org.smooks.api.ExecutionContext; +import org.smooks.api.bean.context.BeanContext; +import org.smooks.api.profile.ProfileStore; +import org.smooks.api.profile.UnknownProfileMemberException; +import org.smooks.api.resource.config.ResourceConfig; +import org.smooks.api.resource.config.ResourceConfigSeq; +import org.smooks.engine.profile.DefaultProfileSet; +import org.smooks.engine.report.HtmlReportGenerator; +import org.smooks.engine.resource.config.XMLConfigDigester; +import org.smooks.resource.URIResourceLocator; +import org.smooks.support.SmooksUtil; import org.jboss.wise.core.i18n.Messages; /** @@ -108,15 +108,15 @@ public SmooksHandler(String smooksResource, Map beans, WSDynamic synchronized (SmooksMapper.class) { // Register the message flow within the Smooks context.... - SmooksUtil.registerProfileSet(DefaultProfileSet.create(Integer.toString(this.hashCode()), new String[] {}), + SmooksUtil.registerProfileSet(new DefaultProfileSet(Integer.toString(this.hashCode()), new String[] {}), smooks); } } - SmooksResourceConfigurationList list = XMLConfigDigester.digestConfig(smooksResourceStream, "wise"); + ResourceConfigSeq list = XMLConfigDigester.digestConfig(smooksResourceStream, "wise"); for (int i = 0; i < list.size(); i++) { - SmooksResourceConfiguration smookResourceElement = list.get(i); + ResourceConfig smookResourceElement = list.get(i); smookResourceElement.setTargetProfile(Integer.toString(this.hashCode())); - SmooksUtil.registerResource(smookResourceElement, smooks); + smooks.addConfiguration(smookResourceElement); } this.smooksReport = smooksReport; @@ -162,7 +162,7 @@ public boolean handleMessage(SOAPMessageContext smc) { ExecutionContext executionContext = smooks.createExecutionContext(Integer.toString(this.hashCode())); if (smooksReport != null) { try { - executionContext.setEventListener(new HtmlReportGenerator(smooksReport)); + executionContext.getContentDeliveryRuntime().addExecutionEventListener(new HtmlReportGenerator(smooksReport)); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(Messages.MESSAGES.errorDuringLoading(smooksReport, e.getMessage())); diff --git a/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java b/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java index 7ed489c..814ac6c 100644 --- a/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java +++ b/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java @@ -38,20 +38,20 @@ import org.jboss.wise.core.client.WSDynamicClient; import org.jboss.wise.core.exception.MappingException; import org.jboss.wise.core.exception.WiseRuntimeException; -import org.milyn.Smooks; -import org.milyn.SmooksUtil; -import org.milyn.cdr.SmooksResourceConfiguration; -import org.milyn.cdr.SmooksResourceConfigurationList; -import org.milyn.cdr.XMLConfigDigester; -import org.milyn.container.ExecutionContext; -import org.milyn.event.report.HtmlReportGenerator; -import org.milyn.payload.JavaResult; -import org.milyn.payload.JavaSource; -import org.milyn.profile.DefaultProfileSet; -import org.milyn.profile.ProfileStore; -import org.milyn.profile.UnknownProfileMemberException; -import org.milyn.resource.URIResourceLocator; import org.jboss.wise.core.i18n.Messages; +import org.smooks.Smooks; +import org.smooks.api.ExecutionContext; +import org.smooks.api.profile.ProfileStore; +import org.smooks.api.profile.UnknownProfileMemberException; +import org.smooks.api.resource.config.ResourceConfig; +import org.smooks.api.resource.config.ResourceConfigSeq; +import org.smooks.engine.profile.DefaultProfileSet; +import org.smooks.engine.report.HtmlReportGenerator; +import org.smooks.engine.resource.config.XMLConfigDigester; +import org.smooks.io.payload.JavaResult; +import org.smooks.io.payload.JavaSource; +import org.smooks.resource.URIResourceLocator; +import org.smooks.support.SmooksUtil; /** * A WiseMapper based on smooks @@ -86,15 +86,15 @@ public SmooksMapper(String smooksResource, String smooksReport, WSDynamicClient synchronized (SmooksMapper.class) { // Register the message flow within the Smooks context.... - SmooksUtil.registerProfileSet(DefaultProfileSet.create(Integer.toString(this.hashCode()), new String[] {}), + SmooksUtil.registerProfileSet(new DefaultProfileSet(Integer.toString(this.hashCode()), new String[] {}), smooks); } } - SmooksResourceConfigurationList list = XMLConfigDigester.digestConfig(smooksResourceStream, "wise"); + ResourceConfigSeq list = XMLConfigDigester.digestConfig(smooksResourceStream, "wise"); for (int i = 0; i < list.size(); i++) { - SmooksResourceConfiguration smookResourceElement = list.get(i); + ResourceConfig smookResourceElement = list.get(i); smookResourceElement.setTargetProfile(Integer.toString(this.hashCode())); - SmooksUtil.registerResource(smookResourceElement, smooks); + smooks.addConfiguration(smookResourceElement); } // smooks.addConfigurations(Integer.toString(this.hashCode()), new // URIResourceLocator().getResource(smooksResource)); @@ -113,7 +113,7 @@ public SmooksMapper(String smooksResource, String smooksReport, WSDynamicClient ExecutionContext executionContext = smooks.createExecutionContext(Integer.toString(this.hashCode())); if (smooksReport != null) { try { - executionContext.setEventListener(new HtmlReportGenerator(smooksReport)); + executionContext.getContentDeliveryRuntime().addExecutionEventListener(new HtmlReportGenerator(smooksReport)); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(Messages.MESSAGES.errorDuringLoading(smooksReport, e.getMessage())); diff --git a/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java b/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java index b295cd2..b2c916c 100644 --- a/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java +++ b/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java @@ -24,10 +24,9 @@ import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; -import org.milyn.javabean.DataDecodeException; -import org.milyn.javabean.DataDecoder; -import org.milyn.javabean.DecodeType; -import org.milyn.javabean.decoders.DateDecoder; +import org.smooks.api.bean.repository.*; +import org.smooks.api.converter.TypeConverter; +import org.smooks.api.converter.TypeConverterException; /** * {@link javax.xml.datatype.Duration} data decoder. @@ -35,18 +34,17 @@ * Decodes the supplied string into a {@link javax.xml.datatype.Duration} String value is supposed to be milliseconds * representing this Duration */ -@DecodeType(Duration.class) -public class DurationDecoder extends DateDecoder implements DataDecoder { +public class DurationDecoder implements TypeConverter { @Override - public Object decode(String data) throws DataDecodeException { - Object result = null; + public Duration convert(String data) throws TypeConverterException { + Duration result = null; try { result = DatatypeFactory.newInstance().newDuration(Long.parseLong(data)); } catch (DatatypeConfigurationException e) { - throw new DataDecodeException("Error decoding Duration data value '" + data, e); + throw new TypeConverterException("Error decoding Duration data value '" + data, e); } catch (NumberFormatException e) { - throw new DataDecodeException("Error decoding Duration data value '" + data, e); + throw new TypeConverterException("Error decoding Duration data value '" + data, e); } return result; diff --git a/core/src/main/java/org/jboss/wise/smooks/decoders/JAXBElementDecoder.java b/core/src/main/java/org/jboss/wise/smooks/decoders/JAXBElementDecoder.java index 1a66719..1038824 100644 --- a/core/src/main/java/org/jboss/wise/smooks/decoders/JAXBElementDecoder.java +++ b/core/src/main/java/org/jboss/wise/smooks/decoders/JAXBElementDecoder.java @@ -21,13 +21,15 @@ */ package org.jboss.wise.smooks.decoders; +import java.util.Properties; + import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; -import org.milyn.cdr.SmooksConfigurationException; -import org.milyn.cdr.SmooksResourceConfiguration; -import org.milyn.javabean.DataDecodeException; -import org.milyn.javabean.DataDecoder; -import org.milyn.javabean.DecodeType; + +import org.smooks.api.SmooksConfigException; +import org.smooks.api.converter.TypeConverter; +import org.smooks.api.converter.TypeConverterException; +import org.smooks.api.resource.config.Configurable; /** * {@link javax.xml.datatype.Duration} data decoder. @@ -36,21 +38,28 @@ * IOW what it does under the wood is: new JAXBElement<String>(new QName(nameSpaceURI, localPart), String.class, String * data); */ -@DecodeType(JAXBElement.class) -public class JAXBElementDecoder implements DataDecoder { + +public class JAXBElementDecoder implements TypeConverter , Configurable { String nameSpaceURI = null; String localPart = null; - public void setConfiguration(SmooksResourceConfiguration resourceConfig) throws SmooksConfigurationException { - nameSpaceURI = resourceConfig.getStringParameter("namespaceURI"); - localPart = resourceConfig.getStringParameter("localPart"); + Properties properties; + + public void setConfiguration(Properties properties) throws SmooksConfigException { + this.properties = properties; + nameSpaceURI = properties.getProperty("namespaceURI"); + localPart = properties.getProperty("localPart"); if (nameSpaceURI == null || localPart == null) { - throw new SmooksConfigurationException("Decoder must specify a QName namespaceURI and a localPart parameter."); + throw new SmooksConfigException("Decoder must specify a QName namespaceURI and a localPart parameter."); } } - public Object decode(String data) throws DataDecodeException { + public Properties getConfiguration() { + return properties; + } + + public JAXBElement convert(String data) throws TypeConverterException { return new JAXBElement(new QName(nameSpaceURI, localPart), String.class, data); } } diff --git a/core/src/main/java/org/jboss/wise/smooks/decoders/XMLGregorianCalendarDecoder.java b/core/src/main/java/org/jboss/wise/smooks/decoders/XMLGregorianCalendarDecoder.java index 0ede70e..8a6753d 100644 --- a/core/src/main/java/org/jboss/wise/smooks/decoders/XMLGregorianCalendarDecoder.java +++ b/core/src/main/java/org/jboss/wise/smooks/decoders/XMLGregorianCalendarDecoder.java @@ -27,10 +27,9 @@ import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; -import org.milyn.javabean.DataDecodeException; -import org.milyn.javabean.DataDecoder; -import org.milyn.javabean.DecodeType; -import org.milyn.javabean.decoders.DateDecoder; +import org.smooks.api.converter.TypeConverter; +import org.smooks.api.converter.TypeConverterException; +import org.smooks.engine.converter.StringToDateConverterFactory.StringToDateConverter; /** * {@link javax.xml.datatype.XMLGregorianCalendar} data decoder. @@ -46,21 +45,19 @@ * * @author stefano.maestri@javalinux.it */ -@DecodeType(XMLGregorianCalendar.class) -public class XMLGregorianCalendarDecoder extends DateDecoder implements DataDecoder { +public class XMLGregorianCalendarDecoder implements TypeConverter { @Override - public Object decode(String data) throws DataDecodeException { - Date date = (Date) super.decode(data); + public XMLGregorianCalendar convert(String data) throws TypeConverterException { + Date date = (Date) new StringToDateConverter().convert(data); - Object result = null; + XMLGregorianCalendar result = null; try { GregorianCalendar gregCal = new GregorianCalendar(); gregCal.setTime(date); result = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregCal); } catch (DatatypeConfigurationException e) { - throw new DataDecodeException("Error decoding XMLGregorianCalendar data value '" + data + "' with decode format '" - + format + "'.", e); + throw new TypeConverterException("Error decoding XMLGregorianCalendar data value '" + data, e); } return result; } diff --git a/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java b/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java index 692b9ab..a15c802 100644 --- a/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java +++ b/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java @@ -50,7 +50,8 @@ import org.jboss.wise.core.exception.ResourceNotAvailableException; import org.junit.Before; import org.junit.Test; -import org.milyn.Smooks; +import org.smooks.Smooks; + /** * This is the Wise core, i.e. the JAX-WS client that handles wsdl retrieval & parsing, invocations, etc. diff --git a/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java b/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java index 11a9147..11fe792 100644 --- a/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java +++ b/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java @@ -43,8 +43,8 @@ import org.jboss.wise.core.mapper.mappingObject.ExternalObject; import org.jboss.wise.core.mapper.mappingObject.InternalObject; import org.junit.Test; -import org.milyn.Smooks; -import org.milyn.container.ExecutionContext; +import org.smooks.Smooks; +import org.smooks.api.ExecutionContext; /** * @author stefano.maestri@javalinux.it @@ -132,9 +132,9 @@ public void shouldHaveDifferentContentDeliveryConfigurationPerxecutionContext() ExecutionContext context2 = mapper2.initExecutionContext(null); ExecutionContext context3 = mapper3.initExecutionContext(null); - assertThat(context.getDeliveryConfig(), not(is(context2.getDeliveryConfig()))); - assertThat(context.getDeliveryConfig(), not(is(context3.getDeliveryConfig()))); - assertThat(context2.getDeliveryConfig(), not(is(context3.getDeliveryConfig()))); + assertThat(context.getContentDeliveryRuntime(), not(is(context2.getContentDeliveryRuntime()))); + assertThat(context.getContentDeliveryRuntime(), not(is(context3.getContentDeliveryRuntime()))); + assertThat(context2.getContentDeliveryRuntime(), not(is(context3.getContentDeliveryRuntime()))); } } diff --git a/core/src/test/java/org/jboss/wise/smooks/decoders/DurationDecoderTest.java b/core/src/test/java/org/jboss/wise/smooks/decoders/DurationDecoderTest.java index a5a4d1a..fa69894 100644 --- a/core/src/test/java/org/jboss/wise/smooks/decoders/DurationDecoderTest.java +++ b/core/src/test/java/org/jboss/wise/smooks/decoders/DurationDecoderTest.java @@ -25,20 +25,20 @@ import static org.junit.Assert.assertThat; import javax.xml.datatype.Duration; import org.junit.Test; -import org.milyn.javabean.DataDecodeException; +import org.smooks.api.converter.TypeConverterException; public class DurationDecoderTest { - @Test(expected = DataDecodeException.class) + @Test(expected = TypeConverterException.class) public void shouldThrowExceptionIfDatIsNotANumber() { DurationDecoder decoder = new DurationDecoder(); - decoder.decode("aa"); + decoder.convert("aa"); } @Test public void shouldReturnDurationAccordingCOnfig() { DurationDecoder decoder = new DurationDecoder(); - assertThat(((Duration) decoder.decode("1000")).getSeconds(), equalTo(1)); + assertThat(((Duration) decoder.convert("1000")).getSeconds(), equalTo(1)); } } diff --git a/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java b/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java index e8a42b2..71416f6 100644 --- a/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java +++ b/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java @@ -25,27 +25,29 @@ import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + +import java.util.Properties; + import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.junit.Test; -import org.milyn.cdr.SmooksConfigurationException; -import org.milyn.cdr.SmooksResourceConfiguration; +import org.smooks.api.SmooksConfigException; public class JAXBElementDecoderTest { - @Test(expected = SmooksConfigurationException.class) + @Test(expected = SmooksConfigException.class) public void setConfigurationShouldThrowExceptionIfNameSpaceURIIsNull() { JAXBElementDecoder decorator = new JAXBElementDecoder(); - SmooksResourceConfiguration config = mock(SmooksResourceConfiguration.class); - when(config.getStringParameter("namespaceURI")).thenReturn(null); + Properties config = mock(Properties.class); + when(config.getProperty("namespaceURI")).thenReturn(null); decorator.setConfiguration(config); } - @Test(expected = SmooksConfigurationException.class) + @Test(expected = SmooksConfigException.class) public void setConfigurationShouldThrowExceptionIfLocalPartNull() { JAXBElementDecoder decorator = new JAXBElementDecoder(); - SmooksResourceConfiguration config = mock(SmooksResourceConfiguration.class); - when(config.getStringParameter("localPart")).thenReturn(null); + Properties config = mock(Properties.class); + when(config.getProperty("localPart")).thenReturn(null); decorator.setConfiguration(config); } @@ -53,12 +55,12 @@ public void setConfigurationShouldThrowExceptionIfLocalPartNull() { @Test public void shouldReturnJAXBElementAccordingConfig() { JAXBElementDecoder decorator = new JAXBElementDecoder(); - SmooksResourceConfiguration config = mock(SmooksResourceConfiguration.class); - when(config.getStringParameter("namespaceURI")).thenReturn("myURI"); - when(config.getStringParameter("localPart")).thenReturn("local"); + Properties config = mock(Properties.class); + when(config.getProperty("namespaceURI")).thenReturn("myURI"); + when(config.getProperty("localPart")).thenReturn("local"); decorator.setConfiguration(config); - assertThat(((JAXBElement) decorator.decode("data")).getValue(), equalTo("data")); - assertThat(((JAXBElement) decorator.decode("data")).getName(), equalTo(new QName("myURI", "local"))); + assertThat(((JAXBElement) decorator.convert("data")).getValue(), equalTo("data")); + assertThat(((JAXBElement) decorator.convert("data")).getName(), equalTo(new QName("myURI", "local"))); } } diff --git a/pom.xml b/pom.xml index 574d825..bc37788 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ false -Xlint:unchecked,deprecation,fallthrough,finally - 1.7.0 + 2.0.0-M3 2.17 1.0.5.Final @@ -262,9 +262,9 @@ - org.milyn - milyn-smooks-core - ${milyn.version} + org.smooks + smooks-core + 2.0.0-M3 xerces @@ -273,7 +273,7 @@ - + net.jcip