当前位置: 首页>>代码示例>>Java>>正文


Java WorkManager类代码示例

本文整理汇总了Java中javax.resource.spi.work.WorkManager的典型用法代码示例。如果您正苦于以下问题:Java WorkManager类的具体用法?Java WorkManager怎么用?Java WorkManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WorkManager类属于javax.resource.spi.work包,在下文中一共展示了WorkManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWorkManager

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Obtain the default JBoss JCA WorkManager through a JMX lookup
 * for the JBossWorkManagerMBean.
 * @param mbeanName the JMX object name to use
 * @see org.jboss.resource.work.JBossWorkManagerMBean
 */
public static WorkManager getWorkManager(String mbeanName) {
	Assert.hasLength(mbeanName, "JBossWorkManagerMBean name must not be empty");
	try {
		Class<?> mbeanClass = JBossWorkManagerUtils.class.getClassLoader().loadClass(JBOSS_WORK_MANAGER_MBEAN_CLASS_NAME);
		InitialContext jndiContext = new InitialContext();
		MBeanServerConnection mconn = (MBeanServerConnection) jndiContext.lookup(MBEAN_SERVER_CONNECTION_JNDI_NAME);
		ObjectName objectName = ObjectName.getInstance(mbeanName);
		Object workManagerMBean = MBeanServerInvocationHandler.newProxyInstance(mconn, objectName, mbeanClass, false);
		Method getInstanceMethod = workManagerMBean.getClass().getMethod("getInstance");
		return (WorkManager) getInstanceMethod.invoke(workManagerMBean);
	}
	catch (Exception ex) {
		throw new IllegalStateException(
				"Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:JBossWorkManagerUtils.java

示例2: run

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * run method
 */
public void run()
{
   try
   {
      if (nestWork != null && workManager != null)
      {
         if (nestDo)
            workManager.doWork(nestWork, WorkManager.INDEFINITE, null, wa);
         else
            workManager.startWork(nestWork, WorkManager.INDEFINITE, null, wa);
      }
   }
   catch (Throwable e)
   {
      throw new RuntimeException(e.getMessage());
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:21,代码来源:NestProviderWork.java

示例3: testThrowWorkCompletedException

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Test for bullet 4 Section 3.3.6
 * When the application server is unable to recreate an execution context if it is  
 *                      specified for the submitted Work instance, it must throw a
 *                      WorkCompletedException set to an appropriate error code.
 * @throws Throwable throwable exception 
 */
@Test(expected = WorkCompletedException.class)
public void testThrowWorkCompletedException() throws Throwable
{
   ExecutionContext ec = new ExecutionContext();
   ShortRunningWork work = new ShortRunningWork();
   ec.setXid(new XidImpl());
   ec.setTransactionTimeout(Long.MAX_VALUE);

   WorkConnection wc = wcf.getConnection();
   try
   {
      wc.doWork(work, WorkManager.INDEFINITE, ec, null);
   }
   finally
   {
      wc.close();
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:26,代码来源:WorkInterfaceTestCase.java

示例4: testFifoStartLifoFinish

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Test for paragraph 3
 * doWork method: this provides a first in, first out (FIFO) execution start 
 *      ordering and last in, first out (LIFO) execution completion ordering guarantee.
 * @throws Throwable throwable exception 
 */
@Test
public void testFifoStartLifoFinish() throws Throwable
{
   ContextWorkAdapter wa = new ContextWorkAdapter();
   NestProviderWork workA = new NestProviderWork("A", wa);
   workA.addContext(new TransactionContext());

   NestProviderWork workB = new NestProviderWork("B", null);
   workB.addContext(new WorkContextSetupListenerTransactionContext());

   WorkConnection wc = wcf.getConnection();
   workA.setNestDo(true);
   workA.setWorkManager(wc.getWorkManager());
   workA.setWork(workB);
   wc.doWork(workA, WorkManager.INDEFINITE, null, wa);

   assertEquals(wa.getStart(), "AB");
   assertEquals(wa.getDone(), "BA");

   wc.close();
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:28,代码来源:NestedWorkAndContextsTestCase.java

示例5: testFifoStart

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Test for paragraph 4
 * startWork method: this provides a FIFO execution start ordering guarantee, 
 *                 but no execution completion ordering guarantee.
 * @throws Throwable throwable exception 
 */
//@Test
public void testFifoStart() throws Throwable
{
   ContextWorkAdapter wa = new ContextWorkAdapter();
   NestProviderWork workA = new NestProviderWork("A", wa);
   workA.addContext(new NestedWorkSecurityContext());

   NestProviderWork workB = new NestProviderWork("B", null);
   workB.addContext(new HintsContext());

   WorkConnection wc = wcf.getConnection();
   workA.setNestDo(false);
   workA.setWorkManager(wc.getWorkManager());
   workA.setWork(workB);
   
   CyclicBarrier barrier = new CyclicBarrier(3);
   workA.setBarrier(barrier);
   workB.setBarrier(barrier);

   wc.startWork(workA, WorkManager.INDEFINITE, null, wa);
   barrier.await();
   assertEquals(wa.getStart(), "AB");
   wc.close();
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:31,代码来源:NestedWorkAndContextsTestCase.java

示例6: testFifoSchedule

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Test for paragraph 4
 * scheduletWork method: this provides a FIFO execution start ordering guarantee, 
 *                 but no execution completion ordering guarantee.
 * @throws Throwable throwable exception 
 */
//@Test
public void testFifoSchedule() throws Throwable
{
   ContextWorkAdapter wa = new ContextWorkAdapter();
   NestProviderWork workA = new NestProviderWork("A", wa);
   workA.addContext(new NestedWorkSecurityContext());

   NestProviderWork workB = new NestProviderWork("B", null);
   workB.addContext(new HintsContext());

   WorkConnection wc = wcf.getConnection();
   workA.setNestDo(false);
   workA.setWorkManager(wc.getWorkManager());
   workA.setWork(workB);
   
   CyclicBarrier barrier = new CyclicBarrier(3);
   workA.setBarrier(barrier);
   workB.setBarrier(barrier);

   wc.scheduleWork(workA, WorkManager.INDEFINITE, null, wa);
   barrier.await();
   assertEquals(wa.getStart(), "AB");

   wc.close();
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:32,代码来源:NestedWorkAndContextsTestCase.java

示例7: testDoWorkUnsupportedContext

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Test unsupported context nested doWork. 
 * @throws Throwable throwable exception 
 */
//@Test(expected = Throwable.class)
public void testDoWorkUnsupportedContext() throws Throwable
{
   ContextWorkAdapter wa = new ContextWorkAdapter();
   NestProviderWork workA = new NestProviderWork("A", wa);
   workA.addContext(new TransactionContext());

   NestProviderWork workB = new NestProviderWork("B", null);
   workB.addContext(new UnsupportedContext());

   WorkConnection wc = wcf.getConnection();
   workA.setNestDo(true);
   workA.setWorkManager(wc.getWorkManager());
   workA.setWork(workB);
   wc.doWork(workA, WorkManager.INDEFINITE, null, wa);
   wc.close();
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:22,代码来源:NestedWorkAndContextsTestCase.java

示例8: testStartWorkUnsupportedContext

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Test unsupported context nested startWork
 * @throws Throwable throwable exception 
 */
//@Test
public void testStartWorkUnsupportedContext() throws Throwable
{
   ContextWorkAdapter wa = new ContextWorkAdapter();
   NestProviderWork workA = new NestProviderWork("A", wa);
   workA.addContext(new HintsContext());

   NestProviderWork workB = new NestProviderWork("B", null);
   workB.addContext(new UnsupportedContext());

   WorkConnection wc = wcf.getConnection();
   workA.setNestDo(false);
   workA.setWorkManager(wc.getWorkManager());
   workA.setWork(workB);
   
   CyclicBarrier barrier = new CyclicBarrier(2);
   workA.setBarrier(barrier);
   workB.setBarrier(barrier);

   wc.startWork(workA, WorkManager.INDEFINITE, null, wa);
   barrier.await();
   assertNotNull(wa.getException());

   wc.close();
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:30,代码来源:NestedWorkAndContextsTestCase.java

示例9: testScheduleWorkUnsupportedContext

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Test unsupported context nested scheduleWork
 * @throws Throwable throwable exception 
 */
//@Test
public void testScheduleWorkUnsupportedContext() throws Throwable
{
   ContextWorkAdapter wa = new ContextWorkAdapter();
   NestProviderWork workA = new NestProviderWork("A", wa);
   workA.addContext(new HintsContext());

   NestProviderWork workB = new NestProviderWork("B", null);
   workB.addContext(new UnsupportedContext());

   WorkConnection wc = wcf.getConnection();
   workA.setNestDo(false);
   workA.setWorkManager(wc.getWorkManager());
   workA.setWork(workB);
   
   CyclicBarrier barrier = new CyclicBarrier(2);
   workA.setBarrier(barrier);
   workB.setBarrier(barrier);

   wc.getWorkManager().scheduleWork(workA, WorkManager.INDEFINITE, null, wa);
   barrier.await();
   assertNotNull(wa.getException());
   wc.close();
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:29,代码来源:NestedWorkAndContextsTestCase.java

示例10: doWork

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void doWork(Work work) throws WorkException
{
   if (policy == null || selector == null || transport == null ||
       work == null || !(work instanceof DistributableWork) || !doWorkDistributionEnabled)
   {
      localDoWork(work);
   }
   else
   {
      doFirstChecks(work, WorkManager.INDEFINITE, null);
      checkTransport();

      DistributableWork dw = (DistributableWork)work;
      boolean executed = false;

      if (policy.shouldDistribute(this, dw))
      {
         Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw);
         if (dwmAddress != null && !getLocalAddress().equals(dwmAddress))
         {
            transport.doWork(dwmAddress, dw);
            executed = true;
         }
      }

      if (!executed)
      {
         localDoWork(work);
      }
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:36,代码来源:DistributedWorkManagerImpl.java

示例11: clone

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
/**
 * Clone the WorkManager implementation
 * @return A copy of the implementation
 * @exception CloneNotSupportedException Thrown if the copy operation isn't supported
 *
 */
@Override
public org.ironjacamar.core.api.workmanager.WorkManager clone() throws CloneNotSupportedException
{
   DistributedWorkManagerImpl wm = (DistributedWorkManagerImpl)super.clone();
   wm.setPolicy(getPolicy());
   wm.setSelector(getSelector());
   wm.setTransport(getTransport());
   wm.setDistributedStatisticsEnabled(isDistributedStatisticsEnabled());
   wm.setDoWorkDistributionEnabled(isDoWorkDistributionEnabled());
   wm.setStartWorkDistributionEnabled(isStartWorkDistributionEnabled());
   wm.setScheduleWorkDistributionEnabled(isScheduleWorkDistributionEnabled());

   DistributedWorkManagerStatisticsImpl dwmsi = new DistributedWorkManagerStatisticsImpl();
   wm.setDistributedStatistics(dwmsi);
   
   if (getPolicy() != null && getPolicy() instanceof NotificationListener)
      wm.listeners.add((NotificationListener)getPolicy());

   if (getSelector() != null && getSelector() instanceof NotificationListener)
      wm.listeners.add((NotificationListener)getSelector());

   if (getTransport() != null && getTransport() instanceof NotificationListener)
      wm.listeners.add((NotificationListener)getTransport());

   wm.listeners.add((NotificationListener)dwmsi);

   return wm;
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:35,代码来源:DistributedWorkManagerImpl.java

示例12: postProcessBeanFactory

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
@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();
		}
	});
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ResourceAdapterApplicationContext.java

示例13: getWorkManager

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
@Override
public WorkManager getWorkManager() {
	if (this.workManager == null) {
		throw new IllegalStateException("No WorkManager available");
	}
	return this.workManager;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SimpleBootstrapContext.java

示例14: afterPropertiesSet

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws NamingException {
	if (this.workManager == null) {
		if (this.workManagerName != null) {
			this.workManager = lookup(this.workManagerName, WorkManager.class);
		}
		else {
			this.workManager = getDefaultWorkManager();
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:WorkManagerTaskExecutor.java

示例15: doWork

import javax.resource.spi.work.WorkManager; //导入依赖的package包/类
@Override
public void doWork(Work work) throws WorkException {
	doWork(work, WorkManager.INDEFINITE, null, null);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SimpleTaskWorkManager.java


注:本文中的javax.resource.spi.work.WorkManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。