javax.resource.spi.BootstrapContext Java Examples

The following examples show how to use javax.resource.spi.BootstrapContext. 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: ResourceAdapterImpl.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Constructor
 * @param resourceAdapter The resource adapter
 * @param bc The BootstrapContext
 * @param configProperties The configuration properties
 * @param statistics The statistics
 * @param productName The product name
 * @param productVersion The product version
 * @param messageListeners The message listeners
 * @param is16 Is a 1.6+ archive
 * @param beanValidation Bean validation
 * @param bvGroups The bean validation groups
 * @param ti The transaction integration
 */
public ResourceAdapterImpl(javax.resource.spi.ResourceAdapter resourceAdapter,
                           BootstrapContext bc,
                           Collection<ConfigProperty> configProperties,
                           StatisticsPlugin statistics,
                           String productName, String productVersion,
                           Map<String, ActivationSpecImpl> messageListeners,
                           boolean is16, BeanValidation beanValidation, List<String> bvGroups,
                           TransactionIntegration ti)
{
   this.activated = false;
   this.resourceAdapter = resourceAdapter;
   this.bc = bc;
   this.configProperties = configProperties;
   this.statistics = statistics;
   this.productName = productName;
   this.productVersion = productVersion;
   this.messageListeners = messageListeners;
   this.is16 = is16;
   this.beanValidation = beanValidation;
   this.bvGroups = bvGroups;
   this.activeEndpoints = new HashMap<>();
   this.transactionIntegration = ti;
}
 
Example #3
Source File: SpringContextResourceAdapter.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Build a Spring ApplicationContext for the given JCA BootstrapContext.
 * <p>The default implementation builds a {@link ResourceAdapterApplicationContext}
 * and delegates to {@link #loadBeanDefinitions} for actually parsing the
 * specified configuration files.
 * @param bootstrapContext this ResourceAdapter's BootstrapContext
 * @return the Spring ApplicationContext instance
 */
protected ConfigurableApplicationContext createApplicationContext(BootstrapContext bootstrapContext) {
	ResourceAdapterApplicationContext applicationContext =
			new ResourceAdapterApplicationContext(bootstrapContext);

	// Set ResourceAdapter's ClassLoader as bean class loader.
	applicationContext.setClassLoader(getClass().getClassLoader());

	// Extract individual config locations.
	String[] configLocations =
			StringUtils.tokenizeToStringArray(getContextConfigLocation(), CONFIG_LOCATION_DELIMITERS);

	loadBeanDefinitions(applicationContext, configLocations);
	applicationContext.refresh();

	return applicationContext;
}
 
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 java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Build a Spring ApplicationContext for the given JCA BootstrapContext.
 * <p>The default implementation builds a {@link ResourceAdapterApplicationContext}
 * and delegates to {@link #loadBeanDefinitions} for actually parsing the
 * specified configuration files.
 * @param bootstrapContext this ResourceAdapter's BootstrapContext
 * @return the Spring ApplicationContext instance
 */
protected ConfigurableApplicationContext createApplicationContext(BootstrapContext bootstrapContext) {
	ResourceAdapterApplicationContext applicationContext =
			new ResourceAdapterApplicationContext(bootstrapContext);

	// Set ResourceAdapter's ClassLoader as bean class loader.
	applicationContext.setClassLoader(getClass().getClassLoader());

	// Extract individual config locations.
	String[] configLocations =
			StringUtils.tokenizeToStringArray(getContextConfigLocation(), CONFIG_LOCATION_DELIMITERS);

	loadBeanDefinitions(applicationContext, configLocations);
	applicationContext.refresh();

	return applicationContext;
}
 
Example #6
Source File: ResourceAdapterApplicationContext.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
	beanFactory.addBeanPostProcessor(new BootstrapContextAwareProcessor(this.bootstrapContext));
	beanFactory.ignoreDependencyInterface(BootstrapContextAware.class);
	beanFactory.registerResolvableDependency(BootstrapContext.class, this.bootstrapContext);

	// JCA WorkManager resolved lazily - may not be available.
	beanFactory.registerResolvableDependency(WorkManager.class, new ObjectFactory<WorkManager>() {
		@Override
		public WorkManager getObject() {
			return bootstrapContext.getWorkManager();
		}
	});
}
 
Example #7
Source File: ResourceAdapterApplicationContext.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
	beanFactory.addBeanPostProcessor(new BootstrapContextAwareProcessor(this.bootstrapContext));
	beanFactory.ignoreDependencyInterface(BootstrapContextAware.class);
	beanFactory.registerResolvableDependency(BootstrapContext.class, this.bootstrapContext);

	// JCA WorkManager resolved lazily - may not be available.
	beanFactory.registerResolvableDependency(WorkManager.class,
			(ObjectFactory<WorkManager>) this.bootstrapContext::getWorkManager);
}
 
