00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.component.request;
00032
00033 import java.io.IOException;
00034
00035 import org.apache.log4j.Logger;
00036 import org.objectweb.proactive.Body;
00037 import org.objectweb.proactive.core.body.request.Request;
00038 import org.objectweb.proactive.core.body.request.RequestReceiverImpl;
00039 import org.objectweb.proactive.core.component.body.ComponentBody;
00040 import org.objectweb.proactive.core.util.log.Loggers;
00041 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00042
00043
00056 public class SynchronousComponentRequestReceiver extends RequestReceiverImpl {
00057 protected static Logger logger = ProActiveLogger.getLogger(Loggers.COMPONENTS_REQUESTS);
00058 public final static int SHORTCUT = 1;
00059
00060 public SynchronousComponentRequestReceiver() {
00061 super();
00062 }
00063
00064 public int receiveRequest(Request r, Body bodyReceiver)
00065 throws IOException {
00066 if (r instanceof ComponentRequest) {
00067 if (!((ComponentRequest) r).isControllerRequest()) {
00068 if ("true".equals(System.getProperty(
00069 "proactive.components.use_shortcuts"))) {
00070 if (!((ComponentBody) bodyReceiver).getProActiveComponentImpl()
00071 .getInputInterceptors().isEmpty() ||
00072 !((ComponentBody) bodyReceiver).getProActiveComponentImpl()
00073 .getOutputInterceptors().isEmpty()) {
00074 if (logger.isDebugEnabled()) {
00075 logger.debug(
00076 "shortcut is stopped in this component, because functional invocations are intercepted");
00077 }
00078
00079
00080 return super.receiveRequest(r, bodyReceiver);
00081 }
00082
00083 ((ComponentRequest) r).shortcutNotification(r.getSender(),
00084 bodyReceiver.getRemoteAdapter());
00085
00086
00087 if (logger.isDebugEnabled()) {
00088 logger.debug("directly executing request " +
00089 r.getMethodCall().getName() +
00090 ((r.getMethodCall().getComponentMetadata().getComponentInterfaceName() != null)
00091 ? (" on interface " +
00092 r.getMethodCall().getComponentMetadata().getComponentInterfaceName()) : ""));
00093 }
00094 }
00095 bodyReceiver.serve(r);
00096
00097 return SynchronousComponentRequestReceiver.SHORTCUT;
00098 }
00099 }
00100
00101
00102 return super.receiveRequest(r, bodyReceiver);
00103 }
00104 }