From 5e78e2a84f0cfcf141f48e58404e8c21c061b079 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:23:10 +0000 Subject: Moving 2.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835154 13f79535-47bb-0310-9956-ffa450edef68 --- .../xml/NodeConfigurationATOMProcessor.java | 160 --------- .../xml/NodeConfigurationProcessor.java | 236 ------------ .../sca/node/impl/CompositeContextImpl.java | 71 ---- .../tuscany/sca/node/impl/NodeFactoryImpl.java | 398 --------------------- .../org/apache/tuscany/sca/node/impl/NodeImpl.java | 369 ------------------- .../org/apache/tuscany/sca/node/impl/NodeUtil.java | 43 --- .../tuscany/sca/node/management/NodeManager.java | 65 ---- .../sca/node/management/NodeManagerMBean.java | 30 -- ...ca.contribution.processor.StAXArtifactProcessor | 18 - .../org.apache.tuscany.sca.node.NodeFactory | 18 - ...sca.node.configuration.NodeConfigurationFactory | 18 - .../impl/node-impl-validation-messages.properties | 22 -- .../node-impl/src/test/java/hello/HelloWorld.java | 30 -- .../src/test/java/hello/HelloWorldImpl.java | 30 -- .../xml/NodeConfigurationProcessorTestCase.java | 86 ----- .../tuscany/sca/node/impl/NodeImplTestCase.java | 107 ------ .../tuscany/sca/node/impl/NodeUtilTestCase.java | 39 -- .../src/test/resources/HelloWorld.composite | 30 -- .../test/resources/META-INF/sca-contribution.xml | 24 -- .../tuscany/sca/node/configuration/node1.xml | 58 --- 20 files changed, 1852 deletions(-) delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorld.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorldImpl.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/HelloWorld.composite delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml delete mode 100644 tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml (limited to 'tags/java/sca/2.0-M4-RC2/modules/node-impl/src') diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java deleted file mode 100644 index d11eb317cf..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java +++ /dev/null @@ -1,160 +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.tuscany.sca.node.configuration.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.node.configuration.ContributionConfiguration; -import org.apache.tuscany.sca.node.configuration.NodeConfiguration; -import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory; - -/** - * Implements a StAX artifact processor for configured node implementations. - * - * @version $Rev$ $Date$ - */ -public class NodeConfigurationATOMProcessor extends BaseStAXArtifactProcessor implements - StAXArtifactProcessor { - - private static final String ATOM_NS = "http://www.w3.org/2005/Atom"; - private static final QName FEED_QNAME = new QName(ATOM_NS, "feed"); - private static final QName ENTRY_QNAME = new QName(ATOM_NS, "entry"); - private static final QName ID_QNAME = new QName(ATOM_NS, "id"); - private static final QName LINK_QNAME = new QName(ATOM_NS, "link"); - private static final QName CONTENT_QNAME = new QName(ATOM_NS, "content"); - private static final String HREF = "href"; - - private NodeConfigurationFactory factory; - - public NodeConfigurationATOMProcessor(FactoryExtensionPoint modelFactories) { - this.factory = modelFactories.getFactory(NodeConfigurationFactory.class); - } - - public QName getArtifactType() { - return null; - } - - public Class getModelType() { - // Returns the type of model processed by this processor - return NodeConfiguration.class; - } - - public NodeConfiguration read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { - - NodeConfiguration config = factory.createNodeConfiguration(); - - // Read a feed containing links to the composite and the contributions assigned to - // the node - ContributionConfiguration contribution = null; - boolean id = false; - QName name = null; - - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - - case START_ELEMENT: - name = reader.getName(); - - if (ENTRY_QNAME.equals(name)) { - - // Read an - contribution = factory.createContributionConfiguration(); - } else if (ID_QNAME.equals(name)) { - - // Read an - id = true; - - } else if (LINK_QNAME.equals(name)) { - - // Read a - String href = getString(reader, HREF); - - if (contribution != null) { - contribution.setLocation(href); - } - } else if (CONTENT_QNAME.equals(name)) { - // Read a - } else if (FEED_QNAME.equals(name)) { - // Read a - } - break; - - case XMLStreamConstants.CHARACTERS: - - // Read characters inside an element - if (id) { - if (contribution != null) { - contribution.setURI(reader.getText()); - } - } - break; - - case END_ELEMENT: - name = reader.getName(); - - // Clear current state when reading reaching end element - if (ENTRY_QNAME.equals(name)) { - if (contribution != null) { - config.getContributions().add(contribution); - } - - contribution = null; - - } else if (ID_QNAME.equals(name)) { - id = false; - - } else if (FEED_QNAME.equals(name)) { - - // We've reached the end of the feed - return config; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - return config; - } - - public void resolve(NodeConfiguration implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { - } - - public void write(NodeConfiguration implementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - } -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java deleted file mode 100644 index 78f4fabb20..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java +++ /dev/null @@ -1,236 +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.tuscany.sca.node.configuration.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.StringTokenizer; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.common.xml.stax.StAXHelper; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.node.configuration.BindingConfiguration; -import org.apache.tuscany.sca.node.configuration.ContributionConfiguration; -import org.apache.tuscany.sca.node.configuration.DeploymentComposite; -import org.apache.tuscany.sca.node.configuration.NodeConfiguration; -import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory; - -/** - * Implements a StAX artifact processor for node implementations. - * - * @version $Rev$ $Date$ - */ -public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implements - StAXArtifactProcessor { - private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - private static final QName NODE = new QName(SCA11_TUSCANY_NS, "node"); - private static final QName CONTRIBUTION = new QName(SCA11_TUSCANY_NS, "contribution"); - private static final QName BINDING = new QName(SCA11_TUSCANY_NS, "binding"); - private static final QName BASE_URI = new QName(SCA11_TUSCANY_NS, "baseURI"); - private static final QName DEPLOYMENT_COMPOSITE = new QName(SCA11_TUSCANY_NS, "deploymentComposite"); - - private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; - private static final QName COMPOSITE = new QName(SCA11_NS, "composite"); - - private StAXArtifactProcessor processor; - private NodeConfigurationFactory nodeConfigurationFactory; - private StAXHelper helper; - - public NodeConfigurationProcessor(ExtensionPointRegistry registry, - StAXArtifactProcessor processor) { - FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); - this.nodeConfigurationFactory = modelFactories.getFactory(NodeConfigurationFactory.class); - this.processor = processor; - this.helper = StAXHelper.getInstance(registry); - } - - public QName getArtifactType() { - // Returns the QName of the XML element processed by this processor - return NODE; - } - - public Class getModelType() { - // Returns the type of model processed by this processor - return NodeConfiguration.class; - } - - public NodeConfiguration read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { - - NodeConfiguration node = null; - ContributionConfiguration contribution = null; - DeploymentComposite composite = null; - BindingConfiguration binding = null; - - // Skip to end element - while (true) { - int event = reader.getEventType(); - switch (event) { - case XMLStreamConstants.START_ELEMENT: - QName name = reader.getName(); - if (NODE.equals(name)) { - node = nodeConfigurationFactory.createNodeConfiguration(); - node.setURI(reader.getAttributeValue(null, "uri")); - node.setDomainURI(reader.getAttributeValue(null, "domain")); - node.setDomainRegistryURI(reader.getAttributeValue(null, "domainRegistry")); - } else if (CONTRIBUTION.equals(name)) { - contribution = nodeConfigurationFactory.createContributionConfiguration(); - contribution.setURI(reader.getAttributeValue(null, "uri")); - contribution.setLocation(reader.getAttributeValue(null, "location")); - node.getContributions().add(contribution); - } else if (BINDING.equals(name)) { - binding = nodeConfigurationFactory.createBindingConfiguration(); - binding.setBindingType(getQName(reader, "name")); - String baseURIs = reader.getAttributeValue(null, "baseURIs"); - if (baseURIs != null) { - StringTokenizer tokenizer = new StringTokenizer(baseURIs); - while (tokenizer.hasMoreTokens()) { - binding.getBaseURIs().add(tokenizer.nextToken()); - } - } - node.getBindings().add(binding); - } else if (DEPLOYMENT_COMPOSITE.equals(name)) { - composite = nodeConfigurationFactory.createDeploymentComposite(); - composite.setLocation(reader.getAttributeValue(null, "location")); - if (contribution != null) { - contribution.getDeploymentComposites().add(composite); - } - } else if(BASE_URI.equals(name)) { - // We also support element - String baseURI = reader.getElementText(); - if (baseURI != null && binding != null) { - baseURI = baseURI.trim(); - binding.addBaseURI(baseURI); - } - // getElementText() moves the event to END_ELEMENT - continue; - } else if (COMPOSITE.equals(name)) { - /* - Object model = processor.read(reader); - if (model instanceof Composite) { - // FIXME: We need to capture the text here - // composite.setComposite((Composite)model); - } - */ - StringWriter sw = new StringWriter(); - XMLStreamWriter writer = helper.createXMLStreamWriter(sw); - helper.save(reader, writer); - composite.setContent(sw.toString()); - } else { - node.getExtensions().add(processor.read(reader, context)); - } - break; - - case END_ELEMENT: - name = reader.getName(); - if (NODE.equals(name)) { - return node; - } else if (CONTRIBUTION.equals(name)) { - contribution = null; - } else if (DEPLOYMENT_COMPOSITE.equals(name)) { - composite = null; - } else if (BINDING.equals(name)) { - binding = null; - } - } - if (reader.hasNext()) { - reader.next(); - } else { - break; - } - } - - return node; - } - - public void resolve(NodeConfiguration node, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { - } - - public void write(NodeConfiguration node, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - - writeStart(writer, - NODE.getNamespaceURI(), - NODE.getLocalPart(), - new XAttr("uri", node.getURI()), - new XAttr("domainRegistry", node.getDomainRegistryURI()), - new XAttr("domain", node.getDomainURI())); - - for (ContributionConfiguration c : node.getContributions()) { - writeStart(writer, - CONTRIBUTION.getNamespaceURI(), - CONTRIBUTION.getLocalPart(), - new XAttr("uri", c.getURI()), - new XAttr("location", c.getLocation())); - for (DeploymentComposite dc : c.getDeploymentComposites()) { - writeStart(writer, - DEPLOYMENT_COMPOSITE.getNamespaceURI(), - DEPLOYMENT_COMPOSITE.getLocalPart(), - new XAttr("location", dc.getLocation()), - new XAttr("contribution", dc.getContributionURI())); - if (dc.getContent() != null) { - XMLStreamReader reader = helper.createXMLStreamReader(new StringReader(dc.getContent())); - reader.nextTag(); // Move to the first element - helper.save(reader, writer); - reader.close(); - } - writeEnd(writer); - } - writeEnd(writer); - } - - for (BindingConfiguration b : node.getBindings()) { - StringBuffer uris = new StringBuffer(); - for (String uri : b.getBaseURIs()) { - uris.append(uri).append(' '); - } - if (uris.length() > 0) { - uris.deleteCharAt(uris.length() - 1); // Remove the trailing space - } else { - uris = null; - } - writeStart(writer, - BINDING.getNamespaceURI(), - BINDING.getLocalPart(), - new XAttr("name", b.getBindingType()), - new XAttr("baseURIs", uris.toString())); - writeEnd(writer); - } - - for(Object o: node.getExtensions()) { - processor.write(o, writer, context); - } - - writeEnd(writer); - } -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java deleted file mode 100644 index 604bb502f9..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java +++ /dev/null @@ -1,71 +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.tuscany.sca.node.impl; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.context.ComponentContextFactory; -import org.apache.tuscany.sca.context.CompositeContext; -import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.runtime.EndpointRegistry; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentContext; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeContextImpl extends CompositeContext { - private final ExtensionPointRegistry extensionPointRegistry; - private final EndpointRegistry endpointRegistry; - private final ComponentContextFactory componentContextFactory; - private final Composite domainComposite; - - public CompositeContextImpl(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite) { - this.extensionPointRegistry = registry; - this.endpointRegistry = endpointRegistry; - ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class); - this.componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class); - this.domainComposite = domainComposite; - } - - public ExtensionPointRegistry getExtensionPointRegistry() { - return extensionPointRegistry; - } - - public EndpointRegistry getEndpointRegistry() { - return endpointRegistry; - } - - public void bindComponent(RuntimeComponent runtimeComponent) { - RuntimeComponentContext componentContext = - (RuntimeComponentContext)componentContextFactory.createComponentContext(this, runtimeComponent); - runtimeComponent.setComponentContext(componentContext); - } - - public void bindEndpointReference(EndpointReference endpointReference) { - - } - - public Composite getDomainComposite() { - return domainComposite; - } - -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java deleted file mode 100644 index e4e2386667..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ /dev/null @@ -1,398 +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.tuscany.sca.node.impl; - -import static java.lang.System.currentTimeMillis; -import static org.apache.tuscany.sca.common.java.io.IOHelper.createURI; -import static org.apache.tuscany.sca.common.java.io.IOHelper.openStream; - -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.net.URI; -import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.common.java.io.IOHelper; -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory; -import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; -import org.apache.tuscany.sca.deployment.Deployer; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; -import org.apache.tuscany.sca.node.configuration.BindingConfiguration; -import org.apache.tuscany.sca.node.configuration.ContributionConfiguration; -import org.apache.tuscany.sca.node.configuration.DeploymentComposite; -import org.apache.tuscany.sca.node.configuration.NodeConfiguration; -import org.apache.tuscany.sca.work.WorkScheduler; -import org.oasisopen.sca.ServiceRuntimeException; - -/** - * This class provides a node factory that can create multiple nodes that share the same - * extension point registry - */ -public class NodeFactoryImpl extends NodeFactory { - protected static final Logger logger = Logger.getLogger(NodeImpl.class.getName()); - - protected boolean inited; - protected Map nodes = new ConcurrentHashMap(); - - protected Deployer deployer; - protected ExtensionPointRegistry registry; - protected ProxyFactory proxyFactory; - protected MonitorFactory monitorFactory; - - - /** - * Automatically destroy the factory when last node is stopped. Subclasses - * can set this flag. - */ - protected boolean autoDestroy = true; - - @Override - public Node createNode(NodeConfiguration configuration) { - return new NodeImpl(this, configuration); - } - - protected Node removeNode(NodeConfiguration configuration) { - Node node = nodes.remove(getNodeKey(configuration)); - if (autoDestroy && nodes.isEmpty()) { - destroy(); - } - return node; - } - - protected void addNode(NodeConfiguration configuration, Node node) { - nodes.put(getNodeKey(configuration), node); - } - - @Override - public NodeConfiguration loadConfiguration(InputStream xml, URL base) { - try { - init(); - InputStreamReader reader = new InputStreamReader(xml, "UTF-8"); - ProcessorContext context = deployer.createProcessorContext(); - NodeConfiguration config = deployer.loadXMLDocument(reader, context.getMonitor()); - if (base != null && config != null) { - // Resolve the contribution location against the node.xml - for (ContributionConfiguration c : config.getContributions()) { - String location = c.getLocation(); - if (location != null) { - URL url = new URL(base, location); - url = IOHelper.normalize(url); - c.setLocation(url.toString()); - } - } - } - return config; - } catch (Throwable e) { - throw new ServiceRuntimeException(e); - } - } - - public Map getNodes() { - return nodes; - } - - protected Object getNodeKey(NodeConfiguration configuration) { - return new NodeKey(configuration); - } - - public synchronized void destroy() { - if (inited) { - for (Node node : nodes.values()) { - node.stop(); - node.destroy(); - } - nodes.clear(); - deployer.stop(); - registry.stop(); - super.destroy(); - inited = false; - } - } - - /** - * Analyze problems reported by the artifact processors and builders. - * - * @throws Exception - */ - private void analyzeProblems(Monitor monitor) throws Throwable { - try { - for (Problem problem : monitor.getProblems()) { - if ((problem.getSeverity() == Severity.ERROR)) { - if (problem.getCause() != null) { - throw problem.getCause(); - } else { - throw new ServiceRuntimeException(problem.toString()); - } - } - } - } finally { - // FIXME: Clear problems so that the monitor is clean again - monitor.reset(); - } - } - - private boolean attachDeploymentComposite(Contribution contribution, Reader xml, String location, boolean attached, ProcessorContext context) - throws XMLStreamException, ContributionReadException { - - // Read the composite model - Composite composite = deployer.loadXMLDocument(xml, context.getMonitor()); - - // Replace the deployable composites with the deployment composites - // Clear the deployable composites if it's the first deployment composite - deployer.attachDeploymentComposite(contribution, composite, attached); - if (!attached) { - attached = true; - } - return attached; - } - - public ExtensionPointRegistry getExtensionPoints() { - return registry; - } - - public synchronized void init() { - if (inited) { - return; - } - long start = currentTimeMillis(); - - if (registry == null) { - // Create extension point registry - registry = createExtensionPointRegistry(); - registry.start(); - } - - // Use the runtime-enabled assembly factory - FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = new RuntimeAssemblyFactory(registry); - modelFactories.addFactory(assemblyFactory); - - UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); - monitorFactory = utilities.getUtility(MonitorFactory.class); - - // Load the Deployer - deployer = utilities.getUtility(Deployer.class); - - // Enable schema validation only of the logger level is FINE or higher - deployer.setSchemaValidationEnabled(isSchemaValidationEnabled()); - - // Initialize the Tuscany module activators - // The module activators will be started - registry.getExtensionPoint(ModuleActivatorExtensionPoint.class); - - // Initialize runtime - - // Get proxy factory - ProxyFactoryExtensionPoint proxyFactories = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class); - proxyFactory = new ExtensibleProxyFactory(proxyFactories); - - utilities.getUtility(WorkScheduler.class); - - inited = true; - - if (logger.isLoggable(Level.FINE)) { - long end = currentTimeMillis(); - logger.fine("The tuscany runtime started in " + (end - start) + " ms."); - } - } - - protected ExtensionPointRegistry createExtensionPointRegistry() { - return new DefaultExtensionPointRegistry(); - } - - protected boolean isSchemaValidationEnabled() { - String enabled = getSystemProperty(ValidationSchemaExtensionPoint.class.getName() + ".enabled"); - if (enabled == null) { - enabled = "true"; - } - boolean debug = logger.isLoggable(Level.FINE); - return "true".equals(enabled) || debug; - } - - protected Composite configureNode(NodeConfiguration configuration, List contributions, ProcessorContext context) - throws Throwable { - if (contributions == null) { - // Load contributions - contributions = loadContributions(configuration, context); - } - - Monitor monitor = context.getMonitor(); - Map> bindingBaseURIs = new HashMap>(); - for (BindingConfiguration config : configuration.getBindings()) { - bindingBaseURIs.put(config.getBindingType(), config.getBaseURIs()); - } - Composite domainComposite = deployer.build(contributions, bindingBaseURIs, monitor); - analyzeProblems(monitor); - - return domainComposite; - } - - protected List loadContributions(NodeConfiguration configuration, ProcessorContext context) throws Throwable { - List contributions = new ArrayList(); - - // Load the specified contributions - for (ContributionConfiguration contrib : configuration.getContributions()) { - URI contributionURI = createURI(contrib.getURI()); - - URI uri = createURI(contrib.getLocation()); - if (uri.getScheme() == null) { - uri = new File(contrib.getLocation()).toURI(); - } - URL contributionURL = uri.toURL(); - - // Load the contribution - logger.log(Level.INFO, "Loading contribution: " + contributionURL); - Contribution contribution = deployer.loadContribution(contributionURI, contributionURL, context.getMonitor()); - contributions.add(contribution); - - boolean attached = false; - for (DeploymentComposite dc : contrib.getDeploymentComposites()) { - if (dc.getContent() != null) { - Reader xml = new StringReader(dc.getContent()); - attached = attachDeploymentComposite(contribution, xml, null, attached, context); - } else if (dc.getLocation() != null) { - URI dcURI = createURI(dc.getLocation()); - if (!dcURI.isAbsolute()) { - Composite composite = null; - // The location is pointing to an artifact within the contribution - for (Artifact a : contribution.getArtifacts()) { - if (dcURI.toString().equals(a.getURI())) { - composite = (Composite)a.getModel(); - if (!attached) { - contribution.getDeployables().clear(); - attached = true; - } - contribution.getDeployables().add(composite); - break; - } - } - if (composite == null) { - // Not found - throw new ServiceRuntimeException("Deployment composite " + dcURI - + " cannot be found within contribution " - + contribution.getLocation()); - } - } else { - URL url = dcURI.toURL(); - InputStream is = openStream(url); - Reader xml = new InputStreamReader(is, "UTF-8"); - attached = attachDeploymentComposite(contribution, xml, url.toString(), attached, context); - } - } - } - analyzeProblems(context.getMonitor()); - } - return contributions; - } - - protected static String getSystemProperty(final String name) { - return AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - return System.getProperty(name); - } - }); - } - - protected static class NodeKey { - private String domainURI; - private String nodeURI; - - public NodeKey(NodeConfiguration configuration) { - this.domainURI = configuration.getDomainURI(); - this.nodeURI = configuration.getURI(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((domainURI == null) ? 0 : domainURI.hashCode()); - result = prime * result + ((nodeURI == null) ? 0 : nodeURI.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NodeKey other = (NodeKey)obj; - if (domainURI == null) { - if (other.domainURI != null) - return false; - } else if (!domainURI.equals(other.domainURI)) - return false; - if (nodeURI == null) { - if (other.nodeURI != null) - return false; - } else if (!nodeURI.equals(other.nodeURI)) - return false; - return true; - } - - public String toString() { - StringBuffer buf = new StringBuffer(); - if (domainURI != null) { - buf.append("{").append(domainURI).append("}"); - } - if (nodeURI != null) { - buf.append(nodeURI); - } - return buf.toString(); - } - } - -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java deleted file mode 100644 index 4be947f125..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ /dev/null @@ -1,369 +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.tuscany.sca.node.impl; - -import java.io.ByteArrayOutputStream; -//import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -//import javax.management.MBeanServer; -import javax.xml.stream.XMLOutputFactory; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.common.java.io.IOHelper; -import org.apache.tuscany.sca.context.CompositeContext; -import org.apache.tuscany.sca.context.ThreadMessageContext; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.node.Client; -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFinder; -import org.apache.tuscany.sca.node.configuration.NodeConfiguration; -import org.apache.tuscany.sca.node.management.NodeManager; -import org.apache.tuscany.sca.runtime.ActivationException; -import org.apache.tuscany.sca.runtime.CompositeActivator; -import org.apache.tuscany.sca.runtime.DomainRegistryFactory; -import org.apache.tuscany.sca.runtime.EndpointRegistry; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentContext; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.oasisopen.sca.ServiceReference; -import org.oasisopen.sca.ServiceRuntimeException; -import org.oasisopen.sca.ServiceUnavailableException; - -/** - * An SCA Node that is managed by the NodeManager - */ -public class NodeImpl implements Node, Client { - private static final Logger logger = Logger.getLogger(NodeImpl.class.getName()); - private ProxyFactory proxyFactory; - private CompositeActivator compositeActivator; - private CompositeContext compositeContext; - private Composite domainComposite; - private NodeConfiguration configuration; - private NodeFactoryImpl manager; - private List contributions; - private NodeManager mbean; - - /** - * Create a node from the configuration - * @param manager - * @param configuration - */ - public NodeImpl(NodeFactoryImpl manager, NodeConfiguration configuration) { - super(); - this.configuration = configuration; - this.manager = manager; - } - - /** - * Create a node from the configuration and loaded contributions - * @param manager - * @param configuration - * @param contributions - */ - public NodeImpl(NodeFactoryImpl manager, NodeConfiguration configuration, List contributions) { - super(); - this.configuration = configuration; - this.manager = manager; - this.contributions = new ArrayList(contributions); - } - - public String getURI() { - return getConfiguration().getURI(); - } - - public void destroy() { - } - - public Node start() { - logger.log(Level.INFO, "Starting node: " + configuration.getURI() + " domain: " + configuration.getDomainName()); - - manager.init(); - manager.addNode(configuration, this); - this.proxyFactory = manager.proxyFactory; - UtilityExtensionPoint utilities = manager.registry.getExtensionPoint(UtilityExtensionPoint.class); - - DomainRegistryFactory domainRegistryFactory = utilities.getUtility(DomainRegistryFactory.class); - EndpointRegistry endpointRegistry = - domainRegistryFactory.getEndpointRegistry(configuration.getDomainRegistryURI(), configuration - .getDomainURI()); - - this.compositeActivator = utilities.getUtility(CompositeActivator.class); - try { - Monitor monitor = manager.monitorFactory.createMonitor(); - ProcessorContext context = new ProcessorContext(monitor); - - // Set up the thead context monitor - Monitor tcm = manager.monitorFactory.setContextMonitor(monitor); - try { - if (contributions == null) { - contributions = manager.loadContributions(configuration, context); - } - domainComposite = manager.configureNode(configuration, contributions, context); - - this.compositeContext = - new CompositeContextImpl(manager.registry, endpointRegistry, domainComposite); - } finally { - // Reset the thread context monitor - manager.monitorFactory.setContextMonitor(tcm); - } - - // Activate the composite - compositeActivator.activate(compositeContext, domainComposite); - - // Start the composite - compositeActivator.start(compositeContext, domainComposite); - - NodeFinder.addNode(IOHelper.createURI(configuration.getDomainURI()), this); - - // FIXME: [rfeng] We should turn the management capability into a system utility. - // In certain environment such as Google App Engine, the JMX API is not allowed - try { - /* - MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); - mbean = new NodeManager(this); - mBeanServer.registerMBean(mbean, mbean.getName()); - */ - /* - LocateRegistry.createRegistry(9999); - JMXServiceURL url = - new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server"); - JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mBeanServer); - connectorServer.start(); - */ - } catch (Throwable e) { - // Ignore the error for now - mbean = null; - logger.log(Level.SEVERE, e.getMessage(), e); - } - - return this; - - } catch (Throwable e) { - throw new IllegalStateException(e); - } - - } - - public void stop() { - logger.log(Level.INFO, "Stopping node: " + configuration.getURI()); - - try { - if (compositeActivator == null) { - return; - } - - /* - if (mbean != null) { - try { - MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); - mBeanServer.unregisterMBean(mbean.getName()); - } catch (Throwable e) { - logger.log(Level.SEVERE, e.getMessage(), e); - } finally { - mbean = null; - } - } - */ - - NodeFinder.removeNode(this); - if( domainComposite != null ) { - - // Stop the composite - compositeActivator.stop(compositeContext, domainComposite); - - // Deactivate the composite - compositeActivator.deactivate(domainComposite); - - } // end if - - manager.removeNode(configuration); - manager.registry.getExtensionPoint(UtilityExtensionPoint.class).removeUtility(compositeActivator); - this.compositeActivator = null; - this.proxyFactory = null; - this.domainComposite = null; - this.compositeContext = null; - - ThreadMessageContext.removeMessageContext(); - - } catch (ActivationException e) { - throw new IllegalStateException(e); - } - - } - - @SuppressWarnings("unchecked") - public > R cast(B target) throws IllegalArgumentException { - return (R)proxyFactory.cast(target); - } - - public B getService(Class businessInterface, String serviceName) { - - ServiceReference serviceReference = getServiceReference(businessInterface, serviceName); - if (serviceReference == null) { - throw new ServiceRuntimeException("Service not found: " + serviceName); - } - return serviceReference.getService(); - } - - public ServiceReference getServiceReference(Class businessInterface, String name) { - - // Extract the component name - String componentName; - String serviceName; - int i = name.indexOf('/'); - if (i != -1) { - componentName = name.substring(0, i); - serviceName = name.substring(i + 1); - - } else { - componentName = name; - serviceName = null; - } - - // Lookup the component - Component component = null; - - for (Component compositeComponent : domainComposite.getComponents()) { - if (compositeComponent.getName().equals(componentName)) { - component = compositeComponent; - } - } - - if (component == null) { - throw new ServiceUnavailableException("The service " + name + " has not been contributed to the domain"); - } - RuntimeComponentContext componentContext = null; - - // If the component is a composite, then we need to find the - // non-composite component that provides the requested service - if (component.getImplementation() instanceof Composite) { - for (ComponentService componentService : component.getServices()) { - if (serviceName == null || serviceName.equals(componentService.getName())) { - CompositeService compositeService = (CompositeService)componentService.getService(); - if (compositeService != null) { - componentContext = - ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext(); - return componentContext.createSelfReference(businessInterface, compositeService - .getPromotedService()); - } - break; - } - } - // No matching service found - throw new ServiceRuntimeException("Composite service not found: " + name); - } else { - componentContext = ((RuntimeComponent)component).getComponentContext(); - if (serviceName != null) { - return componentContext.createSelfReference(businessInterface, serviceName); - } else { - return componentContext.createSelfReference(businessInterface); - } - } - } - - public NodeConfiguration getConfiguration() { - return configuration; - } - - public ExtensionPointRegistry getExtensionPoints() { - return manager.getExtensionPoints(); - } - - /** - * Get the service endpoints in this Node - * TODO: needs review, works for the very simple testcase but i expect there are - * other endpoints to be included - */ - public List getServiceEndpoints() { - List endpoints = new ArrayList(); - if (compositeActivator != null) { - if (domainComposite != null) { - for (Component component : domainComposite.getComponents()) { - for (Service service : component.getServices()) { - // MJE 28/05/2009 - changed to RuntimeComponentService from RuntimeComponentServiceImpl - // - no need to access the Impl directly here - if (service instanceof RuntimeComponentService) { - endpoints.addAll(((RuntimeComponentService)service).getEndpoints()); - } - } - } - } - } - return endpoints; - } - - public Composite getDomainComposite() { - return domainComposite; - } - - public String dumpDomainComposite() { - - StAXArtifactProcessorExtensionPoint xmlProcessors = - getExtensionPoints().getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - StAXArtifactProcessor compositeProcessor = - xmlProcessors.getProcessor(Composite.class); - - return writeComposite(getDomainComposite(), compositeProcessor); - } - - private String writeComposite(Composite composite, StAXArtifactProcessor compositeProcessor){ - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - XMLOutputFactory outputFactory = - manager.getExtensionPoints().getExtensionPoint(FactoryExtensionPoint.class) - .getFactory(XMLOutputFactory.class); - - try { - compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(manager.registry)); - } catch(Exception ex) { - return ex.toString(); - } - - String result = bos.toString(); - - // write out and nested composites - for (Component component : composite.getComponents()) { - if (component.getImplementation() instanceof Composite) { - result += - "\n\n" + writeComposite((Composite)component - .getImplementation(), - compositeProcessor); - } - } - - return result; - } -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java deleted file mode 100644 index 4da41442f5..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java +++ /dev/null @@ -1,43 +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.tuscany.sca.node.impl; - -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.ContributionFactory; - -/** - * NodeUtil - * - * @version $Rev$ $Date$ - */ -public class NodeUtil { - - private NodeUtil() { - } - - static Contribution contribution(ContributionFactory contributionFactory, org.apache.tuscany.sca.node.Contribution c) { - Contribution contribution = contributionFactory.createContribution(); - contribution.setURI(c.getURI()); - contribution.setLocation(c.getLocation()); - contribution.setUnresolved(true); - return contribution; - } - -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java deleted file mode 100644 index 12704a3ee5..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java +++ /dev/null @@ -1,65 +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.tuscany.sca.node.management; - -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; - -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.impl.NodeImpl; - -/** - * MBean implementation for the node - */ -public class NodeManager implements NodeManagerMBean { - private NodeImpl node; - private ObjectName name; - - public NodeManager(NodeImpl node) { - this.node = node; - try { - this.name = getName(node); - } catch (MalformedObjectNameException e) { - // Ignore - } - } - - public String getURI() { - return node.getURI(); - } - - public String getDomainURI() { - return node.getConfiguration().getDomainURI(); - } - - public ObjectName getName() { - return name; - } - - private static ObjectName getName(NodeImpl node) throws MalformedObjectNameException { - String name = - Node.class.getPackage().getName() + ":type=" - + Node.class.getSimpleName() - + ",uri=" - + ObjectName.quote(node.getURI()); - return ObjectName.getInstance(name); - - } -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java deleted file mode 100644 index 3133142c2b..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.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.tuscany.sca.node.management; - - - -/** - * MBean for NodeImpl - */ -public interface NodeManagerMBean { - String getURI(); - String getDomainURI(); -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index a9d0f5ef52..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,18 +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. -org.apache.tuscany.sca.node.configuration.xml.NodeConfigurationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#node,model=org.apache.tuscany.sca.node.configuration.NodeConfiguration - diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory deleted file mode 100644 index a349dd7c26..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory +++ /dev/null @@ -1,18 +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. -org.apache.tuscany.sca.node.impl.NodeFactoryImpl - diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory deleted file mode 100644 index 9b26d0c7c1..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory +++ /dev/null @@ -1,18 +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. -org.apache.tuscany.sca.node.configuration.DefaultNodeConfigurationFactory - diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties deleted file mode 100644 index 0c07a3a30f..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties +++ /dev/null @@ -1,22 +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. -# -# - -UnresolvedImport = Unresolved import: Import = {0} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorld.java deleted file mode 100644 index e3fcdfd25f..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorld.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 hello; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * HelloWorld interface - */ -@Remotable -public interface HelloWorld { - String hello(String name); -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorldImpl.java deleted file mode 100644 index c9a7560b12..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorldImpl.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 hello; - -/** - * HelloWorldImpl - */ -public class HelloWorldImpl implements HelloWorld { - public String hello(String name) { - System.out.println("Hello: " + name); - return "Hello, " + name; - } -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java deleted file mode 100644 index a10f2cccd4..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java +++ /dev/null @@ -1,86 +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.tuscany.sca.node.configuration.xml; - -import java.io.InputStream; -import java.io.StringWriter; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.node.configuration.NodeConfiguration; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - */ -public class NodeConfigurationProcessorTestCase { - private static FactoryExtensionPoint factories; - private static StAXArtifactProcessor processor; - - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(registry); - - factories = new DefaultFactoryExtensionPoint(registry); - StAXArtifactProcessorExtensionPoint processors = - registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - processor = processors.getProcessor(NodeConfiguration.class); - } - - @Test - public void testRead() throws Exception { - InputStream is = getClass().getResourceAsStream("/org/apache/tuscany/sca/node/configuration/node1.xml"); - XMLInputFactory xmlInputFactory = factories.getFactory(XMLInputFactory.class); - XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(is); - is.close(); - reader.nextTag(); - NodeConfiguration config = (NodeConfiguration) processor.read(reader, context); - StringWriter sw = new StringWriter(); - XMLOutputFactory xmlOutputFactory = factories.getFactory(XMLOutputFactory.class); - xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE); - XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(sw); - processor.write(config, writer, context); - writer.flush(); - System.out.println(sw.toString()); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java deleted file mode 100644 index aa7933630a..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java +++ /dev/null @@ -1,107 +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.tuscany.sca.node.impl; - -import hello.HelloWorld; - -import java.io.File; -import java.io.StringReader; -import java.net.MalformedURLException; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.node.Contribution; -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test case for NodeImpl - */ -public class NodeImplTestCase { - private static String composite = - "" - + " " - + " " - + " " - + " "; - - @Test - public void testNodeWithCompositeContent() { - NodeFactory factory = new NodeFactoryImpl(); - Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString()); - Node node = factory.createNode(new StringReader(composite), contribution); - testNode2(node); - } - - @Test - public void testNodeWithRelativeCompositeURI() { - NodeFactory factory = new NodeFactoryImpl(); - Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString()); - String compositeURI = "HelloWorld.composite"; - Node node = factory.createNode(compositeURI, contribution); - testNode(node); - } - - @SuppressWarnings("deprecation") - @Test - public void testNodeWithAbsoluteCompositeURI() throws MalformedURLException { - NodeFactory factory = new NodeFactoryImpl(); - Contribution contribution = new Contribution("c1", new File("target/test-classes").toURL().toString()); - String compositeURI = new File("target/test-classes/HelloWorld.composite").toURL().toString(); - Node node = factory.createNode(compositeURI, contribution); - testNode(node); - } - - @Test - public void testDefaultNode() { - testNode(new NodeFactoryImpl().createNode()); - } - - @Test - public void testGetServiceEndpoints() { - NodeFactory factory = new NodeFactoryImpl(); - Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString()); - NodeImpl node = (NodeImpl)factory.createNode(new StringReader(composite), contribution); - node.start(); - List es = node.getServiceEndpoints(); - Assert.assertEquals(1, es.size()); - Assert.assertEquals("HelloWorld2", es.get(0).getComponent().getName()); - node.stop(); - } - - private void testNode(Node node) { - node.start(); - HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld"); - Assert.assertEquals("Hello, Node", hw.hello("Node")); - node.stop(); - } - - private void testNode2(Node node) { - node.start(); - HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld2"); - Assert.assertEquals("Hello, Node", hw.hello("Node")); - node.stop(); - } -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java deleted file mode 100644 index 5a47465702..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.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.tuscany.sca.node.impl; - -import org.apache.tuscany.sca.common.java.io.IOHelper; -import org.junit.Assert; -import org.junit.Test; - - -/** - * - */ -public class NodeUtilTestCase { - @Test - public void testCreateURI() { - Assert.assertEquals("/a/b", IOHelper.createURI("/a/b").toString()); - Assert.assertEquals("/a%20b", IOHelper.createURI("/a b").toString()); - Assert.assertEquals("file:/a/b", IOHelper.createURI("file:/a/b").toString()); - Assert.assertEquals("file:/a%20b", IOHelper.createURI("file:/a b").toString()); - Assert.assertEquals("file:/a%20b", IOHelper.createURI("file:/a%20b").toString()); - } -} diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/HelloWorld.composite deleted file mode 100644 index efe43cbf2f..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/HelloWorld.composite +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml deleted file mode 100644 index 1149eb5cbf..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml deleted file mode 100644 index 5b2835c434..0000000000 --- a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - http://localhost:8080/jsonrpc - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3