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 +++++++++++++++++ 12 files changed, 581 insertions(+) create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java create mode 100644 sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java (limited to 'sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl') diff --git a/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java b/sandbox/sebastien/java/sca-node/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/sandbox/sebastien/java/sca-node/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; + } + +} -- cgit v1.2.3