1 package org.jacorb.notification.util; 2 3 22 23 import java.util.ArrayList ; 24 import java.util.Collections ; 25 import java.util.HashSet ; 26 import java.util.List ; 27 import java.util.Set ; 28 29 import org.apache.avalon.framework.configuration.Configuration; 30 import org.jacorb.notification.conf.Attributes; 31 import org.jacorb.notification.conf.Default; 32 import org.omg.CORBA.Any ; 33 import org.omg.CosNotification.MaxConsumers; 34 import org.omg.CosNotification.MaxQueueLength; 35 import org.omg.CosNotification.MaxSuppliers; 36 import org.omg.CosNotification.Property; 37 import org.omg.CosNotification.PropertyError; 38 import org.omg.CosNotification.RejectNewEvents; 39 import org.omg.CosNotification.UnsupportedAdmin; 40 41 45 46 public class AdminPropertySet 47 extends PropertySet { 48 49 private final static Set sAdminPropertyNames_; 50 51 private final Property[] defaultProperties_; 52 53 static { 54 HashSet _adminProps = new HashSet (); 55 56 _adminProps.add(MaxQueueLength.value); 57 _adminProps.add(MaxConsumers.value); 58 _adminProps.add(MaxSuppliers.value); 59 _adminProps.add(RejectNewEvents.value); 60 61 sAdminPropertyNames_ = Collections.unmodifiableSet(_adminProps); 62 } 63 64 66 private final Set validNames_ = sAdminPropertyNames_; 67 68 70 public AdminPropertySet(Configuration config) 71 { 72 super(); 73 74 int _maxConsumersDefault = 75 config.getAttributeAsInteger(Attributes.MAX_NUMBER_CONSUMERS, 76 Default.DEFAULT_MAX_NUMBER_CONSUMERS); 77 78 Any _maxConsumersDefaultAny = sORB.create_any(); 79 _maxConsumersDefaultAny.insert_long( _maxConsumersDefault ); 80 81 83 int _maxSuppliersDefault = 84 config.getAttributeAsInteger(Attributes.MAX_NUMBER_SUPPLIERS, 85 Default.DEFAULT_MAX_NUMBER_SUPPLIERS); 86 87 Any _maxSuppliersDefaultAny = sORB.create_any(); 88 _maxSuppliersDefaultAny.insert_long(_maxSuppliersDefault); 89 90 92 int _maxQueueLength = 93 config.getAttributeAsInteger(Attributes.MAX_QUEUE_LENGTH, 94 Default.DEFAULT_MAX_QUEUE_LENGTH); 95 96 Any _maxQueueLengthAny = sORB.create_any(); 97 _maxQueueLengthAny.insert_long(_maxQueueLength); 98 99 101 boolean _rejectNewEvents = 102 config.getAttribute(Attributes.REJECT_NEW_EVENTS, 103 Default.DEFAULT_REJECT_NEW_EVENTS).equals("on"); 104 105 Any _rejectNewEventsAny = sORB.create_any(); 106 _rejectNewEventsAny.insert_boolean(_rejectNewEvents); 107 108 110 defaultProperties_ = new Property[] { 111 new Property(MaxConsumers.value, _maxConsumersDefaultAny), 112 new Property(MaxSuppliers.value, _maxSuppliersDefaultAny), 113 new Property(MaxQueueLength.value, _maxQueueLengthAny), 114 new Property(RejectNewEvents.value, _rejectNewEventsAny) 115 }; 116 117 set_admin(defaultProperties_); 118 } 119 120 121 public Set getValidNames() 122 { 123 return validNames_; 124 } 125 126 127 public void set_admin(Property[] ps) 128 { 129 set_properties(ps); 130 } 131 132 133 public Property[] get_admin() 134 { 135 return toArray(); 136 } 137 138 139 public void validate_admin(Property[] ps) throws UnsupportedAdmin 140 { 141 List _errors = new ArrayList (); 142 143 checkPropertyExistence(ps, _errors); 144 145 if (!_errors.isEmpty()) 146 { 147 throw new UnsupportedAdmin((PropertyError[])_errors.toArray(PROPERTY_ERROR_ARRAY_TEMPLATE)); 148 } 149 } 150 } 151 | Popular Tags |