diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..bf4230d7a --- /dev/null +++ b/.classpath @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 000000000..b7475b87c --- /dev/null +++ b/.project @@ -0,0 +1,38 @@ + + + data-commons + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.ajdt.core.ajbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.ajdt.ui.ajnature + com.springsource.sts.roo.core.nature + org.springframework.ide.eclipse.core.springnature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..20b5b8e93 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Sat Jul 17 11:18:33 EDT 2010 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000..9d396ff7d --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,6 @@ + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000..be3b0394b --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.springBeans b/.springBeans new file mode 100644 index 000000000..4dff64763 --- /dev/null +++ b/.springBeans @@ -0,0 +1,13 @@ + + + 1 + + + + + + + + + + diff --git a/src/main/java/org/springframework/data/core/DataMapper.java b/src/main/java/org/springframework/data/core/DataMapper.java new file mode 100644 index 000000000..bc7fdf042 --- /dev/null +++ b/src/main/java/org/springframework/data/core/DataMapper.java @@ -0,0 +1,29 @@ +/* + * Copyright 2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.core; + +/** + * Class used to map data to a business object. + * + * @author Thomas Risberg + * @since 1.0 + */ +public interface DataMapper { + + T map(S source); + +} diff --git a/src/main/java/org/springframework/data/core/DataValueSource.java b/src/main/java/org/springframework/data/core/DataValueSource.java new file mode 100644 index 000000000..d027458d9 --- /dev/null +++ b/src/main/java/org/springframework/data/core/DataValueSource.java @@ -0,0 +1,29 @@ +/* + * Copyright 2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.core; + +/** + * Class used to map a business object to an object providing the data value. + * + * @author Thomas Risberg + * @since 1.0 + */ +public interface DataValueSource { + + T getValue(S source); + +} diff --git a/src/main/java/org/springframework/data/core/QueryDefinition.java b/src/main/java/org/springframework/data/core/QueryDefinition.java new file mode 100644 index 000000000..61eea7dbf --- /dev/null +++ b/src/main/java/org/springframework/data/core/QueryDefinition.java @@ -0,0 +1,5 @@ +package org.springframework.data.core; + +public interface QueryDefinition { + +} diff --git a/src/main/java/org/springframework/datastore/core/AbstractDatastoreTemplate.java b/src/main/java/org/springframework/datastore/core/AbstractDatastoreTemplate.java new file mode 100644 index 000000000..47a73da10 --- /dev/null +++ b/src/main/java/org/springframework/datastore/core/AbstractDatastoreTemplate.java @@ -0,0 +1,31 @@ +package org.springframework.datastore.core; + +import java.util.List; + +import org.springframework.data.core.DataMapper; +import org.springframework.data.core.QueryDefinition; + +public abstract class AbstractDatastoreTemplate { + + protected DatastoreConnectionFactory datastoreConnectionFactory; + + public DatastoreConnectionFactory getDatastoreConnectionFactory() { + return datastoreConnectionFactory; + } + + public void setDatastoreConnectionFactory(DatastoreConnectionFactory datastoreConnectionFactory) { + this.datastoreConnectionFactory = datastoreConnectionFactory; + } + + public T execute(DatastoreConnectionCallback action) { + try { + return action.doInConnection(datastoreConnectionFactory.getConnection()); + } + catch (Exception e) { + throw new UncategorizedDatastoreException("Failure executing using datastore connection", e); + } + } + + public abstract List query(QueryDefinition query, DataMapper mapper); + +} diff --git a/src/main/java/org/springframework/datastore/core/DatastoreConnectionCallback.java b/src/main/java/org/springframework/datastore/core/DatastoreConnectionCallback.java new file mode 100644 index 000000000..712eb0fc1 --- /dev/null +++ b/src/main/java/org/springframework/datastore/core/DatastoreConnectionCallback.java @@ -0,0 +1,8 @@ +package org.springframework.datastore.core; + +import org.springframework.dao.DataAccessException; + +public interface DatastoreConnectionCallback { + + T doInConnection(C con) throws DataAccessException; +} diff --git a/src/main/java/org/springframework/datastore/core/DatastoreConnectionFactory.java b/src/main/java/org/springframework/datastore/core/DatastoreConnectionFactory.java new file mode 100644 index 000000000..8eb155b3e --- /dev/null +++ b/src/main/java/org/springframework/datastore/core/DatastoreConnectionFactory.java @@ -0,0 +1,5 @@ +package org.springframework.datastore.core; + +public interface DatastoreConnectionFactory { + C getConnection(); +} diff --git a/src/main/java/org/springframework/datastore/core/UncategorizedDatastoreException.java b/src/main/java/org/springframework/datastore/core/UncategorizedDatastoreException.java new file mode 100644 index 000000000..7e4aa49b0 --- /dev/null +++ b/src/main/java/org/springframework/datastore/core/UncategorizedDatastoreException.java @@ -0,0 +1,12 @@ +package org.springframework.datastore.core; + +import org.springframework.dao.UncategorizedDataAccessException; + +public class UncategorizedDatastoreException extends + UncategorizedDataAccessException { + + public UncategorizedDatastoreException(String msg, Throwable cause) { + super(msg, cause); + } + +} diff --git a/src/main/java/org/springframework/data/serialization/SerializationStore.java b/src/main/java/org/springframework/datastore/serialization/SerializationStore.java similarity index 80% rename from src/main/java/org/springframework/data/serialization/SerializationStore.java rename to src/main/java/org/springframework/datastore/serialization/SerializationStore.java index dd4bd317c..0c430c311 100644 --- a/src/main/java/org/springframework/data/serialization/SerializationStore.java +++ b/src/main/java/org/springframework/datastore/serialization/SerializationStore.java @@ -1,4 +1,4 @@ -package org.springframework.data.serialization; +package org.springframework.datastore.serialization; import java.lang.annotation.ElementType; import java.lang.annotation.RetentionPolicy;