static JmsDestinationImpl checkNativeInstance ( Destination destination ) throws InvalidDestinationException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "checkNativeInstance" , destination ) ; JmsDestinationImpl castDest = null ; // if the supplied destination is set to null, throw a jms // InvalidDestinationException. if ( destination == null ) { throw ( InvalidDestinationException ) JmsErrorUtils . newThrowable ( InvalidDestinationException . class , "INVALID_VALUE_CWSIA0281" , new Object [ ] { "Destination" , null } , tc ) ; } // Attempt to convert a non-native destination into a native one. if ( ! ( destination instanceof JmsDestinationImpl ) ) { // Use the variable to pass the failed conversion exception if one occurs. Exception rootCause = null ; //106556: if (destination instanceof java.lang.reflect.Proxy) is commented to generically support all types of Proxies. //We get a WovenProxy here when Apache Aries framework is used to deploy .eba files in liberty. //This WovenProxy is new type itself and it is not extending java.lang.reflect.Proxy. // 412946 workaround - the Spring framework passes in dynamic proxy objects // that wrap a real JmsDestinationImpl object if the application is using // Aspects to implement its transactional behaviour in an OSGi environment. // To work around this we have to take the unpleasant option of recreating // one of our objects using the toString of the object we have been given. // We should never normally rely on the format of a toString, but it seems to // be the only way to resolve the problem in this case. String destToString = destination . toString ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Dynamic proxy has been provided instead of a destination: " + destToString ) ; try { if ( destination instanceof Queue ) { castDest = ( JmsDestinationImpl ) JmsFactoryFactory . getInstance ( ) . createQueue ( destToString ) ; } else if ( destination instanceof Topic ) { castDest = ( JmsDestinationImpl ) JmsFactoryFactory . getInstance ( ) . createTopic ( destToString ) ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "A destination must be either a queue or a topic" ) ; } } catch ( JMSException jmse ) { // No FFDC Code Needed if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Failed to convert the dynamic proxy to a JmsDestinationImpl object;" ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . exception ( tc , jmse ) ; rootCause = jmse ; } // If the supplied destination isn't a Jetstream destination, throw a jms // InvalidDestinationException. if ( castDest == null ) { throw ( InvalidDestinationException ) JmsErrorUtils . newThrowable ( InvalidDestinationException . class , "FOREIGN_IMPLEMENTATION_CWSIA0046" , new Object [ ] { destination } , rootCause , null , JmsDestinationImpl . class , tc ) ; } } else { castDest = ( JmsDestinationImpl ) destination ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "checkNativeInstance" , castDest ) ; return castDest ; }
Check that the supplied destination is a native JMS destination object . If it is then exit quietly . If it is not then throw an exception .