javax.resource.spi.ResourceAdapterInternalException Java Examples

The following examples show how to use javax.resource.spi.ResourceAdapterInternalException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JcaExecutorServiceConnector.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {

    try {
      Class.forName(ORG_CAMUNDA_BPM_ENGINE_PROCESS_ENGINE);
    } catch (Exception e) {
      log.info("ProcessEngine classes not found in shared libraries. Not initializing camunda Platform JobExecutor Resource Adapter.");
      return;
    }

    // initialize the ExecutorService (CommonJ or JCA, depending on configuration)
    if(isUseCommonJWorkManager) {
      if(commonJWorkManagerName != null & commonJWorkManagerName.length() > 0) {
        executorServiceWrapper.setExecutorService(new CommonJWorkManagerExecutorService(this, commonJWorkManagerName));
      } else {
        throw new RuntimeException("Resource Adapter configuration property 'isUseCommonJWorkManager' is set to true but 'commonJWorkManagerName' is not provided.");
      }

    } else {
      executorServiceWrapper.setExecutorService(new JcaWorkManagerExecutorService(this, ctx.getWorkManager()));
    }

    log.log(Level.INFO, "camunda BPM executor service started.");
  }
 
Example #2
Source File: ManagedConnectionFactoryImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void validateReference(AbstractManagedConnectionImpl conn, Subject subject)
    throws ResourceAdapterInternalException {
    boolean valid = true;

    try {
        if (conn.getConnection(null, null) != null) {
            valid = false;
        }
    } catch (ResourceException ignored) {
        // do nothing here
    }

    if (!valid) {
        throw new ResourceAdapterInternalException("invalid");
    }
}
 
Example #3
Source File: AbstractManagedConnectionFactoryImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean isMatch(final AbstractManagedConnectionImpl candidateConn,
                        final ConnectionRequestInfo crInfo, final Subject subject)
    throws ResourceAdapterInternalException {
    boolean result = false;
    final ConnectionRequestInfo candidate = candidateConn.getConnectionRequestInfo();

    if (candidate.equals(crInfo) && (subject == null || subject.equals(candidateConn.getSubject()))) {
        try {
            validateReference(candidateConn, subject);
            result = true;
        } catch (Exception thrown) {
            result = false;
        }
    }

    return result;
}
 
Example #4
Source File: ActiveMQResourceAdapter.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Start
 *
 * @param ctx The bootstrap context
 * @throws ResourceAdapterInternalException Thrown if an error occurs
 */
@Override
public void start(final BootstrapContext ctx) throws ResourceAdapterInternalException {
   if (logger.isTraceEnabled()) {
      logger.trace("start(" + ctx + ")");
   }

   tm = ServiceUtils.getTransactionManager();

   recoveryManager.start(useAutoRecovery);

   this.ctx = ctx;

   if (!configured.getAndSet(true)) {
      try {
         setup();
      } catch (ActiveMQException e) {
         throw new ResourceAdapterInternalException("Unable to create activation", e);
      }
   }

   ActiveMQRALogger.LOGGER.resourceAdaptorStarted();
}
 
Example #5
Source File: SpringContextResourceAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * This implementation loads a Spring ApplicationContext through the
 * {@link #createApplicationContext} template method.
 */
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
	if (logger.isDebugEnabled()) {
		logger.debug("Starting SpringContextResourceAdapter with BootstrapContext: " + bootstrapContext);
	}
	this.applicationContext = createApplicationContext(bootstrapContext);
}
 
Example #6
Source File: MdbConfigTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
    assertFalse("Already started", started);
    assertNotNull("bootstrapContext is null", bootstrapContext);
    assertNotNull("bootstrapContext.getWorkManager() is null", bootstrapContext.getWorkManager());
    assertNotNull("bootstrapContext.getXATerminator() is null", bootstrapContext.getXATerminator());
    try {
        assertNotNull("bootstrapContext.createTimer() is null", bootstrapContext.createTimer());
    } catch (final UnavailableException e) {
        throw new ResourceAdapterInternalException("bootstrapContext.createTimer() threw an exception", e);
    }
}
 
Example #7
Source File: TestResourceAdapter.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void start(BootstrapContext ctx)
      throws ResourceAdapterInternalException
{
   this.bc = (CloneableBootstrapContext) ctx;
   this.workManager = ctx.getWorkManager();
}
 
Example #8
Source File: ManagedConnectionImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssociateConnectionThrowsException() throws Throwable {

    InvocationHandler ih = EasyMock.createMock(InvocationHandler.class);

    Object dodgyHandle = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {Foo.class}, ih);

    try {
        mci.associateConnection(dodgyHandle);
        fail("Except exception on call with ClassCast Exception");
    } catch (ResourceAdapterInternalException raie) {
        // expected
    }

}
 
Example #9
Source File: InvocationHandlerFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    super.setUp();
    testSubject = new Subject();
    try {
        InvocationHandlerFactory factory = new InvocationHandlerFactory(mockBus, mci);
        handler = factory.createHandlers(target, testSubject);
    } catch (ResourceAdapterInternalException e) {
        fail();
    }
}
 
Example #10
Source File: ResourceAdapterImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void start(BootstrapContext aCtx) throws ResourceAdapterInternalException {
    LOG.fine("Resource Adapter is starting by appserver...");
    if (aCtx == null) {
        throw new ResourceAdapterInternalException("BootstrapContext can not be null");
    }
    this.ctx = aCtx;
}
 
