diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:06:50 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:06:50 +0000 |
commit | 0f3f9b59b310833f31ba234ee4aefa808649833c (patch) | |
tree | 4f8b3354beb0643151424eb978eece9e55038c90 /branches/sca-java-0.91/modules/core/src | |
parent | f860c2f35b2f94e379d2ff7d5c13f54cd4a3132a (diff) |
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835120 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-0.91/modules/core/src')
133 files changed, 0 insertions, 8791 deletions
diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java deleted file mode 100644 index f0f0049056..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.component; - -import org.apache.tuscany.sca.factory.ObjectFactory; -import org.osoa.sca.CallableReference; -import org.osoa.sca.Conversation; - -/** - * Base class for implementations of service and callback references. - * - * @version $Rev$ $Date$ - * @param <B> the type of the business interface - */ -public abstract class CallableReferenceImpl<B> implements CallableReference<B> { - private final Class<B> businessInterface; - private final ObjectFactory<B> factory; - - protected CallableReferenceImpl(Class<B> businessInterface, ObjectFactory<B> factory) { - this.businessInterface = businessInterface; - this.factory = factory; - } - - public B getService() { - return factory.getInstance(); - } - - public Class<B> getBusinessInterface() { - return businessInterface; - } - - public boolean isConversational() { - return false; - } - - public Conversation getConversation() { - return null; - } - - public Object getCallbackID() { - return null; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallbackReferenceImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallbackReferenceImpl.java deleted file mode 100644 index 45a48730d3..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallbackReferenceImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.component; - -import org.apache.tuscany.sca.factory.ObjectFactory; - -/** - * Default implementation of a callback reference. - * - * @version $Rev$ $Date$ - * @param <CB> the type of the business interface - */ -public class CallbackReferenceImpl<CB> extends CallableReferenceImpl<CB> { - public CallbackReferenceImpl(Class<CB> businessInterface, ObjectFactory<CB> factory) { - super(businessInterface, factory); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java deleted file mode 100644 index abcd17f505..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.component; - -import org.osoa.sca.CallableReference; -import org.osoa.sca.ComponentContext; -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -/** - * Implementation of ComponentContext that delegates to a ComponentContextProvider. - * - * @version $Rev$ $Date$ - */ -public class ComponentContextImpl implements ComponentContext { - private final ComponentContextProvider component; - - public ComponentContextImpl(ComponentContextProvider component) { - this.component = component; - } - - public String getURI() { - try { - return component.getUri().toString(); - } catch (RuntimeException e) { - throw new ServiceRuntimeException(e.getMessage(), e); - } - } - - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - try { - return (R) component.cast(target); - } catch (RuntimeException e) { - throw new ServiceRuntimeException(e.getMessage(), e); - } - } - - public <B> B getService(Class<B> businessInterface, String referenceName) { - try { - return component.getService(businessInterface, referenceName); - } catch (RuntimeException e) { - throw new ServiceRuntimeException(e.getMessage(), e); - } - } - - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) { - try { - return component.getServiceReference(businessInterface, referenceName); - } catch (RuntimeException e) { - throw new ServiceRuntimeException(e.getMessage(), e); - } - } - - public <B> B getProperty(Class<B> type, String propertyName) { - try { - return component.getProperty(type, propertyName); - } catch (RuntimeException e) { - throw new ServiceRuntimeException(e.getMessage(), e); - } - } - - public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) { - return getServiceReference(businessInterface, "$self$."); - // FIXME: How to get the ObjectFactory? - // ObjectFactory<B> factory = ((AtomicComponent) component).createObjectFactory(); - // return new ServiceReferenceImpl<B>(businessInterface, factory); - } - - public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) { - return getServiceReference(businessInterface, "$self$."+serviceName); - } - - public RequestContext getRequestContext() { - return null; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextProvider.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextProvider.java deleted file mode 100644 index 3999d0d5b4..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.component; - -import java.net.URI; - -import org.osoa.sca.CallableReference; -import org.osoa.sca.ComponentContext; -import org.osoa.sca.ServiceReference; - -/** - * Interface implemented by Component's that want to expose a ComponentContext. - * - * @version $Rev$ $Date$ - */ -public interface ComponentContextProvider { - ComponentContext getComponentContext(); - - URI getUri(); - - <B> B getService(Class<B> businessInterface, String referenceName); - - <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName); - - <B> B getProperty(Class<B> type, String propertyName); - - <B, R extends CallableReference<B>> R cast(B target); -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java deleted file mode 100644 index 3a219b9cd9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.component; - -import javax.security.auth.Subject; - -import org.osoa.sca.CallableReference; -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; - -/** - * @version $Rev$ $Date$ - */ -public class RequestContextImpl implements RequestContext { - - public RequestContextImpl() { - } - - public Subject getSecuritySubject() { - throw new UnsupportedOperationException(); - } - - public String getServiceName() { - throw new UnsupportedOperationException(); - } - - public <B> ServiceReference<B> getServiceReference() { - throw new UnsupportedOperationException(); - } - - public <CB> CB getCallback() { - throw new UnsupportedOperationException(); - } - - public <CB> CallableReference<CB> getCallbackReference() { - throw new UnsupportedOperationException(); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ServiceReferenceImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ServiceReferenceImpl.java deleted file mode 100644 index e268f5750f..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ServiceReferenceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.component; - -import org.apache.tuscany.sca.factory.ObjectFactory; -import org.osoa.sca.ServiceReference; - -/** - * Default implementation of a ServiceReference. - * - * @version $Rev$ $Date$ - * @param <B> the type of the business interface - */ -public class ServiceReferenceImpl<B> extends CallableReferenceImpl<B> implements ServiceReference<B> { - public ServiceReferenceImpl(Class<B> businessInterface, ObjectFactory<B> factory) { - super(businessInterface, factory); - } - - public Object getConversationID() { - return null; - } - - public void setConversationID(Object conversationId) throws IllegalStateException { - } - - public void setCallbackID(Object callbackID) { - } - - public Object getCallback() { - return null; - } - - public void setCallback(Object callback) { - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java deleted file mode 100644 index 517e5579a4..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.tuscany.sca.event.Event; -import org.apache.tuscany.sca.event.EventFilter; -import org.apache.tuscany.sca.event.EventPublisher; -import org.apache.tuscany.sca.event.RuntimeEventListener; -import org.apache.tuscany.sca.event.TrueFilter; - -/** - * Base implementation of an <code>EventPublisher</code> - * - * @version $Rev$ $Date$ - */ -public abstract class BaseEventPublisher implements EventPublisher { - protected static final EventFilter TRUE_FILTER = new TrueFilter(); - protected Map<EventFilter, List<RuntimeEventListener>> listeners; - - public void addListener(RuntimeEventListener listener) { - addListener(TRUE_FILTER, listener); - } - - public void removeListener(RuntimeEventListener listener) { - assert listener != null : "Listener cannot be null"; - synchronized (getListeners()) { - for (List<RuntimeEventListener> currentList : getListeners().values()) { - for (RuntimeEventListener current : currentList) { - if (current == listener) { - currentList.remove(current); - return; - } - } - } - } - } - - public void addListener(EventFilter filter, RuntimeEventListener listener) { - assert listener != null : "Listener cannot be null"; - synchronized (getListeners()) { - List<RuntimeEventListener> list = getListeners().get(filter); - if (list == null) { - list = new CopyOnWriteArrayList<RuntimeEventListener>(); - listeners.put(filter, list); - } - list.add(listener); - } - } - - public void publish(Event event) { - assert event != null : "Event object was null"; - for (Map.Entry<EventFilter, List<RuntimeEventListener>> entry : getListeners().entrySet()) { - if (entry.getKey().match(event)) { - for (RuntimeEventListener listener : entry.getValue()) { - listener.onEvent(event); - } - } - } - } - - protected Map<EventFilter, List<RuntimeEventListener>> getListeners() { - if (listeners == null) { - listeners = new ConcurrentHashMap<EventFilter, List<RuntimeEventListener>>(); - } - return listeners; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java deleted file mode 100644 index 8e90c953e5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import java.net.URI; - -import org.apache.tuscany.sca.event.Event; - -/** - * Propagated when a component starts - * - * @version $$Rev$$ $$Date$$ - */ -public class ComponentStart implements Event { - - private Object source; - private URI uri; - - /** - * Creates a component start event - * - * @param source the source of the event - * @param componentURI the uri of the component being started - */ - public ComponentStart(Object source, URI componentURI) { - this.source = source; - this.uri = componentURI; - } - - public URI getComponentURI() { - return uri; - } - - public Object getSource() { - return source; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java deleted file mode 100644 index d879182e14..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import java.net.URI; - -import org.apache.tuscany.sca.event.Event; - -/** - * Propagated when a component stops - * - * @version $$Rev$$ $$Date$$ - */ -public class ComponentStop implements Event { - - private Object source; - private URI uri; - - /** - * Creates a component stop event - * - * @param source the source of the event - * @param componentUri the composite component associated the component being stopped - */ - public ComponentStop(Object source, URI componentUri) { - this.source = source; - this.uri = componentUri; - } - - public URI getComponentURI() { - return uri; - } - - public Object getSource() { - return source; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java deleted file mode 100644 index cd14710880..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import org.apache.tuscany.sca.event.Event; - - - -/** - * Propagated when a conversation is expired - * - * @version $$Rev$$ $$Date$$ - */ -public class ConversationEnd implements Event { - - private Object source; - private Object id; - - /** - * Creates a new event - * - * @param source the source of the event - * @param id the id of the conversation being ended - */ - public ConversationEnd(Object source, Object id) { - this.source = source; - this.id = id; - } - - public Object getSource() { - return source; - } - - public Object getConversationID() { - return id; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java deleted file mode 100644 index a4cc49204e..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import org.apache.tuscany.sca.event.Event; - - -/** - * Propagated when a conversation has started - * - * @version $$Rev$$ $$Date$$ - */ -public class ConversationStart implements Event { - - private Object source; - private Object id; - - /** - * Creates a new event - * - * @param source the source of the event - * @param id the id of the conversation being started - */ - public ConversationStart(Object source, Object id) { - this.source = source; - this.id = id; - } - - public Object getSource() { - return source; - } - - public Object getConversationID() { - return id; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java deleted file mode 100644 index 4c3fd8b397..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import org.apache.tuscany.sca.event.Event; - - - -/** - * Propagated when an HTTP-based session is expired - * - * @version $$Rev$$ $$Date$$ - */ -public class HttpSessionEnd implements Event { - - private Object source; - private Object id; - - /** - * Creates a new event - * - * @param source the source of the event - * @param id the id of the HTTP session being ended - */ - public HttpSessionEnd(Object source, Object id) { - this.source = source; - this.id = id; - } - - public Object getSource() { - return source; - } - - public Object getSessionID() { - return id; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java deleted file mode 100644 index 67b922b99c..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import org.apache.tuscany.sca.event.Event; - - -/** - * Propagated when an HTTP-based session has started - * - * @version $$Rev$$ $$Date$$ - */ -public class HttpSessionStart implements Event { - - private Object source; - private Object id; - - /** - * Creates a new event - * - * @param source the source of the event - * @param id the id of the HTTP session being started - */ - public HttpSessionStart(Object source, Object id) { - this.source = source; - this.id = id; - } - - public Object getSource() { - return source; - } - - public Object getSessionID() { - return id; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java deleted file mode 100644 index 8b5c512cf2..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import org.apache.tuscany.sca.event.Event; - -/** - * Propagated when a request completes or is ended - * - * @version $$Rev$$ $$Date$$ - */ -public class RequestEnd implements Event { - - private Object source; - - /** - * Creates a new event - * - * @param source the source of the event - */ - public RequestEnd(Object source) { - this.source = source; - } - - public Object getSource() { - return source; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java deleted file mode 100644 index 974563b57c..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import org.apache.tuscany.sca.event.Event; - -/** - * Propagated when a request is started in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public class RequestStart implements Event { - - private Object source; - - /** - * Creates a new event - * - * @param source the source of the event - */ - public RequestStart(Object source) { - this.source = source; - } - - public Object getSource() { - return source; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.java deleted file mode 100644 index 6c1f38e4c2..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import java.util.UUID; - -import org.apache.tuscany.sca.interfacedef.ConversationSequence; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -/** - * Base class for performing invocations on a wire. Subclasses are responsible for retrieving and supplying the - * appropriate chain, target invoker, and invocation arguments. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractInvocationHandler { - protected boolean conversational; - private boolean conversationStarted; - private MessageFactory messageFactory; - - protected AbstractInvocationHandler(MessageFactory messageFactory, boolean conversational) { - this.conversational = conversational; - this.messageFactory = messageFactory; - } - - protected Object invoke(InvocationChain chain, Object[] args, RuntimeWire wire) throws Throwable { - - Message msgContext = ThreadMessageContext.getMessageContext(); - Message msg = messageFactory.createMessage(); - if (conversational) { - Object id = msgContext.getConversationID(); - if (id == null) { - String convIdFromThread = createConversationID(); - msg.setConversationID(convIdFromThread); - } - } - - Invoker headInvoker = chain.getHeadInvoker(); - msg.setCorrelationID(msgContext.getCorrelationID()); - Operation operation = chain.getTargetOperation(); - Interface contract = operation.getInterface(); - if (contract != null && contract.isConversational()) { - ConversationSequence sequence = chain.getTargetOperation().getConversationSequence(); - if (sequence == ConversationSequence.CONVERSATION_END) { - msg.setConversationSequence(ConversationSequence.CONVERSATION_END); - conversationStarted = false; - } else if (sequence == ConversationSequence.CONVERSATION_CONTINUE) { - if (conversationStarted) { - msg.setConversationSequence(ConversationSequence.CONVERSATION_CONTINUE); - } else { - conversationStarted = true; - msg.setConversationSequence(ConversationSequence.CONVERSATION_START); - } - } - } - msg.setBody(args); - msg.setFrom(wire.getSource()); - msg.setTo(wire.getTarget()); - ThreadMessageContext.setMessageContext(msg); - try { - // dispatch the wire down the chain and get the response - Message resp = headInvoker.invoke(msg); - Object body = resp.getBody(); - if (resp.isFault()) { - throw (Throwable)body; - } - return body; - } finally { - ThreadMessageContext.setMessageContext(msgContext); - } - } - - /** - * Creates a new conversational id - * - * @return the conversational id - */ - private String createConversationID() { - return UUID.randomUUID().toString(); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java deleted file mode 100644 index 219dc55536..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.osoa.sca.NoRegisteredCallbackException; - -/** - * An interceptor applied to the forward direction of a wire that ensures the callback target implements the required - * service contract. This is required as callback targets may be set dynamically by service implementations. - * - * @version $Rev$ $Date$ - */ -public class CallbackInterfaceInterceptor implements Interceptor { - private boolean invokingServiceImplements; - private Invoker next; - - public CallbackInterfaceInterceptor(boolean invokingServiceImplements) { - this.invokingServiceImplements = invokingServiceImplements; - } - - public Message invoke(Message msg) { - // TODO check in the context if a callback object is set, if so invoke next since the setCallback will - // perform the check - if (!invokingServiceImplements) { - throw new NoRegisteredCallbackException("Callback target does not implement the callback interface"); - } - return next.invoke(msg); - } - - public void setNext(Invoker next) { - this.next = next; - } - - public Invoker getNext() { - return next; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java deleted file mode 100644 index dae4ed708b..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import java.util.List; - -import org.apache.tuscany.sca.factory.ObjectCreationException; -import org.apache.tuscany.sca.factory.ObjectFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -/** - * Returns proxy instance for a wire callback - * - * @version $Rev$ $Date$ - */ -public class CallbackWireObjectFactory implements ObjectFactory { - private ProxyFactory proxyFactory; - private Class<?> interfaze; - private List<RuntimeWire> wires; - - public CallbackWireObjectFactory(Class<?> interfaze, ProxyFactory proxyService, List<RuntimeWire> wires) { - this.interfaze = interfaze; - this.proxyFactory = proxyService; - this.wires = wires; - } - - public Object getInstance() throws ObjectCreationException { - return proxyFactory.createCallbackProxy(interfaze, wires); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java deleted file mode 100644 index 934f2f7aa0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; - -/** - * The default implementation of an extensible <code>WireProcessor</code> - * - * @version $Rev$ $Date$ - */ -public class ExtensibleWireProcessor implements RuntimeWireProcessor { - - private RuntimeWireProcessorExtensionPoint processors; - - public ExtensibleWireProcessor(RuntimeWireProcessorExtensionPoint processors) { - this.processors = processors; - } - - public void process(RuntimeWire wire) { - for (RuntimeWireProcessor processor : processors.getWireProcessors()) { - processor.process(wire); - } - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java deleted file mode 100644 index e04148e374..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; - -/** - * Default implementation of an invocation chain - * - * @version $Rev$ $Date$ - */ -public class InvocationChainImpl implements InvocationChain { - private Operation sourceOperation; - private Operation targetOperation; - private Invoker invokerChainHead; - private Invoker invokerChainTail; - - public InvocationChainImpl(Operation operation) { - assert operation != null; - this.targetOperation = operation; - this.sourceOperation = operation; - } - - public InvocationChainImpl(Operation sourceOperation, Operation targetOperation) { - assert sourceOperation != null; - assert targetOperation != null; - this.targetOperation = targetOperation; - this.sourceOperation = sourceOperation; - } - - public Operation getTargetOperation() { - return targetOperation; - } - - public void addInterceptor(Interceptor interceptor) { - if (invokerChainHead == null) { - invokerChainHead = interceptor; - } else { - if (invokerChainHead instanceof Interceptor) { - ((Interceptor)invokerChainTail).setNext(interceptor); - } - } - invokerChainTail = interceptor; - } - - public void addInvoker(Invoker invoker) { - if (invokerChainHead == null) { - invokerChainHead = invoker; - } else { - if (invokerChainTail instanceof Interceptor) { - ((Interceptor)invokerChainTail).setNext(invoker); - } - } - invokerChainTail = invoker; - } - - public Invoker getHeadInvoker() { - return invokerChainHead; - } - - public Invoker getTailInvoker() { - return invokerChainTail; - } - - /** - * @return the sourceOperation - */ - public Operation getSourceOperation() { - return sourceOperation; - } - - /** - * @param sourceOperation the sourceOperation to set - */ - public void setSourceOperation(Operation sourceOperation) { - this.sourceOperation = sourceOperation; - } - - public void addInterceptor(int index, Interceptor interceptor) { - int i = 0; - Invoker next = invokerChainHead; - Invoker prev = null; - while (next != null && i < index) { - prev = next; - if (next instanceof Interceptor) { - next = ((Interceptor)next).getNext(); - i++; - } else { - throw new ArrayIndexOutOfBoundsException(index); - } - } - if (i == index) { - if (prev != null) { - ((Interceptor)prev).setNext(interceptor); - } else { - invokerChainHead = interceptor; - } - interceptor.setNext(next); - if (next == null) { - invokerChainTail = interceptor; - } - } else { - throw new ArrayIndexOutOfBoundsException(index); - } - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java deleted file mode 100644 index 5a028e6e22..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.EndpointReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.osoa.sca.NoRegisteredCallbackException; - -/** - * Responsible for dispatching to a callback through a wire. <p/> TODO cache - * target invoker - * - * @version $Rev$ $Date$ - */ -public class JDKCallbackInvocationHandler extends AbstractInvocationHandler implements InvocationHandler { - private static final long serialVersionUID = -3350283555825935609L; - private transient Map<String, RuntimeWire> wires; - - /** - * Constructor used for deserialization only - */ - public JDKCallbackInvocationHandler(MessageFactory messageFactory) { - super(messageFactory, false); - wires = new HashMap<String, RuntimeWire>(); - } - - public JDKCallbackInvocationHandler(MessageFactory messageFactory, List<RuntimeWire> wireList) { - super(messageFactory, false); - this.wires = new HashMap<String, RuntimeWire>(); - for (RuntimeWire wire : wireList) { - wires.put(wire.getSource().getURI(), wire); - } - } - - @SuppressWarnings( {"unchecked"}) - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) { - return "[Proxy - " + Integer.toHexString(hashCode()) + "]"; - } else if (method.getDeclaringClass().equals(Object.class) && "equals".equals(method.getName())) { - // TODO implement - throw new UnsupportedOperationException(); - } else if (Object.class.equals(method.getDeclaringClass()) && "hashCode".equals(method.getName())) { - return hashCode(); - // TODO beter hash algorithm - } - EndpointReference from = ThreadMessageContext.getMessageContext().getFrom(); - RuntimeWire wire = wires.get(from.getURI()); - assert wire != null; - List<InvocationChain> chains = wire.getCallbackInvocationChains(); - IdentityHashMap<Operation, InvocationChain> map = new IdentityHashMap<Operation, InvocationChain>(); - for (InvocationChain chain : chains) { - map.put(chain.getTargetOperation(), chain); - } - Operation operation = JavaInterfaceUtil.findOperation(method, map.keySet()); - InvocationChain chain = map.get(operation); - try { - return invoke(chain, args, wire); - } catch (InvocationTargetException e) { - Throwable t = e.getCause(); - if (t instanceof NoRegisteredCallbackException) { - throw t; - } - throw e; - } - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java deleted file mode 100644 index 756e5c545f..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -/** - * @version $Rev$ $Date$ - */ -public class JDKInvocationHandler extends AbstractInvocationHandler implements InvocationHandler { - // private Class<?> proxyInterface; - private RuntimeWire wire; - - public JDKInvocationHandler(MessageFactory messageFactory, Class<?> proxyInterface, RuntimeWire wire) { - super(messageFactory, false); - this.wire = wire; - init(proxyInterface, wire); - } - - private void init(Class<?> interfaze, RuntimeWire wire) { - InterfaceContract contract = wire.getSource().getInterfaceContract(); - this.conversational = contract.getInterface().isConversational(); - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) { - return "[Proxy - " + Integer.toHexString(hashCode()) + "]"; - } else if (method.getDeclaringClass().equals(Object.class) && "equals".equals(method.getName())) { - Object obj = args[0]; - if (obj == null) { - return false; - } - if (!Proxy.isProxyClass(obj.getClass())) { - return false; - } - return equals(Proxy.getInvocationHandler(obj)); - } else if (Object.class.equals(method.getDeclaringClass()) && "hashCode".equals(method.getName())) { - return hashCode(); - } - InvocationChain chain = getInvocationChain(method); - if (chain == null) { - throw new IllegalArgumentException("No matching opeeration is found: " + method); - } - - // send the invocation down the wire - Object result = invoke(chain, args, wire); - - return result; - } - - /** - * Determines if the given operation matches the given method - * - * @return true if the operation matches, false if does not - */ - private static boolean match(Operation operation, Method method) { - Class<?>[] params = method.getParameterTypes(); - DataType<List<DataType>> inputType = operation.getInputType(); - List<DataType> types = inputType.getLogical(); - boolean matched = true; - if (types.size() == params.length && method.getName().equals(operation.getName())) { - for (int i = 0; i < params.length; i++) { - Class<?> clazz = params[i]; - if (!clazz.equals(operation.getInputType().getLogical().get(i).getPhysical())) { - matched = false; - } - } - } else { - matched = false; - } - return matched; - - } - - private InvocationChain getInvocationChain(Method method) { - for (InvocationChain chain : wire.getInvocationChains()) { - Operation operation = chain.getSourceOperation(); - if (operation.isDynamic()) { - operation.setName(method.getName()); - return chain; - } else if (match(operation, method)) { - return chain; - } - } - return null; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java deleted file mode 100644 index 371f9bedb8..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import java.lang.reflect.Proxy; -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.osoa.sca.CallableReference; - -/** - * the default implementation of a wire service that uses JDK dynamic proxies - * - * @version $$Rev$$ $$Date: 2007-04-11 18:59:43 -0700 (Wed, 11 Apr - * 2007) $$ - */ -public class JDKProxyService implements ProxyFactory { - protected InterfaceContractMapper contractMapper; - private MessageFactory messageFactory; - - public JDKProxyService() { - this(new MessageFactoryImpl(), new InterfaceContractMapperImpl()); - } - - public JDKProxyService(MessageFactory messageFactory, InterfaceContractMapper mapper) { - this.contractMapper = mapper; - this.messageFactory = messageFactory; - } - - public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException { - assert interfaze != null; - assert wire != null; - JDKInvocationHandler handler = new JDKInvocationHandler(messageFactory, interfaze, wire); - ClassLoader cl = interfaze.getClassLoader(); - return interfaze.cast(Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler)); - } - - public Object createCallbackProxy(Class<?> interfaze, List<RuntimeWire> wires) throws ProxyCreationException { - ClassLoader cl = interfaze.getClassLoader(); - JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, wires); - return interfaze.cast(Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler)); - } - - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - throw new UnsupportedOperationException(); - - // InvocationHandler handler = Proxy.getInvocationHandler(target); - // if (handler instanceof JDKInvocationHandler) { - // // TODO return a ServiceReference - // throw new UnsupportedOperationException(); - // } else if (handler instanceof JDKCallbackInvocationHandler) { - // // TODO return a CallbackReference - // throw new UnsupportedOperationException(); - // } else { - // throw new IllegalArgumentException("Not a Tuscany SCA proxy"); - // } - - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageFactoryImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageFactoryImpl.java deleted file mode 100644 index 6e182a6a14..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageFactoryImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.MessageFactory; - -/** - * Implementation of MessageFactory. - * - * @version $Rev$ $Date$ - */ -public class MessageFactoryImpl implements MessageFactory { - - public Message createMessage() { - return new MessageImpl(); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java deleted file mode 100644 index a1b2963cf5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.interfacedef.ConversationSequence; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.EndpointReference; - -/** - * The default implementation of a message flowed through a wire during an invocation - * - * @version $Rev $Date - */ -public class MessageImpl implements Message { - private Object body; - private Object messageID; - private Object correlationID; - private boolean isFault; - private ConversationSequence conversationSequence; - private String conversationId; - - private EndpointReference from; - private EndpointReference to; - - public MessageImpl(String conversationId, ConversationSequence conversationSequence, Object body) { - this.conversationId = conversationId; - this.conversationSequence = conversationSequence; - this.body = body; - } - - public MessageImpl() { - } - - @SuppressWarnings("unchecked") - public <T> T getBody() { - return (T) body; - } - - public <T> void setBody(T body) { - this.isFault = false; - this.body = body; - } - - public String getConversationID() { - return conversationId; - } - - public void setConversationID(String conversationId) { - this.conversationId = conversationId; - } - - public ConversationSequence getConversationSequence() { - return conversationSequence; - } - - public void setConversationSequence(ConversationSequence conversationSequence) { - this.conversationSequence = conversationSequence; - } - - public Object getMessageID() { - return messageID; - } - - public void setMessageID(Object messageId) { - this.messageID = messageId; - } - - public Object getCorrelationID() { - return correlationID; - } - - public void setCorrelationID(Object correlationId) { - this.correlationID = correlationId; - } - - public boolean isFault() { - return isFault; - } - - public void setFaultBody(Object fault) { - this.isFault = true; - this.body = fault; - } - - public EndpointReference getFrom() { - return from; - } - - public void setFrom(EndpointReference from) { - this.from = from; - } - - public EndpointReference getTo() { - return to; - } - - public void setTo(EndpointReference to) { - this.to = to; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NoMethodForOperationException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NoMethodForOperationException.java deleted file mode 100644 index cbeedc086d..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NoMethodForOperationException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - - -/** - * Thrown when an {@link org.apache.tuscany.sca.factory.model.Operation} cannot be mapped to a method on an interface - * @version $Rev$ $Date$ - */ -public class NoMethodForOperationException extends ProxyCreationException { - private static final long serialVersionUID = 5116536602309483679L; - - public NoMethodForOperationException() { - } - - public NoMethodForOperationException(String message) { - super(message); - } - - public NoMethodForOperationException(String message, Throwable cause) { - super(message, cause); - } - - public NoMethodForOperationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java deleted file mode 100644 index be6f364271..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import java.util.LinkedList; - -import org.apache.tuscany.sca.interfacedef.ConversationSequence; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.EndpointReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.apache.tuscany.sca.work.WorkScheduler; -import org.osoa.sca.ServiceRuntimeException; - -/** - * Adds non-blocking behavior to an invocation chain - * - * @version $$Rev$$ $$Date$$ - */ -public class NonBlockingInterceptor implements Interceptor { - - private static final Message RESPONSE = new ImmutableMessage(); - - private WorkScheduler workScheduler; - private Invoker next; - - public NonBlockingInterceptor(WorkScheduler workScheduler) { - this.workScheduler = workScheduler; - } - - public NonBlockingInterceptor(WorkScheduler workScheduler, Interceptor next) { - this.workScheduler = workScheduler; - this.next = next; - } - - public Message invoke(final Message msg) { - // Retrieve conversation id to transfer to new thread - // Notice that we cannot clear the conversation id from the current thread - final String conversationID = ThreadMessageContext.getMessageContext().getConversationID(); - // Schedule the invocation of the next interceptor in a new Work instance - try { - workScheduler.scheduleWork(new Runnable() { - public void run() { - msg.setCorrelationID(null); - // if we got a conversation id, transfer it to new thread - if (conversationID != null) { - msg.setConversationID(conversationID); - } - Message context = ThreadMessageContext.setMessageContext(msg); - try { - next.invoke(msg); - } finally { - ThreadMessageContext.setMessageContext(context); - } - } - }); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - return RESPONSE; - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - /** - * A dummy message passed back on an invocation - */ - private static class ImmutableMessage implements Message { - - public String getConversationID() { - return null; - } - - public RuntimeWire getWire() { - return null; - } - - public void setConversationID(String conversationId) { - throw new UnsupportedOperationException(); - } - - public void setWire(RuntimeWire wire) { - throw new UnsupportedOperationException(); - } - - @SuppressWarnings("unchecked") - public Object getBody() { - return null; - } - - public void setBody(Object body) { - if (body != null) { - throw new UnsupportedOperationException(); - } - } - - public void setCallbackWires(LinkedList<RuntimeWire> wires) { - - } - - public Object getMessageID() { - return null; - } - - public void setMessageID(Object messageId) { - throw new UnsupportedOperationException(); - } - - public Object getCorrelationID() { - return null; - } - - public void setCorrelationID(Object correlationId) { - throw new UnsupportedOperationException(); - } - - public boolean isFault() { - return false; - } - - public void setFaultBody(Object fault) { - throw new UnsupportedOperationException(); - } - - public void setConversationSequence(ConversationSequence sequence) { - throw new UnsupportedOperationException(); - } - - public ConversationSequence getConversationSequence() { - return null; - } - - public EndpointReference getFrom() { - return null; - } - - public EndpointReference getTo() { - return null; - } - - public void setFrom(EndpointReference from) { - throw new UnsupportedOperationException(); - } - - public void setTo(EndpointReference to) { - throw new UnsupportedOperationException(); - } - - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java deleted file mode 100644 index 4900ae9a7e..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.factory.ObjectCreationException; - - -/** - * Denotes an error creating a proxy - * - * @version $$Rev$$ $$Date$$ - */ -public class ProxyCreationException extends ObjectCreationException { - private static final long serialVersionUID = 8002454344828513781L; - - public ProxyCreationException() { - super(); - } - - public ProxyCreationException(String message, Throwable cause) { - super(message, cause); - } - - public ProxyCreationException(String message) { - super(message); - } - - public ProxyCreationException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java deleted file mode 100644 index 381844ffc5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import java.util.List; - -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.osoa.sca.CallableReference; - -/** - * Creates proxies that implement Java interfaces and invocation handlers for fronting wires - * - * @version $$Rev$$ $$Date$$ - */ - -public interface ProxyFactory { - - /** - * Creates a Java proxy for the given wire - * - * @param interfaze the interface the proxy implements - * @param wire the wire to proxy @return the proxy - * @throws ProxyCreationException - */ - <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException; - - /** - * Creates a Java proxy for the service contract callback - * - * @param interfaze the interface the proxy should implement - * @return the proxy - * @throws ProxyCreationException - */ - Object createCallbackProxy(Class<?> interfaze, List<RuntimeWire> wires) throws ProxyCreationException; - - /** - * Cast a proxy to a CallableReference. - * - * @param target a proxy generated by this implementation - * @return a CallableReference (or subclass) equivalent to this prozy - * @throws IllegalArgumentException if the object supplied is not a proxy - */ - <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException; - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java deleted file mode 100644 index 52bea91341..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.invocation.Message; - -/** - * Class for tunneling a WorkContext through the invocation of a user class. - * - * @version $Rev$ $Date$ - */ -public final class ThreadMessageContext { - - private static final ThreadLocal<Message> CONTEXT = new ThreadLocal<Message>() { - protected synchronized Message initialValue() { - return new MessageImpl(); - } - }; - - private ThreadMessageContext() { - } - - /** - * Set the WorkContext for the current thread. - * The current work context is returned and must be restored after the invocation is complete. - * Typical usage would be: - * <pre> - * WorkContext old = PojoWorkContextTunnel.setThreadWorkContext(newContext); - * try { - * ... invoke user code ... - * } finally { - * PojoWorkContextTunnel.setThreadWorkContext(old); - * } - * </pre> - * @param context - * @return the current work context for the thread; this must be restored after the invocation is made - */ - public static Message setMessageContext(Message context) { - Message old = CONTEXT.get(); - CONTEXT.set(context); - return old; - } - - /** - * Returns the WorkContext for the current thread. - * - * @return the WorkContext for the current thread - */ - public static Message getMessageContext() { - return CONTEXT.get(); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java deleted file mode 100644 index e6e41e8f85..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.invocation; - -import org.apache.tuscany.sca.factory.ObjectCreationException; -import org.apache.tuscany.sca.factory.ObjectFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -/** - * Uses a wire to return an object instance - * - * @version $Rev$ $Date$ - */ -public class WireObjectFactory<T> implements ObjectFactory<T> { - private Class<T> interfaze; - private RuntimeWire wire; - private ProxyFactory proxyService; - private boolean optimizable; - - /** - * Constructor. - * - * @param interfaze the interface to inject on the client - * @param wire the backing wire - * @param proxyService the wire service to create the proxy - * @throws NoMethodForOperationException - */ - public WireObjectFactory(Class<T> interfaze, RuntimeWire wire, ProxyFactory proxyService) - throws NoMethodForOperationException { - this.interfaze = interfaze; - this.wire = wire; - this.proxyService = proxyService; - } - - public T getInstance() throws ObjectCreationException { - return interfaze.cast(proxyService.createProxy(interfaze, wire)); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/ActivationException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/ActivationException.java deleted file mode 100644 index 987a8288b0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/ActivationException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - - -/** - * Denotes an error starting the runtime - * - * @version $Rev$ $Date$ - */ -public class ActivationException extends Exception { - private static final long serialVersionUID = 8612661660934426123L; - - public ActivationException(String message) { - super(message); - } - - public ActivationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java deleted file mode 100644 index fc8a8f0a15..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; - -/** - * Start/stop a composite - * - * @version $Rev$ $Date$ - */ -public interface CompositeActivator { - - /** - * Activate a composite - * @param composite - */ - void activate(Composite composite) throws ActivationException; - - /** - * Stop a composite - * @param composite - */ - void deactivate(Composite composite) throws ActivationException; - - /** - * Start a composite - * @deprecated - * @param composite - */ - void start(Composite composite) throws ActivationException; - - /** - * Stop a composite - * @deprecated - * @param composite - */ - void stop(Composite composite) throws ActivationException; - - /** - * Start a component - * @param component - */ - void start(Component component) throws ActivationException; - - /** - * Stop a composite - * @param composite - */ - void stop(Component component) throws ActivationException; - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java deleted file mode 100644 index 9f5d2ab63d..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java +++ /dev/null @@ -1,655 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderMonitor; -import org.apache.tuscany.sca.assembly.builder.Problem; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.core.invocation.InvocationChainImpl; -import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; -import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.BindingProviderFactory; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.EndpointReference; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; -import org.apache.tuscany.sca.scope.ScopeRegistry; -import org.apache.tuscany.sca.scope.ScopedRuntimeComponent; -import org.apache.tuscany.sca.work.WorkScheduler; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeActivatorImpl implements CompositeActivator { - - private final AssemblyFactory assemblyFactory; - private final SCABindingFactory scaBindingFactory; - private final InterfaceContractMapper interfaceContractMapper; - private final ScopeRegistry scopeRegistry; - private final WorkScheduler workScheduler; - private final RuntimeWireProcessor wireProcessor; - private final ProviderFactoryExtensionPoint providerFactories; - - /** - * @param assemblyFactory - * @param interfaceContractMapper - * @param workContext - * @param workScheduler - * @param wirePostProcessorRegistry - */ - public CompositeActivatorImpl(AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - InterfaceContractMapper interfaceContractMapper, - ScopeRegistry scopeRegistry, - WorkScheduler workScheduler, - RuntimeWireProcessor wireProcessor, - ProviderFactoryExtensionPoint providerFactories) { - super(); - this.assemblyFactory = assemblyFactory; - this.scaBindingFactory = scaBindingFactory; - this.interfaceContractMapper = interfaceContractMapper; - this.scopeRegistry = scopeRegistry; - this.workScheduler = workScheduler; - this.wireProcessor = wireProcessor; - this.providerFactories = providerFactories; - } - - /** - * Configure a composite - * - * @param composite - * @throws IncompatibleInterfaceContractException - */ - @SuppressWarnings("unchecked") - protected void configureComposite(Composite composite) throws IncompatibleInterfaceContractException { - for (Component component : composite.getComponents()) { - - for (ComponentService service : component.getServices()) { - for (Binding binding : service.getBindings()) { - BindingProviderFactory providerFactory = (BindingProviderFactory)providerFactories - .getProviderFactory(binding.getClass()); - if (providerFactory != null) { - ServiceBindingProvider bindingProvider = providerFactory - .createServiceBindingProvider((RuntimeComponent)component, - (RuntimeComponentService)service, - binding); - if (bindingProvider != null) { - ((RuntimeComponentService)service).setBindingProvider(binding, bindingProvider); - } - } else { - throw new IllegalStateException("Provider factory not found for class: " + binding.getClass() - .getName()); - } - } - } - for (ComponentReference reference : component.getReferences()) { - for (Binding binding : reference.getBindings()) { - BindingProviderFactory providerFactory = (BindingProviderFactory)providerFactories - .getProviderFactory(binding.getClass()); - if (providerFactory != null) { - ReferenceBindingProvider bindingProvider = providerFactory - .createReferenceBindingProvider((RuntimeComponent)component, - (RuntimeComponentReference)reference, - binding); - if (bindingProvider != null) { - ((RuntimeComponentReference)reference).setBindingProvider(binding, bindingProvider); - } - } else { - throw new IllegalStateException("Provider factory not found for class: " + binding.getClass() - .getName()); - } - } - } - - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - configureComposite((Composite)implementation); - } else if (implementation != null) { - ImplementationProviderFactory providerFactory = (ImplementationProviderFactory)providerFactories - .getProviderFactory(implementation.getClass()); - if (providerFactory != null) { - ImplementationProvider implementationProvider = providerFactory - .createImplementationProvider((RuntimeComponent)component, implementation); - if (implementationProvider != null) { - ((RuntimeComponent)component).setImplementationProvider(implementationProvider); - } - } else { - throw new IllegalStateException("Provider factory not found for class: " + implementation - .getClass().getName()); - } - setScopeContainer(component); - } - } - } - - /** - * Start a composite - */ - protected void startComposite(Composite composite) { - for (Component component : composite.getComponents()) { - startComponent(component); - } - } - - /** - * Stop a composite - */ - public void stopComposite(Composite composite) { - for (Component component : composite.getComponents()) { - stopComponent(component); - - } - - } - - /** - * Start a component - */ - public void startComponent(Component component) { - - for (ComponentService service : component.getServices()) { - for (Binding binding : service.getBindings()) { - ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service) - .getBindingProvider(binding); - if (bindingProvider != null) { - bindingProvider.start(); - } - } - } - for (ComponentReference reference : component.getReferences()) { - for (Binding binding : reference.getBindings()) { - ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference) - .getBindingProvider(binding); - if (bindingProvider != null) { - try { - bindingProvider.start(); - } catch (RuntimeException e) { - // TODO: [rfeng] Ignore the self reference if a runtime exception happens - if (!reference.getName().startsWith("$self$.")) { - throw e; - } - } - } - } - } - - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - startComposite((Composite)implementation); - } else { - ImplementationProvider implementationProvider = ((RuntimeComponent)component) - .getImplementationProvider(); - if (implementationProvider != null) { - implementationProvider.start(); - } - } - - if (component instanceof ScopedRuntimeComponent) { - ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component; - if (runtimeComponent.getScopeContainer() != null) { - runtimeComponent.getScopeContainer().start(); - } - } - - } - - /** - * Stop a component - */ - public void stopComponent(Component component) { - for (ComponentService service : component.getServices()) { - for (Binding binding : service.getBindings()) { - ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service) - .getBindingProvider(binding); - if (bindingProvider != null) { - bindingProvider.stop(); - } - } - } - for (ComponentReference reference : component.getReferences()) { - for (Binding binding : reference.getBindings()) { - ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference) - .getBindingProvider(binding); - if (bindingProvider != null) { - bindingProvider.stop(); - } - } - } - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - stopComposite((Composite)implementation); - } else { - ImplementationProvider implementationProvider = ((RuntimeComponent)component) - .getImplementationProvider(); - if (implementationProvider != null) { - implementationProvider.stop(); - } - } - - if (component instanceof ScopedRuntimeComponent) { - ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component; - if (runtimeComponent.getScopeContainer() != null) { - runtimeComponent.getScopeContainer().stop(); - } - } - - } - - - /** - * Create runtime wires for the composite - * - * @param composite - * @throws IncompatibleInterfaceContractException - */ - protected void createRuntimeWires(Composite composite) throws IncompatibleInterfaceContractException { - for (Component component : composite.getComponents()) { - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - // Recursively create runtime wires - createRuntimeWires((Composite)implementation); - } else { - // Create outbound wires for the component references - for (ComponentReference reference : component.getReferences()) { - for (Binding binding : reference.getBindings()) { - createWires(component, reference, binding); - } - } - // Create inbound wires for the component services - for (ComponentService service : component.getServices()) { - for (Binding binding : service.getBindings()) { - createWires(component, service, binding); - } - } - } - } - } - - /** - * Get the effective interface contract for a reference binding - * - * @param reference - * @param binding - * @return - */ - private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding) { - InterfaceContract interfaceContract = reference.getInterfaceContract(); - ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding); - if (provider != null) { - InterfaceContract bindingContract = provider.getBindingInterfaceContract(); - if (bindingContract != null) { - interfaceContract = bindingContract; - } - } - return interfaceContract; - } - - /** - * Create the runtime wires for a reference binding - * - * @param component - * @param reference - * @param binding - */ - private void createWires(Component component, ComponentReference reference, Binding binding) { - if (!(reference instanceof RuntimeComponentReference)) { - return; - } - RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference; - InterfaceContract bindingContract = getInterfaceContract(reference, binding); - - if (!(binding instanceof SCABinding)) { - InterfaceContract sourceContract = reference.getInterfaceContract(); - - // Component Reference --> External Service - EndpointReference wireSource = new EndpointReferenceImpl((RuntimeComponent)component, - (RuntimeComponentReference)reference, binding, - sourceContract); - - EndpointReference wireTarget = new EndpointReferenceImpl(null, null, binding, bindingContract); - RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget); - - for (Operation operation : sourceContract.getInterface().getOperations()) { - Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation); - InvocationChain chain = new InvocationChainImpl(operation, targetOperation); - if (operation.isNonBlocking()) { - chain.addInterceptor(new NonBlockingInterceptor(workScheduler)); - } - addBindingInterceptor(component, reference, binding, chain, operation, false); - wire.getInvocationChains().add(chain); - } - if (sourceContract.getCallbackInterface() != null) { - for (Operation operation : sourceContract.getCallbackInterface().getOperations()) { - Operation targetOperation = interfaceContractMapper.map(bindingContract.getCallbackInterface(), - operation); - InvocationChain chain = new InvocationChainImpl(operation, targetOperation); - if (operation.isNonBlocking()) { - chain.addInterceptor(new NonBlockingInterceptor(workScheduler)); - } - addBindingInterceptor(component, reference, binding, chain, operation, true); - wire.getCallbackInvocationChains().add(chain); - } - } - runtimeRef.getRuntimeWires().add(wire); - wireProcessor.process(wire); - // TODO: For non-SCA binding, how do we deal with targets? For now, assuming targets only apply to SCABinding - return; - } - for (ComponentService service : reference.getTargets()) { - Component target = null; - SCABinding scaBinding = service.getBinding(SCABinding.class); - if (scaBinding != null) { - target = scaBinding.getComponent(); - } - - // FIXME: [rfeng] Ignore unresolved services - if (service.isUnresolved()) { - continue; - } - - // FIXME: [rfeng] We might need a better way to get the impl interface contract - InterfaceContract targetContract = service.getService().getInterfaceContract(); - - EndpointReference wireSource = new EndpointReferenceImpl((RuntimeComponent)component, - (RuntimeComponentReference)reference, binding, - bindingContract); - - EndpointReference wireTarget = new EndpointReferenceImpl((RuntimeComponent)target, - (RuntimeComponentService)service, binding, - targetContract); - - RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget); - - for (Operation operation : bindingContract.getInterface().getOperations()) { - Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); - InvocationChain chain = new InvocationChainImpl(operation, targetOperation); - if (operation.isNonBlocking()) { - chain.addInterceptor(new NonBlockingInterceptor(workScheduler)); - } - addBindingInterceptor(component, reference, binding, chain, operation, false); - if (target != null) { - addImplementationInterceptor(target, service, chain, targetOperation, false); - } - wire.getInvocationChains().add(chain); - } - if (bindingContract.getCallbackInterface() != null) { - if (reference.getName().startsWith("$self$.")) { - // No callback is needed - continue; - } - for (Operation operation : bindingContract.getCallbackInterface().getOperations()) { - Operation targetOperation = interfaceContractMapper.map(targetContract.getCallbackInterface(), - operation); - InvocationChain chain = new InvocationChainImpl(operation, targetOperation); - if (operation.isNonBlocking()) { - chain.addInterceptor(new NonBlockingInterceptor(workScheduler)); - } - addBindingInterceptor(component, reference, binding, chain, operation, true); - addImplementationInterceptor(component, null, chain, targetOperation, true); - wire.getCallbackInvocationChains().add(chain); - } - } - - runtimeRef.getRuntimeWires().add(wire); - if (!wire.getCallbackInvocationChains().isEmpty()) { - if (wire.getTarget().getContract() != null) { - ((RuntimeComponentService) wire.getTarget().getContract()).getCallbackWires().add(wire); - } - } - wireProcessor.process(wire); - } - } - - /** - * Get the effective interface contract for the service binding - * - * @param service - * @param binding - * @return - */ - private InterfaceContract getInterfaceContract(ComponentService service, Binding binding) { - InterfaceContract interfaceContract = service.getInterfaceContract(); - - ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding); - if (provider != null) { - InterfaceContract bindingContract = provider.getBindingInterfaceContract(); - if (bindingContract != null) { - interfaceContract = bindingContract; - } - } - return interfaceContract; - } - - /** - * Create runtime wires for a service binding - * - * @param component - * @param service - * @param binding - */ - private void createWires(Component component, ComponentService service, Binding binding) { - if (!(service instanceof RuntimeComponentService)) { - return; - } - RuntimeComponentService runtimeService = (RuntimeComponentService)service; - - // FIXME: [rfeng] We might need a better way to get the impl interface contract - InterfaceContract targetContract = service.getService().getInterfaceContract(); - - InterfaceContract sourceContract = getInterfaceContract(service, binding); - - EndpointReference wireSource = new EndpointReferenceImpl(null, null, binding, sourceContract); - - EndpointReference wireTarget = new EndpointReferenceImpl((RuntimeComponent)component, - (RuntimeComponentService)service, binding, - targetContract); - - RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget); - - for (Operation operation : sourceContract.getInterface().getOperations()) { - Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); - InvocationChain chain = new InvocationChainImpl(operation, targetOperation); - /* lresende */ - if (operation.isNonBlocking()) { - chain.addInterceptor(new NonBlockingInterceptor(workScheduler)); - } - - addImplementationInterceptor(component, service, chain, targetOperation, false); - wire.getInvocationChains().add(chain); - } - // if (sourceContract.getCallbackInterface() != null) { - // for (Operation operation : - // sourceContract.getCallbackInterface().getOperations()) { - // Operation targetOperation = - // interfaceContractMapper.map(targetContract.getCallbackInterface(), - // operation); - // InvocationChain chain = new InvocationChainImpl(operation, - // targetOperation); - // if (operation.isNonBlocking()) { - // chain.addInterceptor(new NonBlockingInterceptor(workScheduler, - // workContext)); - // } - // addImplementationInterceptor(component, service, chain, operation, - // true); - // wire.getCallbackInvocationChains().add(chain); - // } - // } - - runtimeService.getRuntimeWires().add(wire); - wireProcessor.process(wire); - } - - /** - * Add the interceptor for a component implementation - * - * @param component - * @param service - * @param chain - * @param operation - * @param isCallback - */ - private void addImplementationInterceptor(Component component, - ComponentService service, - InvocationChain chain, - Operation operation, - boolean isCallback) { - ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider(); - if (provider != null) { - Invoker invoker = null; - if (!isCallback) { - invoker = provider.createInvoker((RuntimeComponentService)service, operation); - } else { - invoker = provider.createCallbackInvoker(operation); - } - chain.addInvoker(invoker); - } - } - - /** - * Add the interceptor for a binding - * - * @param component - * @param reference - * @param binding - * @param chain - * @param operation - * @param isCallback - */ - private void addBindingInterceptor(Component component, - ComponentReference reference, - Binding binding, - InvocationChain chain, - Operation operation, - boolean isCallback) { - try { - ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding); - if (provider != null) { - Invoker invoker = provider.createInvoker(operation, isCallback); - if (invoker != null) { - chain.addInvoker(invoker); - } - } - } catch (RuntimeException e) { - // TODO: [rfeng] Ignore the self reference if a runtime exception happens - if (!reference.getName().startsWith("$self$.")) { - throw e; - } - } - } - - private void setScopeContainer(Component component) { - if (!(component instanceof ScopedRuntimeComponent)) { - return; - } - ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component; - runtimeComponent.setScopeContainer(scopeRegistry.getScopeContainer(runtimeComponent)); - } - - protected void buildComposite(Composite composite) throws CompositeBuilderException { - - CompositeBuilderMonitor monitor = new CompositeBuilderMonitor() { - - public void problem(Problem problem) { - // Uncommenting the following two lines can be useful to detect - // and troubleshoot SCA assembly XML composite configuration - // problems. - - System.out.println("Composite assembly problem: " + problem.getMessage()); - } - }; - - CompositeBuilderImpl builder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, monitor); - - builder.build(composite); - - // if (!problems.isEmpty()) { - // throw new VariantRuntimeException(new RuntimeException("Problems in - // the composite...")); - // } - } - - public void activate(Composite composite) throws ActivationException { - try { - buildComposite(composite); - configureComposite(composite); - createRuntimeWires(composite); - } catch (Exception e) { - throw new ActivationException(e); - } - } - - public void deactivate(Composite composite) throws ActivationException { - } - - public void start(Composite composite) throws ActivationException { - try { - startComposite(composite); - } catch (Exception e) { - throw new ActivationException(e); - } - } - - public void stop(Composite composite) throws ActivationException { - try{ - stopComposite(composite); - } catch(Exception e) { - throw new ActivationException(e); - } - } - - public void start(Component component) throws ActivationException { - try { - startComponent(component); - } catch (Exception e) { - throw new ActivationException(e); - } - - } - - public void stop(Component component) throws ActivationException { - try{ - stopComponent(component); - } catch(Exception e) { - throw new ActivationException(e); - } - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/EndpointReferenceImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/EndpointReferenceImpl.java deleted file mode 100644 index 233f81ccae..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/EndpointReferenceImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.runtime.EndpointReference; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * @version $Rev$ $Date$ - */ -public class EndpointReferenceImpl implements EndpointReference { - private RuntimeComponent component; - private Contract contract; - private Binding binding; - private InterfaceContract interfaceContract; - private String uri; - - /** - * @param component - * @param contract - * @param binding - * @param interfaceContract - */ - public EndpointReferenceImpl(RuntimeComponent component, - Contract contract, - Binding binding, - InterfaceContract interfaceContract) { - super(); - this.component = component; - this.contract = contract; - this.binding = binding; - this.interfaceContract = interfaceContract; - this.uri = binding.getURI(); - } - - /** - * @param uri - */ - public EndpointReferenceImpl(String uri) { - super(); - this.uri = uri; - } - - public Binding getBinding() { - return binding; - } - - public void setBinding(Binding binding) { - this.binding = binding; - } - - public RuntimeComponent getComponent() { - return component; - } - - public void setComponent(RuntimeComponent component) { - this.component = component; - } - - public Contract getContract() { - return contract; - } - - public void setContract(Contract contract) { - this.contract = contract; - } - - public InterfaceContract getInterfaceContract() { - return interfaceContract; - } - - public void setInterfaceContract(InterfaceContract interfaceContract) { - this.interfaceContract = interfaceContract; - } - - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - @Override - public int hashCode() { - final int PRIME = 31; - int result = 1; - result = PRIME * result + ((uri == null) ? 0 : uri.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final EndpointReferenceImpl other = (EndpointReferenceImpl)obj; - if (uri == null) { - if (other.uri != null) - return false; - } else if (!uri.equals(other.uri)) - return false; - return true; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeAssemblyFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeAssemblyFactory.java deleted file mode 100644 index ec0cdadde6..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeAssemblyFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; - -/** - * @version $Rev$ $Date$ - */ -public class RuntimeAssemblyFactory extends DefaultAssemblyFactory implements AssemblyFactory { - private final ProxyFactory proxyFactory; - private final InterfaceContractMapper interfaceContractMapper; - - /** - * @param proxyFactory - */ - public RuntimeAssemblyFactory(InterfaceContractMapper interfaceContractMapper, ProxyFactory proxyFactory) { - super(); - this.proxyFactory = proxyFactory; - this.interfaceContractMapper = interfaceContractMapper; - } - - @Override - public Component createComponent() { - return new RuntimeComponentImpl(proxyFactory); - } - - @Override - public ComponentReference createComponentReference() { - return new RuntimeComponentReferenceImpl(interfaceContractMapper); - } - - @Override - public ComponentService createComponentService() { - return new RuntimeComponentServiceImpl(interfaceContractMapper); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentImpl.java deleted file mode 100644 index aacce904b5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.impl.ComponentImpl; -import org.apache.tuscany.sca.core.component.ServiceReferenceImpl; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.invocation.WireObjectFactory; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopedRuntimeComponent; -import org.osoa.sca.CallableReference; -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; - -/** - * @version $Rev$ $Date$ - */ -public class RuntimeComponentImpl extends ComponentImpl implements RuntimeComponent, ScopedRuntimeComponent { - public static final String SELF_REFERENCE_PREFIX = "$self$."; - protected ImplementationProvider implementationProvider; - protected ProxyFactory proxyService; - protected ScopeContainer scopeContainer; - - /** - * @param proxyService - */ - public RuntimeComponentImpl(ProxyFactory proxyService) { - super(); - this.proxyService = proxyService; - } - - public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) { - return getServiceReference(businessInterface, SELF_REFERENCE_PREFIX); - } - - public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) { - return getServiceReference(businessInterface, SELF_REFERENCE_PREFIX + serviceName); - } - - public <B> B getProperty(Class<B> type, String propertyName) { - for (Property p : getProperties()) { - if (p.getName().equals(propertyName)) { - // FIXME: Need to use the property object factory to create the - // instance - return null; - } - } - return null; - } - - public RequestContext getRequestContext() { - return null; - } - - public <B> B getService(Class<B> businessInterface, String referenceName) { - List<ComponentReference> refs = getReferences(); - for (ComponentReference ref : refs) { - if (ref.getName().equals(referenceName)) { - RuntimeComponentReference attachPoint = (RuntimeComponentReference)ref; - RuntimeWire wire = attachPoint.getRuntimeWires().get(0); - return proxyService.createProxy(businessInterface, wire); - } - } - return null; - } - - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) { - List<ComponentReference> references = getReferences(); - for (ComponentReference reference : references) { - if (reference.getName().equals(referenceName) || referenceName.equals("$self$.") - && reference.getName().startsWith(referenceName)) { - RuntimeComponentReference attachPoint = (RuntimeComponentReference)reference; - RuntimeWire wire = attachPoint.getRuntimeWires().get(0); - WireObjectFactory<B> factory = new WireObjectFactory<B>(businessInterface, wire, proxyService); - return new ServiceReferenceImpl<B>(businessInterface, factory); - } - } - return null; - - } - - @SuppressWarnings("unchecked") - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - Object ref = proxyService.cast(target); - return (R)ref; - } - - public ImplementationProvider getImplementationProvider() { - return implementationProvider; - } - - public void setImplementationProvider(ImplementationProvider provider) { - this.implementationProvider = provider; - } - - public ScopeContainer getScopeContainer() { - return scopeContainer; - } - - public void setScopeContainer(ScopeContainer scopeContainer) { - this.scopeContainer = scopeContainer; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentReferenceImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentReferenceImpl.java deleted file mode 100644 index 128ae29b81..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentReferenceImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implements RuntimeComponentReference { - private List<RuntimeWire> wires = new ArrayList<RuntimeWire>(); - private Map<Binding, ReferenceBindingProvider> bindingProviders = new HashMap<Binding, ReferenceBindingProvider>(); - private InterfaceContractMapper mapper; - - public RuntimeComponentReferenceImpl(InterfaceContractMapper mapper) { - super(); - this.mapper = mapper; - } - - public void addRuntimeWire(RuntimeWire wire) { - wires.add(wire); - } - - public List<RuntimeWire> getRuntimeWires() { - return wires; - } - - public RuntimeWire getRuntimeWire(Binding binding) { - for (RuntimeWire wire : wires) { - if (wire.getSource().getBinding() == binding) { - return wire; - } - } - return null; - } - - public ReferenceBindingProvider getBindingProvider(Binding binding) { - return bindingProviders.get(binding); - } - - public void setBindingProvider(Binding binding, ReferenceBindingProvider bindingProvider) { - bindingProviders.put(binding, bindingProvider); - } - - public Invoker getInvoker(Binding binding, Operation operation) { - RuntimeWire wire = getRuntimeWire(binding); - if (wire == null) { - return null; - } - for (InvocationChain chain : wire.getInvocationChains()) { - Operation op = chain.getSourceOperation(); - if (mapper.isCompatible(operation, op, op.getInterface().isRemotable())) { - return chain.getHeadInvoker(); - } - } - return null; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentServiceImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentServiceImpl.java deleted file mode 100644 index 0bb8e2c457..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeComponentServiceImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -public class RuntimeComponentServiceImpl extends ComponentServiceImpl implements RuntimeComponentService { - private InterfaceContractMapper mapper; - - public RuntimeComponentServiceImpl(InterfaceContractMapper mapper) { - super(); - this.mapper = mapper; - } - - private List<RuntimeWire> wires = new ArrayList<RuntimeWire>(); - private List<RuntimeWire> callbackWires = new ArrayList<RuntimeWire>(); - private Map<Binding, ServiceBindingProvider> bindingProviders = new HashMap<Binding, ServiceBindingProvider>(); - - public void addRuntimeWire(RuntimeWire wire) { - wires.add(wire); - } - - public List<RuntimeWire> getRuntimeWires() { - return wires; - } - - public RuntimeWire getRuntimeWire(Binding binding) { - for (RuntimeWire wire : wires) { - if (wire.getTarget().getBinding() == binding) { - return wire; - } - } - return null; - } - - public List<RuntimeWire> getCallbackWires() { - return callbackWires; - } - - public void addCallbackWire(RuntimeWire callbackWire) { - this.callbackWires.add(callbackWire); - } - - public ServiceBindingProvider getBindingProvider(Binding binding) { - return bindingProviders.get(binding); - } - - public void setBindingProvider(Binding binding, ServiceBindingProvider bindingProvider) { - bindingProviders.put(binding, bindingProvider); - } - - public Invoker getInvoker(Binding binding, Operation operation) { - RuntimeWire wire = getRuntimeWire(binding); - if (wire == null) { - return null; - } - for (InvocationChain chain : wire.getInvocationChains()) { - Operation op = chain.getTargetOperation(); - if (mapper.isCompatible(operation, op, op.getInterface().isRemotable())) { - return chain.getHeadInvoker(); - } - } - return null; - } - - public Invoker getCallbackInvoker(Binding binding, Operation operation) { - for (RuntimeWire wire : callbackWires) { - if (wire.getTarget().getBinding() == binding) { - for (InvocationChain chain : wire.getCallbackInvocationChains()) { - Operation op = chain.getSourceOperation(); - if (mapper.isCompatible(operation, op, op.getInterface().isRemotable())) { - return chain.getHeadInvoker(); - } - } - } - } - return null; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeSCABindingProvider.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeSCABindingProvider.java deleted file mode 100644 index ad055731f3..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeSCABindingProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; - -/** - * @version $Rev$ $Date$ - */ -public class RuntimeSCABindingProvider implements ReferenceBindingProvider { - - private RuntimeComponentReference reference; - - public RuntimeSCABindingProvider(RuntimeComponent component, RuntimeComponentReference reference, SCABinding binding) { - this.reference = reference; - } - - public InterfaceContract getBindingInterfaceContract() { - return reference.getInterfaceContract(); - } - - public Invoker createInvoker(Operation operation, boolean isCallback) { - return null; - } - - public void start() { - } - - public void stop() { - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeSCABindingProviderFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeSCABindingProviderFactory.java deleted file mode 100644 index 06b7b3d40e..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeSCABindingProviderFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.provider.BindingProviderFactory; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public class RuntimeSCABindingProviderFactory implements BindingProviderFactory<SCABinding> { - - public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, - RuntimeComponentReference reference, - SCABinding binding) { - return new RuntimeSCABindingProvider(component, reference, binding); - } - - public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, - RuntimeComponentService service, - SCABinding binding) { - return null; - } - - public Class<SCABinding> getModelType() { - return SCABinding.class; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java deleted file mode 100644 index cdf7ec01c0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/RuntimeWireImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.runtime; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.runtime.EndpointReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -/** - * @version $Rev$ $Date$ - */ -public class RuntimeWireImpl implements RuntimeWire { - private EndpointReference wireSource; - private EndpointReference wireTarget; - - private final List<InvocationChain> chains = new ArrayList<InvocationChain>(); - private final List<InvocationChain> callbackChains = new ArrayList<InvocationChain>(); - - /** - * @param source - * @param target - */ - public RuntimeWireImpl(EndpointReference source, - EndpointReference target) { - super(); - this.wireSource = source; - this.wireTarget = target; - } - - public List<InvocationChain> getCallbackInvocationChains() { - return callbackChains; - } - - public List<InvocationChain> getInvocationChains() { - return chains; - } - - public EndpointReference getSource() { - return wireSource; - } - - public EndpointReference getTarget() { - return wireTarget; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java deleted file mode 100644 index 1d776b729c..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.sca.event.Event; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.AbstractLifecycle; -import org.apache.tuscany.sca.scope.InstanceWrapper; -import org.apache.tuscany.sca.scope.PersistenceException; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopedImplementationProvider; -import org.apache.tuscany.sca.scope.TargetDestructionException; -import org.apache.tuscany.sca.scope.TargetResolutionException; - -/** - * Implements functionality common to scope contexts. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractScopeContainer<KEY> extends AbstractLifecycle implements ScopeContainer<KEY> { - protected Map<KEY, InstanceWrapper<?>> wrappers = new ConcurrentHashMap<KEY, InstanceWrapper<?>>(); - protected final Scope scope; - - protected RuntimeComponent component; - - public AbstractScopeContainer(Scope scope, RuntimeComponent component) { - this.scope = scope; - this.component = component; - } - - protected void checkInit() { - if (getLifecycleState() != RUNNING) { - throw new IllegalStateException("Scope container not running [" + getLifecycleState() + "]"); - } - } - - /** - * Creates a new physical instance of a component, wrapped in an - * InstanceWrapper. - * - * @param component the component whose instance should be created - * @return a wrapped instance that has been injected but not yet started - * @throws TargetResolutionException if there was a problem creating the - * instance - */ - protected InstanceWrapper createInstanceWrapper() throws TargetResolutionException { - ImplementationProvider implementationProvider = component.getImplementationProvider(); - if (implementationProvider instanceof ScopedImplementationProvider) { - return ((ScopedImplementationProvider)implementationProvider).createInstanceWrapper(); - } - return null; - } - - public InstanceWrapper getAssociatedWrapper(KEY contextId) throws TargetResolutionException { - return null; - } - - public Scope getScope() { - return scope; - } - - public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException { - return wrappers.get(contextId); - } - - public void onEvent(Event event) { - } - - protected boolean isEagerInit() { - ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider(); - if (implementationProvider instanceof ScopedImplementationProvider) { - return ((ScopedImplementationProvider)implementationProvider).isEagerInit(); - } - return false; - } - - public void remove() throws PersistenceException { - throw new UnsupportedOperationException("Scope does not support persistence"); - } - - public void returnWrapper(InstanceWrapper wrapper, KEY contextId) throws TargetDestructionException { - } - - public synchronized void start() { - int lifecycleState = getLifecycleState(); - if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { - throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); - } - setLifecycleState(RUNNING); - } - - public void startContext(KEY contextId) { - if(isEagerInit()) { - try { - getWrapper(contextId); - } catch (TargetResolutionException e) { - // - } - } - } - - public synchronized void stop() { - int lifecycleState = getLifecycleState(); - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]"); - } - setLifecycleState(STOPPED); - } - - public void stopContext(KEY contextId) { - wrappers.remove(contextId); - } - - public String toString() { - return "In state [" + super.toString() + ']'; - } - - public RuntimeComponent getComponent() { - return component; - } - - public void setComponent(RuntimeComponent component) { - this.component = component; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java deleted file mode 100644 index 520d3ab48c..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.InstanceWrapper; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.TargetNotFoundException; -import org.apache.tuscany.sca.scope.TargetResolutionException; - -/** - * A scope context which manages atomic component instances keyed by composite - * - * @version $Rev$ $Date$ - */ -public class CompositeScopeContainer<KEY> extends AbstractScopeContainer<KEY> { - private InstanceWrapper<?> wrapper; - - public CompositeScopeContainer(RuntimeComponent component) { - super(Scope.COMPOSITE, component); - } - - public synchronized void stop() { - super.stop(); - wrapper = null; - } - - public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException { - if (wrapper == null) { - wrapper = createInstanceWrapper(); - wrapper.start(); - } - return wrapper; - } - - public InstanceWrapper getAssociatedWrapper(KEY contextId) throws TargetResolutionException { - if (wrapper == null) { - throw new TargetNotFoundException(component.getURI()); - } - return wrapper; - } - - @Override - public synchronized void start() { - super.start(); - if(isEagerInit()) { - try { - getWrapper(null); - } catch (TargetResolutionException e) { - throw new IllegalStateException(e); - } - } - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainerFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainerFactory.java deleted file mode 100644 index 7078903b8b..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainerFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopeContainerFactory; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeScopeContainerFactory implements ScopeContainerFactory { - - public ScopeContainer createScopeContainer(RuntimeComponent component) { - return new CompositeScopeContainer(component); - } - - public Scope getScope() { - return Scope.COMPOSITE; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainer.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainer.java deleted file mode 100644 index 61f7d51c29..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainer.java +++ /dev/null @@ -1,182 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sca.core.scope;
-
-import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
-import org.apache.tuscany.sca.event.Event;
-import org.apache.tuscany.sca.event.RuntimeEventListener;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.scope.InstanceWrapper;
-import org.apache.tuscany.sca.scope.PersistenceException;
-import org.apache.tuscany.sca.scope.Scope;
-import org.apache.tuscany.sca.scope.ScopeContainer;
-import org.apache.tuscany.sca.scope.TargetDestructionException;
-import org.apache.tuscany.sca.scope.TargetResolutionException;
-import org.apache.tuscany.sca.store.Store;
-import org.apache.tuscany.sca.store.StoreExpirationEvent;
-
-/**
- * A scope context which manages atomic component instances keyed on a
- * conversation session
- *
- * @version $Rev: 452655 $ $Date: 2006-10-03 18:09:02 -0400 (Tue, 03 Oct 2006) $
- */
-public class ConversationalScopeContainer extends AbstractScopeContainer implements ScopeContainer {
- private final Store nonDurableStore;
-
- public ConversationalScopeContainer(Store store, RuntimeComponent component) {
- super(Scope.CONVERSATION, component);
- this.nonDurableStore = store;
- if (store != null) {
- store.addListener(new ExpirationListener());
- }
- }
-
- public void onEvent(Event event) {
- checkInit();
- }
-
- public synchronized void start() {
- if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
- throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
- }
- lifecycleState = RUNNING;
- }
-
- public synchronized void stop() {
- lifecycleState = STOPPED;
- }
-
- public void persistNew(RuntimeComponent component, String id, Object instance, long expiration)
- throws PersistenceException {
- // try {
- // nonDurableStore.insertRecord(component, id, instance, expiration);
- // } catch (StoreWriteException e) {
- // throw new PersistenceException(e);
- // }
- }
-
- public void persist(RuntimeComponent component, String id, Object instance, long expiration)
- throws PersistenceException {
- // try {
- // nonDurableStore.updateRecord(component, id, instance, expiration);
- // } catch (StoreWriteException e) {
- // throw new PersistenceException(e);
- // }
- }
-
- public void remove(RuntimeComponent component) throws PersistenceException {
- // String conversationId = getConversationId();
- // try {
- // workContext.setCurrentAtomicComponent(component);
- // // FIXME this should be an InstanceWrapper and shouldn't we stop it?
- // Object instance = nonDurableStore.readRecord(component,
- // conversationId);
- // if (instance != null) {
- // nonDurableStore.removeRecord(component, conversationId);
- // }
- // } catch (StoreReadException e) {
- // throw new PersistenceException(e);
- // } catch (StoreWriteException e) {
- // throw new PersistenceException(e);
- // }
- }
-
- protected InstanceWrapper getInstanceWrapper(RuntimeComponent component, boolean create)
- throws TargetResolutionException {
- throw new UnsupportedOperationException("To be implemented");
- // String conversationId = getConversationId();
- // try {
- // workContext.setCurrentAtomicComponent(component);
- // InstanceWrapper wrapper = (InstanceWrapper)
- // nonDurableStore.readRecord(component, conversationId);
- // if (wrapper != null) {
- // if (component.getMaxIdleTime() > 0) {
- // // update expiration
- // long expire = System.currentTimeMillis() +
- // component.getMaxIdleTime();
- // nonDurableStore.updateRecord(component, conversationId, wrapper,
- // expire);
- // }
- // } else if (create) {
- // // FIXME should the store really be persisting the wrappers
- // wrapper = component.createInstanceWrapper();
- // wrapper.start();
- // long expire = calculateExpiration(component);
- // nonDurableStore.insertRecord(component, conversationId, wrapper,
- // expire);
- // }
- // return wrapper;
- // } catch (StoreReadException e) {
- // throw new TargetResolutionException("Error retrieving target
- // instance", e);
- // } catch (StoreWriteException e) {
- // throw new TargetResolutionException("Error persisting target
- // instance", e);
- // } finally {
- // workContext.setCurrentAtomicComponent(null);
- // }
- }
-
- /**
- * Returns the conversation id associated with the current invocation
- * context
- *
- * @return the conversation id
- */
- private String getConversationId() {
- String conversationId = ThreadMessageContext.getMessageContext().getConversationID();
- assert conversationId != null;
- return conversationId;
- }
-
- // private long calculateExpiration(RuntimeComponent component) {
- // if (component.getMaxAge() > 0) {
- // long now = System.currentTimeMillis();
- // return now + component.getMaxAge();
- // } else if (component.getMaxIdleTime() > 0) {
- // long now = System.currentTimeMillis();
- // return now + component.getMaxIdleTime();
- // } else {
- // return Store.DEFAULT_EXPIRATION_OFFSET;
- // }
- // }
-
- /**
- * Receives expiration events from the store and notifies the corresponding
- * atomic component
- */
- private static class ExpirationListener implements RuntimeEventListener {
-
- public ExpirationListener() {
- }
-
- public void onEvent(Event event) {
- if (event instanceof StoreExpirationEvent) {
- StoreExpirationEvent expiration = (StoreExpirationEvent)event;
- InstanceWrapper wrapper = (InstanceWrapper)expiration.getInstance();
- try {
- wrapper.stop();
- } catch (TargetDestructionException e) {
- // monitor.destructionError(e);
- }
- }
- }
- }
-}
diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainerFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainerFactory.java deleted file mode 100644 index 4fdda90bc2..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainerFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopeContainerFactory; -import org.apache.tuscany.sca.store.Store; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationalScopeContainerFactory implements ScopeContainerFactory { - private Store store; - - public ConversationalScopeContainerFactory(Store store) { - super(); - this.store = store; - } - - public ScopeContainer createScopeContainer(RuntimeComponent component) { - return new ConversationalScopeContainer(store, component); - } - - public Scope getScope() { - return Scope.CONVERSATION; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainer.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainer.java deleted file mode 100644 index bcbf3cdf3c..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainer.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.core.event.HttpSessionEnd; -import org.apache.tuscany.sca.event.Event; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.InstanceWrapper; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.TargetResolutionException; - -/** - * A scope context which manages atomic component instances keyed on HTTP - * session - * - * @version $Rev$ $Date$ - */ -public class HttpSessionScopeContainer extends AbstractScopeContainer<Object> { - - public HttpSessionScopeContainer(RuntimeComponent component) { - super(Scope.SESSION, component); - } - - public void onEvent(Event event) { - checkInit(); - if (event instanceof HttpSessionEnd) { - Object key = ((HttpSessionEnd)event).getSessionID(); - // FIXME: Remove the session id - } - } - - public synchronized void start() { - if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { - throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); - } - lifecycleState = RUNNING; - } - - public synchronized void stop() { - lifecycleState = STOPPED; - } - - protected InstanceWrapper getInstanceWrapper(boolean create) throws TargetResolutionException { -// Object key = workContext.getIdentifier(Scope.SESSION); - // FIXME: Need to fix this - Object key ="http-session-id"; - assert key != null : "HTTP session key not bound in work context"; - InstanceWrapper ctx = wrappers.get(key); - if (ctx == null && !create) { - return null; - } - if (ctx == null) { - ctx = super.createInstanceWrapper(); - ctx.start(); - wrappers.put(key, ctx); - } - return ctx; - } - - @Override - public InstanceWrapper getWrapper(Object contextId) throws TargetResolutionException { - return getInstanceWrapper(true); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainerFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainerFactory.java deleted file mode 100644 index e275bb56b9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainerFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopeContainerFactory; - -/** - * @version $Rev$ $Date$ - */ -public class HttpSessionScopeContainerFactory implements ScopeContainerFactory { - - public HttpSessionScopeContainerFactory() { - super(); - } - - public ScopeContainer createScopeContainer(RuntimeComponent component) { - return new HttpSessionScopeContainer(component); - } - - public Scope getScope() { - return Scope.SESSION; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java deleted file mode 100644 index aaafb4603c..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.sca.core.event.RequestEnd; -import org.apache.tuscany.sca.event.Event; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.InstanceWrapper; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.TargetResolutionException; - -/** - * A scope context which manages atomic component instances keyed on the current - * request context - * - * @version $Rev$ $Date$ - */ -public class RequestScopeContainer extends AbstractScopeContainer<Thread> { - private final Map<Thread, InstanceWrapper> contexts; - - public RequestScopeContainer(RuntimeComponent component) { - super(Scope.REQUEST, component); - contexts = new ConcurrentHashMap<Thread, InstanceWrapper>(); - } - - public void onEvent(Event event) { - checkInit(); - if (event instanceof RequestEnd) { - // shutdownInstances(Thread.currentThread()); - } - } - - public synchronized void start() { - if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { - throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); - } - lifecycleState = RUNNING; - } - - public synchronized void stop() { - contexts.clear(); - // synchronized (destroyQueues) { - // destroyQueues.clear(); - // } - lifecycleState = STOPPED; - } - - protected InstanceWrapper getInstanceWrapper(boolean create) throws TargetResolutionException { - InstanceWrapper ctx = wrappers.get(Thread.currentThread()); - if (ctx == null && !create) { - return null; - } - if (ctx == null) { - ctx = super.createInstanceWrapper(); - ctx.start(); - wrappers.put(Thread.currentThread(), ctx); - } - return ctx; - } - - @Override - public InstanceWrapper getWrapper(Thread contextId) throws TargetResolutionException { - return getInstanceWrapper(true); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainerFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainerFactory.java deleted file mode 100644 index 3851637220..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainerFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopeContainerFactory; - -/** - * @version $Rev$ $Date$ - */ -public class RequestScopeContainerFactory implements ScopeContainerFactory { - - public ScopeContainer createScopeContainer(RuntimeComponent component) { - return new RequestScopeContainer(component); - } - - public Scope getScope() { - return Scope.REQUEST; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistryImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistryImpl.java deleted file mode 100644 index 774c1edf37..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistryImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopeContainerFactory; -import org.apache.tuscany.sca.scope.ScopeRegistry; -import org.apache.tuscany.sca.scope.ScopedImplementationProvider; -import org.apache.tuscany.sca.scope.ScopedRuntimeComponent; - -/** - * The default implementation of a scope registry - * - * @version $Rev$ $Date$ - */ -public class ScopeRegistryImpl implements ScopeRegistry { - private final Map<Scope, ScopeContainerFactory> scopeCache = new ConcurrentHashMap<Scope, ScopeContainerFactory>(); - - public void register(ScopeContainerFactory factory) { - scopeCache.put(factory.getScope(), factory); - } - - public ScopeContainer getScopeContainer(RuntimeComponent runtimeComponent) { - if (!(runtimeComponent instanceof ScopedRuntimeComponent)) { - return null; - } - ScopedRuntimeComponent component = (ScopedRuntimeComponent)runtimeComponent; - if (component.getScopeContainer() != null) { - return component.getScopeContainer(); - } - ImplementationProvider implementationProvider = component.getImplementationProvider(); - if (implementationProvider instanceof ScopedImplementationProvider) { - ScopedImplementationProvider provider = (ScopedImplementationProvider)implementationProvider; - Scope scope = provider.getScope(); - if (scope == null) { - scope = Scope.STATELESS; - } - ScopeContainerFactory factory = scopeCache.get(scope); - ScopeContainer container = factory.createScopeContainer(component); - component.setScopeContainer(container); - return container; - } - return null; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainer.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainer.java deleted file mode 100644 index dd481fa062..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainer.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.InstanceWrapper; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.TargetDestructionException; -import org.apache.tuscany.sca.scope.TargetResolutionException; - -/** - * A scope context which manages stateless atomic component instances in a non-pooled fashion. - * - * @version $Rev$ $Date$ - */ -public class StatelessScopeContainer<KEY> extends AbstractScopeContainer<KEY> { - - public StatelessScopeContainer(RuntimeComponent component) { - super(Scope.STATELESS, component); - } - - public InstanceWrapper getWrapper(KEY contextId) - throws TargetResolutionException { - InstanceWrapper ctx = createInstanceWrapper(); - ctx.start(); - return ctx; - } - - public InstanceWrapper getAssociatedWrapper(KEY contextId) - throws TargetResolutionException { - throw new UnsupportedOperationException(); - } - - public void returnWrapper(InstanceWrapper wrapper, KEY contextId) - throws TargetDestructionException { - wrapper.stop(); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainerFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainerFactory.java deleted file mode 100644 index e0eff710e9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainerFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.Scope; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopeContainerFactory; - -/** - * @version $Rev$ $Date$ - */ -public class StatelessScopeContainerFactory implements ScopeContainerFactory { - - public ScopeContainer createScopeContainer(RuntimeComponent component) { - return new StatelessScopeContainer(component); - } - - public Scope getScope() { - return Scope.STATELESS; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/store/MemoryStore.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/store/MemoryStore.java deleted file mode 100644 index 5b838116c5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/store/MemoryStore.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.store; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import org.apache.tuscany.sca.core.event.BaseEventPublisher; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.store.DuplicateRecordException; -import org.apache.tuscany.sca.store.RecoveryListener; -import org.apache.tuscany.sca.store.Store; -import org.apache.tuscany.sca.store.StoreExpirationEvent; -import org.apache.tuscany.sca.store.StoreMonitor; -import org.apache.tuscany.sca.store.StoreWriteException; -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Service; - -/** - * Implements a non-durable, non-transactional store using a simple in-memory map - * - * @version $Rev$ $Date$ - */ -@Service(Store.class) -@EagerInit -public class MemoryStore extends BaseEventPublisher implements Store { - private Map<RuntimeComponent, Map<String, Record>> store; - // TODO integrate with a core threading scheme - private ScheduledExecutorService scheduler; - private long reaperInterval = 300000; - private StoreMonitor monitor; - private long defaultExpirationOffset = 600000; // 10 minutes - - public MemoryStore(StoreMonitor monitor) { - this.monitor = monitor; - this.store = new ConcurrentHashMap<RuntimeComponent, Map<String, Record>>(); - this.scheduler = Executors.newSingleThreadScheduledExecutor(); - } - - /** - * Returns the maximum default expiration offset for records in the store - * - * @return the maximum default expiration offset for records in the store - */ - public long getDefaultExpirationOffset() { - return defaultExpirationOffset; - } - - /** - * Sets the maximum default expiration offset for records in the store - */ - @Property - public void setDefaultExpirationOffset(long defaultExpirationOffset) { - this.defaultExpirationOffset = defaultExpirationOffset; - } - - /** - * Sets the interval for expired entry scanning to be performed - */ - @Property - public void setReaperInterval(long reaperInterval) { - this.reaperInterval = reaperInterval; - } - - public long getReaperInterval() { - return reaperInterval; - } - - @Init - public void init() { - scheduler.scheduleWithFixedDelay(new Reaper(), reaperInterval, reaperInterval, TimeUnit.MILLISECONDS); - monitor.start("In-memory store started"); - } - - @Destroy - public void destroy() { - scheduler.shutdown(); - monitor.stop("In-memory store stopped"); - } - - public void insertRecord(RuntimeComponent owner, String id, Object object, long expiration) throws StoreWriteException { - Map<String, Record> map = store.get(owner); - if (map == null) { - map = new ConcurrentHashMap<String, Record>(); - store.put(owner, map); - } - if (map.containsKey(id)) { - throw new DuplicateRecordException("Duplicate record: " + owner.getURI() +" : " + id); - } - map.put(id, new Record(object, expiration)); - } - - public void updateRecord(RuntimeComponent owner, String id, Object object, long expiration) throws StoreWriteException { - Map<String, Record> map = store.get(owner); - if (map == null) { - throw new StoreWriteException("Record not found: " + owner.getURI() +" : " + id); - } - Record record = map.get(id); - if (record == null) { - throw new StoreWriteException("Record not found: " + owner.getURI() +" : " + id); - } - record.data = object; - } - - public Object readRecord(RuntimeComponent owner, String id) { - Map<String, Record> map = store.get(owner); - if (map == null) { - return null; - } - Record record = map.get(id); - if (record != null) { - return record.data; - } - return null; - } - - public void removeRecords() { - store.clear(); - } - - public void removeRecord(RuntimeComponent owner, String id) throws StoreWriteException { - Map<String, Record> map = store.get(owner); - if (map == null) { - throw new StoreWriteException("Owner not found: " + owner.getURI() +" : " + id); - } - if (map.remove(id) == null) { - throw new StoreWriteException("Owner not found: " + owner.getURI() +" : " + id); - } - } - - public void recover(RecoveryListener listener) { - throw new UnsupportedOperationException(); - } - - private class Record { - private Object data; - private long expiration = NEVER; - - public Record(Object data, long expiration) { - this.data = data; - this.expiration = expiration; - } - - public Object getData() { - return data; - } - - public long getExpiration() { - return expiration; - } - } - - private class Reaper implements Runnable { - - public void run() { - long now = System.currentTimeMillis(); - for (Map.Entry<RuntimeComponent, Map<String, Record>> entries : store.entrySet()) { - for (Map.Entry<String, Record> entry : entries.getValue().entrySet()) { - final long expiration = entry.getValue().expiration; - if (expiration != NEVER && now >= expiration) { - RuntimeComponent owner = entries.getKey(); - Object instance = entry.getValue().getData(); - // notify listeners of the expiration - StoreExpirationEvent event = new StoreExpirationEvent(this, owner, instance); - publish(event); - entries.getValue().remove(entry.getKey()); - } - } - } - } - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/util/IOHelper.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/util/IOHelper.java deleted file mode 100644 index 2058397fb0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/util/IOHelper.java +++ /dev/null @@ -1,182 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sca.core.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.util.jar.JarFile;
-
-public class IOHelper {
- /**
- * The default buffer size to use.
- */
- private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
-
- protected IOHelper() {
-
- }
-
- /**
- * Unconditionally close an <code>InputStream</code>.
- * <p>
- * Equivalent to {@link InputStream#close()}, except any exceptions will be ignored.
- * This is typically used in finally blocks.
- *
- * @param input the InputStream to close, may be null or already closed
- */
- public static void closeQuietly(InputStream input) {
- try {
- if (input != null) {
- input.close();
- }
- } catch (IOException ioe) {
- // ignore
- }
- }
-
- /**
- * Unconditionally close an <code>OutputStream</code>.
- * <p>
- * Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored.
- * This is typically used in finally blocks.
- *
- * @param output the OutputStream to close, may be null or already closed
- */
- public static void closeQuietly(OutputStream output) {
- try {
- if (output != null) {
- output.close();
- }
- } catch (IOException ioe) {
- // ignore
- }
- }
-
- /**
- * Copy bytes from an <code>InputStream</code> to an
- * <code>OutputStream</code>.
- * <p>
- * This method buffers the input internally, so there is no need to use a
- * <code>BufferedInputStream</code>.
- *
- * @param input the <code>InputStream</code> to read from
- * @param output the <code>OutputStream</code> to write to
- * @return the number of bytes copied
- * @throws NullPointerException if the input or output is null
- * @throws IOException if an I/O error occurs
- * @since Commons IO 1.1
- */
- public static int copy(InputStream input, OutputStream output) throws IOException {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
- int count = 0;
- int n = 0;
- while (-1 != (n = input.read(buffer))) { // NOPMD
- output.write(buffer, 0, n);
- count += n;
- }
- return count;
- }
-
- public static InputStream getInputStream(URL url) throws IOException {
- return new SafeURLInputStream(url);
- }
-
- /**
- * This class is a workaround for URL stream issue as illustrated below.
- * InputStream is=url.getInputStream(); is.close(); // This line doesn't close
- * the JAR file if the URL is a jar entry like "jar:file:/a.jar!/my.composite" We
- * also need to turn off the JarFile cache.
- *
- * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4950148
- *
- * @version $Rev$ $Date$
- */
- public static class SafeURLInputStream extends InputStream {
- private JarFile jarFile;
- private InputStream is;
-
- public SafeURLInputStream(URL url) throws IOException {
- String protocol = url.getProtocol();
- if (protocol != null && (protocol.equals("jar"))) {
- JarURLConnection connection = (JarURLConnection)url.openConnection();
- // We cannot use cache
- connection.setUseCaches(false);
- try {
- is = connection.getInputStream();
- } catch (IOException e) {
- throw e;
- }
- jarFile = connection.getJarFile();
- } else {
- is = url.openStream();
- }
- }
-
- public SafeURLInputStream(JarURLConnection connection) throws IOException {
- // We cannot use cache
- connection.setUseCaches(false);
- is = connection.getInputStream();
- jarFile = connection.getJarFile();
- }
-
- public int available() throws IOException {
- return is.available();
- }
-
- public void close() throws IOException {
- is.close();
- // We need to close the JAR file
- if (jarFile != null) {
- jarFile.close();
- }
- }
-
- public synchronized void mark(int readlimit) {
- is.mark(readlimit);
- }
-
- public boolean markSupported() {
- return is.markSupported();
- }
-
- public int read() throws IOException {
- return is.read();
- }
-
- public int read(byte[] b, int off, int len) throws IOException {
- return is.read(b, off, len);
- }
-
- public int read(byte[] b) throws IOException {
- return is.read(b);
- }
-
- public synchronized void reset() throws IOException {
- is.reset();
- }
-
- public long skip(long n) throws IOException {
- return is.skip(n);
- }
- }
-}
\ No newline at end of file diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237Work.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237Work.java deleted file mode 100644 index 6fe883157f..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237Work.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.work; - -/* - * JCA work wrapper. - */ -public class Jsr237Work<T extends Runnable> implements commonj.work.Work { - - // Work that is being executed. - private T work; - - /* - * Initializes the work instance. - */ - public Jsr237Work(T work) { - this.work = work; - } - - /* - * Returns the completed work. - */ - public T getWork() { - return work; - } - - /* - * Release the work. - */ - public void release() { - } - - /* - * Work attributes are not daemon. - */ - public boolean isDaemon() { - return false; - } - - /* - * Runs the work. - */ - public void run() { - work.run(); - } -}
\ No newline at end of file diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java deleted file mode 100644 index c8a5dd7afe..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.work; - -import org.apache.tuscany.sca.work.NotificationListener; -import org.apache.tuscany.sca.work.WorkScheduler; -import org.apache.tuscany.sca.work.WorkSchedulerException; - -import commonj.work.WorkEvent; -import commonj.work.WorkException; -import commonj.work.WorkListener; -import commonj.work.WorkManager; -import commonj.work.WorkRejectedException; - -/** - * A work scheduler implementation based on a JSR 237 work manager. - * <p/> - * <p/> - * This needs a JSR 237 work manager implementation available for scheduling work. Instances can be configured with a - * work manager implementation that is injected in. It is the responsibility of the runtime environment to make a work - * manager implementaion available. For example, if the managed environment supports work manager the runtime can use - * the appropriate lookup mechanism to inject the work manager implementation. </p> - */ -public class Jsr237WorkScheduler implements WorkScheduler { - - /** - * Underlying JSR-237 work manager - */ - private WorkManager jsr237WorkManager; - - /** - * Initializes the JSR 237 work manager. - * - * @param jsr237WorkManager JSR 237 work manager. - */ - public Jsr237WorkScheduler(WorkManager jsr237WorkManager) { - if (jsr237WorkManager == null) { - throw new IllegalArgumentException("Work manager cannot be null"); - } - this.jsr237WorkManager = jsr237WorkManager; - } - - /** - * Schedules a unit of work for future execution. The notification listener is used to register interest in - * callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - */ - public <T extends Runnable> void scheduleWork(T work) { - scheduleWork(work, null); - } - - /** - * Schedules a unit of work for future execution. The notification listener is used to register interest in - * callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - * @param listener Notification listener for callbacks. - */ - public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) { - - if (work == null) { - throw new IllegalArgumentException("Work cannot be null"); - } - - Jsr237Work<T> jsr237Work = new Jsr237Work<T>(work); - try { - if (listener == null) { - jsr237WorkManager.schedule(jsr237Work); - } else { - Jsr237WorkListener<T> jsr237WorkListener = new Jsr237WorkListener<T>(listener, work); - jsr237WorkManager.schedule(jsr237Work, jsr237WorkListener); - } - } catch (WorkRejectedException ex) { - if (listener != null) { - listener.workRejected(work); - } else { - throw new WorkSchedulerException(ex); - } - } catch (WorkException ex) { - throw new WorkSchedulerException(ex); - } - - } - - /* - * Worklistener for keeping track of work status callbacks. - * - */ - private class Jsr237WorkListener<T extends Runnable> implements WorkListener { - - // Notification listener - private NotificationListener<T> listener; - - // Work - private T work; - - /* - * Initializes the notification listener. - */ - public Jsr237WorkListener(NotificationListener<T> listener, T work) { - this.listener = listener; - this.work = work; - } - - /* - * Callback when the work is accepted. - */ - public void workAccepted(WorkEvent workEvent) { - T work = getWork(); - listener.workAccepted(work); - } - - /* - * Callback when the work is rejected. - */ - public void workRejected(WorkEvent workEvent) { - T work = getWork(); - listener.workRejected(work); - } - - /* - * Callback when the work is started. - */ - public void workStarted(WorkEvent workEvent) { - T work = getWork(); - listener.workStarted(work); - } - - /* - * Callback when the work is completed. - */ - public void workCompleted(WorkEvent workEvent) { - T work = getWork(); - Exception exception = workEvent.getException(); - if (exception != null) { - listener.workFailed(work, exception); - } else { - listener.workCompleted(work); - } - } - - /* - * Gets the underlying work from the work event. - */ - private T getWork() { - return work; - } - - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/ThreadPoolWorkManager.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/ThreadPoolWorkManager.java deleted file mode 100644 index 0bc6f1b336..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/ThreadPoolWorkManager.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.work; - -import java.rmi.server.UID; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionException; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Property; - -import commonj.work.Work; -import commonj.work.WorkEvent; -import commonj.work.WorkException; -import commonj.work.WorkItem; -import commonj.work.WorkListener; -import commonj.work.WorkManager; -import commonj.work.WorkRejectedException; - -/** - * A thread-pool based implementation for the JSR-237 work manager. - * <p/> - * <p/> - * This implementation supports only local work. - * <p/> - * TODO Elaborate the implementation. </p> - */ -public class ThreadPoolWorkManager implements WorkManager { - - // Map of work items currently handled by the work manager - private Map<WorkItemImpl, WorkListener> workItems = new ConcurrentHashMap<WorkItemImpl, WorkListener>(); - - // Thread-pool - private ExecutorService executor; - - /** - * Initializes the thread-pool. - * - * @param threadPoolSize Thread-pool size. - */ - public ThreadPoolWorkManager(@Property(name = "poolSize") int threadPoolSize) { - executor = Executors.newFixedThreadPool(threadPoolSize); - } - - /** - * Schedules a unit of work asynchronously. - * - * @param work Work that needs to be scheduled. - * @return Work Work item representing the asynchronous work - */ - public WorkItem schedule(Work work) throws WorkException { - return schedule(work, null); - } - - /** - * Schedules a unit of work asynchronously. - * - * @param work Work that needs to be scheduled. - * @param workListener Work listener for callbacks. - * @return Work Work item representing the asynchronous work - */ - public WorkItem schedule(Work work, WorkListener workListener) throws WorkRejectedException { - - WorkItemImpl workItem = new WorkItemImpl(new UID().toString(), work); - if (workListener != null) { - workItems.put(workItem, workListener); - } - workAccepted(workItem, work); - if (scheduleWork(work, workItem)) { - return workItem; - } else { - workItem.setStatus(WorkEvent.WORK_REJECTED); - if (workListener != null) { - workListener.workRejected(new WorkEventImpl(workItem)); - } - throw new WorkRejectedException("Unable to schedule work"); - } - } - - /** - * Wait for all the specified units of work to finish. - * - * @param works Units of the work that need to finish. - * @param timeout Timeout for waiting for the units of work to finish. - */ - public boolean waitForAll(Collection works, long timeout) { - throw new UnsupportedOperationException("waitForAll not supported"); - } - - /** - * Wait for any of the specified units of work to finish. - * - * @param works Units of the work that need to finish. - * @param timeout Timeout for waiting for the units of work to finish. - */ - public Collection waitForAny(Collection works, long timeout) { - throw new UnsupportedOperationException("waitForAny not supported"); - } - - /** - * Method provided for subclasses to indicate a work accptance. - * - * @param workItem Work item representing the work that was accepted. - * @param work Work that was accepted. - */ - private void workAccepted(final WorkItemImpl workItem, final Work work) { - WorkListener listener = workItems.get(workItem); - if (listener != null) { - workItem.setStatus(WorkEvent.WORK_ACCEPTED); - WorkEvent event = new WorkEventImpl(workItem); - listener.workAccepted(event); - } - } - - /* - * Method to indicate a work start. - */ - private void workStarted(final WorkItemImpl workItem, final Work work) { - WorkListener listener = workItems.get(workItem); - if (listener != null) { - workItem.setStatus(WorkEvent.WORK_STARTED); - WorkEvent event = new WorkEventImpl(workItem); - listener.workStarted(event); - } - } - - /* - * Method to indicate a work completion. - */ - private void workCompleted(final WorkItemImpl workItem, final Work work) { - workCompleted(workItem, work, null); - } - - /* - * Method to indicate a work completion. - */ - private void workCompleted(final WorkItemImpl workItem, final Work work, final WorkException exception) { - WorkListener listener = workItems.get(workItem); - if (listener != null) { - workItem.setStatus(WorkEvent.WORK_COMPLETED); - workItem.setResult(work); - workItem.setException(exception); - WorkEvent event = new WorkEventImpl(workItem); - listener.workCompleted(event); - workItems.remove(workItem); - } - } - - /* - * Schedules the work using the threadpool. - */ - private boolean scheduleWork(final Work work, final WorkItemImpl workItem) { - try { - executor.execute(new DecoratingWork(workItem, work)); - return true; - } catch (RejectedExecutionException ex) { - return false; - } - } - - /* - * Class that decorates the original worker so that it can get callbacks when work is done. - */ - private final class DecoratingWork implements Runnable { - - // Work item for this work. - private WorkItemImpl workItem; - - // The original work. - private Work decoratedWork; - - /* - * Initializes the work item and underlying work. - */ - private DecoratingWork(final WorkItemImpl workItem, final Work decoratedWork) { - this.workItem = workItem; - this.decoratedWork = decoratedWork; - } - - /* - * Overrides the run method. - */ - public void run() { - workStarted(workItem, decoratedWork); - try { - decoratedWork.run(); - workCompleted(workItem, decoratedWork); - } catch (Throwable th) { - workCompleted(workItem, decoratedWork, new WorkException(th.getMessage(), th)); - } - } - - } - - @Destroy - public void destroy() { - executor.shutdown(); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/WorkEventImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/WorkEventImpl.java deleted file mode 100644 index 62ebeea1fb..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/WorkEventImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.work; - - -import commonj.work.WorkEvent; -import commonj.work.WorkException; -import commonj.work.WorkItem; - -/** - * Default immutable implementation of the <code>WorkEvent</code> class. - */ -class WorkEventImpl implements WorkEvent { - - // Work item for this event - private WorkItem workItem; - - // Exception if something has gone wrong - private WorkException exception; - - /** - * Instantiates the event. - * - * @param workItem Work item for this event. - */ - public WorkEventImpl(final WorkItemImpl workItem) { - this.workItem = workItem; - this.exception = workItem.getException(); - } - - /** - * Returns the work type based on whether the work was accepted, started, - * rejected or completed. - * - * @return Work type. - */ - public int getType() { - return workItem.getStatus(); - } - - /** - * Returns the work item associated with this work type. - * - * @return Work item. - */ - public WorkItem getWorkItem() { - return workItem; - } - - /** - * Returns the exception if the work completed with an exception. - * - * @return Work exception. - */ - public WorkException getException() { - return exception; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/WorkItemImpl.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/WorkItemImpl.java deleted file mode 100644 index fae3f1aae3..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/core/work/WorkItemImpl.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.work; - -import commonj.work.Work; -import commonj.work.WorkException; -import commonj.work.WorkItem; - -/** - * An identity based immutable implementation of the <code>WorkItem</code> - * interface. - * - */ -class WorkItemImpl implements WorkItem { - - // Id scoped for the VM - private String id; - - // Status - private int status = -1; - - // Result - private Work result; - - // Original work - private Work originalWork; - - // Exception - private WorkException exception; - - /** - * Instantiates an id for this item. - * - * @param id of this work event. - */ - protected WorkItemImpl(final String id, final Work orginalWork) { - this.id = id; - this.originalWork = orginalWork; - } - - /** - * Returns the id. - * - * @return Id of this item. - */ - public String getId() { - return id; - } - - /** - * Returns the original work. - * - * @return Original work. - */ - public Work getOriginalWork() { - return originalWork; - } - - /** - * Returns the work result if the work completed. - * - * @return Work. - * @throws WorkException If the work completed with an exception. - */ - public Work getResult() throws WorkException { - return result; - } - - /** - * Sets the result. - * - * @param result Result. - */ - protected void setResult(final Work result) { - this.result = result; - } - - /** - * Returns the exception if work completed with an exception. - * - * @return Work exception. - */ - protected WorkException getException() { - return exception; - } - - /** - * Sets the exception. - * - * @param exception Exception. - */ - protected void setException(final WorkException exception) { - this.exception = exception; - } - - /** - * Returns the work type based on whether the work was accepted, started, - * rejected or completed. - * - * @return Work status. - */ - public int getStatus() { - return status; - } - - /** - * Sets the status. - * - * @param status Status. - */ - protected void setStatus(final int status) { - this.status = status; - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - return id.hashCode(); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj Object to be compared. - * @return true if this object is the same as the obj argument; false - * otherwise.. - */ - public boolean equals(final Object obj) { - return (obj != null) && (obj.getClass() == WorkItemImpl.class) && ((WorkItemImpl) obj).id.equals(id); - } - - /** - * Compares this object with the specified object for order. Returns a - * negative integer, zero, or a positive integer as this object is less - * than, equal to, or greater than the specified object. - * - * @param o Object to be compared. - * @return A negative integer, zero, or a positive integer as this object - * is less than, equal to, or greater than the specified object. - * @throws ClassCastException needs better documentation. - */ - public int compareTo(final Object o) { - if (o.getClass() != WorkItemImpl.class) { - throw new ClassCastException(o.getClass().getName()); - } else { - return ((WorkItemImpl) o).getId().compareTo(getId()); - } - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/ObjectCreationException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/ObjectCreationException.java deleted file mode 100644 index 3432c61c76..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/ObjectCreationException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.factory; - - -/** - * Denotes an error creating a new object instance - * - * @version $Rev$ $Date$ - */ -public class ObjectCreationException extends RuntimeException { - private static final long serialVersionUID = -6423113430265944499L; - - public ObjectCreationException() { - super(); - } - - public ObjectCreationException(String message, Throwable cause) { - super(message, cause); - } - - public ObjectCreationException(String message) { - super(message); - } - - public ObjectCreationException(Throwable cause) { - super(cause); - } - -} - diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/ObjectFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/ObjectFactory.java deleted file mode 100644 index c5e0dad4e7..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/ObjectFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.factory; - -/** - * Implementations create new instances of a particular type - * - * @version $Rev$ $Date$ - */ -public interface ObjectFactory<T> { - - /** - * Return a instance of the type that this factory creates. - * - * @return a instance from this factory - */ - T getInstance() throws ObjectCreationException; - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/SingletonObjectFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/SingletonObjectFactory.java deleted file mode 100644 index 074a1121c9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/factory/SingletonObjectFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.factory; - - -/** - * Implementation of ObjectFactory that returns a single instance, typically an immutable type. - * - * @version $Rev$ $Date$ - */ -public class SingletonObjectFactory<T> implements ObjectFactory<T> { - private final T instance; - - public SingletonObjectFactory(T instance) { - this.instance = instance; - } - - public T getInstance() { - return instance; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/AbstractLifecycle.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/AbstractLifecycle.java deleted file mode 100644 index e5f88d91c6..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/AbstractLifecycle.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Base class providing a simple implementation of Lifecycle. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractLifecycle implements Lifecycle { - protected volatile int lifecycleState = UNINITIALIZED; - - public int getLifecycleState() { - return lifecycleState; - } - - /** - * Set the current state of the Lifecycle. - * - * @param lifecycleState the new state - */ - protected void setLifecycleState(int lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public void start() { - setLifecycleState(RUNNING); - } - - public void stop() { - setLifecycleState(STOPPED); - } - - /** - * Returns the current lifecycle as a String (for example, "RUNNING"). - * - * @return the current lifecycle as a String - */ - public String toString() { - switch (lifecycleState) { - case Lifecycle.CONFIG_ERROR: - return "CONFIG_ERROR"; - case Lifecycle.ERROR: - return "ERROR"; - case Lifecycle.INITIALIZING: - return "INITIALIZING"; - case Lifecycle.INITIALIZED: - return "INITIALIZED"; - case Lifecycle.RUNNING: - return "RUNNING"; - case Lifecycle.STOPPING: - return "STOPPING"; - case Lifecycle.STOPPED: - return "STOPPED"; - case Lifecycle.UNINITIALIZED: - return "UNINITIALIZED"; - default: - return "UNKNOWN"; - } - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/CoreRuntimeException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/CoreRuntimeException.java deleted file mode 100644 index ac3e51a982..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/CoreRuntimeException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - - -/** - * The root exception for the runtime package. Exceptions occurring in the runtime are generally non-recoverable - * - * @version $Rev$ $Date$ - */ -public abstract class CoreRuntimeException extends RuntimeException { - - public CoreRuntimeException() { - super(); - } - - public CoreRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public CoreRuntimeException(String message) { - super(message); - } - - public CoreRuntimeException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/InstanceWrapper.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/InstanceWrapper.java deleted file mode 100644 index a952e2e72b..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/InstanceWrapper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - - -/** - * Provides lifecycle management for an implementation instance associated with - * a component for use by the component's associated {@link org.apache.tuscany.sca.scope.ScopeContainer} - * - * @version $Rev$ $Date$ - */ -public interface InstanceWrapper<T> { - - /** - * @return - */ - T getInstance(); - - /** - * @throws TargetInitializationException - */ - void start() throws TargetInitializationException; - - /** - * @throws TargetDestructionException - */ - void stop() throws TargetDestructionException; - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/Lifecycle.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/Lifecycle.java deleted file mode 100644 index 02075cad01..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/Lifecycle.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Implementations adhere to runtime lifecycle semantics - * - * @version $Rev$ $Date$ - */ -public interface Lifecycle { - /* A configuration error state */ - int CONFIG_ERROR = -1; - /* Has not been initialized */ - int UNINITIALIZED = 0; - /* In the process of being configured and initialized */ - int INITIALIZING = 1; - /* Instantiated and configured */ - int INITIALIZED = 2; - /* Configured and initialized */ - int RUNNING = 4; - /* In the process of being shutdown */ - int STOPPING = 5; - /* Has been shutdown and removed from the composite */ - int STOPPED = 6; - /* In an error state */ - int ERROR = 7; - - /** - * Returns the lifecycle state - * - * @see #UNINITIALIZED - * @see #INITIALIZING - * @see #INITIALIZED - * @see #RUNNING - * @see #STOPPING - * @see #STOPPED - */ - int getLifecycleState(); - - /** - * Starts the Lifecycle. - * - * @throws CoreRuntimeException - */ - void start() throws CoreRuntimeException; - - /** - * Stops the Lifecycle. - * - * @throws CoreRuntimeException - */ - void stop() throws CoreRuntimeException; -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/PersistenceException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/PersistenceException.java deleted file mode 100644 index 54fba1ee03..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/PersistenceException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Raised when an error persisting a component implementation instance is encountered - * - * @version $Rev$ $Date$ - */ -public class PersistenceException extends Exception { - private static final long serialVersionUID = -908468170919651248L; - - public PersistenceException() { - } - - public PersistenceException(String message) { - super(message); - } - - public PersistenceException(String message, Throwable cause) { - super(message, cause); - } - - public PersistenceException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/Scope.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/Scope.java deleted file mode 100644 index 9b3f208cb3..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/Scope.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * The default implementation scopes supported by assemblies. - * - * @version $Rev$ $Date$ - */ -public class 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"); - - private String scope; - - public Scope(String scope) { - this.scope = scope.toUpperCase().intern(); - } - - public String getScope() { - return scope; - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final Scope scope1 = (Scope) o; - return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null); - } - - public int hashCode() { - return scope != null ? scope.hashCode() : 0; - } - - public String toString() { - return scope; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainer.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainer.java deleted file mode 100644 index 30482fae90..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainer.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -import org.apache.tuscany.sca.event.RuntimeEventListener; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - - -/** - * Manages the lifecycle and visibility of instances associated with a an {@link RuntimeComponent}. - * - * @version $Rev$ $Date$ - * @param <KEY> the type of IDs that this container uses to identify its contexts. - * For example, for COMPOSITE scope this could be the URI of the composite component, - * or for HTTP Session scope it might be the HTTP session ID. - */ -public interface ScopeContainer<KEY> extends Lifecycle, RuntimeEventListener { - - /** - * Returns the Scope that this container supports. - * - * @return the Scope that this container supports - */ - Scope getScope(); - - /** - * Start a new context with the supplied ID. - * - * @param contextId an ID that uniquely identifies the context. - */ - void startContext(KEY contextId); - - /** - * Stop the context with the supplied ID. - * - * @param contextId an ID that uniquely identifies the context. - */ - void stopContext(KEY contextId); - - /** - * Returns an instance wrapper associated with the current scope context, creating one if necessary - * @param contextId the id for the scope context - * - * @return the wrapper for the target instance - * @throws TargetResolutionException if there was a problem instantiating the target instance - */ - InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException; - - /** - * Returns an implementation instance associated with the current scope context. - * If no instance is found, a {@link TargetNotFoundException} is thrown. - * @param contextId the id for the scope context - * - * @return the wrapper for the target instance - * @throws TargetResolutionException if there was a problem instantiating the target instance - */ - InstanceWrapper getAssociatedWrapper(KEY contextId) - throws TargetResolutionException; - - /** - * Return a wrapper after use (for example, after invoking the instance). - * @param wrapper the wrapper for the target instance being returned - * @param contextId the id for the scope context - * - * @throws TargetDestructionException if there was a problem returning the target instance - */ - void returnWrapper(InstanceWrapper wrapper, KEY contextId) - throws TargetDestructionException; - - /** - * Removes a component implementation instance associated with the current context from persistent storage - * - * @param component the owning component - * @throws PersistenceException if there was a problem removing the instance - */ - void remove() throws PersistenceException; -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainerFactory.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainerFactory.java deleted file mode 100644 index b6acae7382..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainerFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * Factory to create ScopeContainer for components - * - * @version $Rev$ $Date$ - */ -public interface ScopeContainerFactory { - ScopeContainer createScopeContainer(RuntimeComponent component); - Scope getScope(); -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeIdentifier.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeIdentifier.java deleted file mode 100644 index 77e7d76842..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeIdentifier.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Implementations enable lazy retrieval of a scope id associated with a request, i.e. an id (and presumably a context) - * do not have to be generated if the scope is never accessed. Identifiers are associated with the current request - * thread and keyed on scope type. - * - * @version $Rev$ $Date$ - * @see org.apache.tuscany.sca.factory.component.WorkContext - */ -public interface ScopeIdentifier { - - /** - * Returns the scope id for the request. - */ - Object getIdentifier(); -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeNotFoundException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeNotFoundException.java deleted file mode 100644 index 40a251c6f2..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeNotFoundException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * @version $Rev$ $Date$ - */ -public class ScopeNotFoundException extends Exception { - - private static final long serialVersionUID = -3447306764458851441L; - - public ScopeNotFoundException(String scope) { - super("Scope not found: " + scope); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeRegistry.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeRegistry.java deleted file mode 100644 index f3319ee093..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeRegistry.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; - - -/** - * Manages {@link ScopeContainer}s in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public interface ScopeRegistry { - - /** - * Returns the scope container for the given scope or null if one not found - * - * @param scope the scope - * @return the scope container for the given scope or null if one not found - */ - ScopeContainer getScopeContainer(RuntimeComponent component); - - /** - * @param factory - */ - void register(ScopeContainerFactory factory); -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedImplementationProvider.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedImplementationProvider.java deleted file mode 100644 index 8b9c50b070..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedImplementationProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -import org.apache.tuscany.sca.provider.ImplementationProvider; - -/** - * A component implementation can implement this interface to provide scope - * management for the components - * - * @version $Rev$ $Date$ - */ -public interface ScopedImplementationProvider extends ImplementationProvider { - /** - * Get the scope for the component implementation - * - * @return The scope for the component implementation, if null is returned, - * STATELESS will be used - */ - Scope getScope(); - - /** - * Indicate if the component needs to be eagerly initialized - * - * @return true if the component is marked to be eagerly initialized, false - * otherwise - */ - boolean isEagerInit(); - - /** - * @return the maxAge - */ - long getMaxAge(); - - /** - * @return the maxIdleTime - */ - long getMaxIdleTime(); - - /** - * Create a wrapper for the component instance for the scope management - * - * @return A wrapper for the component instance - */ - InstanceWrapper createInstanceWrapper(); - -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedRuntimeComponent.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedRuntimeComponent.java deleted file mode 100644 index 6c33683bde..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedRuntimeComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * Scoped runtime component - * - * @version $Rev$ $Date$ - */ -public interface ScopedRuntimeComponent extends RuntimeComponent { - /** - * Set the associated scope container - * @param scopeContainer - */ - void setScopeContainer(ScopeContainer scopeContainer); - /** - * Get the assoicated scope container - * @return - */ - ScopeContainer getScopeContainer(); -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetDestructionException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetDestructionException.java deleted file mode 100644 index 6b251295f5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetDestructionException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Denotes an error destroying a target - * - * @version $Rev$ $Date$ - */ -public class TargetDestructionException extends TargetResolutionException { - private static final long serialVersionUID = -6126684147851674709L; - - public TargetDestructionException() { - super(); - } - - public TargetDestructionException(String message, Throwable cause) { - super(message, cause); - } - - public TargetDestructionException(String message) { - super(message); - } - - public TargetDestructionException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInitializationException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInitializationException.java deleted file mode 100644 index 17cd21967f..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInitializationException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Denotes an error initializing a target - * - * @version $Rev$ $Date$ - */ -public class TargetInitializationException extends TargetResolutionException { - private static final long serialVersionUID = -6228778208649752698L; - - public TargetInitializationException() { - super(); - } - - public TargetInitializationException(String message, Throwable cause) { - super(message, cause); - } - - public TargetInitializationException(String message) { - super(message); - } - - public TargetInitializationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvocationException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvocationException.java deleted file mode 100644 index f9bfa0a788..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvocationException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Raised when an error is encountered during a target invocation - * - * @version $Rev$ $Date$ - */ -public class TargetInvocationException extends Exception { - - private static final long serialVersionUID = -6553427708442761743L; - - public TargetInvocationException() { - super(); - } - - public TargetInvocationException(String message, Throwable cause) { - super(message, cause); - } - - public TargetInvocationException(String message) { - super(message); - } - - public TargetInvocationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvokerCreationException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvokerCreationException.java deleted file mode 100644 index a20d030ee8..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvokerCreationException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Denotes an error creating a target invoker - * - * @version $Rev$ $Date$ - * @Deprecated - */ -public abstract class TargetInvokerCreationException extends Exception { - - public TargetInvokerCreationException() { - super(); - } - - public TargetInvokerCreationException(String message, Throwable cause) { - super(message, cause); - } - - public TargetInvokerCreationException(String message) { - super(message); - } - - public TargetInvokerCreationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetNotFoundException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetNotFoundException.java deleted file mode 100644 index 4dd63f58f0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetNotFoundException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Thrown when a target of an operation cannot be found - * - * @version $$Rev$$ $$Date$$ - */ -public class TargetNotFoundException extends TargetResolutionException { - private static final long serialVersionUID = 5541830480658471186L; - - public TargetNotFoundException() { - super(); - } - - public TargetNotFoundException(String message, Throwable cause) { - super(message, cause); - } - - public TargetNotFoundException(String message) { - super(message); - } - - public TargetNotFoundException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetResolutionException.java b/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetResolutionException.java deleted file mode 100644 index 284ab8b6c7..0000000000 --- a/branches/sca-java-0.91/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetResolutionException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -/** - * Denotes an error retrieving a target instance - * - * @version $Rev$ $Date$ - */ -public class TargetResolutionException extends Exception { - private static final long serialVersionUID = 2912513650522019405L; - - public TargetResolutionException() { - super(); - } - - public TargetResolutionException(String message, Throwable cause) { - super(message, cause); - } - - public TargetResolutionException(String message) { - super(message); - } - - public TargetResolutionException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java deleted file mode 100644 index 40a146e129..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core; - -import junit.framework.TestCase; - -public class DefaultExtensionPointRegistryTestCase extends TestCase { - private ExtensionPointRegistry registry; - - protected void setUp() throws Exception { - super.setUp(); - registry = new DefaultExtensionPointRegistry(); - } - - public void testRegistry() { - MyRegistry service = new MyREgistryImpl(); - registry.addExtensionPoint(service); - assertSame(service, registry.getExtensionPoint(MyRegistry.class)); - registry.removeExtensionPoint(service); - assertNull(registry.getExtensionPoint(MyRegistry.class)); - } - - private static interface MyRegistry { - void doSomething(); - } - - private static class MyREgistryImpl implements MyRegistry { - - public void doSomething() { - } - - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java deleted file mode 100644 index d2050523eb..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.event.Event; -import org.apache.tuscany.sca.event.EventFilter; -import org.apache.tuscany.sca.event.EventPublisher; -import org.apache.tuscany.sca.event.RuntimeEventListener; -import org.apache.tuscany.sca.event.TrueFilter; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class BaseEventPublisherTestCase extends TestCase { - EventPublisher publisher; - - public void testFireListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - publisher.addListener(listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - public void testRemoveListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - publisher.addListener(listener); - publisher.removeListener(listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - public void testFalseFilterListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - publisher.addListener(new FalseFilter(), listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - public void testTrueFilterListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - publisher.addListener(new TrueFilter(), listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - protected void setUp() throws Exception { - super.setUp(); - publisher = new BaseEventPublisher() { - }; - } - - private class TestEvent implements Event { - public Object getSource() { - return null; - } - } - - private class FalseFilter implements EventFilter { - - public boolean match(Event event) { - return false; - } - } - - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java deleted file mode 100644 index bf95d640c5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.event; - -import java.net.URI; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class EventTestCase extends TestCase { - private URI uri = URI.create("foo"); - - public void testCompositeStart() { - ComponentStart event = new ComponentStart(this, uri); - assertEquals(uri, event.getComponentURI()); - } - - public void testCompositeStop() { - ComponentStop event = new ComponentStop(this, uri); - assertEquals(uri, event.getComponentURI()); - } - - public void testHttpSessionStart() { - Object id = new Object(); - HttpSessionStart event = new HttpSessionStart(this, id); - assertEquals(this, event.getSource()); - assertEquals(id, event.getSessionID()); - } - - public void testHttpSessionEnd() { - Object id = new Object(); - HttpSessionEnd event = new HttpSessionEnd(this, id); - assertEquals(this, event.getSource()); - assertEquals(id, event.getSessionID()); - } - - public void testRequestStart() { - RequestStart event = new RequestStart(this); - assertEquals(this, event.getSource()); - } - - public void testReequestEnd() { - RequestEnd event = new RequestEnd(this); - assertEquals(this, event.getSource()); - } - - - protected void setUp() throws Exception { - super.setUp(); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/AsyncTarget.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/AsyncTarget.java deleted file mode 100644 index c30e19de88..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/AsyncTarget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.OneWay; - -/** - * @version $Rev$ $Date$ - */ -public interface AsyncTarget { - @OneWay - void invoke(); - - int getCount(); -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BadContextPojo.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BadContextPojo.java deleted file mode 100644 index f9ae94f152..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BadContextPojo.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Context; - -public class BadContextPojo { - - @Context - String context; - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BadNamePojo.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BadNamePojo.java deleted file mode 100644 index c4074484b9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BadNamePojo.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.ComponentName; - -public class BadNamePojo { - @ComponentName - private int name; -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BasicInterface.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BasicInterface.java deleted file mode 100644 index ca305b9ef0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BasicInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * @version $Rev$ $Date$ - */ -public interface BasicInterface { - String returnsProperty(); - - BasicInterface returnsReference(); - - int returnsInt(); -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BasicInterfaceImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BasicInterfaceImpl.java deleted file mode 100644 index ea32d1f6b9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/BasicInterfaceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Reference; - -/** - * @version $Rev$ $Date$ - */ -public class BasicInterfaceImpl implements BasicInterface { - - @Property - public String publicProperty; - - @Reference (required = false) - public BasicInterface publicReference; - - @Property - protected String protectedProperty; - - @Reference (required = false) - protected BasicInterface protectedReference; - - private String privateProperty; - - private BasicInterface privateReference; - - @Property - public void setPrivateProperty(String privateProperty) { - this.privateProperty = privateProperty; - } - - @Reference (required = false) - public void setPrivateReference(BasicInterface privateReference) { - this.privateReference = privateReference; - } - - public String returnsProperty() { - return privateProperty; - } - - public BasicInterface returnsReference() { - return privateReference; - } - - public int returnsInt() { - return 0; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeComponent.java deleted file mode 100644 index 6d320df145..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("COMPOSITE") -public interface CompositeScopeComponent { - - //public boolean isInit(); -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeComponentImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeComponentImpl.java deleted file mode 100644 index 9ff289a502..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeComponentImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Scope; - - -/** - * @version $Rev$ $Date$ - */ -@Scope("COMPOSITE") -public class CompositeScopeComponentImpl implements - CompositeScopeComponent { - - private String foo; - - public void setFoo(String foo) { - this.foo = foo; - } - - public String getFoo() { - return foo; - } -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeDestroyOnlyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeDestroyOnlyComponent.java deleted file mode 100644 index 832055a084..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Destroy; - -public class CompositeScopeDestroyOnlyComponent extends CompositeScopeComponentImpl { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeInitDestroyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeInitDestroyComponent.java deleted file mode 100644 index e8b76e13c0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeInitDestroyComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Destroy; - -public class CompositeScopeInitDestroyComponent extends CompositeScopeInitOnlyComponent { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - if (destroyed) { - throw new AssertionError("Destroy called more than once"); - } - destroyed = true; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeInitOnlyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeInitOnlyComponent.java deleted file mode 100644 index 057580be7a..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/CompositeScopeInitOnlyComponent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Init; - -public class CompositeScopeInitOnlyComponent extends CompositeScopeComponentImpl { - - private boolean initialized; - // this value tests to ensure introspection can find the init() method even - // if a field is named the same. Ultimately, this should be in the introspection tests - private boolean init; - - public boolean isInitialized() { - return initialized; - } - - @Init - public void init() { - if (initialized) { - throw new AssertionError("Init called more than once"); - } - initialized = true; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeComponent.java deleted file mode 100644 index 79f48a57c5..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeComponent.java +++ /dev/null @@ -1,29 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sca.core.mock.component;
-
-import org.osoa.sca.annotations.Scope;
-
-/**
- * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $
- */
-@Scope("CONVERSATION")
-public interface ConversationalScopeComponent {
-
-}
diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeComponentImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeComponentImpl.java deleted file mode 100644 index 5b42d92191..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeComponentImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sca.core.mock.component;
-
-import org.osoa.sca.annotations.Scope;
-
-/**
- * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $
- */
-@Scope("CONVERSATION")
-public class ConversationalScopeComponentImpl implements ConversationalScopeComponent {
-
-}
diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeDestroyOnlyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeDestroyOnlyComponent.java deleted file mode 100644 index c64556e754..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,37 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sca.core.mock.component;
-
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("CONVERSATION")
-public class ConversationalScopeDestroyOnlyComponent extends ConversationalScopeComponentImpl {
-
- boolean destroyed;
-
- public boolean isDestroyed() {
- return destroyed;
- }
-
- @Destroy
- public void destroy() {
- destroyed = true;
- }
-}
diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeInitDestroyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeInitDestroyComponent.java deleted file mode 100644 index 6f930ef750..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeInitDestroyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sca.core.mock.component;
-
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("CONVERSATION")
-public class ConversationalScopeInitDestroyComponent
- extends ConversationalScopeInitOnlyComponent {
-
- private boolean destroyed;
-
- public boolean isDestroyed() {
- return destroyed;
- }
-
- @Destroy
- public void destroy() {
- destroyed = true;
- }
-}
diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeInitOnlyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeInitOnlyComponent.java deleted file mode 100644 index 70733f4d99..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/ConversationalScopeInitOnlyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sca.core.mock.component;
-
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("CONVERSATION")
-public class ConversationalScopeInitOnlyComponent
- extends ConversationalScopeComponentImpl {
-
- private boolean initialized;
-
- public boolean isInitialized() {
- return initialized;
- }
-
- @Init
- public void init() {
- initialized = true;
- }
-}
diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderException.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderException.java deleted file mode 100644 index 4bb9cde958..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -public class OrderException extends Exception { - - public OrderException() { - super(); - } - - public OrderException(String message) { - super(message); - } - - public OrderException(String message, Throwable cause) { - super(message, cause); - } - - public OrderException(Throwable cause) { - super(cause); - } - -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedDependentPojo.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedDependentPojo.java deleted file mode 100644 index df59029884..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedDependentPojo.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * @version $$Rev$$ $$Date$$ - */ -public interface OrderedDependentPojo extends OrderedInitPojo { - - OrderedInitPojo getPojo(); - - void setPojo(OrderedInitPojo pojo); -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedDependentPojoImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedDependentPojoImpl.java deleted file mode 100644 index 1b51c2772d..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedDependentPojoImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class OrderedDependentPojoImpl extends OrderedInitPojoImpl implements OrderedDependentPojo { - - private OrderedInitPojo pojo; - - public OrderedInitPojo getPojo() { - return pojo; - } - - public void setPojo(OrderedInitPojo pojo) { - this.pojo = pojo; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedEagerInitPojo.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedEagerInitPojo.java deleted file mode 100644 index 139086bf0d..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedEagerInitPojo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -@Scope("COMPOSITE") -@EagerInit -public class OrderedEagerInitPojo { - - private static final Object LOCK = new Object(); - private static int numberInstantied; - private int initOrder; - - @Init - public void init() { - synchronized (LOCK) { - ++numberInstantied; - initOrder = numberInstantied; - } - } - - @Destroy - public void destroy() throws OrderException { - synchronized (LOCK) { - if (initOrder != numberInstantied) { - throw new OrderException("Instance shutdown done out of order"); - } - --numberInstantied; - } - } - - public int getNumberInstantiated() { - return numberInstantied; - } - - public int getInitOrder() { - return initOrder; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedInitPojo.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedInitPojo.java deleted file mode 100644 index 1c3615fcd0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedInitPojo.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * @version $$Rev$$ $$Date$$ - */ -public interface OrderedInitPojo { - int getNumberInstantiated(); - - int getInitOrder(); -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedInitPojoImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedInitPojoImpl.java deleted file mode 100644 index b65ead9b19..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OrderedInitPojoImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -@Scope("COMPOSITE") -public class OrderedInitPojoImpl implements OrderedInitPojo { - - private static final Object LOCK = new Object(); - private static int numberInstantied; - private int initOrder; - - public OrderedInitPojoImpl() { - } - - @Init - public void init() { - synchronized (LOCK) { - ++numberInstantied; - initOrder = numberInstantied; - } - } - - @Destroy - public void destroy() throws OrderException { - synchronized (LOCK) { - if (initOrder != numberInstantied) { - throw new OrderException("Instance shutdown done out of order"); - } - --numberInstantied; - } - } - - public int getNumberInstantiated() { - return numberInstantied; - } - - public int getInitOrder() { - return initOrder; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OtherTarget.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OtherTarget.java deleted file mode 100644 index 963c31a4ca..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OtherTarget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * Implementations are used in wiring tests - * - * @version $Rev$ $Date$ - */ -public interface OtherTarget { - - String getString(); - - void setString(String val); -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OtherTargetImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OtherTargetImpl.java deleted file mode 100644 index 91ccc9e772..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/OtherTargetImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * A target used for testing wires with a different source and target interface - * - * @version $Rev$ $Date$ - */ -public class OtherTargetImpl implements OtherTarget { - - private String theString; - - public String getString() { - return theString; - } - - public void setString(String val) { - theString = val; - } - - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeComponent.java deleted file mode 100644 index 7d03c4372d..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("REQUEST") -public interface RequestScopeComponent { - -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeDestroyOnlyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeDestroyOnlyComponent.java deleted file mode 100644 index f94f071086..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Scope; - -@Scope("REQUEST") -public class RequestScopeDestroyOnlyComponent extends SessionScopeComponentImpl { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeInitDestroyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeInitDestroyComponent.java deleted file mode 100644 index f2de2d9afa..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeInitDestroyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Scope; - -@Scope("REQUEST") -public class RequestScopeInitDestroyComponent extends SessionScopeInitOnlyComponent { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeInitOnlyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeInitOnlyComponent.java deleted file mode 100644 index 9bcef40834..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/RequestScopeInitOnlyComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -@Scope("REQUEST") -public class RequestScopeInitOnlyComponent extends SessionScopeComponentImpl { - - private boolean initialized; - - public boolean isInitialized() { - return initialized; - } - - @Init - public void init() { - initialized = true; - } - - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeComponent.java deleted file mode 100644 index 8318333feb..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("SESSION") -public interface SessionScopeComponent { - -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeComponentImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeComponentImpl.java deleted file mode 100644 index 0494d587aa..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeComponentImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("SESSION") -public class SessionScopeComponentImpl implements - SessionScopeComponent { - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeInitDestroyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeInitDestroyComponent.java deleted file mode 100644 index fdc11a80af..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeInitDestroyComponent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Destroy; - -public class SessionScopeInitDestroyComponent extends SessionScopeInitOnlyComponent { - - private boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeInitOnlyComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeInitOnlyComponent.java deleted file mode 100644 index 4e849895f8..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SessionScopeInitOnlyComponent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Init; - -public class SessionScopeInitOnlyComponent extends SessionScopeComponentImpl { - - private boolean initialized; - - public boolean isInitialized() { - return initialized; - } - - @Init - public void init() { - initialized = true; - } - - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SimpleTarget.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SimpleTarget.java deleted file mode 100644 index 44eb94260e..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SimpleTarget.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -public interface SimpleTarget { - - String hello(String message) throws Exception; - - String goodbye(String message) throws Exception; - - String echo(String message) throws Exception; - -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SimpleTargetImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SimpleTargetImpl.java deleted file mode 100644 index 662b21116a..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SimpleTargetImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -public class SimpleTargetImpl implements SimpleTarget { - - public SimpleTargetImpl() { - super(); - } - - public String hello(String message) throws Exception { - return message; - } - - public String goodbye(String message) throws Exception { - return message; - } - - public String echo(String message) throws Exception { - return message; - } - - -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/Source.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/Source.java deleted file mode 100644 index aa3b5be528..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/Source.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import java.util.List; - -/** - * Implementations are used in wiring tests - * - * @version $Rev$ $Date$ - */ -public interface Source { - - Target getTarget(); - - List<Target> getTargets(); - - List<Target> getTargetsThroughField(); - -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SourceImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SourceImpl.java deleted file mode 100644 index 81e39a9fe9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/SourceImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import java.util.List; - -/** - * Mock system component implementation used in wiring tests - * - * @version $Rev$ $Date$ - */ -public class SourceImpl implements Source { - - private Target target; - private List<Target> targets; - private List<Target> targetsThroughField; - private Target[] targetsArray; - - public void setTarget(Target target) { - this.target = target; - } - - public Target getTarget() { - return target; - } - - public List<Target> getTargets() { - return targets; - } - - public void setTargets(List<Target> targets) { - this.targets = targets; - } - - public List<Target> getTargetsThroughField() { - return targetsThroughField; - } - - public Target[] getArrayOfTargets() { - return targetsArray; - } - - public void setArrayOfTargets(Target[] targets) { - targetsArray = targets; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/StatelessComponent.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/StatelessComponent.java deleted file mode 100644 index 89d0be7a53..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/StatelessComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("STATELESS") -public interface StatelessComponent { - -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/StatelessComponentImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/StatelessComponentImpl.java deleted file mode 100644 index 28eb28e76d..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/StatelessComponentImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * @version $Rev$ $Date$ - */ -public class StatelessComponentImpl implements - StatelessComponent { - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/Target.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/Target.java deleted file mode 100644 index 5e85ed48b0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/Target.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * Implementations are used in wiring tests - * - * @version $Rev$ $Date$ - */ -public interface Target { - - String getString(); - - void setString(String val); -} - diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/TargetImpl.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/TargetImpl.java deleted file mode 100644 index 169b38a8d0..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/mock/component/TargetImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.mock.component; - -/** - * Mock system component implementation used in wiring tests - * - * @version $Rev$ $Date$ - */ -public class TargetImpl implements Target { - - private String theString; - - public String getString() { - return theString; - } - - public void setString(String val) { - theString = val; - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java deleted file mode 100644 index 5be8fe21b3..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.scope; - -import java.net.URI; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.InstanceWrapper; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.scope.ScopedImplementationProvider; -import org.easymock.EasyMock; -import org.easymock.IMocksControl; - -/** - * @version $Rev$ $Date$ - */ -public abstract class AbstractScopeContainerTestCase<T, KEY> extends TestCase { - protected IMocksControl control; - protected ScopeContainer<KEY> scopeContainer; - protected URI groupId; - protected KEY contextId; - protected RuntimeComponent component; - protected ScopedImplementation implementation; - protected InstanceWrapper<T> wrapper; - - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - control = EasyMock.createStrictControl(); - component = control.createMock(RuntimeComponent.class); - wrapper = control.createMock(InstanceWrapper.class); - implementation = control.createMock(ScopedImplementation.class); - EasyMock.expect(component.getImplementation()).andReturn(implementation).anyTimes(); - } - - protected void preRegisterComponent() throws Exception { - scopeContainer.start(); - EasyMock.expect(implementation.isEagerInit()).andStubReturn(false); - } - - protected void expectCreateWrapper() throws Exception { - EasyMock.expect(implementation.createInstanceWrapper()).andReturn(wrapper); - wrapper.start(); - } - - protected static interface ScopedImplementation extends ScopedImplementationProvider, Implementation { - - } - - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java deleted file mode 100644 index 2f5c182f45..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.store; - -import java.util.UUID; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.event.RuntimeEventListener; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.store.DuplicateRecordException; -import org.apache.tuscany.sca.store.Store; -import org.apache.tuscany.sca.store.StoreExpirationEvent; -import org.apache.tuscany.sca.store.StoreMonitor; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $Rev$ $Date$ - */ -public class MemoryStoreTestCase extends TestCase { - private StoreMonitor monitor; - - public void testEviction() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, 1); - Thread.sleep(200); - assertNull(store.readRecord(component, id)); - store.destroy(); - } - - public void testNotifyOnEviction() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.isA(StoreExpirationEvent.class)); - EasyMock.expectLastCall().andStubAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - latch.countDown(); - return null; - } - }); - EasyMock.replay(listener); - MemoryStore store = new MemoryStore(monitor); - store.addListener(listener); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, 1); - if (!latch.await(1000, TimeUnit.MILLISECONDS)) { - // failed to notify listener - fail(); - } - EasyMock.verify(listener); - } - - public void testNoEviction() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, Store.NEVER); - Thread.sleep(100); - assertNotNull(store.readRecord(component, id)); - store.destroy(); - } - - public void testInsertRecord() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, Store.NEVER); - store.destroy(); - } - - public void testInsertAlreadyExists() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createMock(RuntimeComponent.class); - EasyMock.expect(component.getURI()).andReturn("component"); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, Store.NEVER); - try { - store.insertRecord(component, id, value, Store.NEVER); - fail(); - } catch (DuplicateRecordException e) { - //expected - } - store.destroy(); - } - - public void testUpdateRecord() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - Object newValue = new Object(); - - store.insertRecord(component, id, value, Store.NEVER); - store.updateRecord(component, id, newValue, 1L); - assertEquals(newValue, store.readRecord(component, id)); - store.destroy(); - } - - public void testDeleteRecord() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - - store.insertRecord(component, id, value, Store.NEVER); - store.removeRecord(component, id); - assertNull(store.readRecord(component, id)); - store.destroy(); - } - - protected void setUp() throws Exception { - super.setUp(); - monitor = EasyMock.createNiceMock(StoreMonitor.class); - EasyMock.replay(monitor); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java deleted file mode 100644 index 58503fd852..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.wire; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.invocation.CallbackInterfaceInterceptor; -import org.apache.tuscany.sca.core.invocation.MessageFactoryImpl; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Message; -import org.easymock.EasyMock; -import org.osoa.sca.NoRegisteredCallbackException; - -/** - * @version $Rev$ $Date$ - */ -public class CallbackInterfaceInterceptorTestCase extends TestCase { - - public void testImplements() { - CallbackInterfaceInterceptor interceptor = new CallbackInterfaceInterceptor(true); - Interceptor next = EasyMock.createMock(Interceptor.class); - EasyMock.expect(next.invoke(EasyMock.isA(Message.class))).andReturn(null); - EasyMock.replay(next); - interceptor.setNext(next); - interceptor.invoke(new MessageFactoryImpl().createMessage()); - EasyMock.verify(next); - } - - public void testDoesNotImplement() { - CallbackInterfaceInterceptor interceptor = new CallbackInterfaceInterceptor(false); - try { - interceptor.invoke(new MessageFactoryImpl().createMessage()); - fail(); - } catch (NoRegisteredCallbackException e) { - // expected - } - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java deleted file mode 100644 index 83f7bdd887..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.wire; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.invocation.InvocationChainImpl; -import org.apache.tuscany.sca.interfacedef.impl.OperationImpl; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - -/** - * @version $Rev$ $Date$ - */ -public class InvocationChainImplTestCase extends TestCase { - - public void testInsertAtEnd() throws Exception { - InvocationChain chain = new InvocationChainImpl(new OperationImpl("foo")); - Interceptor inter2 = new MockInterceptor(); - Interceptor inter1 = new MockInterceptor(); - chain.addInterceptor(inter1); - chain.addInterceptor(inter2); - Interceptor head = (Interceptor)chain.getHeadInvoker(); - assertEquals(inter1, head); - assertEquals(inter2, head.getNext()); - assertEquals(inter2, chain.getTailInvoker()); - - } - - private class MockInterceptor implements Interceptor { - - private Invoker next; - - public Message invoke(Message msg) { - return null; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public Invoker getNext() { - return next; - } - - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java deleted file mode 100644 index c5f93edeb6..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.core.wire; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.getCurrentArguments; -import static org.easymock.EasyMock.isA; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.work.WorkScheduler; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $Rev$ $Date$ - */ -public class NonBlockingInterceptorTestCase extends TestCase { - - public void testInvoke() throws Exception { - WorkScheduler scheduler = createMock(WorkScheduler.class); - scheduler.scheduleWork(isA(Runnable.class)); - expectLastCall().andStubAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - Runnable runnable = (Runnable) getCurrentArguments()[0]; - runnable.run(); - return null; - } - }); - replay(scheduler); - Message context = createMock(Message.class); - String convID = "convID"; - EasyMock.expect(context.getConversationID()).andReturn(convID); - EasyMock.replay(context); - ThreadMessageContext.setMessageContext(context); - Message msg = createMock(Message.class); - msg.setCorrelationID(null); - msg.setConversationID(convID); - Interceptor next = EasyMock.createMock(Interceptor.class); - EasyMock.expect(next.invoke(EasyMock.eq(msg))).andReturn(msg); - EasyMock.replay(next); - EasyMock.replay(msg); - Interceptor interceptor = new NonBlockingInterceptor(scheduler, next); - interceptor.invoke(msg); - verify(context); - verify(next); - verify(msg); - } - -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/factory/AssertionTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/factory/AssertionTestCase.java deleted file mode 100644 index 77d0e01dc9..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/factory/AssertionTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.factory; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class AssertionTestCase extends TestCase { - /** - * test case that confirms that JRE assertions are enabled - */ - public void testAssertionsAreEnabled() { - try { - assert false; - fail("assertions are not enabled"); - } catch (AssertionError e) { - // ok - } - } -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/factory/SingletonObjectFactoryTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/factory/SingletonObjectFactoryTestCase.java deleted file mode 100644 index 4d38c447ea..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/factory/SingletonObjectFactoryTestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.factory; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class SingletonObjectFactoryTestCase extends TestCase { - - public void testSingleton() throws Exception { - Object o = new Object(); - SingletonObjectFactory<Object> factory = new SingletonObjectFactory<Object>(o); - assertEquals(o, factory.getInstance()); - } -} diff --git a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java b/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java deleted file mode 100644 index 1b95c6ff63..0000000000 --- a/branches/sca-java-0.91/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.sca.scope; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.scope.Scope; - -/** - * @version $Rev$ $Date$ - */ -public class ScopeTestCase extends TestCase { - - public void testEquals() throws Exception { - Scope scope = new Scope("COMPOSITE"); - assertTrue(scope.equals(Scope.COMPOSITE)); - } - - public void testEqualsNew() throws Exception { - Scope foo = new Scope("foo"); - Scope foo2 = new Scope("FOO"); - assertTrue(foo.equals(foo2)); - } - - public void testNotEquals() throws Exception { - Scope foo = new Scope("BAR"); - Scope foo2 = new Scope("FOO"); - assertFalse(foo.equals(foo2)); - } - - public void testNotEqualsDifferent() throws Exception { - Scope foo = new Scope("FOO"); - assertFalse(foo.equals(new Bar("FOO"))); - } - - public class Bar { - String scope; - - public Bar(String scope) { - this.scope = scope; - } - } - - -} |