| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
| package org.jboss.as.test.integration.ejb.remote.byreference; | ||
|
|
||
|
|
||
| import java.util.logging.Logger; | ||
|
|
||
| import javax.ejb.Stateless; | ||
|
|
||
| @Stateless | ||
| public class HelloBean implements HelloRemote { | ||
|
|
||
| private Logger log = Logger.getLogger(this.getClass().getSimpleName().toString()); | ||
|
|
||
| public TransferReturnValue hello ( TransferParameter param ) throws RemoteByReferenceException { | ||
| log.info("hello("+ param +") = Hello " + param ); | ||
|
|
||
| if(param == null) | ||
| throw new RemoteByReferenceException("Param was null"); | ||
|
|
||
| return new TransferReturnValue ( "Hello " + param ); | ||
| } | ||
|
|
||
| @Override | ||
| public SerializableObject helloSerializable(SerializableObject param) throws RemoteByReferenceException { | ||
| log.info("helloserializable("+ param +") = Hello " + param ); | ||
|
|
||
| if(param == null) | ||
| throw new RemoteByReferenceException("Param was null"); | ||
| param.setValue("Bye"); | ||
|
|
||
| return param; | ||
| } | ||
|
|
||
| @Override | ||
| public NonSerializableObject helloNonSerializable(NonSerializableObject param) throws RemoteByReferenceException { | ||
| log.info("helloserializable("+ param +") = Hello " + param ); | ||
|
|
||
| if(param == null) | ||
| throw new RemoteByReferenceException("Param was null"); | ||
| param.setValue("Bye"); | ||
|
|
||
| return param; | ||
| } | ||
|
|
||
| @Override | ||
| public SerializableObject helloNonSerializableToSerializable(NonSerializableObject param) | ||
| throws RemoteByReferenceException { | ||
| log.info("helloserializable("+ param +") = Hello " + param ); | ||
|
|
||
| if(param == null) | ||
| throw new RemoteByReferenceException("Param was null"); | ||
| param.setValue("Bye"); | ||
|
|
||
| return new SerializableObject(param.getValue()); | ||
| } | ||
|
|
||
| @Override | ||
| public NonSerializableObject helloSerializableToNonSerializable(SerializableObject param) | ||
| throws RemoteByReferenceException { | ||
| log.info("helloserializable("+ param +") = Hello " + param ); | ||
|
|
||
| if(param == null) | ||
| throw new RemoteByReferenceException("Param was null"); | ||
| param.setValue("Bye"); | ||
|
|
||
| return new NonSerializableObject(param.getValue()); | ||
| } | ||
| } |
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.integration.ejb.remote.byreference; | ||
|
|
||
| import javax.ejb.Remote; | ||
|
|
||
| @Remote | ||
| public interface HelloRemote { | ||
| public TransferReturnValue hello ( TransferParameter param ) throws RemoteByReferenceException; | ||
|
|
||
| public SerializableObject helloSerializable ( SerializableObject param ) throws RemoteByReferenceException; | ||
|
|
||
| public NonSerializableObject helloNonSerializable(NonSerializableObject param) throws RemoteByReferenceException; | ||
|
|
||
| public SerializableObject helloNonSerializableToSerializable(NonSerializableObject param) throws RemoteByReferenceException; | ||
|
|
||
| public NonSerializableObject helloSerializableToNonSerializable(SerializableObject param) throws RemoteByReferenceException; | ||
| } | ||
|
|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.integration.ejb.remote.byreference; | ||
|
|
||
| public class NonSerializableObject { | ||
|
|
||
| private String value; | ||
|
|
||
| public NonSerializableObject() { | ||
| } | ||
|
|
||
| public NonSerializableObject(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
|
|
||
| public void setValue(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String toString() { | ||
| return value; | ||
| } | ||
| } |
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.integration.ejb.remote.byreference; | ||
|
|
||
| public class RemoteByReferenceException extends Exception { | ||
|
|
||
| private NonSerializableObject nonSerializableObject; | ||
|
|
||
| public RemoteByReferenceException() { | ||
| super(); | ||
| nonSerializableObject = new NonSerializableObject("null"); | ||
| } | ||
|
|
||
| public RemoteByReferenceException(String msg) { | ||
| super(msg); | ||
| nonSerializableObject = new NonSerializableObject(msg); | ||
| } | ||
| } | ||
|
|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.integration.ejb.remote.byreference; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| public class SerializableObject implements Serializable { | ||
|
|
||
| private String value; | ||
|
|
||
| public SerializableObject() { | ||
| } | ||
|
|
||
| public SerializableObject(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
|
|
||
| public void setValue(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String toString() { | ||
| return value; | ||
| } | ||
| } |
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.integration.ejb.remote.byreference; | ||
|
|
||
| /** | ||
| * A class that does not implement serializable used in pass-by-reference | ||
| */ | ||
| public class TransferParameter { | ||
|
|
||
| private String value; | ||
|
|
||
| public TransferParameter() { | ||
| } | ||
|
|
||
| public TransferParameter( String value ) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
| public void setValue ( String value ) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String toString() { | ||
| return value; | ||
| } | ||
| } | ||
|
|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.integration.ejb.remote.byreference; | ||
|
|
||
| /** | ||
| * A return value class that does not implement serializable | ||
| */ | ||
| public class TransferReturnValue { | ||
|
|
||
| private String value; | ||
|
|
||
| public TransferReturnValue() { | ||
| } | ||
|
|
||
| public TransferReturnValue( String value ) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
| public void setValue ( String value ) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getString() { | ||
| return value; | ||
| } | ||
| } |
| @@ -0,0 +1,140 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2018, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.txbridge.fromjta; | ||
|
|
||
| import javax.naming.InitialContext; | ||
| import javax.transaction.UserTransaction; | ||
|
|
||
| import org.jboss.arquillian.container.test.api.Deployment; | ||
| import org.jboss.arquillian.junit.Arquillian; | ||
| import org.jboss.as.test.txbridge.fromjta.service.FirstServiceAT; | ||
| import org.jboss.logging.Logger; | ||
| import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
| import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
| import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| /** | ||
| * <p> | ||
| * Simple set of starting JTA transaction and getting it bridged to the XTS-AT. | ||
| * <p> | ||
| * Test ported from https://github.com/jbosstm/quickstart repository. | ||
| */ | ||
| @RunWith(Arquillian.class) | ||
| public class BridgeFromJTATestCase { | ||
| private static final Logger log = Logger.getLogger(BridgeFromJTATestCase.class); | ||
|
|
||
| private static final String DEPLOYMENT = "fromjta-bridge"; | ||
| private static final String ManifestMF = | ||
| "Manifest-Version: 1.0\nDependencies: org.jboss.xts\n"; | ||
| private static final String persistentXml = | ||
| "<persistence>\n" + | ||
| " <persistence-unit name=\"first\">\n" + | ||
| " <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>\n" + | ||
| " <properties>\n" + | ||
| " <property name=\"hibernate.hbm2ddl.auto\" value=\"create-drop\"/>\n" + | ||
| " </properties>\n" + | ||
| " </persistence-unit>\n" + | ||
| "</persistence>"; | ||
|
|
||
| private UserTransaction ut; | ||
| private FirstServiceAT firstClient; | ||
|
|
||
| @Deployment(name = DEPLOYMENT) | ||
| public static JavaArchive createTestArchive1() { | ||
| JavaArchive archive = ShrinkWrap.create(JavaArchive.class, DEPLOYMENT + ".jar") | ||
| .addPackages(true, BridgeFromJTATestCase.class.getPackage()) | ||
| .addAsManifestResource(new StringAsset(ManifestMF), "MANIFEST.MF") | ||
| .addAsManifestResource(new StringAsset(persistentXml), "persistence.xml"); | ||
| return archive; | ||
| } | ||
|
|
||
| @Before | ||
| public void setupTest() throws Exception { | ||
| ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction"); | ||
| firstClient = FirstClient.newInstance(); | ||
| } | ||
|
|
||
| @After | ||
| public void teardownTest() throws Exception { | ||
| tryRollback(ut); | ||
| try { | ||
| ut.begin(); | ||
| firstClient.resetCounter(); | ||
| ut.commit(); | ||
| } finally { | ||
| tryRollback(ut); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Test starts the JTA transaction while calling the 'incrementCounter' on the stub. | ||
| * Expecting the interceptor bridges from JTA to WS-AT. | ||
| * The commit of the JTA transaction should cause the commit of the WS-AT transaction as well. | ||
| */ | ||
| @Test | ||
| public void testCommit() throws Exception { | ||
| ut.begin(); | ||
| firstClient.incrementCounter(1); | ||
| ut.commit(); | ||
|
|
||
| // second JTA checks if the counter was really incremented | ||
| ut.begin(); | ||
| int counter = firstClient.getCounter(); | ||
| ut.commit(); | ||
|
|
||
| Assert.assertEquals("Bridged JTA transaction should commit the WS-AT and the counter is expected to be incremented", | ||
| 1, counter); | ||
| } | ||
|
|
||
| /** | ||
| * Test starts the JTA transaction while calling the 'incrementCounter' on the stub. | ||
| * Expecting the interceptor bridges from JTA to WS-AT. | ||
| * The rollback of the JTA transaction should cause the rollback of the WS-AT transaction as well. | ||
| */ | ||
| @Test | ||
| public void testRollback() throws Exception { | ||
| ut.begin(); | ||
| firstClient.incrementCounter(1); | ||
| ut.rollback(); | ||
|
|
||
| // second JTA checks if the counter was not incremented | ||
| ut.begin(); | ||
| int counter = firstClient.getCounter(); | ||
| ut.commit(); | ||
|
|
||
| Assert.assertEquals("Asserting that the counters were *not* incremented successfully", 0, counter); | ||
| } | ||
|
|
||
| private void tryRollback(UserTransaction ut) { | ||
| try { | ||
| ut.rollback(); | ||
| } catch (Throwable th2) { | ||
| log.trace("Cannot rollback transaction " + ut, th2); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2018, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.txbridge.fromjta; | ||
|
|
||
| import javax.xml.namespace.QName; | ||
| import javax.xml.ws.Service; | ||
|
|
||
| import org.jboss.as.test.txbridge.fromjta.service.FirstServiceAT; | ||
|
|
||
| import java.net.URL; | ||
|
|
||
| public class FirstClient { | ||
|
|
||
| public static FirstServiceAT newInstance() throws Exception { | ||
| URL wsdlLocation = new URL("http://localhost:8080/test/FirstServiceATService/FirstServiceAT?wsdl"); | ||
| QName serviceName = new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/first", "FirstServiceATService"); | ||
| QName portName = new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/first", "FirstServiceAT"); | ||
|
|
||
| Service service = Service.create(wsdlLocation, serviceName); | ||
| FirstServiceAT client = service.getPort(portName, FirstServiceAT.class); | ||
|
|
||
| return client; | ||
| } | ||
| } | ||
|
|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2018, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.txbridge.fromjta.service; | ||
|
|
||
| import javax.persistence.Entity; | ||
| import javax.persistence.Id; | ||
| import java.io.Serializable; | ||
|
|
||
| /** | ||
| * Entity to verify the transaction participant | ||
| * is handled correctly when transaction is bridged | ||
| * from JTA to WS-AT. | ||
| */ | ||
| @Entity | ||
| public class FirstCounterEntity implements Serializable { | ||
| private static final long serialVersionUID = 1L; | ||
| private int id; | ||
| private int counter; | ||
|
|
||
| public FirstCounterEntity() { | ||
| } | ||
|
|
||
| public FirstCounterEntity(int id, int initialCounterValue) { | ||
| this.id = id; | ||
| this.counter = initialCounterValue; | ||
| } | ||
|
|
||
| @Id | ||
| public int getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(int id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public int getCounter() { | ||
| return counter; | ||
| } | ||
|
|
||
| public void setCounter(int counter) { | ||
| this.counter = counter; | ||
| } | ||
|
|
||
| public void incrementCounter(int howMany) { | ||
| setCounter(getCounter() + howMany); | ||
| } | ||
| } |
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2018, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.txbridge.fromjta.service; | ||
|
|
||
| import javax.ejb.Remote; | ||
| import javax.jws.WebMethod; | ||
| import javax.jws.WebService; | ||
| import javax.jws.soap.SOAPBinding; | ||
|
|
||
| /** | ||
| * Interface to a simple First. Provides simple methods to manipulate with counter. | ||
| */ | ||
| @WebService(name = "FirstServiceAT", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first") | ||
| @SOAPBinding(style = SOAPBinding.Style.RPC) | ||
| @Remote | ||
| public interface FirstServiceAT { | ||
|
|
||
| /** | ||
| * Create a new booking | ||
| */ | ||
| @WebMethod | ||
| public void incrementCounter(int numSeats); | ||
|
|
||
| /** | ||
| * Obtain the number of existing bookings | ||
| */ | ||
| @WebMethod | ||
| public int getCounter(); | ||
|
|
||
| /** | ||
| * Reset the booking count to zero | ||
| */ | ||
| @WebMethod | ||
| public void resetCounter(); | ||
|
|
||
| } |
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2018, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.txbridge.fromjta.service; | ||
|
|
||
| import javax.ejb.Remote; | ||
| import javax.ejb.Stateless; | ||
| import javax.ejb.TransactionAttribute; | ||
| import javax.ejb.TransactionAttributeType; | ||
| import javax.jws.WebMethod; | ||
| import javax.jws.WebService; | ||
| import javax.jws.soap.SOAPBinding; | ||
| import javax.persistence.EntityManager; | ||
| import javax.persistence.PersistenceContext; | ||
|
|
||
| import org.jboss.logging.Logger; | ||
|
|
||
| @Stateless | ||
| @Remote(FirstServiceAT.class) | ||
| @WebService(serviceName = "FirstServiceATService", portName = "FirstServiceAT", | ||
| name = "FirstServiceAT", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first") | ||
| @SOAPBinding(style = SOAPBinding.Style.RPC) | ||
| @TransactionAttribute(TransactionAttributeType.MANDATORY) | ||
| public class FirstServiceATImpl implements FirstServiceAT { | ||
| private static final Logger log = Logger.getLogger(FirstServiceATImpl.class); | ||
| private static final int ENTITY_ID = 1; | ||
|
|
||
| @PersistenceContext | ||
| protected EntityManager em; | ||
|
|
||
| /** | ||
| * Increment the first counter. This is done by updating the counter within a JTA transaction. | ||
| * The JTA transaction was automatically bridged from the WS-AT transaction. | ||
| */ | ||
| @WebMethod | ||
| public void incrementCounter(int num) { | ||
| log.trace("Service invoked to increment the counter by '" + num + "'"); | ||
| FirstCounterEntity entityFirst = lookupCounterEntity(); | ||
| entityFirst.incrementCounter(num); | ||
| em.merge(entityFirst); | ||
| } | ||
|
|
||
| @WebMethod | ||
| public int getCounter() { | ||
| log.trace("Service getCounter was invoked"); | ||
| FirstCounterEntity firstCounterEntity = lookupCounterEntity(); | ||
| if (firstCounterEntity == null) { | ||
| return -1; | ||
| } | ||
| return firstCounterEntity.getCounter(); | ||
| } | ||
|
|
||
| @WebMethod | ||
| public void resetCounter() { | ||
| FirstCounterEntity entityFirst = lookupCounterEntity(); | ||
| entityFirst.setCounter(0); | ||
| em.merge(entityFirst); | ||
| } | ||
|
|
||
| private FirstCounterEntity lookupCounterEntity() { | ||
| FirstCounterEntity entityFirst = em.find(FirstCounterEntity.class, ENTITY_ID); | ||
| if (entityFirst == null) { | ||
| entityFirst = new FirstCounterEntity(ENTITY_ID, 0); | ||
| em.persist(entityFirst); | ||
| } | ||
| return entityFirst; | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2018, Red Hat, Inc., and individual contributors | ||
| * as indicated by the @author tags. See the copyright.txt file in the | ||
| * distribution for a full listing of individual contributors. | ||
| * | ||
| * This is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU Lesser General Public License as | ||
| * published by the Free Software Foundation; either version 2.1 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * This software is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY 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 along with this software; if not, write to the Free | ||
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
| */ | ||
|
|
||
| package org.jboss.as.test.txbridge.fromjta.service; | ||
|
|
||
| import javax.xml.namespace.QName; | ||
| import javax.xml.ws.Service; | ||
| import javax.xml.ws.WebEndpoint; | ||
| import javax.xml.ws.WebServiceClient; | ||
| import javax.xml.ws.WebServiceFeature; | ||
|
|
||
| import org.jboss.logging.Logger; | ||
|
|
||
| import java.net.MalformedURLException; | ||
| import java.net.URL; | ||
|
|
||
| /** | ||
| * This class was generated by the JAX-WS RI. JAX-WS RI 2.1.6 in JDK 6 Generated source version: 2.1 | ||
| */ | ||
| @WebServiceClient(name = "FirstServiceATService", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first") | ||
| public class FirstServiceATService extends Service { | ||
| private static final Logger log = Logger.getLogger(FirstServiceATService.class.getName()); | ||
|
|
||
| private static final URL FIRSTSERVICEATSERVICE_WSDL_LOCATION; | ||
|
|
||
| static { | ||
| URL url = null; | ||
| try { | ||
| URL baseUrl; | ||
| baseUrl = FirstServiceATService.class.getResource("."); | ||
| url = new URL(baseUrl, "FirstServiceAT.wsdl"); | ||
| } catch (MalformedURLException e) { | ||
| log.warn("Failed to create URL for the wsdl Location: 'FirstServiceAT.wsdl', retrying as a local file", e); | ||
| } | ||
| FIRSTSERVICEATSERVICE_WSDL_LOCATION = url; | ||
| } | ||
|
|
||
| public FirstServiceATService(URL wsdlLocation, QName serviceName) { | ||
| super(wsdlLocation, serviceName); | ||
| } | ||
|
|
||
| public FirstServiceATService() { | ||
| super(FIRSTSERVICEATSERVICE_WSDL_LOCATION, | ||
| new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceATService")); | ||
| } | ||
|
|
||
| @WebEndpoint(name = "FirstServiceAT") | ||
| public FirstServiceAT getFirstServiceAT() { | ||
| return super.getPort( | ||
| new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceAT"), | ||
| FirstServiceAT.class); | ||
| } | ||
|
|
||
| /** | ||
| * @param features A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. | ||
| * Supported features not in the <code>features</code> parameter will have their default values. | ||
| */ | ||
| @WebEndpoint(name = "FirstServiceAT") | ||
| public FirstServiceAT getFirstServiceAT(WebServiceFeature... features) { | ||
| return super.getPort( | ||
| new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceAT"), | ||
| FirstServiceAT.class, features); | ||
| } | ||
|
|
||
| } |