diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ORBPolicyFactory_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ORBPolicyFactory_impl.java index 9e6661ef..6d37423e 100644 --- a/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ORBPolicyFactory_impl.java +++ b/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ORBPolicyFactory_impl.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 IBM Corporation and others. + * Copyright 2024 IBM Corporation and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,183 +17,253 @@ */ package org.apache.yoko.orb.CORBA; -final public class ORBPolicyFactory_impl extends org.omg.CORBA.LocalObject - implements org.omg.PortableInterceptor.PolicyFactory { +import org.apache.yoko.orb.BiDirPolicy.BidirectionalPolicy_impl; +import org.apache.yoko.orb.Messaging.MaxHopsPolicy_impl; +import org.apache.yoko.orb.Messaging.QueueOrderPolicy_impl; +import org.apache.yoko.orb.Messaging.RebindPolicy_impl; +import org.apache.yoko.orb.Messaging.RelativeRequestTimeoutPolicy_impl; +import org.apache.yoko.orb.Messaging.RelativeRoundtripTimeoutPolicy_impl; +import org.apache.yoko.orb.Messaging.ReplyEndTimePolicy_impl; +import org.apache.yoko.orb.Messaging.ReplyPriorityPolicy_impl; +import org.apache.yoko.orb.Messaging.ReplyStartTimePolicy_impl; +import org.apache.yoko.orb.Messaging.RequestEndTimePolicy_impl; +import org.apache.yoko.orb.Messaging.RequestPriorityPolicy_impl; +import org.apache.yoko.orb.Messaging.RequestStartTimePolicy_impl; +import org.apache.yoko.orb.Messaging.RoutingPolicy_impl; +import org.apache.yoko.orb.Messaging.SyncScopePolicy_impl; +import org.apache.yoko.orb.OB.CONNECTION_REUSE_POLICY_ID; +import org.apache.yoko.orb.OB.CONNECT_TIMEOUT_POLICY_ID; +import org.apache.yoko.orb.OB.ConnectTimeoutPolicy_impl; +import org.apache.yoko.orb.OB.ConnectionReusePolicy_impl; +import org.apache.yoko.orb.OB.INTERCEPTOR_POLICY_ID; +import org.apache.yoko.orb.OB.InterceptorPolicy_impl; +import org.apache.yoko.orb.OB.LOCATE_REQUEST_POLICY_ID; +import org.apache.yoko.orb.OB.LOCATION_TRANSPARENCY_POLICY_ID; +import org.apache.yoko.orb.OB.LocateRequestPolicy_impl; +import org.apache.yoko.orb.OB.LocationTransparencyPolicy_impl; +import org.apache.yoko.orb.OB.PROTOCOL_POLICY_ID; +import org.apache.yoko.orb.OB.ProtocolPolicy_impl; +import org.apache.yoko.orb.OB.REQUEST_TIMEOUT_POLICY_ID; +import org.apache.yoko.orb.OB.RETRY_ALWAYS; +import org.apache.yoko.orb.OB.RETRY_POLICY_ID; +import org.apache.yoko.orb.OB.RequestTimeoutPolicy_impl; +import org.apache.yoko.orb.OB.RetryAttributes; +import org.apache.yoko.orb.OB.RetryAttributesHelper; +import org.apache.yoko.orb.OB.RetryPolicy_impl; +import org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID; +import org.apache.yoko.orb.OB.TimeoutPolicy_impl; +import org.apache.yoko.orb.OB.ZERO_PORT_POLICY_ID; +import org.apache.yoko.orb.OB.ZeroPortPolicy_impl; +import org.omg.BiDirPolicy.BIDIRECTIONAL_POLICY_TYPE; +import org.omg.BiDirPolicy.BidirectionalPolicyValueHelper; +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.BAD_POLICY; +import org.omg.CORBA.BAD_POLICY_TYPE; +import org.omg.CORBA.BAD_POLICY_VALUE; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.Policy; +import org.omg.CORBA.PolicyError; +import org.omg.Messaging.MAX_HOPS_POLICY_TYPE; +import org.omg.Messaging.ORDER_ANY; +import org.omg.Messaging.ORDER_DEADLINE; +import org.omg.Messaging.OrderingHelper; +import org.omg.Messaging.PriorityRange; +import org.omg.Messaging.PriorityRangeHelper; +import org.omg.Messaging.QUEUE_ORDER_POLICY_TYPE; +import org.omg.Messaging.REBIND_POLICY_TYPE; +import org.omg.Messaging.RELATIVE_REQ_TIMEOUT_POLICY_TYPE; +import org.omg.Messaging.RELATIVE_RT_TIMEOUT_POLICY_TYPE; +import org.omg.Messaging.REPLY_END_TIME_POLICY_TYPE; +import org.omg.Messaging.REPLY_PRIORITY_POLICY_TYPE; +import org.omg.Messaging.REPLY_START_TIME_POLICY_TYPE; +import org.omg.Messaging.REQUEST_END_TIME_POLICY_TYPE; +import org.omg.Messaging.REQUEST_PRIORITY_POLICY_TYPE; +import org.omg.Messaging.REQUEST_START_TIME_POLICY_TYPE; +import org.omg.Messaging.ROUTING_POLICY_TYPE; +import org.omg.Messaging.RoutingTypeRange; +import org.omg.Messaging.RoutingTypeRangeHelper; +import org.omg.Messaging.SYNC_SCOPE_POLICY_TYPE; +import org.omg.PortableInterceptor.PolicyFactory; +import org.omg.TimeBase.UtcTHelper; + +final public class ORBPolicyFactory_impl extends LocalObject + implements PolicyFactory { // ------------------------------------------------------------------ // Standard IDL to Java Mapping // ------------------------------------------------------------------ - public org.omg.CORBA.Policy create_policy(int type, org.omg.CORBA.Any any) - throws org.omg.CORBA.PolicyError { + public Policy create_policy(int type, Any any) + throws PolicyError { try { switch (type) { - case org.apache.yoko.orb.OB.CONNECTION_REUSE_POLICY_ID.value: { + case CONNECTION_REUSE_POLICY_ID.value: { boolean b = any.extract_boolean(); - return new org.apache.yoko.orb.OB.ConnectionReusePolicy_impl(b); + return new ConnectionReusePolicy_impl(b); } - case org.apache.yoko.orb.OB.ZERO_PORT_POLICY_ID.value: { + case ZERO_PORT_POLICY_ID.value: { boolean b = any.extract_boolean(); - return new org.apache.yoko.orb.OB.ZeroPortPolicy_impl(b); + return new ZeroPortPolicy_impl(b); } - case org.apache.yoko.orb.OB.PROTOCOL_POLICY_ID.value: { + case PROTOCOL_POLICY_ID.value: { String[] seq = org.apache.yoko.orb.OCI.PluginIdSeqHelper .extract(any); - return new org.apache.yoko.orb.OB.ProtocolPolicy_impl(seq); + return new ProtocolPolicy_impl(seq); } - case org.apache.yoko.orb.OB.RETRY_POLICY_ID.value: { + case RETRY_POLICY_ID.value: { try { short v = any.extract_short(); - if (v > org.apache.yoko.orb.OB.RETRY_ALWAYS.value) - throw new org.omg.CORBA.PolicyError( - org.omg.CORBA.BAD_POLICY_VALUE.value); - return new org.apache.yoko.orb.OB.RetryPolicy_impl(v, 0, 1, + if (v > RETRY_ALWAYS.value) + throw new PolicyError( + BAD_POLICY_VALUE.value); + return new RetryPolicy_impl(v, 0, 1, false); - } catch (org.omg.CORBA.BAD_OPERATION ex) { + } catch (BAD_OPERATION ex) { } - org.apache.yoko.orb.OB.RetryAttributes attr = org.apache.yoko.orb.OB.RetryAttributesHelper + RetryAttributes attr = RetryAttributesHelper .extract(any); - return new org.apache.yoko.orb.OB.RetryPolicy_impl(attr.mode, + return new RetryPolicy_impl(attr.mode, attr.interval, attr.max, attr.remote); } - case org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID.value: { + case TIMEOUT_POLICY_ID.value: { int t = any.extract_ulong(); - return new org.apache.yoko.orb.OB.TimeoutPolicy_impl(t); + return new TimeoutPolicy_impl(t); } - case org.apache.yoko.orb.OB.LOCATION_TRANSPARENCY_POLICY_ID.value: { + case LOCATION_TRANSPARENCY_POLICY_ID.value: { short v = any.extract_short(); - return new org.apache.yoko.orb.OB.LocationTransparencyPolicy_impl( + return new LocationTransparencyPolicy_impl( v); } - case org.omg.Messaging.REQUEST_START_TIME_POLICY_TYPE.value: { - org.omg.TimeBase.UtcT v = org.omg.TimeBase.UtcTHelper + case REQUEST_START_TIME_POLICY_TYPE.value: { + org.omg.TimeBase.UtcT v = UtcTHelper .extract(any); - return new org.apache.yoko.orb.Messaging.RequestStartTimePolicy_impl( + return new RequestStartTimePolicy_impl( v); } - case org.omg.Messaging.REQUEST_END_TIME_POLICY_TYPE.value: { - org.omg.TimeBase.UtcT v = org.omg.TimeBase.UtcTHelper + case REQUEST_END_TIME_POLICY_TYPE.value: { + org.omg.TimeBase.UtcT v = UtcTHelper .extract(any); - return new org.apache.yoko.orb.Messaging.RequestEndTimePolicy_impl( + return new RequestEndTimePolicy_impl( v); } - case org.omg.Messaging.REPLY_START_TIME_POLICY_TYPE.value: { - org.omg.TimeBase.UtcT v = org.omg.TimeBase.UtcTHelper + case REPLY_START_TIME_POLICY_TYPE.value: { + org.omg.TimeBase.UtcT v = UtcTHelper .extract(any); - return new org.apache.yoko.orb.Messaging.ReplyStartTimePolicy_impl( + return new ReplyStartTimePolicy_impl( v); } - case org.omg.Messaging.REPLY_END_TIME_POLICY_TYPE.value: { - org.omg.TimeBase.UtcT v = org.omg.TimeBase.UtcTHelper + case REPLY_END_TIME_POLICY_TYPE.value: { + org.omg.TimeBase.UtcT v = UtcTHelper .extract(any); - return new org.apache.yoko.orb.Messaging.ReplyEndTimePolicy_impl( + return new ReplyEndTimePolicy_impl( v); } - case org.omg.Messaging.RELATIVE_REQ_TIMEOUT_POLICY_TYPE.value: { + case RELATIVE_REQ_TIMEOUT_POLICY_TYPE.value: { long v = any.extract_long(); - return new org.apache.yoko.orb.Messaging.RelativeRequestTimeoutPolicy_impl( + return new RelativeRequestTimeoutPolicy_impl( v); } - case org.omg.Messaging.RELATIVE_RT_TIMEOUT_POLICY_TYPE.value: { + case RELATIVE_RT_TIMEOUT_POLICY_TYPE.value: { long v = any.extract_long(); - return new org.apache.yoko.orb.Messaging.RelativeRoundtripTimeoutPolicy_impl( + return new RelativeRoundtripTimeoutPolicy_impl( v); } - case org.omg.Messaging.REBIND_POLICY_TYPE.value: { + case REBIND_POLICY_TYPE.value: { short v = any.extract_short(); - return new org.apache.yoko.orb.Messaging.RebindPolicy_impl(v); + return new RebindPolicy_impl(v); } - case org.omg.Messaging.SYNC_SCOPE_POLICY_TYPE.value: { + case SYNC_SCOPE_POLICY_TYPE.value: { short v = any.extract_short(); - return new org.apache.yoko.orb.Messaging.SyncScopePolicy_impl(v); + return new SyncScopePolicy_impl(v); } - case org.apache.yoko.orb.OB.INTERCEPTOR_POLICY_ID.value: { + case INTERCEPTOR_POLICY_ID.value: { boolean v = any.extract_boolean(); - return new org.apache.yoko.orb.OB.InterceptorPolicy_impl(v); + return new InterceptorPolicy_impl(v); } - case org.apache.yoko.orb.OB.CONNECT_TIMEOUT_POLICY_ID.value: { + case CONNECT_TIMEOUT_POLICY_ID.value: { int t = any.extract_ulong(); - return new org.apache.yoko.orb.OB.ConnectTimeoutPolicy_impl(t); + return new ConnectTimeoutPolicy_impl(t); } - case org.apache.yoko.orb.OB.REQUEST_TIMEOUT_POLICY_ID.value: { + case REQUEST_TIMEOUT_POLICY_ID.value: { int t = any.extract_ulong(); - return new org.apache.yoko.orb.OB.RequestTimeoutPolicy_impl(t); + return new RequestTimeoutPolicy_impl(t); } - case org.apache.yoko.orb.OB.LOCATE_REQUEST_POLICY_ID.value: { + case LOCATE_REQUEST_POLICY_ID.value: { boolean b = any.extract_boolean(); - return new org.apache.yoko.orb.OB.LocateRequestPolicy_impl(b); + return new LocateRequestPolicy_impl(b); } - case org.omg.BiDirPolicy.BIDIRECTIONAL_POLICY_TYPE.value: { - short v = org.omg.BiDirPolicy.BidirectionalPolicyValueHelper + case BIDIRECTIONAL_POLICY_TYPE.value: { + short v = BidirectionalPolicyValueHelper .extract(any); - return new org.apache.yoko.orb.BiDirPolicy.BidirectionalPolicy_impl( + return new BidirectionalPolicy_impl( v); } - case org.omg.Messaging.REQUEST_PRIORITY_POLICY_TYPE.value: { - org.omg.Messaging.PriorityRange v = org.omg.Messaging.PriorityRangeHelper + case REQUEST_PRIORITY_POLICY_TYPE.value: { + org.omg.Messaging.PriorityRange v = PriorityRangeHelper .extract(any); if (v.min > v.max) - throw new org.omg.CORBA.PolicyError( - org.omg.CORBA.BAD_POLICY_VALUE.value); - return new org.apache.yoko.orb.Messaging.RequestPriorityPolicy_impl( + throw new PolicyError( + BAD_POLICY_VALUE.value); + return new RequestPriorityPolicy_impl( v); } - case org.omg.Messaging.REPLY_PRIORITY_POLICY_TYPE.value: { - org.omg.Messaging.PriorityRange v = org.omg.Messaging.PriorityRangeHelper + case REPLY_PRIORITY_POLICY_TYPE.value: { + PriorityRange v = PriorityRangeHelper .extract(any); if (v.min > v.max) - throw new org.omg.CORBA.PolicyError( - org.omg.CORBA.BAD_POLICY_VALUE.value); - return new org.apache.yoko.orb.Messaging.ReplyPriorityPolicy_impl( + throw new PolicyError( + BAD_POLICY_VALUE.value); + return new ReplyPriorityPolicy_impl( v); } - case org.omg.Messaging.ROUTING_POLICY_TYPE.value: { - org.omg.Messaging.RoutingTypeRange v = org.omg.Messaging.RoutingTypeRangeHelper + case ROUTING_POLICY_TYPE.value: { + RoutingTypeRange v = RoutingTypeRangeHelper .extract(any); if (v.min > v.max) - throw new org.omg.CORBA.PolicyError( - org.omg.CORBA.BAD_POLICY_VALUE.value); - return new org.apache.yoko.orb.Messaging.RoutingPolicy_impl(v); + throw new PolicyError( + BAD_POLICY_VALUE.value); + return new RoutingPolicy_impl(v); } - case org.omg.Messaging.MAX_HOPS_POLICY_TYPE.value: { + case MAX_HOPS_POLICY_TYPE.value: { short v = any.extract_ushort(); - return new org.apache.yoko.orb.Messaging.MaxHopsPolicy_impl(v); - } - case org.omg.Messaging.QUEUE_ORDER_POLICY_TYPE.value: { - short v = org.omg.Messaging.OrderingHelper.extract(any); - if (v < org.omg.Messaging.ORDER_ANY.value - || v > org.omg.Messaging.ORDER_DEADLINE.value) - throw new org.omg.CORBA.PolicyError( - org.omg.CORBA.BAD_POLICY_VALUE.value); - return new org.apache.yoko.orb.Messaging.QueueOrderPolicy_impl( + return new MaxHopsPolicy_impl(v); + } + case QUEUE_ORDER_POLICY_TYPE.value: { + short v = OrderingHelper.extract(any); + if (v < ORDER_ANY.value + || v > ORDER_DEADLINE.value) + throw new PolicyError( + BAD_POLICY_VALUE.value); + return new QueueOrderPolicy_impl( v); } } // end of switch - } catch (org.omg.CORBA.BAD_OPERATION ex) { + } catch (BAD_OPERATION ex) { // // Any extraction failure // - throw new org.omg.CORBA.PolicyError( - org.omg.CORBA.BAD_POLICY_TYPE.value); + throw new PolicyError( + BAD_POLICY_TYPE.value); } - throw new org.omg.CORBA.PolicyError(org.omg.CORBA.BAD_POLICY.value); + throw new PolicyError(BAD_POLICY.value); } }