summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async')
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/builder/AsyncPolicyBuilder.java86
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/invocation/AsyncInterceptor.java108
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/work/DefaultWorkManager.java68
3 files changed, 0 insertions, 262 deletions
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/builder/AsyncPolicyBuilder.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/builder/AsyncPolicyBuilder.java
deleted file mode 100644
index 6acebdaa8e..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/builder/AsyncPolicyBuilder.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.apache.tuscany.core.async.builder;
-
-import java.util.List;
-
-import javax.resource.spi.work.WorkManager;
-
-import org.apache.tuscany.core.async.invocation.AsyncInterceptor;
-import org.apache.tuscany.core.builder.BuilderException;
-import org.apache.tuscany.core.builder.SourcePolicyBuilder;
-import org.apache.tuscany.core.builder.TargetPolicyBuilder;
-import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
-import org.apache.tuscany.core.wire.WireSourceConfiguration;
-import org.apache.tuscany.core.wire.WireTargetConfiguration;
-import org.apache.tuscany.model.assembly.ConfiguredReference;
-import org.apache.tuscany.model.assembly.ConfiguredService;
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.OneWay;
-
-/**
- * Builds context factories for component implementations that map to {@link org.apache.tuscany.container.java.assembly.JavaImplementation}.
- * The logical model is then decorated with the runtime configuration.
- *
- * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
- * @see org.apache.tuscany.core.builder.ContextFactory
- */
-@org.osoa.sca.annotations.Scope("MODULE")
-public class AsyncPolicyBuilder implements SourcePolicyBuilder, TargetPolicyBuilder {
-
- private PolicyBuilderRegistry builderRegistry;
- private WorkManager workManager;
- private MessageFactory messageFactory;
-
- public AsyncPolicyBuilder() {
- }
-
- @Init(eager = true)
- public void init() {
- builderRegistry.registerSourceBuilder(this);
- builderRegistry.registerTargetBuilder(this);
- }
-
- @Autowire
- public void setBuilderRegistry(PolicyBuilderRegistry builderRegistry) {
- this.builderRegistry = builderRegistry;
- }
-
- @Autowire
- public void setWorkManager(WorkManager workManager) {
- this.workManager = workManager;
- }
-
- @Autowire
- public void setMessageFactory(MessageFactory messageFactory) {
- this.messageFactory = messageFactory;
- }
-
- public void build(ConfiguredReference arg0, List<WireSourceConfiguration> arg1) throws BuilderException {
- }
-
- public void build(ConfiguredService service, WireTargetConfiguration wireTargetConfiguration) throws BuilderException {
- for (TargetInvocationConfiguration configuration : wireTargetConfiguration.getInvocationConfigurations().values()) {
- if (configuration.getMethod().getAnnotation(OneWay.class)!=null) {
- configuration.addInterceptor(new AsyncInterceptor(workManager, messageFactory));
- }
- }
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/invocation/AsyncInterceptor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/invocation/AsyncInterceptor.java
deleted file mode 100644
index 08a718bd73..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/invocation/AsyncInterceptor.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.apache.tuscany.core.async.invocation;
-
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkManager;
-
-import org.apache.tuscany.core.message.Message;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.wire.Interceptor;
-import org.osoa.sca.CurrentModuleContext;
-import org.osoa.sca.ModuleContext;
-import org.osoa.sca.SCA;
-import org.osoa.sca.ServiceRuntimeException;
-
-/**
- * A wire interceptor that uses a WorkManager to schedule asynchronous execution of invocations in Work instances.
- */
-public class AsyncInterceptor implements Interceptor {
-
- private static final ContextBinder BINDER = new ContextBinder();
-
- private WorkManager workManager;
- private MessageFactory messageFactory;
- private Interceptor next;
-
- /**
- * Constructs a new instance
- * @param workManager
- */
- public AsyncInterceptor(WorkManager workManager, MessageFactory messageFactory) {
- this.workManager=workManager;
- this.messageFactory=messageFactory;
- }
-
- public Message invoke(final Message message) {
-
- final ModuleContext currentModuleContext=CurrentModuleContext.getContext();
-
- // Schedule the invocation of the next interceptor in a new Work instance
- try {
- workManager.scheduleWork(new Work() {
-
- public void run() {
- ModuleContext oldModuleContext=CurrentModuleContext.getContext();
- try {
- BINDER.setContext(currentModuleContext);
-
- // Invoke the next interceptor
- next.invoke(message);
-
- } catch (Exception e) {
- //FIXME How do we report exceptions?
- e.printStackTrace();
-
- } finally {
-
- BINDER.setContext(oldModuleContext);
- }
- }
-
- public void release() {
- }
-
- });
- } catch (WorkException e) {
- //FIXME Which exception should we throw here?
- throw new ServiceRuntimeException(e);
- }
-
- // No return on a OneWay invocation.
- return messageFactory.createMessage();
- }
-
- public void setNext(Interceptor next) {
- this.next=next;
- }
-
- private static class ContextBinder extends SCA {
- public void setContext(ModuleContext context) {
- setModuleContext(context);
- }
-
- public void start() {
- throw new AssertionError();
- }
-
- public void stop() {
- throw new AssertionError();
- }
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/work/DefaultWorkManager.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/work/DefaultWorkManager.java
deleted file mode 100644
index 866e101b0e..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/async/work/DefaultWorkManager.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.apache.tuscany.core.async.work;
-
-import javax.resource.spi.work.WorkManager;
-
-import org.apache.geronimo.connector.work.GeronimoWorkManager;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Scope;
-import org.osoa.sca.annotations.Service;
-
-/**
- * A Work Manager service component implementation which just reuses the Geronimo WorkManager.
- *
- * @version $Rev$ $Date$
- */
-@Service(WorkManager.class)
-@Scope("MODULE")
-public class DefaultWorkManager extends GeronimoWorkManager implements WorkManager {
-
- private final static int DEFAULT_POOL_SIZE = 10;
-
- @Property
- public int scheduledMaximumPoolSize;
-
- /**
- * Constructs a new instance.
- */
- public DefaultWorkManager() {
- super(DEFAULT_POOL_SIZE, new TransactionContextManager());
- }
-
- @Init(eager=true)
- public void init() throws Exception {
- doStart();
- }
-
- @Destroy
- public void destroy() throws Exception {
- doStop();
- }
-
- public void setScheduledMaximumPoolSize(int maxSize) {
- super.setScheduledMaximumPoolSize(maxSize);
- }
-
- public int getScheduledMaximumPoolSize() {
- return super.getScheduledMaximumPoolSize();
- }
-
-}