[Design of JBoss Web Services] - Inheritance problem
by pio1k
Hello.
I have a problem with class inheritance in web services. I want to make a web service with one method to add objects of classes (B, C and other in the future) which inheritated from my basic class (A). My source code:
Server side:
1) TestService.java
@WebService(serviceName = "TestService")
| @Stateless
| @XmlSeeAlso({B.class, C.class})
| public class TestService {
| @EJB
| TestMgmtLocal tl = null;
|
| @WebMethod(operationName = "testAddA")
| public @WebResult(name = "A")
| A testAddA(@WebParam(name = "testA") A testA) {
| return tl.testAddA(testA);
| }
| }
2) TestMgmtLocal.java
@Local
| public interface TestMgmtLocal extends TestMgmtRemote {
|
| }
3) TestMgmtRemote.java
@Remote
| public interface TestMgmtRemote {
| A testAddA(A testA);
| }
4) TestMgmt.java
@Stateless
| public class TestMgmt implements TestMgmtLocal {
| @Resource
| private SessionContext ctx = null;
|
| public A testAddA(A testA) {
| if (testA instanceof A) {
| System.out.println("class A");
| }
|
| if (testA instanceof B) {
| System.out.println("class B");
| }
|
| if (testA instanceof C) {
| System.out.println("class C");
| }
|
| return testA;
| }
| }
5) A.java
public class A implements Serializable {
|
| private static final long serialVersionUID = 110181269433550832L;
|
| private int a = -1;
|
| public int getA() {
| return a;
| }
|
| public void setA(int a) {
| this.a = a;
| }
| }
6) B.java
public class B extends A implements Serializable {
|
| private static final long serialVersionUID = 6921792702940813727L;
|
| private int b = -1;
|
| public int getB() {
| return b;
| }
|
| public void setB(int b) {
| this.b = b;
| }
| }
7) C.java
public class C extends A implements Serializable {
|
| private static final long serialVersionUID = 7823155353151239133L;
|
| private int c = -1;
|
| public int getC() {
| return c;
| }
|
| public void setC(int c) {
| this.c = c;
| }
| }
Client side:
1) TestClient.java
public class TestClient {
|
| public static void main(String[] args) {
| TestServiceProxy proxy = new TestServiceProxy();
| TestService_PortType port = proxy.getTestService_PortType();
| try {
| C c = new C();
| c.setA(2);
| c.setC(3);
| port.testAddA(c);
| } catch(RemoteException e) {
| System.out.println(e);
| }
| }
| }
I found this page:
http://blog.vinodsingh.com/2008/09/anytype-object-over-webservice-and.html
but it doesn't work in my web service. In testAddA method I always get an object of A class (when I send from client object of B or C class). I've also tried to add @XmlSeeAlso annotation to A class but it doesn't help. Maybe I did something wrong? Any ideas? Any other solutions of this problem?
I'm using:
1) JBoss 4.2.3GA (I tired also on JBoss 5.1.GA)
2) Java 1.5 update 15
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244812#4244812
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244812
16 years, 8 months
[Design of Messaging on JBoss (Messaging/JBoss)] - Moving Messages Twice and LargeMessage links
by clebert.suconic@jboss.com
I have https://jira.jboss.org/jira/browse/JBMESSAGING-1496 complete at my local box, but there is one small detail I need to figure out.
I'm using _JBM_ORIG_MESSAGE_ID to link the Message to the original file. This way instead of copying the file I just use the original file, and I' m just making sure reference counting is working properly with this.
However, when you move messages twice (say... first ExpiryQueue, then DLA), the ORIG_MESSAGE_ID won' t be pointing to the original message any more.
Because of that, I changed the method makeCopy:
ServerMessage copy = message.copy(newMessageId);
|
| if (ref.getMessage().getProperty(HDR_ORIG_MESSAGE_ID) != null)
| {
| copy.putStringProperty(HDR_ORIGINAL_DESTINATION, (SimpleString)ref.getMessage()
| .getProperty(HDR_ORIGINAL_DESTINATION));
| copy.putLongProperty(HDR_ORIG_MESSAGE_ID, (Long)ref.getMessage().getProperty(HDR_ORIG_MESSAGE_ID));
| }
| else
| {
| SimpleString originalQueue = copy.getDestination();
| copy.putStringProperty(HDR_ORIGINAL_DESTINATION, originalQueue);
| copy.putLongProperty(HDR_ORIG_MESSAGE_ID, message.getMessageID());
| }
|
which is what I would expect as the semantic of Original Message.
If someone has a different expectation for this, I will just create a different property.
It' s a very minimal change and I could do it either way.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244774#4244774
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244774
16 years, 8 months
[Design of JBoss jBPM] - Re: Is it possible to avoid hibernate?
by kukeltje
I don't think Tom disagrees with you (and he might not have reread the whole thread, otherwise I think he would have made a different statement).
The thing is, is that the target of the *current* release of jBPM 4 was 'normal users' and not to support multiple models. That is intended for 4.1/4.2 so the 'not programming against interfaces' currently is not a real problem. For you it is, and your remarks are valid (I think Tom agrees on that). The only thing I disagree with is your remark about it being released to soon. Nobody expected that someone would pick this part up that quickly. :-)
The easiest thing you can do is make patches, attach them to a jira issue and they will get fixed some time it the future. The best you can after that is flooding this list with requests about reviewing your patches and in the meantime fill in the contributors agreement. If both 'succeed' you can make the patches yourself and discuss on this list the directions of your other repository solution.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244751#4244751
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244751
16 years, 8 months