Example #11
Source File: JmsTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();

    // create a transaction manager
    final GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();

    // create the ActiveMQ resource adapter instance
    ra = new ActiveMQResourceAdapter();

    // initialize properties
    ra.setServerUrl(brokerAddress);
    ra.setBrokerXmlConfig(brokerXmlConfig);
    ra.setStartupTimeout(new Duration(10, TimeUnit.SECONDS));

    // create a thead pool for ActiveMQ
    final Executor threadPool = Executors.newFixedThreadPool(30);

    // create a work manager which ActiveMQ uses to dispatch message delivery jobs
    final TransactionContextHandler txWorkContextHandler = new TransactionContextHandler(transactionManager);
    final GeronimoWorkManager workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, Collections.<WorkContextHandler>singletonList(txWorkContextHandler));

    // wrap the work mananger and transaction manager in a bootstrap context (connector spec thing)
    final BootstrapContext bootstrapContext = new GeronimoBootstrapContext(workManager, transactionManager, transactionManager);

    // Create a ConnectionFactory
    connectionFactory = new ActiveMQConnectionFactory(brokerAddress);
    ra.setConnectionFactory(connectionFactory);

    // start the resource adapter
    try {
        ra.start(bootstrapContext);
    } catch (final ResourceAdapterInternalException e) {
        throw new OpenEJBException(e);
    }
}
 
Example #12
Source File: SpringContextResourceAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * This implementation loads a Spring ApplicationContext through the
 * {@link #createApplicationContext} template method.
 */
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
	if (logger.isInfoEnabled()) {
		logger.info("Starting SpringContextResourceAdapter with BootstrapContext: " + bootstrapContext);
	}
	this.applicationContext = createApplicationContext(bootstrapContext);
}
 
Example #13
Source File: XAMCF.java    From dacapobench with Apache License 2.0 5 votes vote down vote up
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
    CredentialExtractor credentialExtractor = new CredentialExtractor(subject, connectionRequestInfo, this);

    XAConnection sqlConnection = getPhysicalConnection(subject, credentialExtractor);
    try {
        return new ManagedXAConnection(this, sqlConnection, credentialExtractor, exceptionSorter);
    } catch (SQLException e) {
        throw new ResourceAdapterInternalException("Could not set up ManagedXAConnection", e);
    }
}
 
Example #14
Source File: SpringContextResourceAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * This implementation loads a Spring ApplicationContext through the
 * {@link #createApplicationContext} template method.
 */
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
	if (logger.isDebugEnabled()) {
		logger.debug("Starting SpringContextResourceAdapter with BootstrapContext: " + bootstrapContext);
	}
	this.applicationContext = createApplicationContext(bootstrapContext);
}
 
Example #15
Source File: SpringContextResourceAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This implementation loads a Spring ApplicationContext through the
 * {@link #createApplicationContext} template method.
 */
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
	if (logger.isInfoEnabled()) {
		logger.info("Starting SpringContextResourceAdapter with BootstrapContext: " + bootstrapContext);
	}
	this.applicationContext = createApplicationContext(bootstrapContext);
}
 
Example #16
Source File: ActiveMQResourceAdapter.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {

    this.bootstrapContext = bootstrapContext;
    final String brokerXmlConfig = getBrokerXmlConfig();
    super.setBrokerXmlConfig(null);
    super.start(bootstrapContext);

    final Properties properties = new Properties();

    if (null != this.dataSource) {
        properties.put("DataSource", this.dataSource);
    }

    if (null != this.useDatabaseLock) {
        properties.put("UseDatabaseLock", this.useDatabaseLock);
    }

    if (null != this.startupTimeout) {
        properties.put("StartupTimeout", this.startupTimeout);
    }

    // prefix server uri with 'broker:' so our broker factory is used
    if (brokerXmlConfig != null && !brokerXmlConfig.trim().isEmpty()) {

        try {

            if (brokerXmlConfig.startsWith("broker:")) {

                final URISupport.CompositeData compositeData = URISupport.parseComposite(URLs.uri(brokerXmlConfig));

                if (!compositeData.getParameters().containsKey("persistent")) {
                    //Override default - Which is 'true'
                    //noinspection unchecked
                    compositeData.getParameters().put("persistent", "false");
                }

                if ("false".equalsIgnoreCase(compositeData.getParameters().get("persistent").toString())) {
                    properties.remove("DataSource"); // no need
                }

                setBrokerXmlConfig(ActiveMQFactory.getBrokerMetaFile() + compositeData.toURI());
            } else if (brokerXmlConfig.toLowerCase(Locale.ENGLISH).startsWith("xbean:")) {
                setBrokerXmlConfig(ActiveMQFactory.getBrokerMetaFile() + brokerXmlConfig);
            }

        } catch (final URISyntaxException e) {
            throw new ResourceAdapterInternalException("Invalid BrokerXmlConfig", e);
        }

        createInternalBroker(brokerXmlConfig, properties);
    }
}
 
Example #17
Source File: AutoConnectionTrackerTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #18
Source File: StubResourceAdapter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #19
Source File: GetterConnectorTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final BootstrapContext ctx) throws ResourceAdapterInternalException {
    // no-op
}
 
Example #20
Source File: AutoConfigMdbContainerTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #21
Source File: ConnectorProxyNoNoArgConstructorTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final BootstrapContext ctx) throws ResourceAdapterInternalException {
    // no-op
}
 
Example #22
Source File: ConnectorProxyTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final BootstrapContext ctx) throws ResourceAdapterInternalException {
    // no-op
}
 
Example #23
Source File: AnnotationDeployerTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(final BootstrapContext ctx) throws ResourceAdapterInternalException {
}
 
Example #24
Source File: CustomMdbContainerTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #25
Source File: FakeResourceAdapter.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #26
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #27
Source File: NoMessageDeliveryTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #28
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #29
Source File: SampleResourceAdapter.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
 
Example #30
Source File: ManagedConnectionFactoryImplTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void close() throws ResourceAdapterInternalException {
    // do nothing here
}