Example #8
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 #9
Source File: ResourceAdapterApplicationContext.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
	beanFactory.addBeanPostProcessor(new BootstrapContextAwareProcessor(this.bootstrapContext));
	beanFactory.ignoreDependencyInterface(BootstrapContextAware.class);
	beanFactory.registerResolvableDependency(BootstrapContext.class, this.bootstrapContext);

	// JCA WorkManager resolved lazily - may not be available.
	beanFactory.registerResolvableDependency(WorkManager.class,
			(ObjectFactory<WorkManager>) this.bootstrapContext::getWorkManager);
}
 
Example #10
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 #11
Source File: ResourceAdapterApplicationContext.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
	beanFactory.addBeanPostProcessor(new BootstrapContextAwareProcessor(this.bootstrapContext));
	beanFactory.ignoreDependencyInterface(BootstrapContextAware.class);
	beanFactory.registerResolvableDependency(BootstrapContext.class, this.bootstrapContext);

	// JCA WorkManager resolved lazily - may not be available.
	beanFactory.registerResolvableDependency(WorkManager.class, new ObjectFactory<WorkManager>() {
		@Override
		public WorkManager getObject() {
			return bootstrapContext.getWorkManager();
		}
	});
}
 
Example #12
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 #13
Source File: SpringContextResourceAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Build a Spring ApplicationContext for the given JCA BootstrapContext.
 * <p>The default implementation builds a {@link ResourceAdapterApplicationContext}
 * and delegates to {@link #loadBeanDefinitions} for actually parsing the
 * specified configuration files.
 * @param bootstrapContext this ResourceAdapter's BootstrapContext
 * @return the Spring ApplicationContext instance
 */
protected ConfigurableApplicationContext createApplicationContext(BootstrapContext bootstrapContext) {
	ResourceAdapterApplicationContext applicationContext =
			new ResourceAdapterApplicationContext(bootstrapContext);
	// Set ResourceAdapter's ClassLoader as bean class loader.
	applicationContext.setClassLoader(getClass().getClassLoader());
	// Extract individual config locations.
	String[] configLocations =
			StringUtils.tokenizeToStringArray(getContextConfigLocation(), CONFIG_LOCATION_DELIMITERS);
	if (configLocations != null) {
		loadBeanDefinitions(applicationContext, configLocations);
	}
	applicationContext.refresh();
	return applicationContext;
}
 
Example #14
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 #15
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 #16
Source File: SpringContextResourceAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Build a Spring ApplicationContext for the given JCA BootstrapContext.
 * <p>The default implementation builds a {@link ResourceAdapterApplicationContext}
 * and delegates to {@link #loadBeanDefinitions} for actually parsing the
 * specified configuration files.
 * @param bootstrapContext this ResourceAdapter's BootstrapContext
 * @return the Spring ApplicationContext instance
 */
protected ConfigurableApplicationContext createApplicationContext(BootstrapContext bootstrapContext) {
	ResourceAdapterApplicationContext applicationContext =
			new ResourceAdapterApplicationContext(bootstrapContext);
	// Set ResourceAdapter's ClassLoader as bean class loader.
	applicationContext.setClassLoader(getClass().getClassLoader());
	// Extract individual config locations.
	String[] configLocations =
			StringUtils.tokenizeToStringArray(getContextConfigLocation(), CONFIG_LOCATION_DELIMITERS);
	if (configLocations != null) {
		loadBeanDefinitions(applicationContext, configLocations);
	}
	applicationContext.refresh();
	return applicationContext;
}
 
Example #17
Source File: JCABusFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public WorkManager getWorkManager() {
    if (getBootstrapContext() instanceof BootstrapContext) {
        BootstrapContext context = (BootstrapContext)getBootstrapContext();
        return context.getWorkManager();
    }
    return null;
}
 
Example #18
Source File: ResourceAdapterImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetCorrectBootstrapContext() throws Exception {
    ResourceAdapterImpl rai = new ResourceAdapterImpl();
    BootstrapContext bc = EasyMock.createMock(BootstrapContext.class);
    assertNotNull("BootstrapContext not null", bc);
    rai.start(bc);
    assertEquals("BootstrapContext set", rai.getBootstrapContext(), bc);
}
 
Example #19
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 #20
Source File: CustomBootstrapAndWorkmanagerTestCase.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Deployment
 * @throws Throwable In case of an error
 */
@Test
public void testDeployment() throws Throwable
{
   assertNotNull(cf);
   assertNotNull(cf2);

   TestConnection conn = cf.getConnection();
   assertNotNull(conn);
   TestConnection conn2 = cf2.getConnection();
   assertNotNull(conn2);

   assertNotEquals(conn, conn2);

   assertNotEquals(conn.getWorkManager(), conn2.getWorkManager());
   assertEquals("Default", conn.getWorkManagerName());
   assertEquals("WorkManager2", conn2.getWorkManagerName());

   assertTrue(conn.getBootstrapContext() instanceof BootstrapContext);
   assertTrue(conn.getBootstrapContext() instanceof org.ironjacamar.core.api.bootstrapcontext.BootstrapContext);
   assertTrue(conn.getBootstrapContext() instanceof CloneableBootstrapContext);
   assertTrue(conn2.getBootstrapContext() instanceof BootstrapContext);
   assertTrue(conn2.getBootstrapContext() instanceof org.ironjacamar.core.api.bootstrapcontext.BootstrapContext);
   assertTrue(conn2.getBootstrapContext() instanceof CloneableBootstrapContext);

   assertNotEquals(((CloneableBootstrapContext) conn.getBootstrapContext()).getId(),
         ((CloneableBootstrapContext) conn2.getBootstrapContext()).getId());
   assertNotEquals(((CloneableBootstrapContext) conn.getBootstrapContext()).getName(),
         ((CloneableBootstrapContext) conn2.getBootstrapContext()).getName());
   assertEquals(conn.getBootstrapContext().getTransactionSynchronizationRegistry(),
         conn2.getBootstrapContext().getTransactionSynchronizationRegistry());

   conn.close();
   conn2.close();

}
 
Example #21
Source File: BootstrapContextTestCase.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Deployment
 * @throws Throwable In case of an error
 */
@Test
public void testDeployment() throws Throwable
{
   assertNotNull(cf);
   assertNotNull(cf2);

   TestConnection conn = cf.getConnection();
   assertNotNull(conn);
   TestConnection conn2 = cf2.getConnection();
   assertNotNull(conn2);

   assertNotEquals(conn, conn2);

   assertEquals(conn.getWorkManager(), conn2.getWorkManager());

   assertTrue(conn.getBootstrapContext() instanceof BootstrapContext);
   assertTrue(conn.getBootstrapContext() instanceof org.ironjacamar.core.api.bootstrapcontext.BootstrapContext);
   assertTrue(conn.getBootstrapContext() instanceof CloneableBootstrapContext);

   assertEquals(((CloneableBootstrapContext) conn.getBootstrapContext()).getId(),
         ((CloneableBootstrapContext) conn2.getBootstrapContext()).getId());
   assertEquals(((CloneableBootstrapContext) conn.getBootstrapContext()).getName(),
         ((CloneableBootstrapContext) conn2.getBootstrapContext()).getName());
   assertEquals(conn.getBootstrapContext().getTransactionSynchronizationRegistry(),
         conn2.getBootstrapContext().getTransactionSynchronizationRegistry());

   conn.close();
   conn2.close();
}
 
Example #22
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 #23
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 #24
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 #25
Source File: ResourceAdapterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public BootstrapContext getBootstrapContext() {
    return ctx;
}
 
Example #26
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 #27
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 #28
Source File: TestConnectionImpl.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public BootstrapContext getBootstrapContext()
{
   return mc.getBootstrapContext();
}
 
Example #29
Source File: BootstrapContextAwareProcessor.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Create a new BootstrapContextAwareProcessor for the given context.
 */
public BootstrapContextAwareProcessor(@Nullable BootstrapContext bootstrapContext) {
	this.bootstrapContext = bootstrapContext;
}
 
Example #30
Source File: TestManagedConnection.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * get BootstrapContext
 * @return BootstrapContext
 */
BootstrapContext getBootstrapContext()
{
   return ((TestResourceAdapter)mcf.getResourceAdapter()).getBootstrapContext();
}