Search in sources :

Example 6 with InvalidPropertyException

use of javax.resource.spi.InvalidPropertyException in project teiid by teiid.

the class CouchbaseManagedConnectionFactory method createConnectionFactory.

@SuppressWarnings("serial")
@Override
public BasicConnectionFactory<CouchbaseConnectionImpl> createConnectionFactory() throws ResourceException {
    final CouchbaseEnvironment environment = DefaultCouchbaseEnvironment.builder().managementTimeout(managementTimeout).queryTimeout(queryTimeout).viewTimeout(viewTimeout).kvTimeout(kvTimeout).searchTimeout(searchTimeout).connectTimeout(connectTimeout).dnsSrvEnabled(dnsSrvEnabled).build();
    if (this.connectionString == null) {
        // $NON-NLS-1$
        throw new InvalidPropertyException(UTIL.getString("no_server"));
    }
    if (this.keyspace == null) {
        // $NON-NLS-1$
        throw new InvalidPropertyException(UTIL.getString("no_keyspace"));
    }
    if (this.namespace == null) {
        // $NON-NLS-1$
        throw new InvalidPropertyException(UTIL.getString("no_namespace"));
    }
    final ScanConsistency consistency = ScanConsistency.valueOf(scanConsistency);
    TimeUnit unit = TimeUnit.MILLISECONDS;
    if (this.timeUnit != null) {
        try {
            unit = TimeUnit.valueOf(timeUnit);
        } catch (IllegalArgumentException e) {
            // $NON-NLS-1$
            throw new InvalidPropertyException(UTIL.getString("invalid_timeUnit", timeUnit));
        }
    }
    final TimeUnit timeoutUnit = unit;
    return new BasicConnectionFactory<CouchbaseConnectionImpl>() {

        @Override
        public CouchbaseConnectionImpl getConnection() throws ResourceException {
            return new CouchbaseConnectionImpl(environment, connectionString, keyspace, password, timeoutUnit, namespace, consistency);
        }
    };
}
Also used : BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) InvalidPropertyException(javax.resource.spi.InvalidPropertyException) ScanConsistency(com.couchbase.client.java.query.consistency.ScanConsistency) TimeUnit(java.util.concurrent.TimeUnit) DefaultCouchbaseEnvironment(com.couchbase.client.java.env.DefaultCouchbaseEnvironment) CouchbaseEnvironment(com.couchbase.client.java.env.CouchbaseEnvironment)

Example 7 with InvalidPropertyException

use of javax.resource.spi.InvalidPropertyException in project tomee by apache.

the class JobSpec method validate.

// -- ActivationSpec methods
@SuppressWarnings("unchecked")
@Override
public void validate() throws InvalidPropertyException {
    if (invalidProperty != null) {
        throw invalidProperty;
    }
    final int i = hashCode();
    detail = JobBuilder.newJob(QuartzResourceAdapter.JobEndpoint.class).withIdentity("Job" + i, Scheduler.DEFAULT_GROUP).withDescription(description).requestRecovery(recoverable).storeDurably(durable).build();
    final TriggerBuilder tb = TriggerBuilder.newTrigger().forJob(detail).withIdentity("Trigger" + i, Scheduler.DEFAULT_GROUP).withDescription(description);
    if (startTime != null) {
        tb.startAt(parse(startTime));
    }
    if (endTime != null) {
        tb.endAt(parse(endTime));
    }
    if (calendarName != null) {
        tb.modifiedByCalendar(calendarName);
    }
    final CronScheduleBuilder csb = CronScheduleBuilder.cronSchedule(getCronExpression());
    if (timeZone != null) {
        csb.inTimeZone(TimeZone.getTimeZone(timeZone));
    }
    trigger = tb.withSchedule(csb).build();
    try {
        ((CronTriggerImpl) trigger).validate();
    } catch (final SchedulerException e) {
        throw new InvalidPropertyException(e);
    }
}
Also used : CronScheduleBuilder(org.apache.openejb.quartz.CronScheduleBuilder) SchedulerException(org.apache.openejb.quartz.SchedulerException) InvalidPropertyException(javax.resource.spi.InvalidPropertyException) CronTriggerImpl(org.apache.openejb.quartz.impl.triggers.CronTriggerImpl) TriggerBuilder(org.apache.openejb.quartz.TriggerBuilder) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint)

Example 8 with InvalidPropertyException

use of javax.resource.spi.InvalidPropertyException in project wildfly by wildfly.

the class TelnetActivationSpec method validate.

@Override
public void validate() throws InvalidPropertyException {
    if (beanClassName == null)
        throw new InvalidPropertyException("beanClass is null");
    final Class<?> beanClass = beanClass();
    // Set Prompt
    final Prompt prompt = beanClass.getAnnotation(Prompt.class);
    if (prompt != null) {
        this.prompt = prompt.value();
    }
    // Get Commands
    final Method[] methods = beanClass.getMethods();
    for (Method method : methods) {
        if (method.isAnnotationPresent(Command.class)) {
            final Command command = method.getAnnotation(Command.class);
            cmds.add(new Cmd(command.value(), method));
        }
    }
    // Validate
    if (this.prompt == null || this.prompt.length() == 0) {
        this.prompt = "prompt>";
    }
    if (this.cmds.size() == 0) {
        throw new InvalidPropertyException("No @Command methods");
    }
}
Also used : Command(org.jboss.as.test.integration.ejb.mdb.dynamic.api.Command) InvalidPropertyException(javax.resource.spi.InvalidPropertyException) Prompt(org.jboss.as.test.integration.ejb.mdb.dynamic.api.Prompt) Method(java.lang.reflect.Method) Cmd(org.jboss.as.test.integration.ejb.mdb.dynamic.impl.Cmd)

Aggregations

InvalidPropertyException (javax.resource.spi.InvalidPropertyException)8 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 JMSException (javax.jms.JMSException)2 ResourceException (javax.resource.ResourceException)2 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)2 ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)2 ActiveMQActivationSpec (org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec)2 Test (org.junit.Test)2 BasicConnectionFactory (org.teiid.resource.spi.BasicConnectionFactory)2 CouchbaseEnvironment (com.couchbase.client.java.env.CouchbaseEnvironment)1 DefaultCouchbaseEnvironment (com.couchbase.client.java.env.DefaultCouchbaseEnvironment)1 ScanConsistency (com.couchbase.client.java.query.consistency.ScanConsistency)1 ServerAddress (com.mongodb.ServerAddress)1 IntrospectionException (java.beans.IntrospectionException)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 File (java.io.File)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1