| <reference name="addService" target="AddServiceComponent" /> <reference name="subtractService" target="SubtractServiceComponent" /> <reference name="multiplyService" target="MultiplyServiceComponent" /> <reference name="divideService" target="DivideServiceComponent" /> <component name="AddServiceComponent"> <implementation.java class="calculator.AddServiceImpl"/> </component> <component name="SubtractServiceComponent"> <implementation.java class="calculator.SubtractServiceImpl"/> </component> <component name="MultiplyServiceComponent"> <implementation.java class="calculator.MultiplyServiceImpl"/> </component> <component name="DivideServiceComponent"> <implementation.java class="calculator.DivideServiceImpl"/> </component> |
| org.apache.tuscany.sca.implementation.java.context.ReflectiveInstanceFactory<T> public InstanceWrapper<T> newInstance() { T instance; try { if (ctrArgs != null) { Object[] args = new Object[ctrArgs.length]; for (int i = 0; i < args.length; i++) { args[i] = ctrArgs[i].getInstance(); } instance = ctr.newInstance(args); } else { instance = ctr.newInstance(); } } catch (InstantiationException e) { String name = ctr.getDeclaringClass().getName(); throw new AssertionError("Class is not instantiable [" + name + "]"); } catch (IllegalAccessException e) { String name = ctr.getName(); throw new AssertionError("Constructor is not accessible [" + name + "]"); } catch (InvocationTargetException e) { String name = ctr.getName(); throw new ObjectCreationException("Exception thrown by constructor: " + name, e); } if (injectors != null) { for (Injector<T> injector : injectors) { //FIXME Injectors should never be null if (injector != null) injector.inject(instance); } } |
| org.apache.tuscany.sca.core.invocation.JDKInvocationHandler if (wire.getSource() != null && wire.getSource().getCallbackEndpoint() != null) { if (callbackObject != null) { if (callbackObject instanceof ServiceReference) { msg.setFrom(((CallableReferenceImpl)callbackObject).getRuntimeWire().getTarget()); } else { if (contract != null) { if (!contract.isConversational()) { throw new NoRegisteredCallbackException( "Callback object for stateless callback is not a ServiceReference"); } else { //FIXME: add callback object to scope container msg.setFrom(wire.getSource().getCallbackEndpoint()); } } } } else { //FIXME: check that the source component implements the callback interface msg.setFrom(wire.getSource().getCallbackEndpoint()); } } if (endpoint != null) { msg.setTo(endpoint); } else { msg.setTo(wire.getTarget()); } |
| org.apache.tuscany.sca.core.scope.scope public static final Scope STATELESS = new Scope("STATELESS"); public static final Scope REQUEST = new Scope("REQUEST"); public static final Scope SESSION = new Scope("SESSION"); public static final Scope CONVERSATION = new Scope("CONVERSATION"); public static final Scope COMPOSITE = new Scope("COMPOSITE"); public static final Scope SYSTEM = new Scope("SYSTEM"); public static final Scope UNDEFINED = new Scope("UNDEFINED"); |
| public enum ConversationSequence { CONVERSATION_NONE, CONVERSATION_START, CONVERSATION_CONTINUE, CONVERSATION_END } |
| Interface contract = operation.getInterface(); if (contract != null && contract.isConversational()) { ConversationSequence sequence = operation.getConversationSequence(); if (sequence == ConversationSequence.CONVERSATION_END) { msg.setConversationSequence(ConversationSequence.CONVERSATION_END); conversationStarted = false; if (conversation != null) { conversation.setConversationID(null); } } else if (sequence == ConversationSequence.CONVERSATION_CONTINUE) { if (conversationStarted) { msg.setConversationSequence(ConversationSequence.CONVERSATION_CONTINUE); } else { conversationStarted = true; msg.setConversationSequence(ConversationSequence.CONVERSATION_START); } } } |
| protected Map<KEY, InstanceWrapper<?>> wrappers = new ConcurrentHashMap<KEY, InstanceWrapper<?>>(); protected volatile int lifecycleState = UNINITIALIZED; private InstanceWrapper getInstance(ConversationSequence sequence, Object contextId) throws TargetResolutionException, InvalidConversationSequenceException { if (sequence == null) { return scopeContainer.getWrapper(contextId); } else { switch (sequence) { case CONVERSATION_START: return scopeContainer.getWrapper(contextId); case CONVERSATION_CONTINUE: case CONVERSATION_END: return scopeContainer.getAssociatedWrapper(contextId); default: throw new InvalidConversationSequenceException("Unknown sequence type: " + String.valueOf(sequence)); } } } |
| private static final ThreadLocal<Message> CONTEXT = new ThreadLocal<Message>() { @Override protected synchronized Message initialValue() { return new MessageImpl(); } }; public static Message setMessageContext(Message context) { Message old = CONTEXT.get(); CONTEXT.set(context); return old; } public static Message getMessageContext() { return CONTEXT.get(); } |
关注此文的读者还看过: