You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/09/08 10:56:32 UTC
[1/2] olingo-odata4 git commit: [OLINGO-562] split the code between
the generic part and the spring specific part
Repository: olingo-odata4
Updated Branches:
refs/heads/OLINGO-562_SpringExtension ec82a5d11 -> bb1dbba35
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHttpHandlerBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHttpHandlerBeanDefinitionParser.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHttpHandlerBeanDefinitionParser.java
deleted file mode 100644
index 6414fc5..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHttpHandlerBeanDefinitionParser.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Element;
-
-public class OlingoHttpHandlerBeanDefinitionParser extends AbstractBeanDefinitionParser {
-
- @Override
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- BeanDefinition configuration = OlingoHandlerBeanDefinitionHelper.parseHttpHandler(element, parserContext);
- return (AbstractBeanDefinition) configuration;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoNamespaceHandler.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoNamespaceHandler.java
deleted file mode 100644
index 2dc64fa..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoNamespaceHandler.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
-/**
- * Dedicated Spring namespace handler for Olingo. This namespace is directly
- * usable within a Spring application context.
- *
- * This namespace can be configured in Spring XML configuration files using
- * standard mechanisms of XML namespace, as following:
- *
- * <beans xmlns="http://www.springframework.org/schema/beans"
- * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- * xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo"
- * xsi:schemaLocation="http://www.springframework.org/schema/beans
- * http://www.springframework.org/schema/beans/spring-beans.xsd
- * http://olingo.apache.org/schema/olingo/spring-olingo
- * http://olingo.apache.org/schema/olingo/spring-olingo.xsd">
- * (...)
- * </beans>
- *
- * @author Thierry Templier
- */
-public class OlingoNamespaceHandler extends NamespaceHandlerSupport {
-
- public static final String EDM_PROVIDER_ELEMENT = "edm-provider";
-
- public static final String HTTP_HANDLER_ELEMENT = "http-handler";
-
- /**
- * Registers bean definition parsers for the olingo namespace.
- *
- * @see OlingoEdmProviderBeanDefinitionParser
- * @see OlingoHttpHandlerBeanDefinitionParser
- */
- public void init() {
- registerBeanDefinitionParser(EDM_PROVIDER_ELEMENT,
- new OlingoEdmProviderBeanDefinitionParser());
- registerBeanDefinitionParser(HTTP_HANDLER_ELEMENT,
- new OlingoHttpHandlerBeanDefinitionParser());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameConverter.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameConverter.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameConverter.java
deleted file mode 100644
index b1cdb7e..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameConverter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.editor;
-
-
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.springframework.core.convert.converter.Converter;
-
-public class FullQualifiedNameConverter implements Converter<FullQualifiedName, String>{
- @Override
- public String convert(FullQualifiedName fullQualifiedName) {
- return fullQualifiedName.getFullQualifiedNameAsString();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameEditor.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameEditor.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameEditor.java
deleted file mode 100644
index 71bf208..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/FullQualifiedNameEditor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.editor;
-
-import java.beans.PropertyEditorSupport;
-
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-
-public class FullQualifiedNameEditor extends PropertyEditorSupport {
- public void setAsText(String text) {
- String[] tokens = text.split("\\.");
- if (tokens.length == 2) {
- setValue(new FullQualifiedName(tokens[0], tokens[1]));
- } else {
- setValue(new FullQualifiedName(text));
- }
- }
-
- @Override
- public String getAsText() {
- return super.getAsText();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/ToFullQualifiedNameConverter.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/ToFullQualifiedNameConverter.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/ToFullQualifiedNameConverter.java
deleted file mode 100644
index bf2482a..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/editor/ToFullQualifiedNameConverter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.editor;
-
-
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.springframework.core.convert.converter.Converter;
-
-public class ToFullQualifiedNameConverter implements Converter<String, FullQualifiedName> {
- @Override
- public FullQualifiedName convert(String s) {
- return new FullQualifiedName(s);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/edm/GenericEdmProvider.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/edm/GenericEdmProvider.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/edm/GenericEdmProvider.java
deleted file mode 100644
index f8574da..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/edm/GenericEdmProvider.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.edm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
-import org.apache.olingo.commons.api.edm.provider.CsdlAction;
-import org.apache.olingo.commons.api.edm.provider.CsdlActionImport;
-import org.apache.olingo.commons.api.edm.provider.CsdlAliasInfo;
-import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
-import org.apache.olingo.commons.api.edm.provider.CsdlEnumType;
-import org.apache.olingo.commons.api.edm.provider.CsdlFunction;
-import org.apache.olingo.commons.api.edm.provider.CsdlFunctionImport;
-import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
-import org.apache.olingo.commons.api.edm.provider.CsdlSingleton;
-import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
-import org.apache.olingo.commons.api.edm.provider.CsdlTypeDefinition;
-
-public class GenericEdmProvider extends CsdlAbstractEdmProvider {
-
- private String containerName = "default";
-
- private List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
-
- // OData
-
- @Override
- public List<CsdlSchema> getSchemas() throws ODataException {
- return schemas;
- }
-
- @Override
- public CsdlEntityContainer getEntityContainer() throws ODataException {
- CsdlEntityContainer container = new CsdlEntityContainer();
- container.setName(containerName);
-
- // EntitySets
- List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
- container.setEntitySets(entitySets);
-
- // Load entity sets per index
- for (CsdlSchema schema : schemas) {
-
- if (schema.getEntityContainer() != null
- && schema.getEntityContainer().getEntitySets() != null) {
- for (CsdlEntitySet schemaEntitySet : schema.getEntityContainer()
- .getEntitySets()) {
- CsdlEntitySet entitySet = new CsdlEntitySet().setName(
- schemaEntitySet.getName()).setType(
- new FullQualifiedName(
- schemaEntitySet.getTypeFQN().getNamespace(),
- schemaEntitySet.getTypeFQN().getName()));
- entitySets.add(entitySet);
- }
- }
- }
-
- return container;
- }
-
- private CsdlSchema findSchema(String namespace) {
- for (CsdlSchema schema : schemas) {
- if (schema.getNamespace().equals(namespace)) {
- return schema;
- }
- }
-
- return null;
- }
-
- private CsdlEntityType findEntityType(CsdlSchema schema, String entityTypeName) {
- for (CsdlEntityType entityType : schema.getEntityTypes()) {
- if (entityType.getName().equals(entityTypeName)) {
- return entityType;
- }
- }
-
- return null;
- }
-
- @Override
- public CsdlEntityType getEntityType(FullQualifiedName entityTypeName)
- throws ODataException {
- CsdlSchema schema = findSchema(entityTypeName.getNamespace());
- return findEntityType(schema, entityTypeName.getName());
- }
-
- private CsdlEnumType findEnumType(CsdlSchema schema, String enumTypeName) {
- for (CsdlEnumType enumType : schema.getEnumTypes()) {
- if (enumType.getName().equals(enumTypeName)) {
- return enumType;
- }
- }
-
- return null;
- }
-
- @Override
- public CsdlEnumType getEnumType(FullQualifiedName enumTypeName)
- throws ODataException {
- CsdlSchema schema = findSchema(enumTypeName.getNamespace());
- return findEnumType(schema, enumTypeName.getName());
- }
-
- @Override
- public CsdlTypeDefinition getTypeDefinition(FullQualifiedName typeDefinitionName)
- throws ODataException {
- System.out.println(">> getTypeDefinition");
- // TODO Auto-generated method stub
- return super.getTypeDefinition(typeDefinitionName);
- }
-
- private CsdlComplexType findComplexType(CsdlSchema schema, String complexTypeName) {
- for (CsdlComplexType complexType : schema.getComplexTypes()) {
- if (complexType.getName().equals(complexTypeName)) {
- return complexType;
- }
- }
-
- return null;
- }
-
- @Override
- public CsdlComplexType getComplexType(FullQualifiedName complexTypeName)
- throws ODataException {
- CsdlSchema schema = findSchema(complexTypeName.getNamespace());
- return findComplexType(schema, complexTypeName.getName());
- }
-
- @Override
- public List<CsdlAction> getActions(FullQualifiedName actionName)
- throws ODataException {
- System.out.println(">> getActions");
- // TODO Auto-generated method stub
- return super.getActions(actionName);
- }
-
- @Override
- public List<CsdlFunction> getFunctions(FullQualifiedName functionName)
- throws ODataException {
- System.out.println(">> getFunctions");
- // TODO Auto-generated method stub
- return super.getFunctions(functionName);
- }
-
- @Override
- public CsdlTerm getTerm(FullQualifiedName termName) throws ODataException {
- System.out.println(">> getTerm");
- // TODO Auto-generated method stub
- return super.getTerm(termName);
- }
-
- private CsdlEntitySet findEntitySetInSchemas(String entitySetName)
- throws ODataException {
- List<CsdlSchema> schemas = getSchemas();
- for (CsdlSchema schema : schemas) {
- CsdlEntityContainer entityContainer = schema.getEntityContainer();
- List<CsdlEntitySet> entitySets = entityContainer.getEntitySets();
- for (CsdlEntitySet entitySet : entitySets) {
- if (entitySet.getName().equals(entitySetName)) {
- return entitySet;
- }
- }
- }
- return null;
- }
-
- @Override
- public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer,
- String entitySetName) throws ODataException {
- return findEntitySetInSchemas(entitySetName);
- }
-
- @Override
- public CsdlSingleton getSingleton(FullQualifiedName entityContainer,
- String singletonName) throws ODataException {
- System.out.println(">> getSingleton");
- // TODO Auto-generated method stub
- return super.getSingleton(entityContainer, singletonName);
- }
-
- @Override
- public CsdlActionImport getActionImport(FullQualifiedName entityContainer,
- String actionImportName) throws ODataException {
- System.out.println(">> getActionImport");
- // TODO Auto-generated method stub
- return super.getActionImport(entityContainer, actionImportName);
- }
-
- @Override
- public CsdlFunctionImport getFunctionImport(FullQualifiedName entityContainer,
- String functionImportName) throws ODataException {
- System.out.println(">> getFunctionImport");
- // TODO Auto-generated method stub
- return super.getFunctionImport(entityContainer, functionImportName);
- }
-
- @Override
- public CsdlEntityContainerInfo getEntityContainerInfo(
- FullQualifiedName entityContainerName) throws ODataException {
- CsdlEntityContainer container = getEntityContainer();
- FullQualifiedName fqName = new FullQualifiedName(container.getName(),
- container.getName());
- CsdlEntityContainerInfo info = new CsdlEntityContainerInfo();
- info.setContainerName(fqName);
- return info;
- }
-
- @Override
- public List<CsdlAliasInfo> getAliasInfos() throws ODataException {
- System.out.println(">> getAliasInfos");
- // TODO Auto-generated method stub
- return super.getAliasInfos();
- }
-
- // DI
-
- public void setSchemas(List<CsdlSchema> schemas) {
- this.schemas = schemas;
- }
-
- public String getContainerName() {
- return containerName;
- }
-
- public void setContainerName(String containerName) {
- this.containerName = containerName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/EdmxReferenceFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/EdmxReferenceFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/EdmxReferenceFactoryBean.java
deleted file mode 100644
index 49684e4..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/EdmxReferenceFactoryBean.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.factory;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-
-public class EdmxReferenceFactoryBean implements FactoryBean<EdmxReference>,
- InitializingBean {
- private String uri;
- private Map<String, String> includes;
-
- @Override
- public void afterPropertiesSet() throws Exception {
- if (uri == null) {
- throw new IllegalArgumentException("The property uri is required.");
- }
- }
-
- @Override
- public EdmxReference getObject() throws Exception {
- EdmxReference reference = new EdmxReference(URI.create(uri));
- if (includes != null) {
- for (Entry<String, String> include : includes.entrySet()) {
- reference.addInclude(new EdmxReferenceInclude(include.getKey(),
- include.getValue()));
- }
- }
- return reference;
- }
-
- @Override
- public Class<?> getObjectType() {
- return EdmxReference.class;
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
-
- public String getUri() {
- return uri;
- }
-
- public void setUri(String uri) {
- this.uri = uri;
- }
-
- public Map<String, String> getIncludes() {
- return includes;
- }
-
- public void setIncludes(Map<String, String> includes) {
- this.includes = includes;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataFactoryBean.java
deleted file mode 100644
index a310c7f..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataFactoryBean.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.factory;
-
-import org.apache.olingo.server.api.OData;
-import org.springframework.beans.factory.FactoryBean;
-
-public class ODataFactoryBean implements FactoryBean<OData> {
-
- @Override
- public OData getObject() throws Exception {
- return OData.newInstance();
- }
-
- @Override
- public Class<?> getObjectType() {
- return OData.class;
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataHttpHandlerFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataHttpHandlerFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataHttpHandlerFactoryBean.java
deleted file mode 100644
index 5456957..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ODataHttpHandlerFactoryBean.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.factory;
-
-import java.util.List;
-
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataHttpHandler;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.processor.Processor;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-
-public class ODataHttpHandlerFactoryBean implements
- FactoryBean<ODataHttpHandler>, InitializingBean {
- private OData odata;
- private ServiceMetadata serviceMetadata;
- private List<Processor> processors;
-
- @Override
- public ODataHttpHandler getObject() throws Exception {
- ODataHttpHandler handler = odata.createHandler(serviceMetadata);
- if (processors != null) {
- for (Processor processor : processors) {
- handler.register(processor);
- }
- }
- return handler;
- }
-
- @Override
- public Class<?> getObjectType() {
- return ODataHttpHandler.class;
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
-
- @Override
- public void afterPropertiesSet() throws Exception {
- if (odata == null) {
- throw new IllegalArgumentException(
- "The property odata is required.");
- }
-
- if (serviceMetadata == null) {
- throw new IllegalArgumentException(
- "The property serviceMetadata is required.");
- }
- }
-
- public OData getOdata() {
- return odata;
- }
-
- public void setOdata(OData odata) {
- this.odata = odata;
- }
-
- public ServiceMetadata getServiceMetadata() {
- return serviceMetadata;
- }
-
- public void setServiceMetadata(ServiceMetadata serviceMetadata) {
- this.serviceMetadata = serviceMetadata;
- }
-
- public List<Processor> getProcessors() {
- return processors;
- }
-
- public void setProcessors(List<Processor> processors) {
- this.processors = processors;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ServiceMetadataFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ServiceMetadataFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ServiceMetadataFactoryBean.java
deleted file mode 100644
index 0e5b754..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/factory/ServiceMetadataFactoryBean.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.factory;
-
-import java.util.List;
-
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-
-public class ServiceMetadataFactoryBean implements
- FactoryBean<ServiceMetadata>, InitializingBean {
- private OData odata;
- private CsdlEdmProvider edmProvider;
- private List<EdmxReference> references;
-
- @Override
- public void afterPropertiesSet() throws Exception {
- if (odata == null) {
- throw new IllegalArgumentException(
- "The property odata is required.");
- }
-
- if (edmProvider == null) {
- throw new IllegalArgumentException(
- "The property edmProvider is required.");
- }
-
- if (references == null) {
- throw new IllegalArgumentException(
- "The property references is required.");
- }
- }
-
- @Override
- public ServiceMetadata getObject() throws Exception {
- return odata.createServiceMetadata(edmProvider, references);
- }
-
- @Override
- public Class<?> getObjectType() {
- return ServiceMetadata.class;
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
-
- public OData getOdata() {
- return odata;
- }
-
- public void setOdata(OData odata) {
- this.odata = odata;
- }
-
- public CsdlEdmProvider getEdmProvider() {
- return edmProvider;
- }
-
- public void setEdmProvider(CsdlEdmProvider edmProvider) {
- this.edmProvider = edmProvider;
- }
-
- public List<EdmxReference> getReferences() {
- return references;
- }
-
- public void setReferences(List<EdmxReference> references) {
- this.references = references;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/resources/META-INF/spring.handlers b/ext/spring/src/main/resources/META-INF/spring.handlers
index 13d1260..5c583c5 100644
--- a/ext/spring/src/main/resources/META-INF/spring.handlers
+++ b/ext/spring/src/main/resources/META-INF/spring.handlers
@@ -1 +1 @@
-http\://olingo.apache.org/schema/olingo/spring-olingo=org.apache.olingo.ext.spring.config.OlingoNamespaceHandler
\ No newline at end of file
+http\://olingo.apache.org/schema/olingo4=org.apache.olingo.ext.config.spring.OlingoNamespaceHandler
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/resources/META-INF/spring.schemas
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/resources/META-INF/spring.schemas b/ext/spring/src/main/resources/META-INF/spring.schemas
index 1eb42b2..166f5e5 100644
--- a/ext/spring/src/main/resources/META-INF/spring.schemas
+++ b/ext/spring/src/main/resources/META-INF/spring.schemas
@@ -1 +1 @@
-http\://olingo.apache.org/schema/olingo/spring-olingo.xsd=org/apache/olingo/ext/spring/config/spring-olingo.xsd
\ No newline at end of file
+http\://olingo.apache.org/schema/configuration/olingo4.xsd=schemas/configuration/olingo4.xsd
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd b/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd
deleted file mode 100644
index bff82f0..0000000
--- a/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd
+++ /dev/null
@@ -1,118 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
-
- 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.
-
--->
-<xsd:schema xmlns="http://olingo.apache.org/schema/olingo/spring-olingo"
- xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://olingo.apache.org/schema/olingo/spring-olingo"
- elementFormDefault="qualified" attributeFormDefault="unqualified">
-
- <xsd:import namespace="http://www.springframework.org/schema/beans"
- schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" />
-
- <!-- Edm provider -->
-
- <xsd:attributeGroup name="configurationAttributes">
- <xsd:attribute name="id" type="xsd:string" use="required" />
- </xsd:attributeGroup>
-
- <xsd:element name="edm-provider" type="edmProviderBeanType">
- </xsd:element>
-
- <xsd:complexType name="edmProviderBeanType">
- <xsd:sequence>
- <xsd:element name="schema" maxOccurs="unbounded" type="schemaBeanType"/>
- </xsd:sequence>
- <xsd:attribute name="id" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="schemaBeanType">
- <xsd:sequence>
- <xsd:element name="entityContainer" minOccurs="1" maxOccurs="1" type="entityContainerBeanType"/>
- <xsd:element name="entityType" minOccurs="0" maxOccurs="unbounded" type="entityTypeBeanType"/>
- <xsd:element name="complexType" minOccurs="0" maxOccurs="unbounded" type="complexTypeBeanType"/>
- </xsd:sequence>
- <xsd:attribute name="namespace" type="xsd:string" use="required"/>
- <xsd:attribute name="alias" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="entityContainerBeanType">
- <xsd:sequence>
- <xsd:element name="entitySet" minOccurs="0" maxOccurs="unbounded" type="entitySetBeanType"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="entitySetBeanType">
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="entityTypeBeanType">
- <xsd:sequence>
- <xsd:element name="key" minOccurs="1" maxOccurs="unbounded" type="entityTypeKeyBeanType"/>
- <xsd:element name="property" minOccurs="1" maxOccurs="unbounded" type="entityTypePropertyBeanType"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="entityTypeKeyBeanType">
- <xsd:attribute name="property-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="entityTypePropertyBeanType">
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="complexTypeBeanType">
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- Http handler -->
-
- <xsd:element name="http-handler" type="httpHandlerBeanType">
- </xsd:element>
-
- <xsd:complexType name="httpHandlerBeanType">
- <xsd:sequence>
- <xsd:element name="reference" minOccurs="1" maxOccurs="unbounded" type="referenceBeanType"/>
- <xsd:element name="processor" maxOccurs="unbounded" type="processorBeanType"/>
- </xsd:sequence>
- <xsd:attribute name="id" type="xsd:string" use="required"/>
- <xsd:attribute name="edm-provider" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="referenceBeanType">
- <xsd:sequence>
- <xsd:element name="include" maxOccurs="unbounded" type="referenceIncludeBeanType"/>
- </xsd:sequence>
- <xsd:attribute name="uri" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="referenceIncludeBeanType">
- <xsd:attribute name="key" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="processorBeanType">
- <xsd:attribute name="ref" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-</xsd:schema>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoEdmProviderWithoutNamespaceTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoEdmProviderWithoutNamespaceTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoEdmProviderWithoutNamespaceTest.java
new file mode 100644
index 0000000..8bc0092
--- /dev/null
+++ b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoEdmProviderWithoutNamespaceTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringOlingoEdmProviderWithoutNamespaceTest {
+ @Test
+ public void testLaunchSpring() {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
+ "/applicationContext-edm-provider-beans.xml");
+ try {
+ CsdlEdmProvider edmProvider = (CsdlEdmProvider) context
+ .getBean("edmProvider");
+ Assert.assertNotNull(edmProvider);
+ try {
+ CsdlEntityContainer entityContainer = edmProvider.getEntityContainer();
+ Assert.assertNotNull(entityContainer);
+ Assert.assertNotNull(entityContainer.getEntitySets());
+ Assert.assertEquals(1, entityContainer.getEntitySets().size());
+
+ List<CsdlSchema> schemas = edmProvider.getSchemas();
+ Assert.assertNotNull(schemas);
+ Assert.assertEquals(1, schemas.size());
+
+ CsdlSchema schema = schemas.get(0);
+ Assert.assertEquals("test", schema.getNamespace());
+
+ List<CsdlEntityType> entityTypes = schema.getEntityTypes();
+ Assert.assertNotNull(entityTypes);
+ Assert.assertEquals(1, entityTypes.size());
+
+ CsdlEntityType entityType = entityTypes.get(0);
+ Assert.assertEquals("sources1", entityType.getName());
+
+
+ List<CsdlProperty> properties = entityType.getProperties();
+ Assert.assertNotNull(properties);
+ Assert.assertEquals(1, properties.size());
+ CsdlProperty property0 = properties.get(0);
+ Assert.assertEquals("field1", property0.getName());
+ Assert.assertEquals("Edm.String", property0.getType().toString());
+
+ List<CsdlPropertyRef> key = entityType.getKey();
+ Assert.assertNotNull(key);
+ Assert.assertEquals(1, key.size());
+ CsdlPropertyRef key0 = key.get(0);
+ Assert.assertEquals("field1", key0.getName());
+ } catch (ODataException ex) {
+ ex.printStackTrace();
+ }
+ } finally {
+ if (context != null) {
+ context.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoHttpHandlerWithoutNamespaceTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoHttpHandlerWithoutNamespaceTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoHttpHandlerWithoutNamespaceTest.java
new file mode 100644
index 0000000..af041b2
--- /dev/null
+++ b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoHttpHandlerWithoutNamespaceTest.java
@@ -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.olingo.ext.config.spring;
+
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringOlingoHttpHandlerWithoutNamespaceTest {
+ @Test
+ public void testLaunchSpring() {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
+ "/applicationContext-http-handler-beans.xml");
+ try {
+ ODataHttpHandler httpHandler = (ODataHttpHandler) context
+ .getBean("httpHandler");
+ Assert.assertNotNull(httpHandler);
+ } finally {
+ if (context != null) {
+ context.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceEdmProviderTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceEdmProviderTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceEdmProviderTest.java
new file mode 100644
index 0000000..05d18ac
--- /dev/null
+++ b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceEdmProviderTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringOlingoNamespaceEdmProviderTest {
+ @Test
+ public void testLaunchSpring() {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
+ "/applicationContext-edm-provider-namespace.xml");
+ try {
+ CsdlEdmProvider edmProvider = (CsdlEdmProvider) context
+ .getBean("edmProvider");
+ Assert.assertNotNull(edmProvider);
+ try {
+ CsdlEntityContainer entityContainer = edmProvider.getEntityContainer();
+ Assert.assertNotNull(entityContainer);
+ Assert.assertNotNull(entityContainer.getEntitySets());
+ Assert.assertEquals(1, entityContainer.getEntitySets().size());
+
+ List<CsdlSchema> schemas = edmProvider.getSchemas();
+ Assert.assertNotNull(schemas);
+ Assert.assertEquals(1, schemas.size());
+
+ CsdlSchema schema = schemas.get(0);
+ Assert.assertEquals("test", schema.getNamespace());
+
+ List<CsdlEntityType> entityTypes = schema.getEntityTypes();
+ Assert.assertNotNull(entityTypes);
+ Assert.assertEquals(1, entityTypes.size());
+
+ CsdlEntityType entityType = entityTypes.get(0);
+ Assert.assertEquals("sources1", entityType.getName());
+
+ List<CsdlProperty> properties = entityType.getProperties();
+ Assert.assertNotNull(properties);
+ Assert.assertEquals(6, properties.size());
+ // field #0
+ CsdlProperty property0 = properties.get(0);
+ Assert.assertEquals("field1", property0.getName());
+ Assert.assertEquals("Edm.String", property0.getType().toString());
+ // field #1
+ CsdlProperty property1 = properties.get(1);
+ Assert.assertEquals("field2", property1.getName());
+ Assert.assertEquals("Edm.Int32", property1.getType().toString());
+ // field #2
+ CsdlProperty property2 = properties.get(2);
+ Assert.assertEquals("field3", property2.getName());
+ Assert.assertEquals("Edm.Int64", property2.getType().toString());
+ // field #3
+ CsdlProperty property3 = properties.get(3);
+ Assert.assertEquals("field4", property3.getName());
+ Assert.assertEquals("Edm.Double", property3.getType().toString());
+ // field #4
+ CsdlProperty property4 = properties.get(4);
+ Assert.assertEquals("field5", property4.getName());
+ Assert.assertEquals("Edm.Double", property4.getType().toString());
+ // field #5
+ CsdlProperty property5 = properties.get(5);
+ Assert.assertEquals("field6", property5.getName());
+ Assert.assertEquals("Edm.Boolean", property5.getType().toString());
+
+ List<CsdlPropertyRef> key = entityType.getKey();
+ Assert.assertNotNull(key);
+ Assert.assertEquals(1, key.size());
+ CsdlPropertyRef key0 = key.get(0);
+ Assert.assertEquals("field1", key0.getName());
+ } catch (ODataException ex) {
+ ex.printStackTrace();
+ }
+ } finally {
+ if (context != null) {
+ context.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceHttpHandlerTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceHttpHandlerTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceHttpHandlerTest.java
new file mode 100644
index 0000000..0036c61
--- /dev/null
+++ b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/SpringOlingoNamespaceHttpHandlerTest.java
@@ -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.olingo.ext.config.spring;
+
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringOlingoNamespaceHttpHandlerTest {
+ @Test
+ public void testLaunchSpring() {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
+ "/applicationContext-http-handler-namespace.xml");
+ try {
+ ODataHttpHandler httpHandler = (ODataHttpHandler) context
+ .getBean("httpHandler");
+ Assert.assertNotNull(httpHandler);
+ } finally {
+ if (context != null) {
+ context.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/TestProcessor.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/TestProcessor.java b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/TestProcessor.java
new file mode 100644
index 0000000..5475341
--- /dev/null
+++ b/ext/spring/src/test/java/org/apache/olingo/ext/config/spring/TestProcessor.java
@@ -0,0 +1,33 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.processor.Processor;
+
+public class TestProcessor implements Processor {
+
+ @Override
+ public void init(OData arg0, ServiceMetadata arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java
deleted file mode 100644
index 36fe33b..0000000
--- a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
-import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
-import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class SpringOlingoEdmProviderWithoutNamespaceTest {
- @Test
- public void testLaunchSpring() {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
- "/applicationContext-edm-provider-beans.xml");
- try {
- CsdlEdmProvider edmProvider = (CsdlEdmProvider) context
- .getBean("edmProvider");
- Assert.assertNotNull(edmProvider);
- try {
- CsdlEntityContainer entityContainer = edmProvider.getEntityContainer();
- Assert.assertNotNull(entityContainer);
- Assert.assertNotNull(entityContainer.getEntitySets());
- Assert.assertEquals(1, entityContainer.getEntitySets().size());
-
- List<CsdlSchema> schemas = edmProvider.getSchemas();
- Assert.assertNotNull(schemas);
- Assert.assertEquals(1, schemas.size());
-
- CsdlSchema schema = schemas.get(0);
- Assert.assertEquals("test", schema.getNamespace());
-
- List<CsdlEntityType> entityTypes = schema.getEntityTypes();
- Assert.assertNotNull(entityTypes);
- Assert.assertEquals(1, entityTypes.size());
-
- CsdlEntityType entityType = entityTypes.get(0);
- Assert.assertEquals("sources1", entityType.getName());
-
-
- List<CsdlProperty> properties = entityType.getProperties();
- Assert.assertNotNull(properties);
- Assert.assertEquals(1, properties.size());
- CsdlProperty property0 = properties.get(0);
- Assert.assertEquals("field1", property0.getName());
- Assert.assertEquals("Edm.String", property0.getType().toString());
-
- List<CsdlPropertyRef> key = entityType.getKey();
- Assert.assertNotNull(key);
- Assert.assertEquals(1, key.size());
- CsdlPropertyRef key0 = key.get(0);
- Assert.assertEquals("field1", key0.getName());
- } catch (ODataException ex) {
- ex.printStackTrace();
- }
- } finally {
- if (context != null) {
- context.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java
deleted file mode 100644
index 5e402a6..0000000
--- a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import org.apache.olingo.server.api.ODataHttpHandler;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class SpringOlingoHttpHandlerWithoutNamespaceTest {
- @Test
- public void testLaunchSpring() {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
- "/applicationContext-http-handler-beans.xml");
- try {
- ODataHttpHandler httpHandler = (ODataHttpHandler) context
- .getBean("httpHandler");
- Assert.assertNotNull(httpHandler);
- } finally {
- if (context != null) {
- context.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java
deleted file mode 100644
index e1380e5..0000000
--- a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
-import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
-import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class SpringOlingoNamespaceEdmProviderTest {
- @Test
- public void testLaunchSpring() {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
- "/applicationContext-edm-provider-namespace.xml");
- try {
- CsdlEdmProvider edmProvider = (CsdlEdmProvider) context
- .getBean("edmProvider");
- Assert.assertNotNull(edmProvider);
- try {
- CsdlEntityContainer entityContainer = edmProvider.getEntityContainer();
- Assert.assertNotNull(entityContainer);
- Assert.assertNotNull(entityContainer.getEntitySets());
- Assert.assertEquals(1, entityContainer.getEntitySets().size());
-
- List<CsdlSchema> schemas = edmProvider.getSchemas();
- Assert.assertNotNull(schemas);
- Assert.assertEquals(1, schemas.size());
-
- CsdlSchema schema = schemas.get(0);
- Assert.assertEquals("test", schema.getNamespace());
-
- List<CsdlEntityType> entityTypes = schema.getEntityTypes();
- Assert.assertNotNull(entityTypes);
- Assert.assertEquals(1, entityTypes.size());
-
- CsdlEntityType entityType = entityTypes.get(0);
- Assert.assertEquals("sources1", entityType.getName());
-
- List<CsdlProperty> properties = entityType.getProperties();
- Assert.assertNotNull(properties);
- Assert.assertEquals(6, properties.size());
- // field #0
- CsdlProperty property0 = properties.get(0);
- Assert.assertEquals("field1", property0.getName());
- Assert.assertEquals("Edm.String", property0.getType().toString());
- // field #1
- CsdlProperty property1 = properties.get(1);
- Assert.assertEquals("field2", property1.getName());
- Assert.assertEquals("Edm.Int32", property1.getType().toString());
- // field #2
- CsdlProperty property2 = properties.get(2);
- Assert.assertEquals("field3", property2.getName());
- Assert.assertEquals("Edm.Int64", property2.getType().toString());
- // field #3
- CsdlProperty property3 = properties.get(3);
- Assert.assertEquals("field4", property3.getName());
- Assert.assertEquals("Edm.Double", property3.getType().toString());
- // field #4
- CsdlProperty property4 = properties.get(4);
- Assert.assertEquals("field5", property4.getName());
- Assert.assertEquals("Edm.Double", property4.getType().toString());
- // field #5
- CsdlProperty property5 = properties.get(5);
- Assert.assertEquals("field6", property5.getName());
- Assert.assertEquals("Edm.Boolean", property5.getType().toString());
-
- List<CsdlPropertyRef> key = entityType.getKey();
- Assert.assertNotNull(key);
- Assert.assertEquals(1, key.size());
- CsdlPropertyRef key0 = key.get(0);
- Assert.assertEquals("field1", key0.getName());
- } catch (ODataException ex) {
- ex.printStackTrace();
- }
- } finally {
- if (context != null) {
- context.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java
deleted file mode 100644
index 00d4b4d..0000000
--- a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import org.apache.olingo.server.api.ODataHttpHandler;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class SpringOlingoNamespaceHttpHandlerTest {
- @Test
- public void testLaunchSpring() {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
- "/applicationContext-http-handler-namespace.xml");
- try {
- ODataHttpHandler httpHandler = (ODataHttpHandler) context
- .getBean("httpHandler");
- Assert.assertNotNull(httpHandler);
- } finally {
- if (context != null) {
- context.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java
deleted file mode 100644
index b60c45e..0000000
--- a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.processor.Processor;
-
-public class TestProcessor implements Processor {
-
- @Override
- public void init(OData arg0, ServiceMetadata arg1) {
- // TODO Auto-generated method stub
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml b/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml
index 53e6323..8bd549d 100644
--- a/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml
+++ b/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml
@@ -20,18 +20,18 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:olingo="http://olingo.apache.org/schema/spring-olingo"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:olingo="http://olingo.apache.org/schema/olingo4"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://olingo.apache.org/schema/spring-olingo
- http://olingo.apache.org/schema/olingo/spring-olingo.xsd">
+ http://olingo.apache.org/schema/olingo4
+ http://olingo.apache.org/schema/configuration/olingo4.xsd">
<!--
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="org.apache.olingo.commons.api.edm.FullQualifiedName"
- value="org.apache.olingo.ext.spring.editor.FullQualifiedNameEditor" />
+ value="org.apache.olingo.ext.config.spring.editor.FullQualifiedNameEditor" />
</map>
</property>
</bean>
@@ -41,13 +41,13 @@
class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
- <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/>
- <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.FullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.ToFullQualifiedNameConverter"/>
</set>
</property>
</bean>
- <bean id="edmProvider" class="org.apache.olingo.ext.spring.edm.GenericEdmProvider">
+ <bean id="edmProvider" class="org.apache.olingo.ext.config.edm.GenericEdmProvider">
<property name="schemas">
<list>
<bean class="org.apache.olingo.commons.api.edm.provider.CsdlSchema">
@@ -96,4 +96,4 @@
</property>
</bean>
-</beans>
\ No newline at end of file
+</beans>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml b/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml
index d59fb0a..53b8bc4 100644
--- a/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml
+++ b/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml
@@ -21,18 +21,18 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo"
+ xmlns:olingo="http://olingo.apache.org/schema/olingo4"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://olingo.apache.org/schema/olingo/spring-olingo
- http://olingo.apache.org/schema/olingo/spring-olingo.xsd">
+ http://olingo.apache.org/schema/olingo4
+ http://olingo.apache.org/schema/configuration/olingo4.xsd">
<bean id="conversionService"
class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
- <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/>
- <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.FullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.ToFullQualifiedNameConverter"/>
</set>
</property>
</bean>
@@ -71,4 +71,4 @@
<!-- getEntityContainer -->
</olingo:schema>
</olingo:edm-provider>
-</beans>
\ No newline at end of file
+</beans>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml b/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml
index 37c14d7..b00105f 100644
--- a/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml
+++ b/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml
@@ -20,34 +20,34 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:olingo="http://olingo.apache.org/schema/spring-olingo"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:olingo="http://olingo.apache.org/schema/olingo4"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://olingo.apache.org/schema/spring-olingo
- http://olingo.apache.org/schema/olingo/spring-olingo.xsd">
+ http://olingo.apache.org/schema/olingo4
+ http://olingo.apache.org/schema/configuration/olingo4.xsd">
<bean id="conversionService"
class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
- <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/>
- <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.FullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.ToFullQualifiedNameConverter"/>
</set>
</property>
</bean>
- <bean id="odata" class="org.apache.olingo.ext.spring.factory.ODataFactoryBean" />
+ <bean id="odata" class="org.apache.olingo.ext.config.spring.factory.ODataFactoryBean" />
<bean id="httpHandler"
- class="org.apache.olingo.ext.spring.factory.ODataHttpHandlerFactoryBean">
+ class="org.apache.olingo.ext.config.spring.factory.ODataHttpHandlerFactoryBean">
<property name="odata" ref="odata" />
<property name="serviceMetadata">
- <bean class="org.apache.olingo.ext.spring.factory.ServiceMetadataFactoryBean">
+ <bean class="org.apache.olingo.ext.config.spring.factory.ServiceMetadataFactoryBean">
<property name="odata" ref="odata" />
<property name="edmProvider" ref="edmProvider" />
<property name="references">
<list>
- <bean class="org.apache.olingo.ext.spring.factory.EdmxReferenceFactoryBean">
+ <bean class="org.apache.olingo.ext.config.spring.factory.EdmxReferenceFactoryBean">
<property name="uri"
value="../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml" />
<property name="includes">
@@ -67,8 +67,8 @@
</property>
</bean>
- <bean id="edmProvider" class="org.apache.olingo.ext.spring.edm.GenericEdmProvider" />
+ <bean id="edmProvider" class="org.apache.olingo.ext.config.edm.GenericEdmProvider" />
- <bean id="testProcessor" class="org.apache.olingo.ext.spring.config.TestProcessor" />
+ <bean id="testProcessor" class="org.apache.olingo.ext.config.spring.TestProcessor" />
-</beans>
\ No newline at end of file
+</beans>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml b/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml
index e40b29d..d689005 100644
--- a/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml
+++ b/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml
@@ -21,11 +21,11 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo"
+ xmlns:olingo="http://olingo.apache.org/schema/olingo4"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://olingo.apache.org/schema/olingo/spring-olingo
- http://olingo.apache.org/schema/olingo/spring-olingo.xsd">
+ http://olingo.apache.org/schema/olingo4
+ http://olingo.apache.org/schema/configuration/olingo4.xsd">
<olingo:http-handler id="httpHandler" edm-provider="edmProvider">
<olingo:reference uri="../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml">
@@ -38,13 +38,13 @@
class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
- <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/>
- <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.FullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.ToFullQualifiedNameConverter"/>
</set>
</property>
</bean>
- <bean id="edmProvider" class="org.apache.olingo.ext.spring.edm.GenericEdmProvider" />
+ <bean id="edmProvider" class="org.apache.olingo.ext.config.edm.GenericEdmProvider" />
- <bean id="testProcessor" class="org.apache.olingo.ext.spring.config.TestProcessor" />
-</beans>
\ No newline at end of file
+ <bean id="testProcessor" class="org.apache.olingo.ext.config.spring.TestProcessor" />
+</beans>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/test/resources/applicationContext-namespace.xml
----------------------------------------------------------------------
diff --git a/ext/spring/src/test/resources/applicationContext-namespace.xml b/ext/spring/src/test/resources/applicationContext-namespace.xml
index 4e0c384..30b2cfd 100644
--- a/ext/spring/src/test/resources/applicationContext-namespace.xml
+++ b/ext/spring/src/test/resources/applicationContext-namespace.xml
@@ -21,11 +21,11 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo"
+ xmlns:olingo="http://olingo.apache.org/schema/olingo4"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://olingo.apache.org/schema/olingo/spring-olingo
- http://olingo.apache.org/schema/olingo/spring-olingo.xsd">
+ http://olingo.apache.org/schema/olingo4
+ http://olingo.apache.org/schema/configuration/olingo4.xsd">
<olingo:http-handler id="httpHandler" edm-provider="edmProvider">
<olingo:reference uri="../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml">
@@ -54,15 +54,15 @@
</olingo:schema>
</olingo:edm-provider>
- <bean id="testProcessor" class="org.apache.olingo.ext.spring.config.TestProcessor" />
+ <bean id="testProcessor" class="org.apache.olingo.ext.config.spring.TestProcessor" />
<bean id="conversionService"
class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
- <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/>
- <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.FullQualifiedNameConverter"/>
+ <bean class="org.apache.olingo.ext.config.spring.editor.ToFullQualifiedNameConverter"/>
</set>
</property>
</bean>
-</beans>
\ No newline at end of file
+</beans>
[2/2] olingo-odata4 git commit: [OLINGO-562] split the code between
the generic part and the spring specific part
Posted by mi...@apache.org.
[OLINGO-562] split the code between the generic part and the spring specific part
Signed-off-by: Michael Bolz <mi...@sap.com>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/bb1dbba3
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/bb1dbba3
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/bb1dbba3
Branch: refs/heads/OLINGO-562_SpringExtension
Commit: bb1dbba35fa94726456526e4fe1cd43f1d040357
Parents: ec82a5d
Author: Aki Yoshida <el...@gmail.com>
Authored: Wed Jun 24 16:47:09 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Sep 8 10:41:50 2015 +0200
----------------------------------------------------------------------
ext/config/pom.xml | 80 ++++++
.../config/editor/FullQualifiedNameEditor.java | 39 +++
.../ext/config/edm/GenericEdmProvider.java | 254 ++++++++++++++++++
.../resources/schemas/configuration/olingo4.xsd | 115 ++++++++
ext/pom.xml | 1 +
ext/spring/pom.xml | 8 +-
.../spring/OlingoEdmBeanDefinitionHelper.java | 266 +++++++++++++++++++
.../OlingoEdmProviderBeanDefinitionParser.java | 36 +++
.../OlingoHandlerBeanDefinitionHelper.java | 159 +++++++++++
.../OlingoHttpHandlerBeanDefinitionParser.java | 34 +++
.../config/spring/OlingoNamespaceHandler.java | 61 +++++
.../editor/FullQualifiedNameConverter.java | 30 +++
.../editor/ToFullQualifiedNameConverter.java | 30 +++
.../factory/EdmxReferenceFactoryBean.java | 80 ++++++
.../config/spring/factory/ODataFactoryBean.java | 41 +++
.../factory/ODataHttpHandlerFactoryBean.java | 94 +++++++
.../factory/ServiceMetadataFactoryBean.java | 92 +++++++
.../config/OlingoEdmBeanDefinitionHelper.java | 266 -------------------
.../OlingoEdmProviderBeanDefinitionParser.java | 36 ---
.../OlingoHandlerBeanDefinitionHelper.java | 159 -----------
.../OlingoHttpHandlerBeanDefinitionParser.java | 34 ---
.../spring/config/OlingoNamespaceHandler.java | 61 -----
.../editor/FullQualifiedNameConverter.java | 30 ---
.../spring/editor/FullQualifiedNameEditor.java | 39 ---
.../editor/ToFullQualifiedNameConverter.java | 30 ---
.../ext/spring/edm/GenericEdmProvider.java | 254 ------------------
.../factory/EdmxReferenceFactoryBean.java | 80 ------
.../ext/spring/factory/ODataFactoryBean.java | 41 ---
.../factory/ODataHttpHandlerFactoryBean.java | 94 -------
.../factory/ServiceMetadataFactoryBean.java | 92 -------
.../src/main/resources/META-INF/spring.handlers | 2 +-
.../src/main/resources/META-INF/spring.schemas | 2 +-
.../olingo/ext/spring/config/spring-olingo.xsd | 118 --------
...ngOlingoEdmProviderWithoutNamespaceTest.java | 85 ++++++
...ngOlingoHttpHandlerWithoutNamespaceTest.java | 41 +++
.../SpringOlingoNamespaceEdmProviderTest.java | 105 ++++++++
.../SpringOlingoNamespaceHttpHandlerTest.java | 41 +++
.../olingo/ext/config/spring/TestProcessor.java | 33 +++
...ngOlingoEdmProviderWithoutNamespaceTest.java | 85 ------
...ngOlingoHttpHandlerWithoutNamespaceTest.java | 41 ---
.../SpringOlingoNamespaceEdmProviderTest.java | 105 --------
.../SpringOlingoNamespaceHttpHandlerTest.java | 41 ---
.../olingo/ext/spring/config/TestProcessor.java | 33 ---
.../applicationContext-edm-provider-beans.xml | 16 +-
...pplicationContext-edm-provider-namespace.xml | 12 +-
.../applicationContext-http-handler-beans.xml | 24 +-
...pplicationContext-http-handler-namespace.xml | 16 +-
.../resources/applicationContext-namespace.xml | 14 +-
48 files changed, 1767 insertions(+), 1683 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/config/pom.xml
----------------------------------------------------------------------
diff --git a/ext/config/pom.xml b/ext/config/pom.xml
new file mode 100644
index 0000000..1ac690a
--- /dev/null
+++ b/ext/config/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>odata-config</artifactId>
+ <name>${project.artifactId}</name>
+ <packaging>jar</packaging>
+
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-ext</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-server-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-server-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-commons-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-commons-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-client-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-client-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${sl4j.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/config/src/main/java/org/apache/olingo/ext/config/editor/FullQualifiedNameEditor.java
----------------------------------------------------------------------
diff --git a/ext/config/src/main/java/org/apache/olingo/ext/config/editor/FullQualifiedNameEditor.java b/ext/config/src/main/java/org/apache/olingo/ext/config/editor/FullQualifiedNameEditor.java
new file mode 100644
index 0000000..861096e
--- /dev/null
+++ b/ext/config/src/main/java/org/apache/olingo/ext/config/editor/FullQualifiedNameEditor.java
@@ -0,0 +1,39 @@
+/*
+ * 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.olingo.ext.config.editor;
+
+import java.beans.PropertyEditorSupport;
+
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+
+public class FullQualifiedNameEditor extends PropertyEditorSupport {
+ public void setAsText(String text) {
+ String[] tokens = text.split("\\.");
+ if (tokens.length == 2) {
+ setValue(new FullQualifiedName(tokens[0], tokens[1]));
+ } else {
+ setValue(new FullQualifiedName(text));
+ }
+ }
+
+ @Override
+ public String getAsText() {
+ return super.getAsText();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/config/src/main/java/org/apache/olingo/ext/config/edm/GenericEdmProvider.java
----------------------------------------------------------------------
diff --git a/ext/config/src/main/java/org/apache/olingo/ext/config/edm/GenericEdmProvider.java b/ext/config/src/main/java/org/apache/olingo/ext/config/edm/GenericEdmProvider.java
new file mode 100644
index 0000000..a606680
--- /dev/null
+++ b/ext/config/src/main/java/org/apache/olingo/ext/config/edm/GenericEdmProvider.java
@@ -0,0 +1,254 @@
+/*
+ * 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.olingo.ext.config.edm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlAction;
+import org.apache.olingo.commons.api.edm.provider.CsdlActionImport;
+import org.apache.olingo.commons.api.edm.provider.CsdlAliasInfo;
+import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlEnumType;
+import org.apache.olingo.commons.api.edm.provider.CsdlFunction;
+import org.apache.olingo.commons.api.edm.provider.CsdlFunctionImport;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+import org.apache.olingo.commons.api.edm.provider.CsdlSingleton;
+import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
+import org.apache.olingo.commons.api.edm.provider.CsdlTypeDefinition;
+
+public class GenericEdmProvider extends CsdlAbstractEdmProvider {
+
+ private String containerName = "default";
+
+ private List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
+
+ // OData
+
+ @Override
+ public List<CsdlSchema> getSchemas() throws ODataException {
+ return schemas;
+ }
+
+ @Override
+ public CsdlEntityContainer getEntityContainer() throws ODataException {
+ CsdlEntityContainer container = new CsdlEntityContainer();
+ container.setName(containerName);
+
+ // EntitySets
+ List<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
+ container.setEntitySets(entitySets);
+
+ // Load entity sets per index
+ for (CsdlSchema schema : schemas) {
+
+ if (schema.getEntityContainer() != null
+ && schema.getEntityContainer().getEntitySets() != null) {
+ for (CsdlEntitySet schemaEntitySet : schema.getEntityContainer()
+ .getEntitySets()) {
+ CsdlEntitySet entitySet = new CsdlEntitySet().setName(
+ schemaEntitySet.getName()).setType(
+ new FullQualifiedName(
+ schemaEntitySet.getTypeFQN().getNamespace(),
+ schemaEntitySet.getTypeFQN().getName()));
+ entitySets.add(entitySet);
+ }
+ }
+ }
+
+ return container;
+ }
+
+ private CsdlSchema findSchema(String namespace) {
+ for (CsdlSchema schema : schemas) {
+ if (schema.getNamespace().equals(namespace)) {
+ return schema;
+ }
+ }
+
+ return null;
+ }
+
+ private CsdlEntityType findEntityType(CsdlSchema schema, String entityTypeName) {
+ for (CsdlEntityType entityType : schema.getEntityTypes()) {
+ if (entityType.getName().equals(entityTypeName)) {
+ return entityType;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public CsdlEntityType getEntityType(FullQualifiedName entityTypeName)
+ throws ODataException {
+ CsdlSchema schema = findSchema(entityTypeName.getNamespace());
+ return findEntityType(schema, entityTypeName.getName());
+ }
+
+ private CsdlEnumType findEnumType(CsdlSchema schema, String enumTypeName) {
+ for (CsdlEnumType enumType : schema.getEnumTypes()) {
+ if (enumType.getName().equals(enumTypeName)) {
+ return enumType;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public CsdlEnumType getEnumType(FullQualifiedName enumTypeName)
+ throws ODataException {
+ CsdlSchema schema = findSchema(enumTypeName.getNamespace());
+ return findEnumType(schema, enumTypeName.getName());
+ }
+
+ @Override
+ public CsdlTypeDefinition getTypeDefinition(FullQualifiedName typeDefinitionName)
+ throws ODataException {
+ System.out.println(">> getTypeDefinition");
+ // TODO Auto-generated method stub
+ return super.getTypeDefinition(typeDefinitionName);
+ }
+
+ private CsdlComplexType findComplexType(CsdlSchema schema, String complexTypeName) {
+ for (CsdlComplexType complexType : schema.getComplexTypes()) {
+ if (complexType.getName().equals(complexTypeName)) {
+ return complexType;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public CsdlComplexType getComplexType(FullQualifiedName complexTypeName)
+ throws ODataException {
+ CsdlSchema schema = findSchema(complexTypeName.getNamespace());
+ return findComplexType(schema, complexTypeName.getName());
+ }
+
+ @Override
+ public List<CsdlAction> getActions(FullQualifiedName actionName)
+ throws ODataException {
+ System.out.println(">> getActions");
+ // TODO Auto-generated method stub
+ return super.getActions(actionName);
+ }
+
+ @Override
+ public List<CsdlFunction> getFunctions(FullQualifiedName functionName)
+ throws ODataException {
+ System.out.println(">> getFunctions");
+ // TODO Auto-generated method stub
+ return super.getFunctions(functionName);
+ }
+
+ @Override
+ public CsdlTerm getTerm(FullQualifiedName termName) throws ODataException {
+ System.out.println(">> getTerm");
+ // TODO Auto-generated method stub
+ return super.getTerm(termName);
+ }
+
+ private CsdlEntitySet findEntitySetInSchemas(String entitySetName)
+ throws ODataException {
+ List<CsdlSchema> schemas = getSchemas();
+ for (CsdlSchema schema : schemas) {
+ CsdlEntityContainer entityContainer = schema.getEntityContainer();
+ List<CsdlEntitySet> entitySets = entityContainer.getEntitySets();
+ for (CsdlEntitySet entitySet : entitySets) {
+ if (entitySet.getName().equals(entitySetName)) {
+ return entitySet;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer,
+ String entitySetName) throws ODataException {
+ return findEntitySetInSchemas(entitySetName);
+ }
+
+ @Override
+ public CsdlSingleton getSingleton(FullQualifiedName entityContainer,
+ String singletonName) throws ODataException {
+ System.out.println(">> getSingleton");
+ // TODO Auto-generated method stub
+ return super.getSingleton(entityContainer, singletonName);
+ }
+
+ @Override
+ public CsdlActionImport getActionImport(FullQualifiedName entityContainer,
+ String actionImportName) throws ODataException {
+ System.out.println(">> getActionImport");
+ // TODO Auto-generated method stub
+ return super.getActionImport(entityContainer, actionImportName);
+ }
+
+ @Override
+ public CsdlFunctionImport getFunctionImport(FullQualifiedName entityContainer,
+ String functionImportName) throws ODataException {
+ System.out.println(">> getFunctionImport");
+ // TODO Auto-generated method stub
+ return super.getFunctionImport(entityContainer, functionImportName);
+ }
+
+ @Override
+ public CsdlEntityContainerInfo getEntityContainerInfo(
+ FullQualifiedName entityContainerName) throws ODataException {
+ CsdlEntityContainer container = getEntityContainer();
+ FullQualifiedName fqName = new FullQualifiedName(container.getName(),
+ container.getName());
+ CsdlEntityContainerInfo info = new CsdlEntityContainerInfo();
+ info.setContainerName(fqName);
+ return info;
+ }
+
+ @Override
+ public List<CsdlAliasInfo> getAliasInfos() throws ODataException {
+ System.out.println(">> getAliasInfos");
+ // TODO Auto-generated method stub
+ return super.getAliasInfos();
+ }
+
+ // DI
+
+ public void setSchemas(List<CsdlSchema> schemas) {
+ this.schemas = schemas;
+ }
+
+ public String getContainerName() {
+ return containerName;
+ }
+
+ public void setContainerName(String containerName) {
+ this.containerName = containerName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/config/src/main/resources/schemas/configuration/olingo4.xsd
----------------------------------------------------------------------
diff --git a/ext/config/src/main/resources/schemas/configuration/olingo4.xsd b/ext/config/src/main/resources/schemas/configuration/olingo4.xsd
new file mode 100644
index 0000000..a85dd59
--- /dev/null
+++ b/ext/config/src/main/resources/schemas/configuration/olingo4.xsd
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+ 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.
+
+-->
+<xsd:schema xmlns="http://olingo.apache.org/schema/olingo4"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://olingo.apache.org/schema/olingo4"
+ elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+ <!-- Edm provider -->
+
+ <xsd:attributeGroup name="configurationAttributes">
+ <xsd:attribute name="id" type="xsd:string" use="required" />
+ </xsd:attributeGroup>
+
+ <xsd:element name="edm-provider" type="edmProviderBeanType">
+ </xsd:element>
+
+ <xsd:complexType name="edmProviderBeanType">
+ <xsd:sequence>
+ <xsd:element name="schema" maxOccurs="unbounded" type="schemaBeanType"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="schemaBeanType">
+ <xsd:sequence>
+ <xsd:element name="entityContainer" minOccurs="1" maxOccurs="1" type="entityContainerBeanType"/>
+ <xsd:element name="entityType" minOccurs="0" maxOccurs="unbounded" type="entityTypeBeanType"/>
+ <xsd:element name="complexType" minOccurs="0" maxOccurs="unbounded" type="complexTypeBeanType"/>
+ </xsd:sequence>
+ <xsd:attribute name="namespace" type="xsd:string" use="required"/>
+ <xsd:attribute name="alias" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="entityContainerBeanType">
+ <xsd:sequence>
+ <xsd:element name="entitySet" minOccurs="0" maxOccurs="unbounded" type="entitySetBeanType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="entitySetBeanType">
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="type" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="entityTypeBeanType">
+ <xsd:sequence>
+ <xsd:element name="key" minOccurs="1" maxOccurs="unbounded" type="entityTypeKeyBeanType"/>
+ <xsd:element name="property" minOccurs="1" maxOccurs="unbounded" type="entityTypePropertyBeanType"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="entityTypeKeyBeanType">
+ <xsd:attribute name="property-name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="entityTypePropertyBeanType">
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="type" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="complexTypeBeanType">
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <!-- Http handler -->
+
+ <xsd:element name="http-handler" type="httpHandlerBeanType">
+ </xsd:element>
+
+ <xsd:complexType name="httpHandlerBeanType">
+ <xsd:sequence>
+ <xsd:element name="reference" minOccurs="1" maxOccurs="unbounded" type="referenceBeanType"/>
+ <xsd:element name="processor" maxOccurs="unbounded" type="processorBeanType"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:string" use="required"/>
+ <xsd:attribute name="edm-provider" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="referenceBeanType">
+ <xsd:sequence>
+ <xsd:element name="include" maxOccurs="unbounded" type="referenceIncludeBeanType"/>
+ </xsd:sequence>
+ <xsd:attribute name="uri" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="referenceIncludeBeanType">
+ <xsd:attribute name="key" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="processorBeanType">
+ <xsd:attribute name="ref" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+</xsd:schema>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pom.xml b/ext/pom.xml
index f483789..41a7721 100644
--- a/ext/pom.xml
+++ b/ext/pom.xml
@@ -39,6 +39,7 @@
<module>pojogen-maven-plugin</module>
<module>client-proxy</module>
<module>client-android</module>
+ <module>config</module>
</modules>
<profiles>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/pom.xml
----------------------------------------------------------------------
diff --git a/ext/spring/pom.xml b/ext/spring/pom.xml
index b18e4b7..97d0e94 100644
--- a/ext/spring/pom.xml
+++ b/ext/spring/pom.xml
@@ -13,7 +13,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <artifactId>spring</artifactId>
+ <artifactId>odata-spring</artifactId>
<name>${project.artifactId}</name>
<packaging>jar</packaging>
@@ -77,6 +77,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>odata-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${sl4j.version}</version>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmBeanDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmBeanDefinitionHelper.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmBeanDefinitionHelper.java
new file mode 100644
index 0000000..083b012
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmBeanDefinitionHelper.java
@@ -0,0 +1,266 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+import org.apache.olingo.ext.config.edm.GenericEdmProvider;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+public abstract class OlingoEdmBeanDefinitionHelper {
+ private static final Class<?> EDM_PROVIDER_CLASS = GenericEdmProvider.class;
+ private static final Class<?> SCHEMA_CLASS = CsdlSchema.class;
+ private static final Class<?> ENTITY_CONTAINER_CLASS = CsdlEntityContainer.class;
+ private static final Class<?> ENTITY_SET_CLASS = CsdlEntitySet.class;
+ private static final Class<?> ENTITY_TYPE_CLASS = CsdlEntityType.class;
+ private static final Class<?> PROPERTY_REF_CLASS = CsdlPropertyRef.class;
+ private static final Class<?> PROPERTY_CLASS = CsdlProperty.class;
+ private static final Class<?> FULL_QUALIFIED_NAME_CLASS = FullQualifiedName.class;
+
+ private static final String SCHEMA_ELEMENT = "schema";
+ private static final String ENTITY_CONTAINER_ELEMENT = "entityContainer";
+ private static final String ENTITY_TYPE_ELEMENT = "entityType";
+ private static final String COMPLEX_TYPE_ELEMENT = "complexType";
+ private static final String ENTITY_SET_ELEMENT = "entitySet";
+ private static final String KEY_ELEMENT = "key";
+ private static final String PROPERTY_ELEMENT = "property";
+
+ private static final String NAME_ATTR = "name";
+ private static final String NAMESPACE_ATTR = "namespace";
+ private static final String TYPE_ATTR = "type";
+ private static final String PROPERTY_NAME_ATTR = "property-name";
+ private static final String ALIAS_ATTR = "alias";
+
+ private static final String SCHEMA_LIST_PROPERTY = "schemas";
+ private static final String ENTITY_TYPE_LIST_PROPERTY = "entityTypes";
+ private static final String COMPLEX_TYPE_LIST_PROPERTY = "complexTypes";
+ private static final String ENTITY_SET_LIST_PROPERTY = "entitySets";
+ private static final String ENTITY_CONTAINER_PROPERTY = "entityContainer";
+ private static final String NAME_PROPERTY = "name";
+ private static final String NAMESPACE_PROPERTY = "namespace";
+ private static final String ALIAS_PROPERTY = "alias";
+ private static final String TYPE_PROPERTY = "type";
+ private static final String KEY_LIST_PROPERTY = "key";
+ private static final String PROPERTY_LIST_PROPERTY = "properties";
+ private static final String PROPERTY_NAME_PROPERTY = "name";
+
+ private static String elementAttribute(Element element, String name) {
+ String value = element.getAttribute(name);
+ return value.length() == 0 ? null : value;
+ }
+
+ private static BeanDefinitionBuilder createBeanDefinitionBuilder(
+ Class<?> beanClass) {
+ return BeanDefinitionBuilder.rootBeanDefinition(beanClass);
+ }
+
+ public static BeanDefinition parseEdmProvider(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder configuration = createBeanDefinitionBuilder(EDM_PROVIDER_CLASS);
+
+ // Schemas
+ List<Element> schemaElements = DomUtils.getChildElementsByTagName(
+ element, SCHEMA_ELEMENT);
+ if (schemaElements.size() > 0) {
+ ManagedList<BeanDefinition> schemaList = new ManagedList<BeanDefinition>(
+ schemaElements.size());
+ for (Element schemaElement : schemaElements) {
+ BeanDefinition schema = parseSchema(schemaElement,
+ parserContext);
+ schemaList.add(schema);
+ }
+ configuration.addPropertyValue(SCHEMA_LIST_PROPERTY, schemaList);
+ }
+
+ return configuration.getBeanDefinition();
+ }
+
+ private static BeanDefinition parseSchema(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder schema = createBeanDefinitionBuilder(SCHEMA_CLASS);
+
+ String namespace = elementAttribute(element, NAMESPACE_ATTR);
+ schema.addPropertyValue(NAMESPACE_PROPERTY, namespace);
+ String alias = elementAttribute(element, ALIAS_ATTR);
+ if (alias != null && !alias.isEmpty()) {
+ schema.addPropertyValue(ALIAS_PROPERTY, alias);
+ }
+
+ // Entity container
+ List<Element> entityContainerElements = DomUtils
+ .getChildElementsByTagName(element, ENTITY_CONTAINER_ELEMENT);
+ if (entityContainerElements.size() == 1) {
+ Element entityContainerElement = entityContainerElements.get(0);
+ BeanDefinition entityContainer = parseEntityContainer(
+ entityContainerElement, namespace, parserContext);
+ schema.addPropertyValue(ENTITY_CONTAINER_PROPERTY, entityContainer);
+ }
+
+ // Entity types
+ List<Element> entityTypeElements = DomUtils.getChildElementsByTagName(
+ element, ENTITY_TYPE_ELEMENT);
+ if (entityTypeElements.size() > 0) {
+ List<BeanDefinition> entityTypeList = new ManagedList<BeanDefinition>(
+ entityTypeElements.size());
+ for (Element entityTypeElement : entityTypeElements) {
+ BeanDefinition entityType = parseEntityType(entityTypeElement,
+ parserContext);
+ entityTypeList.add(entityType);
+ }
+ schema.addPropertyValue(ENTITY_TYPE_LIST_PROPERTY, entityTypeList);
+ }
+
+ // Complex types
+ List<Element> complexTypeElements = DomUtils.getChildElementsByTagName(
+ element, COMPLEX_TYPE_ELEMENT);
+ if (complexTypeElements.size() > 0) {
+ ManagedList<BeanDefinition> complexTypeList = new ManagedList<BeanDefinition>(
+ complexTypeElements.size());
+ for (Element complexTypeElement : complexTypeElements) {
+ BeanDefinition complexType = parseComplexType(
+ complexTypeElement, parserContext);
+ complexTypeList.add(complexType);
+ }
+ schema.addPropertyValue(COMPLEX_TYPE_LIST_PROPERTY, complexTypeList);
+ }
+
+ return schema.getBeanDefinition();
+ }
+
+ private static BeanDefinition parseEntityContainer(Element element,
+ String namespace, ParserContext parserContext) {
+ BeanDefinitionBuilder entityContainer = createBeanDefinitionBuilder(ENTITY_CONTAINER_CLASS);
+
+ // Name
+ entityContainer.addPropertyValue(NAME_PROPERTY, namespace
+ + "EntityContainer");
+
+ // Entity sets
+ List<Element> entitySetElements = DomUtils.getChildElementsByTagName(
+ element, ENTITY_SET_ELEMENT);
+ if (entitySetElements.size() > 0) {
+ ManagedList<BeanDefinition> entitySetList = new ManagedList<BeanDefinition>(
+ entitySetElements.size());
+ for (Element entitySetElement : entitySetElements) {
+ BeanDefinition entitySet = parseEntitySet(entitySetElement,
+ namespace, parserContext);
+ entitySetList.add(entitySet);
+ }
+ entityContainer.addPropertyValue(ENTITY_SET_LIST_PROPERTY,
+ entitySetList);
+ }
+
+ return entityContainer.getBeanDefinition();
+ }
+
+ private static BeanDefinition parseEntitySet(Element element,
+ String namespace, ParserContext parserContext) {
+ BeanDefinitionBuilder entitySet = createBeanDefinitionBuilder(ENTITY_SET_CLASS);
+
+ String name = elementAttribute(element, NAME_ATTR);
+ String type = elementAttribute(element, TYPE_ATTR);
+ entitySet.addPropertyValue(NAME_PROPERTY, name);
+
+ BeanDefinitionBuilder fqn = createBeanDefinitionBuilder(FULL_QUALIFIED_NAME_CLASS);
+ fqn.addConstructorArgValue(namespace);
+ fqn.addConstructorArgValue(type);
+
+ entitySet.addPropertyValue(TYPE_PROPERTY, fqn.getBeanDefinition());
+
+ return entitySet.getBeanDefinition();
+ }
+
+ private static BeanDefinition parseEntityType(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder entityType = createBeanDefinitionBuilder(ENTITY_TYPE_CLASS);
+
+ String propertyName = elementAttribute(element, NAME_ATTR);
+ entityType.addPropertyValue(NAME_PROPERTY, propertyName);
+
+ // Key
+ List<Element> keyElements = DomUtils.getChildElementsByTagName(element,
+ KEY_ELEMENT);
+ if (keyElements.size() > 0) {
+ ManagedList<BeanDefinition> keyList = new ManagedList<BeanDefinition>(
+ keyElements.size());
+ for (Element keyElement : keyElements) {
+ BeanDefinition key = parseKey(keyElement, parserContext);
+ keyList.add(key);
+ }
+ entityType.addPropertyValue(KEY_LIST_PROPERTY, keyList);
+ }
+
+ // Properties
+ List<Element> propertyElements = DomUtils.getChildElementsByTagName(
+ element, PROPERTY_ELEMENT);
+ if (propertyElements.size() > 0) {
+ ManagedList<BeanDefinition> entitySetList = new ManagedList<BeanDefinition>(
+ propertyElements.size());
+ for (Element propertyElement : propertyElements) {
+ BeanDefinition property = parseProperty(propertyElement,
+ parserContext);
+ entitySetList.add(property);
+ }
+ entityType.addPropertyValue(PROPERTY_LIST_PROPERTY, entitySetList);
+ }
+
+ return entityType.getBeanDefinition();
+ }
+
+ private static BeanDefinition parseKey(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder property = createBeanDefinitionBuilder(PROPERTY_REF_CLASS);
+
+ String propertyName = elementAttribute(element, PROPERTY_NAME_ATTR);
+ property.addPropertyValue(PROPERTY_NAME_PROPERTY, propertyName);
+
+ return property.getBeanDefinition();
+ }
+
+ private static BeanDefinition parseProperty(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder property = createBeanDefinitionBuilder(PROPERTY_CLASS);
+
+ String name = elementAttribute(element, NAME_ATTR);
+ String type = elementAttribute(element, TYPE_ATTR);
+ property.addPropertyValue(NAME_PROPERTY, name);
+ property.addPropertyValue(TYPE_PROPERTY, type);
+
+ return property.getBeanDefinition();
+ }
+
+ private static BeanDefinition parseComplexType(Element complexTypeElement,
+ ParserContext parserContext) {
+ // TODO to be implemented
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmProviderBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmProviderBeanDefinitionParser.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmProviderBeanDefinitionParser.java
new file mode 100644
index 0000000..e152a11
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoEdmProviderBeanDefinitionParser.java
@@ -0,0 +1,36 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+public class OlingoEdmProviderBeanDefinitionParser extends AbstractBeanDefinitionParser {
+
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
+ BeanDefinition configuration = OlingoEdmBeanDefinitionHelper.parseEdmProvider(element, parserContext);
+ return (AbstractBeanDefinition) configuration;
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHandlerBeanDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHandlerBeanDefinitionHelper.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHandlerBeanDefinitionHelper.java
new file mode 100644
index 0000000..ab4f89d
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHandlerBeanDefinitionHelper.java
@@ -0,0 +1,159 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import java.util.List;
+
+import org.apache.olingo.ext.config.spring.factory.EdmxReferenceFactoryBean;
+import org.apache.olingo.ext.config.spring.factory.ODataFactoryBean;
+import org.apache.olingo.ext.config.spring.factory.ODataHttpHandlerFactoryBean;
+import org.apache.olingo.ext.config.spring.factory.ServiceMetadataFactoryBean;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+public abstract class OlingoHandlerBeanDefinitionHelper {
+
+ private static final Class<?> ODATA_FACTORY_BEAN_CLASS = ODataFactoryBean.class;
+ private static final Class<?> HTTP_HANDLER_FACTORY_BEAN_CLASS = ODataHttpHandlerFactoryBean.class;
+ private static final Class<?> SERVICE_METADATA_FACTORY_BEAN_CLASS = ServiceMetadataFactoryBean.class;
+ private static final Class<?> EDMX_REFERENCE_FACTORY_BEAN = EdmxReferenceFactoryBean.class;
+
+ private static final String REFERENCE_ELEMENT = "reference";
+ private static final String PROCESSOR_ELEMENT = "processor";
+ private static final String INCLUDE_ELEMENT = "include";
+
+ private static final String EDM_PROVIDER_ATTR = "edm-provider";
+ private static final String REF_ATTR = "ref";
+ private static final String URI_ATTR = "uri";
+ private static final String KEY_ATTR = "key";
+ private static final String VALUE_ATTR = "value";
+
+ private static final String ODATA_PROPERTY = "odata";
+ private static final String SERVICE_METADATA_PROPERTY = "serviceMetadata";
+ private static final String REFERENCES_LIST_PROPERTY = "references";
+ private static final String PROCESSORS_LIST_PROPERTY = "processors";
+ private static final String EDM_PROVIDER_PROPERTY = "edmProvider";
+ private static final String URI_PROPERTY = "uri";
+ private static final String INCLUDES_PROPERTY = "includes";
+
+ private static String elementAttribute(Element element, String name) {
+ String value = element.getAttribute(name);
+ return value.length() == 0 ? null : value;
+ }
+
+ private static BeanDefinitionBuilder createBeanDefinitionBuilder(
+ Class<?> beanClass) {
+ return BeanDefinitionBuilder.rootBeanDefinition(beanClass);
+ }
+
+ public static BeanDefinition parseHttpHandler(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder httpHandler = createBeanDefinitionBuilder(HTTP_HANDLER_FACTORY_BEAN_CLASS);
+
+ // OData
+ BeanDefinitionBuilder odataBuilder = createBeanDefinitionBuilder(ODATA_FACTORY_BEAN_CLASS);
+ BeanDefinition odata = odataBuilder.getBeanDefinition();
+
+ httpHandler.addPropertyValue(ODATA_PROPERTY, odata);
+
+ // ServiceMetadata
+ BeanDefinitionBuilder serviceMetadata =
+ createBeanDefinitionBuilder(SERVICE_METADATA_FACTORY_BEAN_CLASS);
+ serviceMetadata.addPropertyValue(ODATA_PROPERTY, odata);
+
+ String edmProviderRef = elementAttribute(element, EDM_PROVIDER_ATTR);
+ serviceMetadata.addPropertyValue(EDM_PROVIDER_PROPERTY,
+ new RuntimeBeanReference(edmProviderRef));
+
+ // References
+ List<Element> referenceElements = DomUtils.getChildElementsByTagName(
+ element, REFERENCE_ELEMENT);
+ if (referenceElements.size() > 0) {
+ ManagedList<BeanDefinition> referenceList = new ManagedList<BeanDefinition>(
+ referenceElements.size());
+ for (Element referenceElement : referenceElements) {
+ BeanDefinition reference = parseReference(referenceElement,
+ parserContext);
+ referenceList.add(reference);
+ }
+ serviceMetadata.addPropertyValue(REFERENCES_LIST_PROPERTY,
+ referenceList);
+ }
+
+ httpHandler.addPropertyValue(SERVICE_METADATA_PROPERTY,
+ serviceMetadata.getBeanDefinition());
+
+ // Processors
+ List<Element> processorElements = DomUtils.getChildElementsByTagName(
+ element, PROCESSOR_ELEMENT);
+ if (processorElements.size() > 0) {
+ ManagedList<RuntimeBeanReference> processorList = new ManagedList<RuntimeBeanReference>(
+ processorElements.size());
+ for (Element processorElement : processorElements) {
+ RuntimeBeanReference processorRef = parseProcessor(
+ processorElement, parserContext);
+ processorList.add(processorRef);
+ }
+ httpHandler.addPropertyValue(PROCESSORS_LIST_PROPERTY,
+ processorList);
+ }
+
+ AbstractBeanDefinition configurationDef = httpHandler
+ .getBeanDefinition();
+ return configurationDef;
+ }
+
+ private static BeanDefinition parseReference(Element referenceElement,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder reference = createBeanDefinitionBuilder(EDMX_REFERENCE_FACTORY_BEAN);
+
+ String uri = elementAttribute(referenceElement, URI_ATTR);
+ reference.addPropertyValue(URI_PROPERTY, uri);
+
+ // Processors
+ List<Element> includeElements = DomUtils.getChildElementsByTagName(
+ referenceElement, INCLUDE_ELEMENT);
+ if (includeElements.size() > 0) {
+ ManagedMap<String, String> includeMap = new ManagedMap<String, String>(
+ includeElements.size());
+ for (Element includeElement : includeElements) {
+ String key = elementAttribute(includeElement, KEY_ATTR);
+ String value = elementAttribute(includeElement, VALUE_ATTR);
+ includeMap.put(key, value);
+ }
+ reference.addPropertyValue(INCLUDES_PROPERTY, includeMap);
+ }
+
+ return reference.getBeanDefinition();
+ }
+
+ private static RuntimeBeanReference parseProcessor(
+ Element processorElement, ParserContext parserContext) {
+ String ref = elementAttribute(processorElement, REF_ATTR);
+ return new RuntimeBeanReference(ref);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHttpHandlerBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHttpHandlerBeanDefinitionParser.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHttpHandlerBeanDefinitionParser.java
new file mode 100644
index 0000000..5719b9b
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoHttpHandlerBeanDefinitionParser.java
@@ -0,0 +1,34 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+public class OlingoHttpHandlerBeanDefinitionParser extends AbstractBeanDefinitionParser {
+
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
+ BeanDefinition configuration = OlingoHandlerBeanDefinitionHelper.parseHttpHandler(element, parserContext);
+ return (AbstractBeanDefinition) configuration;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoNamespaceHandler.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoNamespaceHandler.java
new file mode 100644
index 0000000..1450bc5
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/OlingoNamespaceHandler.java
@@ -0,0 +1,61 @@
+/*
+ * 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.olingo.ext.config.spring;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Dedicated Spring namespace handler for Olingo. This namespace is directly
+ * usable within a Spring application context.
+ *
+ * This namespace can be configured in Spring XML configuration files using
+ * standard mechanisms of XML namespace, as following:
+ *
+ * <beans xmlns="http://www.springframework.org/schema/beans"
+ * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ * xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo"
+ * xsi:schemaLocation="http://www.springframework.org/schema/beans
+ * http://www.springframework.org/schema/beans/spring-beans.xsd
+ * http://olingo.apache.org/schema/olingo/spring-olingo
+ * http://olingo.apache.org/schema/olingo/spring-olingo.xsd">
+ * (...)
+ * </beans>
+ *
+ * @author Thierry Templier
+ */
+public class OlingoNamespaceHandler extends NamespaceHandlerSupport {
+
+ public static final String EDM_PROVIDER_ELEMENT = "edm-provider";
+
+ public static final String HTTP_HANDLER_ELEMENT = "http-handler";
+
+ /**
+ * Registers bean definition parsers for the olingo namespace.
+ *
+ * @see OlingoEdmProviderBeanDefinitionParser
+ * @see OlingoHttpHandlerBeanDefinitionParser
+ */
+ public void init() {
+ registerBeanDefinitionParser(EDM_PROVIDER_ELEMENT,
+ new OlingoEdmProviderBeanDefinitionParser());
+ registerBeanDefinitionParser(HTTP_HANDLER_ELEMENT,
+ new OlingoHttpHandlerBeanDefinitionParser());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/FullQualifiedNameConverter.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/FullQualifiedNameConverter.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/FullQualifiedNameConverter.java
new file mode 100644
index 0000000..25c61b0
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/FullQualifiedNameConverter.java
@@ -0,0 +1,30 @@
+/*
+ * 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.olingo.ext.config.spring.editor;
+
+
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.springframework.core.convert.converter.Converter;
+
+public class FullQualifiedNameConverter implements Converter<FullQualifiedName, String>{
+ @Override
+ public String convert(FullQualifiedName fullQualifiedName) {
+ return fullQualifiedName.getFullQualifiedNameAsString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/ToFullQualifiedNameConverter.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/ToFullQualifiedNameConverter.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/ToFullQualifiedNameConverter.java
new file mode 100644
index 0000000..c92d5f9
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/editor/ToFullQualifiedNameConverter.java
@@ -0,0 +1,30 @@
+/*
+ * 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.olingo.ext.config.spring.editor;
+
+
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.springframework.core.convert.converter.Converter;
+
+public class ToFullQualifiedNameConverter implements Converter<String, FullQualifiedName> {
+ @Override
+ public FullQualifiedName convert(String s) {
+ return new FullQualifiedName(s);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/EdmxReferenceFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/EdmxReferenceFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/EdmxReferenceFactoryBean.java
new file mode 100644
index 0000000..d4f7774
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/EdmxReferenceFactoryBean.java
@@ -0,0 +1,80 @@
+/*
+ * 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.olingo.ext.config.spring.factory;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+public class EdmxReferenceFactoryBean implements FactoryBean<EdmxReference>,
+ InitializingBean {
+ private String uri;
+ private Map<String, String> includes;
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ if (uri == null) {
+ throw new IllegalArgumentException("The property uri is required.");
+ }
+ }
+
+ @Override
+ public EdmxReference getObject() throws Exception {
+ EdmxReference reference = new EdmxReference(URI.create(uri));
+ if (includes != null) {
+ for (Entry<String, String> include : includes.entrySet()) {
+ reference.addInclude(new EdmxReferenceInclude(include.getKey(),
+ include.getValue()));
+ }
+ }
+ return reference;
+ }
+
+ @Override
+ public Class<?> getObjectType() {
+ return EdmxReference.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public Map<String, String> getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(Map<String, String> includes) {
+ this.includes = includes;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataFactoryBean.java
new file mode 100644
index 0000000..d1e0e3a
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataFactoryBean.java
@@ -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.olingo.ext.config.spring.factory;
+
+import org.apache.olingo.server.api.OData;
+import org.springframework.beans.factory.FactoryBean;
+
+public class ODataFactoryBean implements FactoryBean<OData> {
+
+ @Override
+ public OData getObject() throws Exception {
+ return OData.newInstance();
+ }
+
+ @Override
+ public Class<?> getObjectType() {
+ return OData.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataHttpHandlerFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataHttpHandlerFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataHttpHandlerFactoryBean.java
new file mode 100644
index 0000000..c0f846b
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ODataHttpHandlerFactoryBean.java
@@ -0,0 +1,94 @@
+/*
+ * 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.olingo.ext.config.spring.factory;
+
+import java.util.List;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.processor.Processor;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+public class ODataHttpHandlerFactoryBean implements
+ FactoryBean<ODataHttpHandler>, InitializingBean {
+ private OData odata;
+ private ServiceMetadata serviceMetadata;
+ private List<Processor> processors;
+
+ @Override
+ public ODataHttpHandler getObject() throws Exception {
+ ODataHttpHandler handler = odata.createHandler(serviceMetadata);
+ if (processors != null) {
+ for (Processor processor : processors) {
+ handler.register(processor);
+ }
+ }
+ return handler;
+ }
+
+ @Override
+ public Class<?> getObjectType() {
+ return ODataHttpHandler.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ if (odata == null) {
+ throw new IllegalArgumentException(
+ "The property odata is required.");
+ }
+
+ if (serviceMetadata == null) {
+ throw new IllegalArgumentException(
+ "The property serviceMetadata is required.");
+ }
+ }
+
+ public OData getOdata() {
+ return odata;
+ }
+
+ public void setOdata(OData odata) {
+ this.odata = odata;
+ }
+
+ public ServiceMetadata getServiceMetadata() {
+ return serviceMetadata;
+ }
+
+ public void setServiceMetadata(ServiceMetadata serviceMetadata) {
+ this.serviceMetadata = serviceMetadata;
+ }
+
+ public List<Processor> getProcessors() {
+ return processors;
+ }
+
+ public void setProcessors(List<Processor> processors) {
+ this.processors = processors;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ServiceMetadataFactoryBean.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ServiceMetadataFactoryBean.java b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ServiceMetadataFactoryBean.java
new file mode 100644
index 0000000..52e41e4
--- /dev/null
+++ b/ext/spring/src/main/java/org/apache/olingo/ext/config/spring/factory/ServiceMetadataFactoryBean.java
@@ -0,0 +1,92 @@
+/*
+ * 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.olingo.ext.config.spring.factory;
+
+import java.util.List;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+public class ServiceMetadataFactoryBean implements
+ FactoryBean<ServiceMetadata>, InitializingBean {
+ private OData odata;
+ private CsdlEdmProvider edmProvider;
+ private List<EdmxReference> references;
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ if (odata == null) {
+ throw new IllegalArgumentException(
+ "The property odata is required.");
+ }
+
+ if (edmProvider == null) {
+ throw new IllegalArgumentException(
+ "The property edmProvider is required.");
+ }
+
+ if (references == null) {
+ throw new IllegalArgumentException(
+ "The property references is required.");
+ }
+ }
+
+ @Override
+ public ServiceMetadata getObject() throws Exception {
+ return odata.createServiceMetadata(edmProvider, references);
+ }
+
+ @Override
+ public Class<?> getObjectType() {
+ return ServiceMetadata.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public OData getOdata() {
+ return odata;
+ }
+
+ public void setOdata(OData odata) {
+ this.odata = odata;
+ }
+
+ public CsdlEdmProvider getEdmProvider() {
+ return edmProvider;
+ }
+
+ public void setEdmProvider(CsdlEdmProvider edmProvider) {
+ this.edmProvider = edmProvider;
+ }
+
+ public List<EdmxReference> getReferences() {
+ return references;
+ }
+
+ public void setReferences(List<EdmxReference> references) {
+ this.references = references;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmBeanDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmBeanDefinitionHelper.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmBeanDefinitionHelper.java
deleted file mode 100644
index a3c24dd..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmBeanDefinitionHelper.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.ext.spring.edm.GenericEdmProvider;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
-import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
-import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-
-public abstract class OlingoEdmBeanDefinitionHelper {
- private static final Class<?> EDM_PROVIDER_CLASS = GenericEdmProvider.class;
- private static final Class<?> SCHEMA_CLASS = CsdlSchema.class;
- private static final Class<?> ENTITY_CONTAINER_CLASS = CsdlEntityContainer.class;
- private static final Class<?> ENTITY_SET_CLASS = CsdlEntitySet.class;
- private static final Class<?> ENTITY_TYPE_CLASS = CsdlEntityType.class;
- private static final Class<?> PROPERTY_REF_CLASS = CsdlPropertyRef.class;
- private static final Class<?> PROPERTY_CLASS = CsdlProperty.class;
- private static final Class<?> FULL_QUALIFIED_NAME_CLASS = FullQualifiedName.class;
-
- private static final String SCHEMA_ELEMENT = "schema";
- private static final String ENTITY_CONTAINER_ELEMENT = "entityContainer";
- private static final String ENTITY_TYPE_ELEMENT = "entityType";
- private static final String COMPLEX_TYPE_ELEMENT = "complexType";
- private static final String ENTITY_SET_ELEMENT = "entitySet";
- private static final String KEY_ELEMENT = "key";
- private static final String PROPERTY_ELEMENT = "property";
-
- private static final String NAME_ATTR = "name";
- private static final String NAMESPACE_ATTR = "namespace";
- private static final String TYPE_ATTR = "type";
- private static final String PROPERTY_NAME_ATTR = "property-name";
- private static final String ALIAS_ATTR = "alias";
-
- private static final String SCHEMA_LIST_PROPERTY = "schemas";
- private static final String ENTITY_TYPE_LIST_PROPERTY = "entityTypes";
- private static final String COMPLEX_TYPE_LIST_PROPERTY = "complexTypes";
- private static final String ENTITY_SET_LIST_PROPERTY = "entitySets";
- private static final String ENTITY_CONTAINER_PROPERTY = "entityContainer";
- private static final String NAME_PROPERTY = "name";
- private static final String NAMESPACE_PROPERTY = "namespace";
- private static final String ALIAS_PROPERTY = "alias";
- private static final String TYPE_PROPERTY = "type";
- private static final String KEY_LIST_PROPERTY = "key";
- private static final String PROPERTY_LIST_PROPERTY = "properties";
- private static final String PROPERTY_NAME_PROPERTY = "name";
-
- private static String elementAttribute(Element element, String name) {
- String value = element.getAttribute(name);
- return value.length() == 0 ? null : value;
- }
-
- private static BeanDefinitionBuilder createBeanDefinitionBuilder(
- Class<?> beanClass) {
- return BeanDefinitionBuilder.rootBeanDefinition(beanClass);
- }
-
- public static BeanDefinition parseEdmProvider(Element element,
- ParserContext parserContext) {
- BeanDefinitionBuilder configuration = createBeanDefinitionBuilder(EDM_PROVIDER_CLASS);
-
- // Schemas
- List<Element> schemaElements = DomUtils.getChildElementsByTagName(
- element, SCHEMA_ELEMENT);
- if (schemaElements.size() > 0) {
- ManagedList<BeanDefinition> schemaList = new ManagedList<BeanDefinition>(
- schemaElements.size());
- for (Element schemaElement : schemaElements) {
- BeanDefinition schema = parseSchema(schemaElement,
- parserContext);
- schemaList.add(schema);
- }
- configuration.addPropertyValue(SCHEMA_LIST_PROPERTY, schemaList);
- }
-
- return configuration.getBeanDefinition();
- }
-
- private static BeanDefinition parseSchema(Element element,
- ParserContext parserContext) {
- BeanDefinitionBuilder schema = createBeanDefinitionBuilder(SCHEMA_CLASS);
-
- String namespace = elementAttribute(element, NAMESPACE_ATTR);
- schema.addPropertyValue(NAMESPACE_PROPERTY, namespace);
- String alias = elementAttribute(element, ALIAS_ATTR);
- if (alias != null && !alias.isEmpty()) {
- schema.addPropertyValue(ALIAS_PROPERTY, alias);
- }
-
- // Entity container
- List<Element> entityContainerElements = DomUtils
- .getChildElementsByTagName(element, ENTITY_CONTAINER_ELEMENT);
- if (entityContainerElements.size() == 1) {
- Element entityContainerElement = entityContainerElements.get(0);
- BeanDefinition entityContainer = parseEntityContainer(
- entityContainerElement, namespace, parserContext);
- schema.addPropertyValue(ENTITY_CONTAINER_PROPERTY, entityContainer);
- }
-
- // Entity types
- List<Element> entityTypeElements = DomUtils.getChildElementsByTagName(
- element, ENTITY_TYPE_ELEMENT);
- if (entityTypeElements.size() > 0) {
- List<BeanDefinition> entityTypeList = new ManagedList<BeanDefinition>(
- entityTypeElements.size());
- for (Element entityTypeElement : entityTypeElements) {
- BeanDefinition entityType = parseEntityType(entityTypeElement,
- parserContext);
- entityTypeList.add(entityType);
- }
- schema.addPropertyValue(ENTITY_TYPE_LIST_PROPERTY, entityTypeList);
- }
-
- // Complex types
- List<Element> complexTypeElements = DomUtils.getChildElementsByTagName(
- element, COMPLEX_TYPE_ELEMENT);
- if (complexTypeElements.size() > 0) {
- ManagedList<BeanDefinition> complexTypeList = new ManagedList<BeanDefinition>(
- complexTypeElements.size());
- for (Element complexTypeElement : complexTypeElements) {
- BeanDefinition complexType = parseComplexType(
- complexTypeElement, parserContext);
- complexTypeList.add(complexType);
- }
- schema.addPropertyValue(COMPLEX_TYPE_LIST_PROPERTY, complexTypeList);
- }
-
- return schema.getBeanDefinition();
- }
-
- private static BeanDefinition parseEntityContainer(Element element,
- String namespace, ParserContext parserContext) {
- BeanDefinitionBuilder entityContainer = createBeanDefinitionBuilder(ENTITY_CONTAINER_CLASS);
-
- // Name
- entityContainer.addPropertyValue(NAME_PROPERTY, namespace
- + "EntityContainer");
-
- // Entity sets
- List<Element> entitySetElements = DomUtils.getChildElementsByTagName(
- element, ENTITY_SET_ELEMENT);
- if (entitySetElements.size() > 0) {
- ManagedList<BeanDefinition> entitySetList = new ManagedList<BeanDefinition>(
- entitySetElements.size());
- for (Element entitySetElement : entitySetElements) {
- BeanDefinition entitySet = parseEntitySet(entitySetElement,
- namespace, parserContext);
- entitySetList.add(entitySet);
- }
- entityContainer.addPropertyValue(ENTITY_SET_LIST_PROPERTY,
- entitySetList);
- }
-
- return entityContainer.getBeanDefinition();
- }
-
- private static BeanDefinition parseEntitySet(Element element,
- String namespace, ParserContext parserContext) {
- BeanDefinitionBuilder entitySet = createBeanDefinitionBuilder(ENTITY_SET_CLASS);
-
- String name = elementAttribute(element, NAME_ATTR);
- String type = elementAttribute(element, TYPE_ATTR);
- entitySet.addPropertyValue(NAME_PROPERTY, name);
-
- BeanDefinitionBuilder fqn = createBeanDefinitionBuilder(FULL_QUALIFIED_NAME_CLASS);
- fqn.addConstructorArgValue(namespace);
- fqn.addConstructorArgValue(type);
-
- entitySet.addPropertyValue(TYPE_PROPERTY, fqn.getBeanDefinition());
-
- return entitySet.getBeanDefinition();
- }
-
- private static BeanDefinition parseEntityType(Element element,
- ParserContext parserContext) {
- BeanDefinitionBuilder entityType = createBeanDefinitionBuilder(ENTITY_TYPE_CLASS);
-
- String propertyName = elementAttribute(element, NAME_ATTR);
- entityType.addPropertyValue(NAME_PROPERTY, propertyName);
-
- // Key
- List<Element> keyElements = DomUtils.getChildElementsByTagName(element,
- KEY_ELEMENT);
- if (keyElements.size() > 0) {
- ManagedList<BeanDefinition> keyList = new ManagedList<BeanDefinition>(
- keyElements.size());
- for (Element keyElement : keyElements) {
- BeanDefinition key = parseKey(keyElement, parserContext);
- keyList.add(key);
- }
- entityType.addPropertyValue(KEY_LIST_PROPERTY, keyList);
- }
-
- // Properties
- List<Element> propertyElements = DomUtils.getChildElementsByTagName(
- element, PROPERTY_ELEMENT);
- if (propertyElements.size() > 0) {
- ManagedList<BeanDefinition> entitySetList = new ManagedList<BeanDefinition>(
- propertyElements.size());
- for (Element propertyElement : propertyElements) {
- BeanDefinition property = parseProperty(propertyElement,
- parserContext);
- entitySetList.add(property);
- }
- entityType.addPropertyValue(PROPERTY_LIST_PROPERTY, entitySetList);
- }
-
- return entityType.getBeanDefinition();
- }
-
- private static BeanDefinition parseKey(Element element,
- ParserContext parserContext) {
- BeanDefinitionBuilder property = createBeanDefinitionBuilder(PROPERTY_REF_CLASS);
-
- String propertyName = elementAttribute(element, PROPERTY_NAME_ATTR);
- property.addPropertyValue(PROPERTY_NAME_PROPERTY, propertyName);
-
- return property.getBeanDefinition();
- }
-
- private static BeanDefinition parseProperty(Element element,
- ParserContext parserContext) {
- BeanDefinitionBuilder property = createBeanDefinitionBuilder(PROPERTY_CLASS);
-
- String name = elementAttribute(element, NAME_ATTR);
- String type = elementAttribute(element, TYPE_ATTR);
- property.addPropertyValue(NAME_PROPERTY, name);
- property.addPropertyValue(TYPE_PROPERTY, type);
-
- return property.getBeanDefinition();
- }
-
- private static BeanDefinition parseComplexType(Element complexTypeElement,
- ParserContext parserContext) {
- // TODO to be implemented
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmProviderBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmProviderBeanDefinitionParser.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmProviderBeanDefinitionParser.java
deleted file mode 100644
index b64ebd0..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoEdmProviderBeanDefinitionParser.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Element;
-
-public class OlingoEdmProviderBeanDefinitionParser extends AbstractBeanDefinitionParser {
-
- @Override
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- BeanDefinition configuration = OlingoEdmBeanDefinitionHelper.parseEdmProvider(element, parserContext);
- return (AbstractBeanDefinition) configuration;
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bb1dbba3/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHandlerBeanDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHandlerBeanDefinitionHelper.java b/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHandlerBeanDefinitionHelper.java
deleted file mode 100644
index 42f8889..0000000
--- a/ext/spring/src/main/java/org/apache/olingo/ext/spring/config/OlingoHandlerBeanDefinitionHelper.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.ext.spring.config;
-
-import java.util.List;
-
-import org.apache.olingo.ext.spring.factory.EdmxReferenceFactoryBean;
-import org.apache.olingo.ext.spring.factory.ODataFactoryBean;
-import org.apache.olingo.ext.spring.factory.ODataHttpHandlerFactoryBean;
-import org.apache.olingo.ext.spring.factory.ServiceMetadataFactoryBean;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.ManagedMap;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-
-public abstract class OlingoHandlerBeanDefinitionHelper {
-
- private static final Class<?> ODATA_FACTORY_BEAN_CLASS = ODataFactoryBean.class;
- private static final Class<?> HTTP_HANDLER_FACTORY_BEAN_CLASS = ODataHttpHandlerFactoryBean.class;
- private static final Class<?> SERVICE_METADATA_FACTORY_BEAN_CLASS = ServiceMetadataFactoryBean.class;
- private static final Class<?> EDMX_REFERENCE_FACTORY_BEAN = EdmxReferenceFactoryBean.class;
-
- private static final String REFERENCE_ELEMENT = "reference";
- private static final String PROCESSOR_ELEMENT = "processor";
- private static final String INCLUDE_ELEMENT = "include";
-
- private static final String EDM_PROVIDER_ATTR = "edm-provider";
- private static final String REF_ATTR = "ref";
- private static final String URI_ATTR = "uri";
- private static final String KEY_ATTR = "key";
- private static final String VALUE_ATTR = "value";
-
- private static final String ODATA_PROPERTY = "odata";
- private static final String SERVICE_METADATA_PROPERTY = "serviceMetadata";
- private static final String REFERENCES_LIST_PROPERTY = "references";
- private static final String PROCESSORS_LIST_PROPERTY = "processors";
- private static final String EDM_PROVIDER_PROPERTY = "edmProvider";
- private static final String URI_PROPERTY = "uri";
- private static final String INCLUDES_PROPERTY = "includes";
-
- private static String elementAttribute(Element element, String name) {
- String value = element.getAttribute(name);
- return value.length() == 0 ? null : value;
- }
-
- private static BeanDefinitionBuilder createBeanDefinitionBuilder(
- Class<?> beanClass) {
- return BeanDefinitionBuilder.rootBeanDefinition(beanClass);
- }
-
- public static BeanDefinition parseHttpHandler(Element element,
- ParserContext parserContext) {
- BeanDefinitionBuilder httpHandler = createBeanDefinitionBuilder(HTTP_HANDLER_FACTORY_BEAN_CLASS);
-
- // OData
- BeanDefinitionBuilder odataBuilder = createBeanDefinitionBuilder(ODATA_FACTORY_BEAN_CLASS);
- BeanDefinition odata = odataBuilder.getBeanDefinition();
-
- httpHandler.addPropertyValue(ODATA_PROPERTY, odata);
-
- // ServiceMetadata
- BeanDefinitionBuilder serviceMetadata =
- createBeanDefinitionBuilder(SERVICE_METADATA_FACTORY_BEAN_CLASS);
- serviceMetadata.addPropertyValue(ODATA_PROPERTY, odata);
-
- String edmProviderRef = elementAttribute(element, EDM_PROVIDER_ATTR);
- serviceMetadata.addPropertyValue(EDM_PROVIDER_PROPERTY,
- new RuntimeBeanReference(edmProviderRef));
-
- // References
- List<Element> referenceElements = DomUtils.getChildElementsByTagName(
- element, REFERENCE_ELEMENT);
- if (referenceElements.size() > 0) {
- ManagedList<BeanDefinition> referenceList = new ManagedList<BeanDefinition>(
- referenceElements.size());
- for (Element referenceElement : referenceElements) {
- BeanDefinition reference = parseReference(referenceElement,
- parserContext);
- referenceList.add(reference);
- }
- serviceMetadata.addPropertyValue(REFERENCES_LIST_PROPERTY,
- referenceList);
- }
-
- httpHandler.addPropertyValue(SERVICE_METADATA_PROPERTY,
- serviceMetadata.getBeanDefinition());
-
- // Processors
- List<Element> processorElements = DomUtils.getChildElementsByTagName(
- element, PROCESSOR_ELEMENT);
- if (processorElements.size() > 0) {
- ManagedList<RuntimeBeanReference> processorList = new ManagedList<RuntimeBeanReference>(
- processorElements.size());
- for (Element processorElement : processorElements) {
- RuntimeBeanReference processorRef = parseProcessor(
- processorElement, parserContext);
- processorList.add(processorRef);
- }
- httpHandler.addPropertyValue(PROCESSORS_LIST_PROPERTY,
- processorList);
- }
-
- AbstractBeanDefinition configurationDef = httpHandler
- .getBeanDefinition();
- return configurationDef;
- }
-
- private static BeanDefinition parseReference(Element referenceElement,
- ParserContext parserContext) {
- BeanDefinitionBuilder reference = createBeanDefinitionBuilder(EDMX_REFERENCE_FACTORY_BEAN);
-
- String uri = elementAttribute(referenceElement, URI_ATTR);
- reference.addPropertyValue(URI_PROPERTY, uri);
-
- // Processors
- List<Element> includeElements = DomUtils.getChildElementsByTagName(
- referenceElement, INCLUDE_ELEMENT);
- if (includeElements.size() > 0) {
- ManagedMap<String, String> includeMap = new ManagedMap<String, String>(
- includeElements.size());
- for (Element includeElement : includeElements) {
- String key = elementAttribute(includeElement, KEY_ATTR);
- String value = elementAttribute(includeElement, VALUE_ATTR);
- includeMap.put(key, value);
- }
- reference.addPropertyValue(INCLUDES_PROPERTY, includeMap);
- }
-
- return reference.getBeanDefinition();
- }
-
- private static RuntimeBeanReference parseProcessor(
- Element processorElement, ParserContext parserContext) {
- String ref = elementAttribute(processorElement, REF_ATTR);
- return new RuntimeBeanReference(ref);
- }
-
-}