本文整理汇总了Java中javax.resource.spi.ActivationSpec类的典型用法代码示例。如果您正苦于以下问题:Java ActivationSpec类的具体用法?Java ActivationSpec怎么用?Java ActivationSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActivationSpec类属于javax.resource.spi包,在下文中一共展示了ActivationSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* Prepares the message endpoint, and automatically activates it
* if the "autoStartup" flag is set to "true".
*/
@Override
public void afterPropertiesSet() throws ResourceException {
if (getResourceAdapter() == null) {
throw new IllegalArgumentException("Property 'resourceAdapter' is required");
}
if (getMessageEndpointFactory() == null) {
throw new IllegalArgumentException("Property 'messageEndpointFactory' is required");
}
ActivationSpec activationSpec = getActivationSpec();
if (activationSpec == null) {
throw new IllegalArgumentException("Property 'activationSpec' is required");
}
if (activationSpec.getResourceAdapter() == null) {
activationSpec.setResourceAdapter(getResourceAdapter());
}
else if (activationSpec.getResourceAdapter() != getResourceAdapter()) {
throw new IllegalArgumentException("ActivationSpec [" + activationSpec +
"] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter());
}
}
示例2: createActivationSpec
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
@Override
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
Class<?> activationSpecClassToUse = this.activationSpecClass;
if (activationSpecClassToUse == null) {
activationSpecClassToUse = determineActivationSpecClass(adapter);
if (activationSpecClassToUse == null) {
throw new IllegalStateException("Property 'activationSpecClass' is required");
}
}
ActivationSpec spec = (ActivationSpec) BeanUtils.instantiateClass(activationSpecClassToUse);
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(spec);
if (this.defaultProperties != null) {
bw.setPropertyValues(this.defaultProperties);
}
populateActivationSpecProperties(bw, config);
return spec;
}
示例3: endpointActivation
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* This is called during the activation of a message endpoint.
*
* @param endpointFactory
* A message endpoint factory instance.
* @param spec
* An activation spec JavaBean instance.
* @throws ResourceException
* generic exception
*/
public void endpointActivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) throws ResourceException {
if (!equals(spec.getResourceAdapter())) {
throw new ResourceException(
"Activation spec not initialized with this ResourceAdapter instance ("
+ spec.getResourceAdapter() + " != " + this + ")");
}
if (!(spec instanceof RabbitmqActivationSpec)) {
throw new NotSupportedException(
"That type of ActivationSpec not supported: "
+ spec.getClass());
}
RabbitmqActivation activation = new RabbitmqActivation(this,
(RabbitmqActivationSpec) spec, endpointFactory);
activations.put((RabbitmqActivationSpec) spec, activation);
activation.start();
log.tracef("endpointActivation(%s, %s)", endpointFactory, spec);
}
示例4: endpointActivation
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* Endpoint activation
*
* @param endpointFactory The endpoint factory
* @param spec The activation spec
* @throws ResourceException Thrown if an error occurs
*/
@Override
public void endpointActivation(final MessageEndpointFactory endpointFactory,
final ActivationSpec spec) throws ResourceException {
if (spec == null) {
throw ActiveMQRABundle.BUNDLE.noActivationSpec();
}
if (!configured.getAndSet(true)) {
try {
setup();
} catch (ActiveMQException e) {
throw new ResourceException("Unable to create activation", e);
}
}
if (logger.isTraceEnabled()) {
logger.trace("endpointActivation(" + endpointFactory + ", " + spec + ")");
}
ActiveMQActivation activation = new ActiveMQActivation(this, endpointFactory, (ActiveMQActivationSpec) spec);
activations.put(spec, activation);
activation.start();
}
示例5: getXAResources
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* Get XA resources
*
* @param specs The activation specs
* @return The XA resources
* @throws ResourceException Thrown if an error occurs or unsupported
*/
@Override
public XAResource[] getXAResources(final ActivationSpec[] specs) throws ResourceException {
if (logger.isTraceEnabled()) {
logger.trace("getXAResources(" + Arrays.toString(specs) + ")");
}
if (useAutoRecovery) {
// let the TM handle the recovery
return null;
} else {
List<XAResource> xaresources = new ArrayList<>();
for (ActivationSpec spec : specs) {
ActiveMQActivation activation = activations.get(spec);
if (activation != null) {
xaresources.addAll(activation.getXAResources());
}
}
return xaresources.toArray(new XAResource[xaresources.size()]);
}
}
示例6: afterPropertiesSet
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* Prepares the message endpoint, and automatically activates it
* if the "autoStartup" flag is set to "true".
*/
public void afterPropertiesSet() throws ResourceException {
if (getResourceAdapter() == null) {
throw new IllegalArgumentException("Property 'resourceAdapter' is required");
}
if (getMessageEndpointFactory() == null) {
throw new IllegalArgumentException("Property 'messageEndpointFactory' is required");
}
ActivationSpec activationSpec = getActivationSpec();
if (activationSpec == null) {
throw new IllegalArgumentException("Property 'activationSpec' is required");
}
if (activationSpec.getResourceAdapter() == null) {
activationSpec.setResourceAdapter(getResourceAdapter());
}
else if (activationSpec.getResourceAdapter() != getResourceAdapter()) {
throw new IllegalArgumentException("ActivationSpec [" + activationSpec +
"] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter());
}
}
示例7: createActivationSpec
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
Class activationSpecClassToUse = this.activationSpecClass;
if (activationSpecClassToUse == null) {
activationSpecClassToUse = determineActivationSpecClass(adapter);
if (activationSpecClassToUse == null) {
throw new IllegalStateException("Property 'activationSpecClass' is required");
}
}
ActivationSpec spec = (ActivationSpec) BeanUtils.instantiateClass(activationSpecClassToUse);
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(spec);
if (this.defaultProperties != null) {
bw.setPropertyValues(this.defaultProperties);
}
populateActivationSpecProperties(bw, config);
return spec;
}
示例8: endpointActivation
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
@Override
public void endpointActivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec)
throws ResourceException {
log.info("[TrafficResourceAdapter] endpointActivation()");
tSpec = (TrafficActivationSpec) spec;
/* New in JCA 1.7 - Get the endpoint class implementation (i.e. the
* MDB class). This allows looking at the MDB implementation for
* annotations. */
Class endpointClass = endpointFactory.getEndpointClass();
tSpec.setBeanClass(endpointClass);
tSpec.findCommandsInMDB();
/* MessageEndpoint msgEndpoint = endpointFactory.createEndpoint(null);
* but we need to do that in a different thread, otherwise the MDB
* never deploys. */
ObtainEndpointWork work = new ObtainEndpointWork(this, endpointFactory);
workManager.scheduleWork(work);
}
示例9: endpointActivation
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
@Override
public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec activationSpec) throws ResourceException {
FSWatcherActivationSpec fsWatcherAS = (FSWatcherActivationSpec) activationSpec;
try {
WatchKey watchKey = fileSystem.getPath(fsWatcherAS.getDir()).register(watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY);
listeners.put(watchKey, endpointFactory);
// On TomEE the endpoint class is available via activationSpec.getBeanClass()
// even though not JavaEE 7 compliant yet!
endpointFactoryToBeanClass.put(
endpointFactory,
fsWatcherAS.getBeanClass() != null ? fsWatcherAS.getBeanClass() : endpointFactory.getEndpointClass());
} catch (IOException e) {
throw new ResourceException(e);
}
}
示例10: validate
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* Validate
* @param vo The validate object
* @param rb The resource bundle
* @return The list of failures found; <code>null</code> if none
*/
@SuppressWarnings("unchecked")
public List<Failure> validate(Validate vo, ResourceBundle rb)
{
if (vo != null && Key.ACTIVATION_SPEC == vo.getKey())
{
if (vo.getClazz() != null && !ActivationSpec.class.isAssignableFrom(vo.getClazz()))
{
List<Failure> failures = new ArrayList<Failure>(1);
Failure failure = new Failure(Severity.ERROR,
SECTION,
rb.getString("as.AS"),
vo.getClazz().getName());
failures.add(failure);
return failures;
}
}
return null;
}
示例11: validate
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* Validate
* @param v The validate object
* @param rb The resource bundle
* @return The list of failures found; <code>null</code> if none
*/
@SuppressWarnings("unchecked")
public List<Failure> validate(Validate v, ResourceBundle rb)
{
if (v != null &&
Key.ACTIVATION_SPEC == v.getKey() &&
v.getClazz() != null &&
ActivationSpec.class.isAssignableFrom(v.getClazz()))
{
ValidateClass vo = (ValidateClass)v;
if (vo.getConfigProperties() != null && !vo.getConfigProperties().isEmpty())
{
return ConfigPropertiesHelper.validateConfigPropertiesType(vo, SECTION,
rb.getString("as.ASConfigProperties"));
}
}
return null;
}
示例12: XAResourceRecoveryInflowImpl
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* Constructor
*
* @param rar The resource adapter
* @param as The activation spec
* @param productName The product name
* @param productVersion The product version
*/
public XAResourceRecoveryInflowImpl(ResourceAdapter rar, ActivationSpec as,
String productName, String productVersion)
{
if (rar == null)
throw new IllegalArgumentException("ResourceAdapter is null");
if (as == null)
throw new IllegalArgumentException("ActivationSpec is null");
this.resourceAdapter = rar;
this.activationSpec = as;
this.productName = productName;
this.productVersion = productVersion;
this.jndiName = null;
}
示例13: initialize
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void initialize() throws Exception
{
if (rar != null)
{
for (XAResource xar : rar.getXAResources(new ActivationSpec[] {as}))
{
// Trigger a recovery pass
xar.recover(XAResource.TMSTARTRSCAN);
xar.recover(XAResource.TMENDRSCAN);
}
}
else
{
// Create ManagedConnection
mc = mcf.createManagedConnection(subjectFactory.createSubject(securityDomain), null);
// Trigger a recovery pass
mc.getXAResource().recover(XAResource.TMSTARTRSCAN);
mc.getXAResource().recover(XAResource.TMENDRSCAN);
}
}
示例14: endpointDeactivation
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void endpointDeactivation(MessageEndpointFactory mef, ActivationSpec as) throws Exception
{
if (mef == null)
throw new Exception("MessageEndpointFactory is null");
if (as == null)
throw new Exception("ActivationSpec is null");
Endpoint e = new Endpoint(mef, as);
InflowRecovery ir = activeEndpoints.get(e);
if (ir != null)
ir.deactivate();
try
{
resourceAdapter.endpointDeactivation(mef, as);
}
finally
{
activeEndpoints.remove(e);
}
}
示例15: endpointActivation
import javax.resource.spi.ActivationSpec; //导入依赖的package包/类
@Override
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) throws ResourceException {
final Scheduler s = scheduler.get();
if (null == s) {
throw new ResourceException("Quartz Scheduler is not available");
}
try {
final JobSpec spec = (JobSpec) activationSpec;
final MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
spec.setEndpoint(endpoint);
final Job job = (Job) endpoint;
final JobDataMap jobDataMap = spec.getDetail().getJobDataMap();
jobDataMap.put(Data.class.getName(), new Data(job));
s.scheduleJob(spec.getDetail(), spec.getTrigger());
} catch (final SchedulerException e) {
throw new ResourceException("Failed to schedule job", e);
}
}