Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2012 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.kuali.rice.ksb.messaging.serviceproxies;
 import java.util.List;

A proxy which schedules a service to be executed asynchronously after some delay period.

Kuali Rice Team (
     private static final Logger LOG = Logger.getLogger(DelayedAsynchronousServiceCallProxy.class);
     private Serializable context;
     private String value1;
     private String value2;
     private long delayMilliseconds;
     protected DelayedAsynchronousServiceCallProxy(List<EndpointendpointsSerializable context,
 	    String value1String value2long delayMilliseconds) {
 	this. = endpoints;
 	this. = context;
 	this. = value1;
 	this. = value2;
 	this. = delayMilliseconds;
     public static Object createInstance(List<EndpointendpointsSerializable contextString value1,
 	    String value2long delayMilliseconds) {
 	if (endpoints == null || endpoints.isEmpty()) {
 	    throw new RuntimeException("Cannot create service proxy, no service(s) passed in.");
 	try {
 	    return Proxy.newProxyInstance(ClassLoaderUtils.getDefaultClassLoader(), ContextClassLoaderProxy
 		    new DelayedAsynchronousServiceCallProxy(endpointscontextvalue1value2delayMilliseconds));
 	} catch (Exception e) {
 	    throw new RiceRuntimeException(e);
     protected Object invokeInternal(Object proxyMethod methodObject[] argumentsthrows Throwable {
 	    // there are multiple service calls to make in the case of topics.
 	    AsynchronousCall methodCall = null;
 	    PersistedMessageBO message = null;
 	    synchronized (this) {
 	        // consider moving all this topic invocation stuff to the service
 	        // invoker for speed reasons
 	        for (Endpoint endpoint : this.) {
 		        ServiceConfiguration serviceConfiguration = endpoint.getServiceConfiguration();
 		        methodCall = new AsynchronousCall(method.getParameterTypes(), argumentsserviceConfiguration,
                         method.getName(), nullthis.);
 		        message = PersistedMessageBO.buildMessage(serviceConfigurationmethodCall);
 		        Calendar now = Calendar.getInstance();
		        now.add(., (int);
		        message.setQueueDate(new Timestamp(now.getTimeInMillis()));
		        // only do one iteration if this is a queue. The load balancing
		        // will be handled when the service is
		        // fetched by the MessageServiceInvoker through the GRL (and
		        // then through the RemoteResourceServiceLocatorImpl)
		        if (serviceConfiguration.isQueue()) {
	    return null;
    protected void scheduleMessage(PersistedMessageBO messagethrows SchedulerException {
	.debug("Scheduling execution of a delayed asynchronous message.");
	Scheduler scheduler = KSBServiceLocator.getScheduler();
	JobDataMap jobData = new JobDataMap();
	JobDetail jobDetail = new JobDetail("Delayed_Asynchronous_Call-" + Math.random(), "Delayed_Asynchronous_Call",
	Trigger trigger = new SimpleTrigger("Delayed_Asynchronous_Call_Trigger-" + Math.random(),
	trigger.setJobDataMap(jobData);// 1.6 bug required or derby will choke

Returns the List<RemotedServiceHolder> of asynchronous services which will be invoked by calls to this proxy. This is a List because, in the case of Topics, there can be more than one service invoked.
    public Object getTarget() {
	return this.;
New to GrepCode? Check out our FAQ X