@Override public void validate() throws InvalidPropertyException { if (bootstrapServersConfig == null) { throw new InvalidPropertyException("bootstrapServersConfig is a mandatory property"); } if (keyDeserializer == null) { throw new InvalidPropertyException("keyDeserializer is a mandatory property"); } if (valueDeserializer == null) { throw new InvalidPropertyException("valueDeserializer is a mandatory property"); } }
private static void buildAndThrowExceptionIfNeeded(List<PropertyDescriptor> propsNotSet, List<String> errorMessages) throws InvalidPropertyException { if (propsNotSet.size() > 0) { StringBuffer b = new StringBuffer(); b.append("Invalid settings:"); for (String errorMessage : errorMessages) { b.append(" "); b.append(errorMessage); } InvalidPropertyException e = new InvalidPropertyException(b.toString()); final PropertyDescriptor[] descriptors = propsNotSet.toArray(new PropertyDescriptor[propsNotSet.size()]); e.setInvalidPropertyDescriptors(descriptors); throw e; } } }
@Test public void testBadDestinationType() throws Exception { ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter(); MyBootstrapContext ctx = new MyBootstrapContext(); qResourceAdapter.start(ctx); ActiveMQActivationSpec spec = new ActiveMQActivationSpec(); spec.setResourceAdapter(qResourceAdapter); spec.setUseJNDI(false); spec.setDestinationType("badDestinationType"); spec.setDestination("mdbTopic"); spec.setSetupAttempts(1); spec.setShareSubscriptions(true); spec.setMaxSession(1); CountDownLatch latch = new CountDownLatch(5); DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch); DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false); try { qResourceAdapter.endpointActivation(endpointFactory, spec); fail(); } catch (Exception e) { assertTrue(e instanceof InvalidPropertyException); assertEquals("destinationType", ((InvalidPropertyException) e).getInvalidPropertyDescriptors()[0].getName()); } }
@Test public void testNullSubscriptionName() throws Exception { ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter(); MyBootstrapContext ctx = new MyBootstrapContext(); qResourceAdapter.start(ctx); ActiveMQActivationSpec spec = new ActiveMQActivationSpec(); spec.setResourceAdapter(qResourceAdapter); spec.setUseJNDI(false); spec.setDestination("mdbTopic"); spec.setSubscriptionDurability("Durable"); spec.setClientID("id-1"); spec.setSetupAttempts(1); spec.setShareSubscriptions(true); spec.setMaxSession(1); CountDownLatch latch = new CountDownLatch(5); DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch); DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false); try { qResourceAdapter.endpointActivation(endpointFactory, spec); fail(); } catch (Exception e) { assertTrue(e instanceof InvalidPropertyException); assertEquals("subscriptionName", ((InvalidPropertyException) e).getInvalidPropertyDescriptors()[0].getName()); } }
@Override public void validate() throws InvalidPropertyException { if (topicFilter == null) { throw new InvalidPropertyException("Topic Filter can not be null"); } }
private static void buildAndThrowExceptionIfNeeded(List<PropertyDescriptor> propsNotSet, List<String> errorMessages) throws InvalidPropertyException { if (propsNotSet.size() > 0) { StringBuffer b = new StringBuffer(); b.append("Invalid settings:"); for (String errorMessage : errorMessages) { b.append(" "); b.append(errorMessage); } InvalidPropertyException e = new InvalidPropertyException(b.toString()); final PropertyDescriptor[] descriptors = propsNotSet.toArray(new PropertyDescriptor[propsNotSet.size()]); e.setInvalidPropertyDescriptors(descriptors); throw e; } } }
@Override public void validate() throws InvalidPropertyException { if (region == null) { throw new InvalidPropertyException("region must be specified"); } if (awsAccessKeyId == null) { throw new InvalidPropertyException("awsAccessKeyId must be specified"); } if (awsSecretKey == null) { throw new InvalidPropertyException("awsSecretKey must be specified"); } if (queueURL == null) { throw new InvalidPropertyException("queueURL must be specified"); } }
/** * Set the JDBC connection URL. * This URL is passed directly to the Driver and should contain any properties * required to configure the connection. * * @param url the JDBC connection URL * @throws javax.resource.spi.InvalidPropertyException if url missing */ public void setConnectionURL(String url) throws InvalidPropertyException { if (url == null || url.length() == 0) { throw new InvalidPropertyException("Empty connection URL"); } this.url = url; }
@Override public void validate() throws InvalidPropertyException { if (nameSpace == null || nameSpace.isEmpty()) { throw new InvalidPropertyException("NameSpace can not be emtpy"); } if (sasKeyName == null || sasKeyName.isEmpty()) { throw new InvalidPropertyException("sasKeyName can not be emtpy"); } if (sasKey == null || sasKey.isEmpty()) { throw new InvalidPropertyException("sasKey can not be emtpy"); } if (queueName == null || queueName.isEmpty()) { throw new InvalidPropertyException("sasKey can not be emtpy"); } }
@Override public void validate() throws InvalidPropertyException { if (nameSpace == null || nameSpace.isEmpty()) { throw new InvalidPropertyException("NameSpace can not be emtpy"); } if (sasKeyName == null || sasKeyName.isEmpty()) { throw new InvalidPropertyException("sasKeyName can not be emtpy"); } if (sasKey == null || sasKey.isEmpty()) { throw new InvalidPropertyException("sasKey can not be emtpy"); } if (queueName == null || queueName.isEmpty()) { throw new InvalidPropertyException("sasKey can not be emtpy"); } }
/** * This method may be called by a deployment tool to validate the overall * activation configuration information provided by the endpoint deployer. * * @throws InvalidPropertyException * indicates invalid configuration property settings. */ public void validate() throws InvalidPropertyException { log.finest("validate()"); if (this.address == null || this.address.length() == 0) { throw new InvalidPropertyException("Address must be specified."); } }
public void validate() throws InvalidPropertyException { if (log.isTraceEnabled()) { log.trace("validate " + this); } if (destination == null || destination.trim().equals("")) { throw new InvalidPropertyException("destination is mandatory"); } if (connectionFactory == null || connectionFactory.trim().equals("")) { throw new InvalidPropertyException("connectionFactory is mandatory"); } }
/** * Set the name of the ExceptionSorter implementation so use. * * @param className the class name of an ExceptionSorter to use * * @throws InvalidPropertyException if the class name is null or empty */ public void setExceptionSorterClass(String className) throws InvalidPropertyException { if (className == null || className.length() == 0) { throw new InvalidPropertyException("Empty class name"); } try { Class<ExceptionSorter> clazz = (Class<ExceptionSorter>) loadClass(className); exceptionSorter = clazz.newInstance(); } catch (ClassNotFoundException e) { throw new InvalidPropertyException("Unable to load class: " + className, e); } catch (IllegalAccessException e) { throw new InvalidPropertyException("Unable to instantiate class: " + className, e); } catch (InstantiationException e) { throw new InvalidPropertyException("Unable to instantiate class: " + className, e); } catch (ClassCastException e) { throw new InvalidPropertyException("Class is not a "+ ExceptionSorter.class.getName() + ": " + driver, e); } }
public void validate() throws InvalidPropertyException { Iterator iter = fileNamesAndInterests.values().iterator(); while (iter.hasNext()) { String interest = (String) iter.next(); try { Integer.valueOf(interest); } catch (NumberFormatException nfe) { throw new InvalidPropertyException("Invalid event-interest specification : " + interest); } } }
/** * Set the name of the Driver class * * @param driver the name of the Driver class * * @throws InvalidPropertyException if the class name is null or empty */ public void setDriver(String driver) throws InvalidPropertyException { if (driver == null || driver.length() == 0) { throw new InvalidPropertyException("Empty driver class name"); } try { Class<Driver> driverClass = (Class<Driver>) loadClass(driver); this.driver = driverClass.newInstance(); } catch (ClassNotFoundException e) { throw new InvalidPropertyException("Unable to load driver class: " + driver, e); } catch (InstantiationException e) { throw new InvalidPropertyException("Unable to instantiate driver class: " + driver, e); } catch (IllegalAccessException e) { throw new InvalidPropertyException("Unable to instantiate driver class: " + driver, e); } catch (ClassCastException e) { throw new InvalidPropertyException("Class is not a "+ Driver.class.getName() + ": " + driver, e); } }
/** * Validate * @exception InvalidPropertyException Thrown if a validation exception occurs */ public void validate() throws InvalidPropertyException { if (_log.isTraceEnabled()) { _log.trace("validate()"); } if (_destination == null || _destination.trim().equals("")) { throw new InvalidPropertyException("Destination is mandatory"); } }
/** * Checks if the configuration information is valid. * * @exception InvalidPropertyException If a parameter is missing, incorrect, * or not consistent with other * parameters. */ public void validate() throws InvalidPropertyException { if (destinationType != null && ! destinationType.equals("javax.jms.Queue") && ! destinationType.equals("javax.jms.Topic")) throw new InvalidPropertyException("Invalid destination type: " + destinationType); if (destination == null) throw new InvalidPropertyException("Missing destination property."); if (acknowledgeMode != null && ! acknowledgeMode.equals(AUTO_ACKNOWLEDGE) && ! acknowledgeMode.equals(DUPS_OK_ACKNOWLEDGE)) throw new InvalidPropertyException("Invalid acknowledge mode: " + acknowledgeMode); if (subscriptionDurability != null) { if (subscriptionDurability.equals("Durable") && destinationType.equals("javax.jms.Queue")) throw new InvalidPropertyException("Can't set a durable subscription " + "on a JMS queue."); if (subscriptionDurability.equals("Durable") && subscriptionName == null) throw new InvalidPropertyException("Missing durable subscription name."); } }
public void setLoginTimeout(Integer timeout) throws ResourceException { try { dataSource.setLoginTimeout(timeout.intValue()); } catch (SQLException e) { throw new InvalidPropertyException(e.getMessage()); } }
public void setLoginTimeout(Integer timeout) throws ResourceException { try { xaDataSource.setLoginTimeout(timeout); } catch (SQLException e) { throw new InvalidPropertyException(e.getMessage()); } }
public void setCronExpression(String s) { try { trigger.setCronExpression(s); } catch (ParseException e) { invalidProperty = new InvalidPropertyException("Invalid cron expression " + s, e); } }