diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-10 23:33:46 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-10 23:33:46 +0000 |
commit | fb886109649dcf5e0843f447642cde6eccb49253 (patch) | |
tree | d213e16a839870d9a132690470d04e230ddbdc26 /branches/sca-equinox/modules/core/src | |
parent | 3365b668407cf48a17216bf496829f15b2fed6de (diff) |
Remove dead code (Event/Store)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@703606 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/modules/core/src')
20 files changed, 6 insertions, 1060 deletions
diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/BaseEventPublisher.java deleted file mode 100644 index 517e5579a4..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStart.java deleted file mode 100644 index 45eab7da1b..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ComponentStop.java deleted file mode 100644 index 4dc79c3844..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationEnd.java deleted file mode 100644 index d3106c7052..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/ConversationStart.java deleted file mode 100644 index 123400fbdd..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionEnd.java deleted file mode 100644 index 68cb5c2966..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/HttpSessionStart.java deleted file mode 100644 index 38a4fb10d6..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestEnd.java deleted file mode 100644 index d7e797bbb9..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/event/RequestStart.java deleted file mode 100644 index 7530156b11..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java index 1168d1d0dd..ff92aa00a8 100644 --- a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java +++ b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java @@ -22,7 +22,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.tuscany.sca.core.context.InstanceWrapper; -import org.apache.tuscany.sca.event.Event; import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; @@ -88,9 +87,6 @@ public abstract class AbstractScopeContainer<KEY> implements ScopeContainer<KEY> // do nothing here. the conversational scope container implements this } - public void onEvent(Event event) { - } - protected boolean isEagerInit() { ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider(); if (implementationProvider instanceof ScopedImplementationProvider) { diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainer.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainer.java index 3ae1ca51c5..dc5d9ea8fe 100644 --- a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainer.java +++ b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainer.java @@ -32,7 +32,6 @@ import org.apache.tuscany.sca.core.conversation.ExtendedConversation; import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.store.Store;
/**
* A scope context which manages atomic component instances keyed on ConversationID
@@ -44,7 +43,7 @@ public class ConversationalScopeContainer extends AbstractScopeContainer<Object> private Map<Object, InstanceLifeCycleWrapper> instanceLifecycleCollection =
new ConcurrentHashMap<Object, InstanceLifeCycleWrapper>();
- public ConversationalScopeContainer(Store aStore, RuntimeComponent component) {
+ public ConversationalScopeContainer(RuntimeComponent component) {
super(Scope.CONVERSATION, component);
// Note: aStore is here to preserve the original factory interface. It is not currently used in this
diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainerFactory.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainerFactory.java index a6663aba09..6263cf6313 100644 --- a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainerFactory.java +++ b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ConversationalScopeContainerFactory.java @@ -20,21 +20,18 @@ package org.apache.tuscany.sca.core.scope; import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.store.Store; /** * @version $Rev$ $Date$ */ public class ConversationalScopeContainerFactory implements ScopeContainerFactory { - private Store store; - public ConversationalScopeContainerFactory(Store store) { + public ConversationalScopeContainerFactory() { super(); - this.store = store; } public ScopeContainer createScopeContainer(RuntimeComponent component) { - return new ConversationalScopeContainer(store, component); + return new ConversationalScopeContainer(component); } public Scope getScope() { diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java index 94f26845ed..4d4b324e05 100644 --- a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java +++ b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java @@ -22,7 +22,7 @@ package org.apache.tuscany.sca.core.scope; /** * A default scope registry implementation. * - * @version $Rev: $ $Date: $ + * @version $Rev$ $Date$ */ public class DefaultScopeRegistry extends ScopeRegistryImpl implements ScopeRegistry { @@ -30,7 +30,7 @@ public class DefaultScopeRegistry extends ScopeRegistryImpl implements ScopeRegi ScopeContainerFactory[] factories = new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory(), new RequestScopeContainerFactory(), - new ConversationalScopeContainerFactory(null), + new ConversationalScopeContainerFactory(), // new HttpSessionScopeContainer(monitor) }; for (ScopeContainerFactory f : factories) { diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainer.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainer.java index 5ae8b94647..c359f04ae0 100644 --- a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainer.java +++ b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/HttpSessionScopeContainer.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.core.scope; import org.apache.tuscany.sca.core.context.InstanceWrapper; -import org.apache.tuscany.sca.core.event.HttpSessionEnd; -import org.apache.tuscany.sca.event.Event; import org.apache.tuscany.sca.runtime.RuntimeComponent; /** @@ -36,16 +34,6 @@ public class HttpSessionScopeContainer extends AbstractScopeContainer<Object> { } @Override - public void onEvent(Event event) { - checkInit(); - if (event instanceof HttpSessionEnd) { - //FIXME key is not used - //Object key = ((HttpSessionEnd)event).getSessionID(); - // FIXME: Remove the session id - } - } - - @Override public synchronized void start() { if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java index f11a61e662..c6fd9ec067 100644 --- a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java +++ b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java @@ -22,8 +22,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.tuscany.sca.core.context.InstanceWrapper; -import org.apache.tuscany.sca.core.event.RequestEnd; -import org.apache.tuscany.sca.event.Event; import org.apache.tuscany.sca.runtime.RuntimeComponent; /** @@ -41,14 +39,6 @@ public class RequestScopeContainer extends AbstractScopeContainer<Thread> { } @Override - public void onEvent(Event event) { - checkInit(); - if (event instanceof RequestEnd) { - // shutdownInstances(Thread.currentThread()); - } - } - - @Override public synchronized void start() { if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java index 6b2980b989..0f82e5e864 100644 --- a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java +++ b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.core.scope; import org.apache.tuscany.sca.core.context.InstanceWrapper; -import org.apache.tuscany.sca.event.RuntimeEventListener; import org.apache.tuscany.sca.runtime.RuntimeComponent; @@ -31,7 +30,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent; * 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 RuntimeEventListener { +public interface ScopeContainer<KEY> { /** * Returns the Scope that this container supports. diff --git a/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/store/MemoryStore.java b/branches/sca-equinox/modules/core/src/main/java/org/apache/tuscany/sca/core/store/MemoryStore.java deleted file mode 100644 index 5b838116c5..0000000000 --- a/branches/sca-equinox/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-equinox/modules/core/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java b/branches/sca-equinox/modules/core/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java deleted file mode 100644 index 2bc78c3d35..0000000000 --- a/branches/sca-equinox/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); - } - - @Override - protected void setUp() throws Exception { - 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-equinox/modules/core/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java b/branches/sca-equinox/modules/core/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java deleted file mode 100644 index 48dcf8df07..0000000000 --- a/branches/sca-equinox/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()); - } - - - @Override - protected void setUp() throws Exception { - } -} diff --git a/branches/sca-equinox/modules/core/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java b/branches/sca-equinox/modules/core/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java deleted file mode 100644 index d46d77b4b8..0000000000 --- a/branches/sca-equinox/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(); - } - - @Override - protected void setUp() throws Exception { - monitor = EasyMock.createNiceMock(StoreMonitor.class); - EasyMock.replay(monitor); - } - -} |