From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/assembly/dsl/AssemblyBuilder.java | 37 +++++++++++ .../tuscany/sca/assembly/dsl/ComponentBuilder.java | 34 ++++++++++ .../sca/assembly/dsl/ComponentPropertyBuilder.java | 28 ++++++++ .../assembly/dsl/ComponentReferenceBuilder.java | 36 ++++++++++ .../sca/assembly/dsl/ComponentServiceBuilder.java | 32 +++++++++ .../tuscany/sca/assembly/dsl/CompositeBuilder.java | 29 ++++++++ .../sca/assembly/dsl/impl/AssemblyBuilderImpl.java | 70 ++++++++++++++++++++ .../assembly/dsl/impl/ComponentBuilderImpl.java | 74 +++++++++++++++++++++ .../dsl/impl/ComponentPropertyBuilderImpl.java | 40 +++++++++++ .../dsl/impl/ComponentReferenceBuilderImpl.java | 77 ++++++++++++++++++++++ .../dsl/impl/ComponentServiceBuilderImpl.java | 62 +++++++++++++++++ .../assembly/dsl/impl/CompositeBuilderImpl.java | 62 +++++++++++++++++ .../sca/assembly/dsl/AccountDataService.java | 24 +++++++ .../sca/assembly/dsl/AccountDataServiceImpl.java | 24 +++++++ .../tuscany/sca/assembly/dsl/AccountService.java | 24 +++++++ .../sca/assembly/dsl/AccountServiceImpl.java | 24 +++++++ .../tuscany/sca/assembly/dsl/BigBankBuilder.java | 59 +++++++++++++++++ .../sca/assembly/dsl/BigBankBuilderTestCase.java | 33 ++++++++++ .../sca/assembly/dsl/StockQuoteService.java | 24 +++++++ 19 files changed, 793 insertions(+) create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java create mode 100644 java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java create mode 100644 java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java create mode 100644 java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java create mode 100644 java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java create mode 100644 java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java (limited to 'java/sca/modules/assembly-java-dsl/src') diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java new file mode 100644 index 0000000000..28a5ecdc24 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + + +public interface AssemblyBuilder { + + CompositeBuilder composite(String name); + + ComponentBuilder component(String name); + + ComponentReferenceBuilder reference(String name); + + ComponentServiceBuilder service(String name); + + ComponentPropertyBuilder property(String name); + + CompositeBuilder domain(String uri); + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java new file mode 100644 index 0000000000..3d97041907 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.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.tuscany.sca.assembly.dsl; + +public interface ComponentBuilder { + + ComponentBuilder implementedBy(Class clazz); + + ComponentBuilder implementedBy(CompositeBuilder composite); + + ComponentBuilder uses(ComponentReferenceBuilder... componentReferences); + + ComponentBuilder provides(ComponentServiceBuilder... componentServices); + + ComponentBuilder declares(ComponentPropertyBuilder...componentProperties); + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java new file mode 100644 index 0000000000..7f3c89fd2f --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +public interface ComponentPropertyBuilder { + + ComponentPropertyBuilder ofType(String type); + + ComponentPropertyBuilder configuredTo(Object value); + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java new file mode 100644 index 0000000000..8966a4be9d --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.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.tuscany.sca.assembly.dsl; + +public interface ComponentReferenceBuilder { + + ComponentReferenceBuilder wiredTo(String target); + + ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target); + + ComponentReferenceBuilder typedBy(Class interfaceClass); + + ComponentReferenceBuilder promotedAs(String promoted); + + ComponentReferenceBuilder promoted(); + + ComponentReferenceBuilder boundTo(String uri); + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java new file mode 100644 index 0000000000..f3e36e8c38 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +public interface ComponentServiceBuilder { + + ComponentServiceBuilder typedBy(Class interfaceClass); + + ComponentServiceBuilder promotedAs(String promoted); + + ComponentServiceBuilder promoted(); + + ComponentServiceBuilder boundTo(String uri); + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java new file mode 100644 index 0000000000..e2108b5ef8 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + + +public interface CompositeBuilder { + + CompositeBuilder contains(ComponentBuilder... components); + + CompositeBuilder includes(CompositeBuilder... includes); + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java new file mode 100644 index 0000000000..0968310548 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.assembly.dsl.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.dsl.AssemblyBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder; + +public class AssemblyBuilderImpl extends DefaultAssemblyFactory implements AssemblyBuilder { + + public ComponentBuilder component(String name) { + ComponentBuilderImpl component = new ComponentBuilderImpl(); + component.setName(name); + return component; + } + + public CompositeBuilder composite(String name) { + CompositeBuilderImpl composite = new CompositeBuilderImpl(); + //TODO handle namespace + composite.setName(new QName("", name)); + return composite; + } + + public CompositeBuilder domain(String uri) { + CompositeBuilderImpl composite = new CompositeBuilderImpl(); + composite.setName(new QName(uri, "")); + return composite; + } + + public ComponentPropertyBuilder property(String name) { + ComponentPropertyBuilderImpl property = new ComponentPropertyBuilderImpl(); + property.setName(name); + return property; + } + + public ComponentReferenceBuilder reference(String name) { + ComponentReferenceBuilderImpl reference = new ComponentReferenceBuilderImpl(this); + reference.setName(name); + return reference; + } + + public ComponentServiceBuilder service(String name) { + ComponentServiceBuilderImpl service = new ComponentServiceBuilderImpl(this); + service.setName(name); + return service; + } + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java new file mode 100644 index 0000000000..9022b9d9e6 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl.impl; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.ComponentProperty; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentImpl; + +public class ComponentBuilderImpl extends ComponentImpl implements ComponentBuilder { + + public ComponentBuilderImpl() { + } + + public ComponentBuilder implementedBy(Class clazz) { + //FIXME support Java implementations + return this; + } + + public ComponentBuilder implementedBy(CompositeBuilder composite) { + setImplementation((Composite)composite); + return this; + } + + public ComponentBuilder uses(ComponentReferenceBuilder... componentReferences) { + List references = getReferences(); + for (ComponentReferenceBuilder componentReference: componentReferences) { + references.add((ComponentReference)componentReference); + } + return this; + } + + public ComponentBuilder provides(ComponentServiceBuilder... componentServices) { + List services = getServices(); + for (ComponentServiceBuilder componentService: componentServices) { + services.add((ComponentService)componentService); + } + return this; + } + + public ComponentBuilder declares(ComponentPropertyBuilder...componentProperties) { + List properties = getProperties(); + for (ComponentPropertyBuilder componentProperty: componentProperties) { + properties.add((ComponentProperty)componentProperty); + } + return this; + } + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java new file mode 100644 index 0000000000..49f7cd46b2 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentPropertyImpl; + +public class ComponentPropertyBuilderImpl extends ComponentPropertyImpl implements ComponentPropertyBuilder { + + public ComponentPropertyBuilderImpl ofType(String type) { + //TODO handle namespace + this.setXSDType(new QName("", type)); + return this; + } + + public ComponentPropertyBuilderImpl configuredTo(Object value) { + this.setValue(value); + return this; + } + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java new file mode 100644 index 0000000000..d9aab9de22 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl.impl; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.CompositeReference; +import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl; +import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl; + +public class ComponentReferenceBuilderImpl extends ComponentReferenceImpl implements ComponentReferenceBuilder { + + private CompositeReference compositeReference; + private AssemblyFactory assemblyFactory; + + protected ComponentReferenceBuilderImpl(AssemblyFactory assemblyFactory) { + this.assemblyFactory = assemblyFactory; + } + + public ComponentReferenceBuilder wiredTo(String target) { + ComponentService componentService = assemblyFactory.createComponentService(); + componentService.setUnresolved(true); + componentService.setName(target); + getTargets().add(componentService); + return this; + } + + public ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target) { + getTargets().add((ComponentServiceImpl)target); + return this; + } + + public ComponentReferenceBuilderImpl typedBy(Class interfaceClass) { + //FIXME support for Java interfaces + return this; + } + + public ComponentReferenceBuilderImpl promotedAs(String promoted) { + compositeReference = assemblyFactory.createCompositeReference(); + compositeReference.setName(promoted); + return this; + } + + public ComponentReferenceBuilderImpl promoted() { + compositeReference = assemblyFactory.createCompositeReference(); + compositeReference.setName(getName()); + return this; + } + + public ComponentReferenceBuilder boundTo(String uri) { + //TODO support bindings + return this; + } + + CompositeReference getCompositeReference() { + return compositeReference; + } +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java new file mode 100644 index 0000000000..379429d17e --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl.impl; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl; + +public class ComponentServiceBuilderImpl extends ComponentServiceImpl implements ComponentServiceBuilder { + + private CompositeService compositeService; + private AssemblyFactory assemblyFactory; + + protected ComponentServiceBuilderImpl(AssemblyFactory assemblyFactory) { + this.assemblyFactory = assemblyFactory; + } + + public ComponentServiceBuilderImpl typedBy(Class interfaceClass) { + //FIXME support for Java interfaces + return this; + } + + public ComponentServiceBuilderImpl promotedAs(String promoted) { + compositeService = assemblyFactory.createCompositeService(); + compositeService.setName(promoted); + return this; + } + + public ComponentServiceBuilderImpl promoted() { + compositeService = assemblyFactory.createCompositeService(); + compositeService.setName(getName()); + return this; + } + + public ComponentServiceBuilder boundTo(String uri) { + // TODO support bindings + return this; + } + + CompositeService getCompositeService() { + return compositeService; + } + +} diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java new file mode 100644 index 0000000000..709562cd72 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl.impl; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder; +import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder; +import org.apache.tuscany.sca.assembly.impl.CompositeImpl; + +public class CompositeBuilderImpl extends CompositeImpl implements CompositeBuilder { + + public CompositeBuilder contains(ComponentBuilder... componentBuilders) { + List components = getComponents(); + for (ComponentBuilder componentBuilder: componentBuilders) { + Component component = (Component)componentBuilder; + components.add(component); + + for (ComponentService componentService: component.getServices()) { + ComponentServiceBuilderImpl builder = (ComponentServiceBuilderImpl)componentService; + if (builder.getCompositeService() != null) + getServices().add(builder.getCompositeService()); + } + for (ComponentReference componentReference: component.getReferences()) { + ComponentReferenceBuilderImpl builder = (ComponentReferenceBuilderImpl)componentReference; + if (builder.getCompositeReference() != null) + getReferences().add(builder.getCompositeReference()); + } + } + return this; + } + + public CompositeBuilder includes(CompositeBuilder... compositeBuilders) { + List list = getIncludes(); + for (CompositeBuilder composite: compositeBuilders) { + list.add((Composite)composite); + } + return this; + } + +} diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java new file mode 100644 index 0000000000..ba91fd2168 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +public interface AccountDataService { + +} diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java new file mode 100644 index 0000000000..4e239d03d3 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +public class AccountDataServiceImpl { + +} diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java new file mode 100644 index 0000000000..030c820ed2 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +public interface AccountService { + +} diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java new file mode 100644 index 0000000000..92f448ec87 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +public class AccountServiceImpl { + +} diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java new file mode 100644 index 0000000000..b856201551 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +import org.apache.tuscany.sca.assembly.dsl.impl.AssemblyBuilderImpl; + +public class BigBankBuilder extends AssemblyBuilderImpl { + + public CompositeBuilder build() { + + CompositeBuilder bigbankAccount = composite("bigbank.account").contains( + + component("AccountServiceComponent"). + implementedBy(AccountServiceImpl.class). + uses( + reference("accountDataService").typedBy(AccountDataService.class).wiredTo("AccountDataServiceComponent/AccountDataService"), + reference("stockQuoteService").promotedAs("StockQuoteService") + ). + provides( + service("AccountDataService").typedBy(AccountService.class).promoted() + ). + declares( + property("currency").ofType("string").configuredTo("USD") + ), + + component("AccountDataServiceComponent"). + implementedBy(AccountDataServiceImpl.class). + provides( + service("AccountDataService").typedBy(AccountDataService.class) + ) + ); + + CompositeBuilder bigbankApp = composite("bigbank.app"). + contains( + component("BigBankAccount").implementedBy(bigbankAccount) + ); + + CompositeBuilder domain = domain("http://bigbank.org").includes(bigbankApp); + + return domain; + } +} diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java new file mode 100644 index 0000000000..fb950b5c13 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.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.tuscany.sca.assembly.dsl; + +import junit.framework.TestCase; + +public class BigBankBuilderTestCase extends TestCase { + + public void testBuild() throws Exception { + + BigBankBuilder builder = new BigBankBuilder(); + CompositeBuilder domain = builder.build(); + assertNotNull(domain); + } + +} diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java new file mode 100644 index 0000000000..a0580095a0 --- /dev/null +++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.assembly.dsl; + +public interface StockQuoteService { + +} -- cgit v1.2.3