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


Java Work类代码示例

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


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

示例1: startWork

import javax.resource.spi.work.Work; //导入依赖的package包/类
@Override
public long startWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
		throws WorkException {

	Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set");
	return executeWork(this.asyncTaskExecutor, work, startTimeout, true, executionContext, workListener);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SimpleTaskWorkManager.java

示例2: testFailingWork

import javax.resource.spi.work.Work; //导入依赖的package包/类
@Test public void testFailingWork() throws Exception {
	pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
	final Semaphore signal = new Semaphore(1);
	pool.execute(new Work() {
		@Override
		public void run() {
			signal.release();
			throw new RuntimeException();
		}
		
		@Override
		public void release() {
			
		}
	});
	assertTrue(signal.tryAcquire(2, TimeUnit.SECONDS));
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:18,代码来源:TestThreadReuseExecutor.java

示例3: execute

import javax.resource.spi.work.Work; //导入依赖的package包/类
void execute(final Work arg0, final WorkListener arg3, boolean join) throws WorkException {
	if (arg3 != null) {
		arg3.workAccepted(Mockito.mock(WorkEvent.class));
		arg3.workStarted(Mockito.mock(WorkEvent.class));
	}
	
	t = new Thread(new Runnable() {
		
		@Override
		public void run() {
			arg0.run();
			if (arg3 != null) {
				arg3.workCompleted(Mockito.mock(WorkEvent.class));
			}							
		}
	});
	t.start();
	if (join) {
		try {
			t.join();
		} catch (InterruptedException e) {
			throw new WorkException(e);
		}
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:26,代码来源:FakeWorkManager.java

示例4: invoke

import javax.resource.spi.work.Work; //导入依赖的package包/类
private void invoke(final MessageEndpoint endpoint, final Method m, final Path path) throws WorkException {
	resourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new Work() {
		
		@Override
		public void run() {
			try {
				Method endpointMethod = endpoint.getClass().getMethod(m.getName(), m.getParameterTypes()); 
				endpoint.beforeDelivery(endpointMethod);
				
				endpointMethod.invoke(endpoint, path.toFile());
				
				endpoint.afterDelivery();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		@Override
		public void release() {}
	});
}
 
开发者ID:robertpanzer,项目名称:filesystemwatch-connector,代码行数:22,代码来源:FSWatchingThread.java

示例5: workStarted

import javax.resource.spi.work.Work; //导入依赖的package包/类
/**
 * start work 
 *
 * @param e workEvent
 */
@Override
public void workStarted(WorkEvent e)
{
   if (e.getType() != WorkEvent.WORK_STARTED)
      fail("Wrong started type");
   timeStarted = System.currentTimeMillis();
   super.workStarted(e);
   Work work = e.getWork();
   if (work instanceof NestProviderWork)
   {
      NestProviderWork nw = (NestProviderWork) work;
      start.append(nw.getName());
   }

}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:21,代码来源:ContextWorkAdapter.java

示例6: workRejected

import javax.resource.spi.work.Work; //导入依赖的package包/类
/**
 * start work 
 *
 * @param e workEvent
 */
@Override
public void workRejected(WorkEvent e)
{
   if (e.getType() != WorkEvent.WORK_REJECTED)
      fail("Wrong rejected type");
   timeRejected = System.currentTimeMillis();
   super.workRejected(e);
   Work work = e.getWork();
   if (work instanceof NestProviderWork)
   {
      NestProviderWork nw = (NestProviderWork) work;
      reject.append(nw.getName());
   }

}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:21,代码来源:ContextWorkAdapter.java

示例7: workCompleted

import javax.resource.spi.work.Work; //导入依赖的package包/类
/**
 * complete work 
 *
 * @param e workEvent
 */
@Override
public void workCompleted(WorkEvent e)
{
   if (e.getType() != WorkEvent.WORK_COMPLETED)
      fail("Wrong completed type");
   timeCompleted = System.currentTimeMillis();
   super.workCompleted(e);
   Work work = e.getWork();
   if (work instanceof NestProviderWork)
   {
      NestProviderWork nw = (NestProviderWork) work;
      done.append(nw.getName());
      exception = e.getException();
   }

}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:22,代码来源:ContextWorkAdapter.java

示例8: doWork

import javax.resource.spi.work.Work; //导入依赖的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

示例9: verifyWork

import javax.resource.spi.work.Work; //导入依赖的package包/类
/**
 * Verify the given work instance.
 * @param work The work
 * @throws WorkException Thrown if a spec compliant issue is found
 */
private void verifyWork(Work work) throws WorkException
{
   Class<? extends Work> workClass = work.getClass();
   String className = workClass.getName();

   if (!validatedWork.contains(className))
   {

      if (isWorkMethodSynchronized(workClass, RUN_METHOD_NAME))
         throw new WorkException(bundle.runMethodIsSynchronized(className));

      if (isWorkMethodSynchronized(workClass, RELEASE_METHOD_NAME))
         throw new WorkException(bundle.releaseMethodIsSynchronized(className));

      validatedWork.add(className);
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:23,代码来源:WorkManagerImpl.java

示例10: isWorkMethodSynchronized

import javax.resource.spi.work.Work; //导入依赖的package包/类
/**
 * Checks, if Work implementation class method is synchronized
 * @param workClass - implementation class
 * @param methodName - could be "run" or "release"
 * @return true, if method is synchronized, false elsewhere
 */
private boolean isWorkMethodSynchronized(Class<? extends Work> workClass, String methodName)
{
   try
   {
      Method method = SecurityActions.getMethod(workClass, methodName, new Class[0]);
      if (Modifier.isSynchronized(method.getModifiers()))
         return true;
   }
   catch (NoSuchMethodException e)
   {
      //Never happens, Work implementation should have these methods
   }

   return false;
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:22,代码来源:WorkManagerImpl.java

示例11: doWork

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

示例12: scheduleWork

import javax.resource.spi.work.Work; //导入依赖的package包/类
@Override
public void scheduleWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
		throws WorkException {

	Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set");
	executeWork(this.asyncTaskExecutor, work, startTimeout, false, executionContext, workListener);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SimpleTaskWorkManager.java

示例13: doWork

import javax.resource.spi.work.Work; //导入依赖的package包/类
@Override
public void doWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
		throws WorkException {

	Assert.state(this.syncTaskExecutor != null, "No 'syncTaskExecutor' set");
	executeWork(this.syncTaskExecutor, work, startTimeout, false, executionContext, workListener);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:SimpleTaskWorkManager.java

示例14: startWork

import javax.resource.spi.work.Work; //导入依赖的package包/类
@Override
public long startWork(Work work,
                      long l,
                      ExecutionContext executionContext,
                      WorkListener workListener) throws WorkException {
   return 0;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:ActiveMQRATestBase.java

示例15: stop

import javax.resource.spi.work.Work; //导入依赖的package包/类
public void stop() {
	for (int i = 0; this.workList != null && i < this.workList.size(); i++) {
		Work work = this.workList.get(i);
		try {
			work.release();
		} catch (RuntimeException rex) {
			logger.debug(rex.getMessage(), rex);
		}
	}
}
 
开发者ID:liuyangming,项目名称:ByteJTA,代码行数:11,代码来源:ResourceAdapterImpl.java


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