You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/05/07 10:47:42 UTC
svn commit: r535784 [1/2] - in /incubator/tuscany/java/sca/modules:
core-spi/src/main/java/org/apache/tuscany/spi/event/
core-spi/src/main/java/org/apache/tuscany/spi/services/
core-spi/src/main/java/org/apache/tuscany/store/
core-spi/src/main/java/org...
Author: jsdelfino
Date: Mon May 7 01:47:32 2007
New Revision: 535784
URL: http://svn.apache.org/viewvc?view=rev&rev=535784
Log:
More cleanup and refactoring of the core runtime.
Added:
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/DuplicateRecordException.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/RecoveryListener.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/Store.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreException.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreExpirationEvent.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreMonitor.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreReadException.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreWriteException.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/NotificationListener.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkScheduler.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkSchedulerException.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/BaseEventPublisher.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStart.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStop.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationEnd.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationStart.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionEnd.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionStart.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestEnd.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestStart.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/BaseInstanceWrapper.java (with props)
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/MemoryStore.java (with props)
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/DefaultExtensionPointRegistryTestCase.java (with props)
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/BaseEventPublisherTestCase.java (with props)
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/EventTestCase.java (with props)
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/scope/
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/scope/AbstractScopeContainerTestCase.java (with props)
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/scope/InstanceWrapperBaseTestCase.java (with props)
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/scope/WorkContextTestCase.java (with props)
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/store/
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/store/MemoryStoreTestCase.java (with props)
Removed:
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/services/
incubator/tuscany/java/sca/modules/core-spi/src/test/java/org/apache/tuscany/spi/event/
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/event/
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/InstanceWrapperBase.java
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/ExtensionPointRegistryImplTestCase.java
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/event/
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/services/
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/integration/MemoryStore.java
Modified:
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/ConversationalScopeContainer.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/HttpSessionScopeContainer.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/RequestScopeContainer.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/work/Jsr237WorkScheduler.java
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorTestCase.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/ReallySmallRuntimeBuilder.java
incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/http/jetty/JettyServer.java
incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/http/jetty/module/JettyRuntimeModuleActivator.java
incubator/tuscany/java/sca/modules/http-jetty/src/test/java/org/apache/tuscany/http/jetty/JettyServerTestCase.java
incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/http/tomcat/TomcatServer.java
incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/http/tomcat/module/TomcatRuntimeModuleActivator.java
incubator/tuscany/java/sca/modules/http-tomcat/src/test/java/org/apache/tuscany/http/tomcat/TomcatServerTestCase.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/context/ReflectiveInstanceWrapper.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/context/InstanceWrapperBaseTestCase.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/integration/AbstractConversationTestCase.java
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/DuplicateRecordException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/DuplicateRecordException.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/DuplicateRecordException.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/DuplicateRecordException.java Mon May 7 01:47:32 2007
@@ -0,0 +1,32 @@
+/*
+ * 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.store;
+
+/**
+ * thrown when a record already exists during an insert operation
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateRecordException extends StoreWriteException {
+ private static final long serialVersionUID = 3116253222569378447L;
+
+ public DuplicateRecordException(String owner, String identifier) {
+ super(null, owner, identifier);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/DuplicateRecordException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/DuplicateRecordException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/RecoveryListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/RecoveryListener.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/RecoveryListener.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/RecoveryListener.java Mon May 7 01:47:32 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.store;
+
+import java.util.UUID;
+
+/**
+ * Implementations receive callback events during a store recovery operation
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RecoveryListener {
+
+ /**
+ * Signals the start of a recovery
+ */
+ void onBegin();
+
+ /**
+ * Received when a record is recovered
+ *
+ * @param id
+ */
+ void onRecord(UUID id);
+
+ /**
+ * Signals the end of recovery
+ */
+ void onEnd();
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/RecoveryListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/RecoveryListener.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/Store.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/Store.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/Store.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/Store.java Mon May 7 01:47:32 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.store;
+
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.spi.event.EventPublisher;
+
+/**
+ * Implementations provide a persistent store for runtime data such as conversational state. A persistent store could be
+ * implemented in a durable fashion using JDBC or a journaling system, or using a non-durable mechanism such as an
+ * in-memory map.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Store extends EventPublisher {
+
+ /* Used to indicate an the default expiration offset for records for the store */
+ long DEFAULT_EXPIRATION_OFFSET = -1;
+
+ /* Used to indicate an entry should not expire */
+ long NEVER = -2;
+
+ /**
+ * Adds the given record to the store. Implementations may choose different strategies for writing data such as
+ * write-through or write-behind.
+ *
+ * @param owner the instance owner
+ * @param id the unique id of the record
+ * @param object the object representing the data to write
+ * @param expiration the time in milliseconds when the entry expires
+ * @throws StoreWriteException if an error occurs during the write operation
+ */
+ void insertRecord(RuntimeComponent owner, String id, Object object, long expiration) throws StoreWriteException;
+
+ /**
+ * Updates a given record in the store, overwriting previous information.
+ *
+ * @param owner the instance owner
+ * @param id the unique id of the record
+ * @param object the object representing the data to write
+ * @param expiration the time in milliseconds when the entry expires
+ * @throws StoreWriteException
+ */
+ void updateRecord(RuntimeComponent owner, String id, Object object, long expiration) throws StoreWriteException;
+
+ /**
+ * Returns the deserialized object in the store corresponding to the given id
+ *
+ * @param owner the instance owner
+ * @param id the unique id of the record
+ * @return the deserialized object or null if one is not found
+ * @throws StoreReadException
+ */
+ Object readRecord(RuntimeComponent owner, String id) throws StoreReadException;
+
+ /**
+ * Removes a record from the store
+ *
+ * @param owner the instance owner
+ * @param id the unique id of the record
+ * @throws StoreWriteException
+ */
+ void removeRecord(RuntimeComponent owner, String id) throws StoreWriteException;
+
+ /**
+ * Removes all records from the store
+ *
+ * @throws StoreWriteException
+ */
+ void removeRecords() throws StoreWriteException;
+
+ /**
+ * Initiates a recovery operation, for example during restart after a crash
+ *
+ * @param listener the listener to receive recovery callback events
+ * @throws StoreReadException
+ */
+ void recover(RecoveryListener listener) throws StoreReadException;
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/Store.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/Store.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreException.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreException.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreException.java Mon May 7 01:47:32 2007
@@ -0,0 +1,55 @@
+/*
+ * 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.store;
+
+import org.apache.tuscany.spi.TuscanyException;
+
+/**
+ * Represents a generic exception thrown by a <code>Store</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class StoreException extends TuscanyException {
+ private static final long serialVersionUID = -319152147419962709L;
+ private final String owner;
+
+ public StoreException(String message, String owner, String identifier) {
+ super(message, identifier);
+ this.owner = owner;
+ }
+
+ public StoreException(String message, String owner, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ this.owner = owner;
+ }
+
+ public StoreException(String message, String owner, Throwable cause) {
+ super(message, cause);
+ this.owner = owner;
+ }
+
+ public StoreException(Throwable cause) {
+ super(cause);
+ owner = null;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreExpirationEvent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreExpirationEvent.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreExpirationEvent.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreExpirationEvent.java Mon May 7 01:47:32 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.store;
+
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.spi.event.Event;
+
+/**
+ * Fired when a store implementation expires a resource
+ *
+ * @version $Rev$ $Date$
+ */
+public class StoreExpirationEvent implements Event {
+ private Object source;
+ private RuntimeComponent owner;
+ private Object instance;
+
+ /**
+ * Constructor.
+ *
+ * @param source the source of the event
+ * @param owner the owner of the expiring object
+ * @param instance the expiring object
+ */
+ public StoreExpirationEvent(Object source, RuntimeComponent owner, Object instance) {
+ assert source != null;
+ assert owner != null;
+ assert instance != null;
+ this.source = source;
+ this.owner = owner;
+ this.instance = instance;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the owner of the expiring object.
+ *
+ * @return the owner of the expiring object.
+ */
+ public RuntimeComponent getOwner() {
+ return owner;
+ }
+
+ /**
+ * Returns the expiring object.
+ *
+ * @return the expiring object.
+ */
+ public Object getInstance() {
+ return instance;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreExpirationEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreExpirationEvent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreMonitor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreMonitor.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreMonitor.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreMonitor.java Mon May 7 01:47:32 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.store;
+
+
+/**
+ * A generic monintor interface for services to log events
+ *
+ * @version $Rev$ $Date$
+ */
+public interface StoreMonitor {
+
+ /**
+ * Signals the service has started
+ *
+ * @param msg
+ */
+ void start(String msg);
+
+ /**
+ * Signals the service has been shutdown
+ *
+ * @param msg
+ */
+ void stop(String msg);
+
+ /**
+ * Fired when recovery is started
+ */
+
+ void beginRecover();
+
+ /**
+ * Fired when recovery is completed
+ */
+
+ void endRecover();
+
+ /**
+ * Fired when a record is processed during recovery
+ *
+ * @param recordId the id of the record being recovered
+ */
+
+ void recover(Object recordId);
+
+ /**
+ * Signals an error event
+ *
+ * @param e the error
+ */
+
+ void error(Throwable e);
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreMonitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreMonitor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreReadException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreReadException.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreReadException.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreReadException.java Mon May 7 01:47:32 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.store;
+
+/**
+ * Thrown when an error occurs reading from persistent storage
+ *
+ * @version $Rev$ $Date$
+ */
+public class StoreReadException extends StoreException {
+ private static final long serialVersionUID = -8624542082121467271L;
+
+ public StoreReadException(Throwable cause) {
+ super(cause);
+ }
+
+ public StoreReadException(String message, String owner, String identifier) {
+ super(message, owner, identifier);
+ }
+
+ public StoreReadException(String owner, String identifier, Throwable throwable) {
+ super(owner, identifier, throwable);
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreReadException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreReadException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreWriteException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreWriteException.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreWriteException.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreWriteException.java Mon May 7 01:47:32 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.store;
+
+/**
+ * Thrown when an error occurs writing to persistent storage
+ *
+ * @version $Rev$ $Date$
+ */
+public class StoreWriteException extends StoreException {
+ private static final long serialVersionUID = 5539070473942048555L;
+
+ public StoreWriteException(String message, String owner, String identifier) {
+ super(message, owner, identifier);
+ }
+
+ public StoreWriteException(String message, String owner, String identifier, Throwable cause) {
+ super(message, owner, identifier, cause);
+ }
+
+ public StoreWriteException(String message, String owner, Throwable cause) {
+ super(message, owner, cause);
+ }
+
+ public StoreWriteException(Throwable cause) {
+ super(cause);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreWriteException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/store/StoreWriteException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/NotificationListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/NotificationListener.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/NotificationListener.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/NotificationListener.java Mon May 7 01:47:32 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.work;
+
+/**
+ * A callback inyterface that can be optionally used for registering
+ * interest in status of asynchronously scheduled unit of work.
+ *
+ */
+public interface NotificationListener<T extends Runnable> {
+
+ /**
+ * Callback method when the unit of work is accepted.
+ *
+ * @param work Work that was accepted.
+ */
+ void workAccepted(T work);
+
+ /**
+ * Callback method when the unit of work is successfully completed.
+ *
+ * @param work Work that was succesfully completed.
+ */
+ void workCompleted(T work);
+
+ /**
+ * Callback when the unit of work is started.
+ *
+ * @param work Unit of work that was started.
+ */
+ void workStarted(T work);
+
+ /**
+ * Callback when the unit of work is rejected.
+ *
+ * @param work Unit of work that was rejected.
+ */
+ void workRejected(T work);
+
+ /**
+ * Callnack when the unit of work fails to complete.
+ *
+ * @param work Unit of work that failed to complete.
+ * @param error Error that caused the unit of work to fail.
+ */
+ void workFailed(T work, Throwable error);
+
+
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/NotificationListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/NotificationListener.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkScheduler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkScheduler.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkScheduler.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkScheduler.java Mon May 7 01:47:32 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.work;
+
+/**
+ * Defines the contract for scheduling asychronous units of work.
+ *
+ * <p>
+ * Units of work can be scheduled with an optional <code>NotificationListener</code>.
+ * If a notification listener is specified, the caller will be notified regarding the
+ * status of the work. The unit of work can either be completed, rejected or completed
+ * with an error. If the work completed with an error, the caller is notfied with the
+ * error details.
+ * </p>
+ *
+ */
+public interface WorkScheduler {
+
+ /**
+ * 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.
+ */
+ <T extends Runnable>void scheduleWork(T work, NotificationListener<T> listener);
+
+ /**
+ * 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.
+ */
+ <T extends Runnable>void scheduleWork(T work);
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkScheduler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkScheduler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkSchedulerException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkSchedulerException.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkSchedulerException.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkSchedulerException.java Mon May 7 01:47:32 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.work;
+
+import org.apache.tuscany.spi.TuscanyRuntimeException;
+
+/**
+ * Exception thrown by the work scheduler in case of unexpected exceptions.
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+@SuppressWarnings("serial")
+public class WorkSchedulerException extends TuscanyRuntimeException {
+
+ /**
+ * Wraps the root cause.
+ *
+ * @param cause Root cause for the exception.
+ */
+ public WorkSchedulerException(Throwable cause) {
+ super(cause);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkSchedulerException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/work/WorkSchedulerException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/BaseEventPublisher.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/BaseEventPublisher.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/BaseEventPublisher.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/BaseEventPublisher.java Mon May 7 01:47:32 2007
@@ -0,0 +1,89 @@
+/*
+ * 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.core.event;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.EventPublisher;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.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;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/BaseEventPublisher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/BaseEventPublisher.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStart.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStart.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStart.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStart.java Mon May 7 01:47:32 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.core.event;
+
+import java.net.URI;
+
+import org.apache.tuscany.spi.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;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStart.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStart.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStop.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStop.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStop.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStop.java Mon May 7 01:47:32 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.core.event;
+
+import java.net.URI;
+
+import org.apache.tuscany.spi.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;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStop.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ComponentStop.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationEnd.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationEnd.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationEnd.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationEnd.java Mon May 7 01:47:32 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.core.event;
+
+import org.apache.tuscany.spi.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;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationEnd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationEnd.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationStart.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationStart.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationStart.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationStart.java Mon May 7 01:47:32 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.core.event;
+
+import org.apache.tuscany.spi.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;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationStart.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/ConversationStart.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionEnd.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionEnd.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionEnd.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionEnd.java Mon May 7 01:47:32 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.core.event;
+
+import org.apache.tuscany.spi.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;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionEnd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionEnd.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionStart.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionStart.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionStart.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionStart.java Mon May 7 01:47:32 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.core.event;
+
+import org.apache.tuscany.spi.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;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionStart.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/HttpSessionStart.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestEnd.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestEnd.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestEnd.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestEnd.java Mon May 7 01:47:32 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.core.event;
+
+import org.apache.tuscany.spi.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;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestEnd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestEnd.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestStart.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestStart.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestStart.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestStart.java Mon May 7 01:47:32 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.core.event;
+
+import org.apache.tuscany.spi.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;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestStart.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/event/RequestStart.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java?view=diff&rev=535784&r1=535783&r2=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java Mon May 7 01:47:32 2007
@@ -26,7 +26,7 @@
import org.apache.tuscany.invocation.Message;
import org.apache.tuscany.scope.Scope;
import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.work.WorkScheduler;
import org.osoa.sca.ServiceRuntimeException;
/**
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java?view=diff&rev=535784&r1=535783&r2=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java Mon May 7 01:47:32 2007
@@ -53,7 +53,7 @@
import org.apache.tuscany.invocation.InvocationChain;
import org.apache.tuscany.scope.Scope;
import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.work.WorkScheduler;
/**
* @version $Rev$ $Date$
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/BaseInstanceWrapper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/BaseInstanceWrapper.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/BaseInstanceWrapper.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/BaseInstanceWrapper.java Mon May 7 01:47:32 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.core.scope;
+
+import org.apache.tuscany.scope.InstanceWrapper;
+import org.apache.tuscany.spi.component.TargetDestructionException;
+import org.apache.tuscany.spi.component.TargetInitializationException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BaseInstanceWrapper<T> implements InstanceWrapper<T> {
+ protected final T instance;
+ private boolean started;
+
+ public BaseInstanceWrapper(T instance) {
+ assert instance != null;
+ this.instance = instance;
+ }
+
+ public T getInstance() {
+ assert started;
+ return instance;
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+
+ public void start() throws TargetInitializationException {
+ started = true;
+ }
+
+ public void stop() throws TargetDestructionException {
+ started = false;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/BaseInstanceWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/BaseInstanceWrapper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/ConversationalScopeContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/ConversationalScopeContainer.java?view=diff&rev=535784&r1=535783&r2=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/ConversationalScopeContainer.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/ConversationalScopeContainer.java Mon May 7 01:47:32 2007
@@ -30,10 +30,10 @@
import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.event.Event;
import org.apache.tuscany.spi.event.RuntimeEventListener;
-import org.apache.tuscany.spi.services.store.Store;
-import org.apache.tuscany.spi.services.store.StoreExpirationEvent;
-import org.apache.tuscany.spi.services.store.StoreReadException;
-import org.apache.tuscany.spi.services.store.StoreWriteException;
+import org.apache.tuscany.store.Store;
+import org.apache.tuscany.store.StoreExpirationEvent;
+import org.apache.tuscany.store.StoreReadException;
+import org.apache.tuscany.store.StoreWriteException;
/**
* A scope context which manages atomic component instances keyed on a conversation session
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/HttpSessionScopeContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/HttpSessionScopeContainer.java?view=diff&rev=535784&r1=535783&r2=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/HttpSessionScopeContainer.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/HttpSessionScopeContainer.java Mon May 7 01:47:32 2007
@@ -25,7 +25,7 @@
import java.util.concurrent.ConcurrentHashMap;
import org.apache.tuscany.core.RuntimeComponent;
-import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.event.HttpSessionEnd;
import org.apache.tuscany.scope.InstanceWrapper;
import org.apache.tuscany.scope.Scope;
import org.apache.tuscany.spi.component.TargetDestructionException;
@@ -54,7 +54,7 @@
public void onEvent(Event event) {
checkInit();
if (event instanceof HttpSessionEnd) {
- Object key = ((HttpSessionEnd)event).getId();
+ Object key = ((HttpSessionEnd)event).getSessionID();
shutdownInstances(key);
workContext.clearIdentifier(key);
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/RequestScopeContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/RequestScopeContainer.java?view=diff&rev=535784&r1=535783&r2=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/RequestScopeContainer.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/scope/RequestScopeContainer.java Mon May 7 01:47:32 2007
@@ -26,7 +26,7 @@
import java.util.concurrent.ConcurrentHashMap;
import org.apache.tuscany.core.RuntimeComponent;
-import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.event.RequestEnd;
import org.apache.tuscany.scope.InstanceWrapper;
import org.apache.tuscany.scope.Scope;
import org.apache.tuscany.spi.component.TargetDestructionException;
Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/MemoryStore.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/MemoryStore.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/MemoryStore.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/MemoryStore.java Mon May 7 01:47:32 2007
@@ -0,0 +1,195 @@
+/*
+ * 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.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.core.RuntimeComponent;
+import org.apache.tuscany.core.event.BaseEventPublisher;
+import org.apache.tuscany.store.DuplicateRecordException;
+import org.apache.tuscany.store.RecoveryListener;
+import org.apache.tuscany.store.Store;
+import org.apache.tuscany.store.StoreExpirationEvent;
+import org.apache.tuscany.store.StoreMonitor;
+import org.apache.tuscany.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(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());
+ }
+ }
+ }
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/MemoryStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/store/MemoryStore.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/work/Jsr237WorkScheduler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/work/Jsr237WorkScheduler.java?view=diff&rev=535784&r1=535783&r2=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/work/Jsr237WorkScheduler.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/work/Jsr237WorkScheduler.java Mon May 7 01:47:32 2007
@@ -18,9 +18,9 @@
*/
package org.apache.tuscany.core.work;
-import org.apache.tuscany.spi.services.work.NotificationListener;
-import org.apache.tuscany.spi.services.work.WorkScheduler;
-import org.apache.tuscany.spi.services.work.WorkSchedulerException;
+import org.apache.tuscany.work.NotificationListener;
+import org.apache.tuscany.work.WorkScheduler;
+import org.apache.tuscany.work.WorkSchedulerException;
import commonj.work.WorkEvent;
import commonj.work.WorkException;
Added: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/DefaultExtensionPointRegistryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/DefaultExtensionPointRegistryTestCase.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/DefaultExtensionPointRegistryTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/DefaultExtensionPointRegistryTestCase.java Mon May 7 01:47:32 2007
@@ -0,0 +1,35 @@
+package org.apache.tuscany.core;
+
+import org.apache.tuscany.core.ExtensionPointRegistry;
+import org.apache.tuscany.core.DefaultExtensionPointRegistry;
+
+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(MyRegistry.class, service);
+ assertSame(service, registry.getExtensionPoint(MyRegistry.class));
+ registry.removeExtensionPoint(MyRegistry.class);
+ assertNull(registry.getExtensionPoint(MyRegistry.class));
+ }
+
+ private static interface MyRegistry {
+ void doSomething();
+ }
+
+ private static class MyREgistryImpl implements MyRegistry {
+
+ public void doSomething() {
+ }
+
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/DefaultExtensionPointRegistryTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/DefaultExtensionPointRegistryTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/BaseEventPublisherTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/BaseEventPublisherTestCase.java?view=auto&rev=535784
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/BaseEventPublisherTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/BaseEventPublisherTestCase.java Mon May 7 01:47:32 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.core.event;
+
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.EventPublisher;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.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;
+ }
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/BaseEventPublisherTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/event/BaseEventPublisherTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org