Bugzilla – Bug 5739
specupgrade related problem in ReflectionResource
Last modified: 2007-12-21 05:28:23
You need to log in before you can comment on or make changes to this bug.
The method to set the termination time for the resource property TerminationTime in ReflectionResource is looked up in ReflectionResource.createNewResourceProperty() But the wrong parameter is given as part of the input of MethodCache.getMethod(): ### ReflectionResource SET_TERM_TIME_PARAM = new Class[] {Calendar.class}; ### The method to set the termination time of the class that is auto-generated from the resource property document of (e.g. ws-gram's) port type and which gets called looks like this: ### auto-generated code from the RP document of a port-type with ### the RP TerminationTime inherited from the ScheduledTerminationTime ### port type public void setTerminationTime( org.oasis.wsrf.lifetime.TerminationTime terminationTime) { this.terminationTime = terminationTime; } ### The MethodCache does not find an appropriate method because the input parameter is of type TerminationTime and not Calendar and thus returns null. So if ReflectionResource.setTerminationTime(...) is called, it does set the termination time but does nothing instead, because this.setTerminationTimeMethod is null: ### ReflectionResource public void setTerminationTime(Calendar time) { if (this.setTerminationTimeMethod != null) { try { this.setTerminationTimeMethod .invoke(this.getResourceBean(), new Object[] { new SetTerminationTime(time, null)}); } catch (Exception e) { logger.error("", e); throw new RuntimeException(e.getMessage()); } } } ### A fix in ReflectionResource that works for me: 1. change SET_TERM_TIME_PARAM to private static final Class[] SET_TERM_TIME_PARAM = new Class[] {TerminationTime.class}; 2. change the code to call the setTerminationTime method in ReflectionResource.setTerminationTime() from this.setTerminationTimeMethod .invoke(this.getResourceBean(), new Object[] { new SetTerminationTime(time, null)}); to this.setTerminationTimeMethod .invoke(this.getResourceBean(), new Object[] { new TerminationTime(time)}); because the auto-generated method to set the termination time (see above) expects an object of type TerminationTime and not of type SetTerminationTime as input
Sorry, i had a typo: "So if ReflectionResource.setTerminationTime(...) is called, it does set the termination time but does nothing instead, because this.setTerminationTimeMethod is null" should be "So if ReflectionResource.setTerminationTime(...) is called, it does NOT set the termination time, because this.setTerminationTimeMethod is null"
Do you mean ScheduledResourceTermination porttype? The method there is public interface ScheduledResourceTermination extends java.rmi.Remote { public org.oasis.wsrf.lifetime.SetTerminationTimeResponse setTerminationTime(org.oasis.wsrf.lifetime.SetTerminationTime setTerminationTimeRequest) throws java.rmi.RemoteException, org.oasis.wsrf.resource.ResourceUnavailableFaultType, org.oasis.wsrf.lifetime.UnableToSetTerminationTimeFaultType, org.oasis.wsrf.resource.ResourceUnknownFaultType, org.oasis.wsrf.lifetime.TerminationTimeChangeRejectedFaultType; } So the parameter needs to be SetTerminationTime I think. Do you see different method generated?
That's weird naming stuff and i hope one can understand what i want to say here: I think there's a difference between the port type method 'SetTerminationTime' and the auto-generated setter and getter of the RP 'TerminationTime' of the port type ScheduledResourceTermination. The method 'setTerminationTime' exposed by the port type indeed requires an input of type 'SetTerminationTime', but the generated setter for the RP 'TerminationTime' (which is unfortunately named 'setTerminationTime' too (-:) requires an argument of type TerminationTime: public void setTerminationTime( org.oasis.wsrf.lifetime.TerminationTime terminationTime) { this.terminationTime = terminationTime; } Since ws-grams port type extends from the ScheduledResourceTermination port type the generated datatype for ws-gram's resource property document includes an object of type 'TerminationTime' with getter and setter that work with the type 'TerminationTime' and not 'SetTerminationTime' ReflectionResource works on the generated data type and not on the port type and thus needs to use TerminationTime as type in it's 'setTerminationTime' method. ... i think
Martin, thanks for the explanation. Fix has been committed to trunk now. Rachana