From 1fb6a28a73ca17dbb8c4b3059db590e2f9620943 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 3 Aug 2011 09:21:41 +0000 Subject: Correct tag name git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1153404 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/contribution/Artifact.java | 74 --- .../apache/tuscany/sca/contribution/Constants.java | 32 -- .../tuscany/sca/contribution/ContentType.java | 40 -- .../tuscany/sca/contribution/Contribution.java | 132 ----- .../sca/contribution/ContributionFactory.java | 73 --- .../sca/contribution/ContributionMetadata.java | 56 -- .../contribution/DefaultContributionFactory.java | 32 -- .../tuscany/sca/contribution/DefaultExport.java | 30 - .../tuscany/sca/contribution/DefaultImport.java | 30 - .../DefaultModelFactoryExtensionPoint.java | 130 ----- .../tuscany/sca/contribution/DeployedArtifact.java | 29 - .../apache/tuscany/sca/contribution/Export.java | 48 -- .../apache/tuscany/sca/contribution/Import.java | 57 -- .../contribution/ModelFactoryExtensionPoint.java | 54 -- .../tuscany/sca/contribution/PackageType.java | 57 -- .../sca/contribution/impl/ArtifactImpl.java | 94 ---- .../contribution/impl/ContributionFactoryImpl.java | 67 --- .../sca/contribution/impl/ContributionImpl.java | 164 ------ .../impl/ContributionMetadataImpl.java | 65 --- .../sca/contribution/impl/DefaultExportImpl.java | 46 -- .../sca/contribution/impl/DefaultImportImpl.java | 56 -- .../contribution/processor/ArtifactProcessor.java | 48 -- .../processor/ArtifactProcessorExtensionPoint.java | 58 -- .../processor/BaseStAXArtifactProcessor.java | 618 --------------------- .../DefaultArtifactProcessorExtensionPoint.java | 66 --- .../DefaultPackageProcessorExtensionPoint.java | 129 ----- ...DefaultStAXArtifactProcessorExtensionPoint.java | 392 ------------- ...efaultStAXAttributeProcessorExtensionPoint.java | 327 ----------- .../DefaultURLArtifactProcessorExtensionPoint.java | 244 -------- .../DefaultValidatingXMLInputFactory.java | 317 ----------- .../DefaultValidationSchemaExtensionPoint.java | 95 ---- .../processor/ExtensiblePackageProcessor.java | 99 ---- .../processor/ExtensibleStAXArtifactProcessor.java | 264 --------- .../ExtensibleStAXAttributeProcessor.java | 247 -------- .../processor/ExtensibleURLArtifactProcessor.java | 143 ----- .../contribution/processor/PackageProcessor.java | 70 --- .../processor/PackageProcessorExtensionPoint.java | 50 -- .../processor/StAXArtifactProcessor.java | 61 -- .../StAXArtifactProcessorExtensionPoint.java | 29 - .../processor/StAXAttributeProcessor.java | 63 --- .../StAXAttributeProcessorExtensionPoint.java | 29 - .../processor/TuscanyNamespaceContext.java | 111 ---- .../processor/TuscanyXMLStreamReader.java | 131 ----- .../processor/URLArtifactProcessor.java | 51 -- .../URLArtifactProcessorExtensionPoint.java | 29 - .../processor/ValidatingXMLInputFactory.java | 42 -- .../processor/ValidatingXMLStreamReader.java | 396 ------------- .../processor/ValidationSchemaExtensionPoint.java | 52 -- .../sca/contribution/resolver/ClassReference.java | 107 ---- .../resolver/DefaultDelegatingModelResolver.java | 68 --- .../resolver/DefaultImportAllModelResolver.java | 80 --- .../resolver/DefaultImportModelResolver.java | 69 --- .../resolver/DefaultModelResolver.java | 66 --- .../DefaultModelResolverExtensionPoint.java | 117 ---- .../resolver/ExtensibleModelResolver.java | 213 ------- .../sca/contribution/resolver/ModelResolver.java | 69 --- .../resolver/ModelResolverExtensionPoint.java | 52 -- .../contribution/resolver/ResolverExtension.java | 45 -- .../contribution/resolver/ResourceReference.java | 103 ---- .../contribution/scanner/ContributionScanner.java | 65 --- .../scanner/ContributionScannerExtensionPoint.java | 50 -- .../DefaultContributionScannerExtensionPoint.java | 125 ----- .../service/ContributionException.java | 45 -- .../contribution/service/ContributionListener.java | 58 -- .../ContributionListenerExtensionPoint.java | 44 -- .../service/ContributionReadException.java | 94 ---- .../service/ContributionRepository.java | 128 ----- .../service/ContributionResolveException.java | 41 -- .../service/ContributionRuntimeException.java | 44 -- .../contribution/service/ContributionService.java | 137 ----- .../service/ContributionWriteException.java | 61 -- .../DefaultContributionListenerExtensionPoint.java | 118 ---- .../service/ExtensibleContributionListener.java | 77 --- .../sca/contribution/service/TypeDescriber.java | 38 -- .../service/UnrecognizedElementException.java | 48 -- .../service/UnsupportedContentTypeException.java | 42 -- .../service/UnsupportedPackageTypeException.java | 39 -- 77 files changed, 7770 deletions(-) delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DeployedArtifact.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ModelFactoryExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyNamespaceContext.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java (limited to 'sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca') diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java deleted file mode 100644 index 84a6a9a8f9..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java +++ /dev/null @@ -1,74 +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.contribution; - -import org.apache.tuscany.sca.assembly.Base; - - -/** - * Represents an artifact in an SCA contribution. - * - * @version $Rev$ $Date$ - */ -public interface Artifact extends Base { - - /** - * Returns the URI that unique identifies the artifact inside the contribution. - * - * @return The artifact URI - */ - String getURI(); - - /** - * Sets the URI that uniquely identifies the artifact inside the contribution. - * - * @param uri The artifact URI - */ - void setURI(String uri); - - /** - * Returns the location of the artifact. - * - * @return The artifact location - */ - String getLocation(); - - /** - * Set the location of the artifact. - * - * @param location The artifact location - */ - void setLocation(String location); - - - /** - * Returns the in-memory model representing the artifact. - * - * @return The model object - */ - Object getModel(); - - /** - * Sets the in-memory model representing the artifact. - * - * @param model The model object - */ - void setModel(Object model); -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java deleted file mode 100644 index 14131a9806..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java +++ /dev/null @@ -1,32 +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.contribution; - -/** - * Constants used in SCA contribution. - * - * @version $Rev$ $Date$ - */ -public interface Constants { - String XMLSCHEMA_NS = "http://www.w3.org/2001/XMLSchema"; - - String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0"; - String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0"; -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java deleted file mode 100644 index 81b0b08b9d..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java +++ /dev/null @@ -1,40 +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.contribution; - -/** - * Constants for the main supported contribution package type. - * - * @version $Rev$ $Date$ - */ -@Deprecated -public interface ContentType { - - /** - * Java compressed contribution package - */ - String JAR = "application/x-compressed"; - - /** - * Filesystem folder contribution package - */ - String FOLDER = "application/vnd.tuscany.folder"; - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java deleted file mode 100644 index 0076e1c89f..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java +++ /dev/null @@ -1,132 +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.contribution; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Extensible; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * The representation of an SCA contribution. - * - * @version $Rev$ $Date$ - */ -public interface Contribution extends Artifact, Extensible { - - /** - * Default location of contribution metadata in an SCA contribution. - */ - String SCA_CONTRIBUTION_META = "META-INF/sca-contribution.xml"; - - /** - * Default location of a generated contribution metadata in an SCA contribution. - */ - String SCA_CONTRIBUTION_GENERATED_META = "META-INF/sca-contribution-generated.xml"; - - /** - * Default location of deployable composites in an SCA contribution. - */ - String SCA_CONTRIBUTION_DEPLOYABLES = "META-INF/sca-deployables/"; - - - /** - * Returns a list of exports based on the contribution metadata. - * - * @return The list of exports in this contribution - */ - List getExports(); - - /** - * Returns a list of imports based on the contribution metadata. - * - * @return The list of imports in this contribution - */ - List getImports(); - - /** - * Returns the list of deployable composites in the contribution. - * - * @return The list of deployable composites - */ - List getDeployables(); - - /** - * Returns the list of artifacts in the contribution. - * - * @return The list of artifacts in the contribution - */ - List getArtifacts(); - - /** - * Returns the model resolver for the models representing the artifacts - * visible in the scope of this contribution. - * - * @return The model resolver - */ - ModelResolver getModelResolver(); - - /** - * Sets the model resolver for the models representing the artifacts - * visible in the scope of this contribution. - * - * @param modelResolver The model resolver - */ - void setModelResolver(ModelResolver modelResolver); - - /** - * Returns the ClassLoader used to load classes and resources from - * this contribution - * - * FIXME Remove this, the base contribution model should not depend - * on Java ClassLoaders. - * - * @return The contribution ClassLoader - */ - ClassLoader getClassLoader(); - - /** - * Sets the ClassLoader used to load classes and resources from - * this contribution - * - * FIXME Remove this, the base contribution model should not depend - * on Java ClassLoaders. - * - * @param classLoader the contribution class loader - */ - void setClassLoader(ClassLoader classLoader); - - /** - * Returns the type string based on the types that appear in - * o.a.t.s.contribution.PackageType - * - * @return the contribution type string - */ - String getType(); - - /** - * Sets the type string based on the types that appear in - * o.a.t.s.contribution.PackageType - * - * @param contributionType the contribution type string - */ - void setType(String contributionType); -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java deleted file mode 100644 index 67c9a05a0b..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java +++ /dev/null @@ -1,73 +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.contribution; - - -/** - * A factory for the contribution model. - * - * @version $Rev$ $Date$ - */ -public interface ContributionFactory { - - /** - * Create a contribution model object - * - * @return The new contribution model object - */ - Contribution createContribution(); - - /** - * Create a contribution metadata model object - * - * @return The new contribution metadata model object - */ - ContributionMetadata createContributionMetadata(); - - /** - * Create a deployedArtifact model object - * - * @return The new deployedArtifact model object - */ - @Deprecated - DeployedArtifact createDeployedArtifact(); - - /** - * Create an artifact model object - * - * @return The new artifact model object - */ - Artifact createArtifact(); - - /** - * Create a default import model object. - * - * @return the new default import model object - */ - DefaultImport createDefaultImport(); - - /** - * Create a default export model object. - * - * @return the new default export model object - */ - DefaultExport createDefaultExport(); - -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java deleted file mode 100644 index 5f26c3d907..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java +++ /dev/null @@ -1,56 +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.contribution; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Base; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Extensible; - -/** - * The representation of SCA contribution metadata. - * - * @version $Rev$ $Date$ - */ -public interface ContributionMetadata extends Base, Extensible { - - /** - * Returns a list of exports based on the contribution metadata. - * - * @return The list of exports - */ - List getExports(); - - /** - * Returns a list of imports based on the contribution metadata. - * - * @return The list of imports - */ - List getImports(); - - /** - * Returns the list of deployable based on the contribution metadata. - * - * @return The list of deployable composites - */ - List getDeployables(); - -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java deleted file mode 100644 index e13e8bcbd6..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java +++ /dev/null @@ -1,32 +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.contribution; - -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; - - -/** - * Default implementation of a contribution model factory. - * - * @version $Rev$ $Date$ - */ -public class DefaultContributionFactory extends ContributionFactoryImpl implements ContributionFactory { - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java deleted file mode 100644 index b2eddb8336..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.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.contribution; - - -/** - * The representation of an export that exports all artifacts in - * a contribution. - * - * @version $Rev$ $Date$ - */ -public interface DefaultExport extends Export { -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java deleted file mode 100644 index 20798dcd17..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.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.contribution; - - -/** - * The representation of a default import that imports artifacts from - * all contributions. - * - * @version $Rev$ $Date$ - */ -public interface DefaultImport extends Import { -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java deleted file mode 100644 index b69c58a0ff..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java +++ /dev/null @@ -1,130 +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.contribution; - -import java.lang.reflect.Constructor; -import java.util.HashMap; - -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; - - -/** - * Default implementation of a model factory extension point. - * - * @version $Rev$ $Date$ - */ -public class DefaultModelFactoryExtensionPoint implements ModelFactoryExtensionPoint { - - private HashMap, Object> factories = new HashMap, Object>(); - - /** - * Constructs a new DefaultModelFactoryExtensionPoint. - */ - public DefaultModelFactoryExtensionPoint() { - } - - /** - * Add a model factory extension. - * - * @param factory The factory to add - */ - public void addFactory(Object factory) { - Class[] interfaces = factory.getClass().getInterfaces(); - if (interfaces.length == 0) { - Class sc = factory.getClass().getSuperclass(); - if (sc != Object.class) { - factories.put(sc, factory); - } - } else { - for (int i = 0; i[] interfaces = factory.getClass().getInterfaces(); - if (interfaces.length == 0) { - Class sc = factory.getClass().getSuperclass(); - if (sc != Object.class) { - factories.remove(sc); - } - } else { - for (int i = 0; i T getFactory(Class factoryInterface) { - Object factory = factories.get(factoryInterface); - if (factory == null) { - - if (factoryInterface.isInterface()) { - - // Dynamically load a factory class declared under META-INF/services - try { - Class factoryClass = ServiceDiscovery.getInstance().loadFirstServiceClass(factoryInterface); - if (factoryClass != null) { - - try { - // Default empty constructor - Constructor constructor = factoryClass.getConstructor(); - factory = constructor.newInstance(); - } catch (NoSuchMethodException e) { - - // Constructor taking the model factory extension point - Constructor constructor = factoryClass.getConstructor(ModelFactoryExtensionPoint.class); - factory = constructor.newInstance(this); - } - - // Cache the loaded factory - addFactory(factory); - } - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } else { - - // Call the newInstance static method on the factory abstract class - try { - factory = ServiceDiscovery.getInstance().newFactoryClassInstance(factoryInterface); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - - // Cache the factory - addFactory(factory); - } - } - return factoryInterface.cast(factory); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DeployedArtifact.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DeployedArtifact.java deleted file mode 100644 index ffe190132c..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/DeployedArtifact.java +++ /dev/null @@ -1,29 +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.contribution; - -/** - * Representation of a deployed artifact - * - * @version $Rev$ $Date$ - */ -@Deprecated -public interface DeployedArtifact extends Artifact { -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java deleted file mode 100644 index a6e5afe7b8..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java +++ /dev/null @@ -1,48 +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.contribution; - -import org.apache.tuscany.sca.assembly.Extensible; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * The representation of an export. - * - * @version $Rev$ $Date$ - */ -public interface Export extends Extensible { - - /** - * Returns the model resolver for the models representing artifacts - * made available by this export. - * - * @return The model resolver - */ - ModelResolver getModelResolver(); - - /** - * Sets the model resolver for the models representing artifacts - * made available by this export. - * - * @param modelResolver - */ - void setModelResolver(ModelResolver modelResolver); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java deleted file mode 100644 index 256a2387f1..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java +++ /dev/null @@ -1,57 +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.contribution; - -import org.apache.tuscany.sca.assembly.Extensible; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - - -/** - * The representation of an import. - * - * @version $Rev$ $Date$ - */ -public interface Import extends Extensible { - - /** - * Returns the model resolver for the models representing artifacts - * made available by this import. - * - * @return The model resolver - */ - ModelResolver getModelResolver(); - - /** - * Sets the model resolver for the models representing artifacts - * made available by this import. - * - * @param modelResolver The model resolver - */ - void setModelResolver(ModelResolver modelResolver); - - /** - * Verify that a specific export actually exports what is being imported. - * - * @param export The Exported being verified - * @return true/false - */ - boolean match(Export export); - -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ModelFactoryExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ModelFactoryExtensionPoint.java deleted file mode 100644 index 0ada4ebec3..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/ModelFactoryExtensionPoint.java +++ /dev/null @@ -1,54 +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.contribution; - -/** - * An extension point for model factories. Model factories are provided to - * abstract the classes that represent artifacts in the assembly model away - * from their creation mechanism. When the runtime needs to extend the model - * as it reads in contributed artifacts it looks up the factory for the - * artifact required in this registry - * - * @version $Rev$ $Date$ - */ -public interface ModelFactoryExtensionPoint { - - /** - * Add a model factory extension. - * - * @param factory The factory to add - */ - void addFactory(Object factory); - - /** - * Remove a model factory extension. - * - * @param factory The factory to remove - */ - void removeFactory(Object factory); - - /** - * Get a factory implementing the given interface. - * @param factoryInterface the lookup key (factory interface) - * @return The factory - */ - T getFactory(Class factoryInterface); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java deleted file mode 100644 index 26833bb4c0..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java +++ /dev/null @@ -1,57 +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.contribution; - -/** - * Constants for the main supported contribution package types. - * - * @version $Rev$ $Date$ - */ -public interface PackageType { - - /** - * Java compressed contribution package - */ - String JAR = "application/x-compressed"; - - /** - * Zip archive contribution package - */ - String ZIP = "application/x-compressed"; - - /** - * Filesystem folder contribution package - */ - String FOLDER = "application/vnd.tuscany.folder"; - - - String BUNDLE = "application/osgi.bundle"; - - /** - * Java EE Web Application Archive - */ - String WAR = "application/war"; - - /** - * Java EE Enterprise Application Archive - */ - String EAR = "application/ear"; - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java deleted file mode 100644 index 3ce27d47c3..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.contribution.impl; - -import org.apache.tuscany.sca.contribution.Artifact; - - -/** - * The model representing an artifact in a contribution. - * - * @version $Rev$ $Date$ - */ -class ArtifactImpl implements Artifact { - private String uri; - private String location; - private Object model; - private boolean unresolved; - - ArtifactImpl() { - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public Object getModel() { - return model; - } - - public void setModel(Object model) { - this.model = model; - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - - @Override - public int hashCode() { - return uri.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else { - if (obj instanceof Artifact) { - return uri.equals(((Artifact)obj).getURI()); - } else { - return false; - } - } - } - - @Override - public String toString() { - return "Artifact:" + uri + "\n" + - "at: " + location; - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java deleted file mode 100644 index c678c2eaef..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java +++ /dev/null @@ -1,67 +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.contribution.impl; - -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.ContributionMetadata; -import org.apache.tuscany.sca.contribution.DefaultExport; -import org.apache.tuscany.sca.contribution.DefaultImport; -import org.apache.tuscany.sca.contribution.DeployedArtifact; - - -/** - * Default implementation of a contribution model factory. - * - * @version $Rev$ $Date$ - */ -public class ContributionFactoryImpl implements ContributionFactory { - - protected ContributionFactoryImpl() { - } - - public Contribution createContribution() { - return new ContributionImpl(); - } - - public ContributionMetadata createContributionMetadata() { - return new ContributionMetadataImpl(); - } - - public Artifact createArtifact() { - return new ArtifactImpl(); - } - - public DefaultExport createDefaultExport() { - return new DefaultExportImpl(); - } - - public DefaultImport createDefaultImport() { - return new DefaultImportImpl(); - } - - @Deprecated - public DeployedArtifact createDeployedArtifact() { - class DeployedArtifactImpl extends ArtifactImpl implements DeployedArtifact { - } - return new DeployedArtifactImpl(); - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java deleted file mode 100644 index 3bad5c3612..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java +++ /dev/null @@ -1,164 +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.contribution.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl; -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.Export; -import org.apache.tuscany.sca.contribution.Import; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * The representation of a deployed contribution - * - * @version $Rev$ $Date$ - */ -class ContributionImpl extends ExtensibleImpl implements Contribution { - private String type; - private String uri; - private String location; - private Object model; - private byte[] contents; - private boolean unresolved; - private List exports = new ArrayList(); - private List imports = new ArrayList(); - private List deployables = new ArrayList(); - private List artifacts = new ArrayList(); - private ModelResolver modelResolver; - - // FIXME remove this dependency on Java ClassLoaders - private ClassLoader classLoader; - - ContributionImpl() { - } - - public String getLocation() { - return this.location; - } - - public void setLocation(String location) { - this.location = location; - } - - //FIXME Remove dependency on Java ClassLoaders - public ClassLoader getClassLoader() { - return classLoader; - } - - //FIXME Remove dependency on Java ClassLoaders - public void setClassLoader(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - - public String getURI() { - return this.uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public Object getModel() { - return model; - } - - public void setModel(Object model) { - this.model = model; - } - - public byte[] getContents() { - return contents; - } - - public void setContents(byte[] contents) { - this.contents = contents; - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - - public ModelResolver getModelResolver() { - return modelResolver; - } - - public void setModelResolver(ModelResolver modelResolver) { - this.modelResolver = modelResolver; - } - - public List getExports() { - return exports; - } - - public List getImports() { - return imports; - } - - public List getDeployables() { - return deployables; - } - - public List getArtifacts() { - return artifacts; - } - - @Override - public int hashCode() { - return uri.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else { - if (obj instanceof Artifact) { - return uri.equals(((Artifact)obj).getURI()); - } else { - return false; - } - } - } - - @Override - public String toString() { - return "Contribution : " + uri + " \n" + - "from: " + location; - } - - public String getType() { - return type; - } - - public void setType(String contributionType) { - this.type = contributionType; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java deleted file mode 100644 index da8c879a93..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.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.contribution.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl; -import org.apache.tuscany.sca.contribution.ContributionMetadata; -import org.apache.tuscany.sca.contribution.Export; -import org.apache.tuscany.sca.contribution.Import; - -/** - * The representation of a deployed contribution - * - * @version $Rev$ $Date$ - */ -class ContributionMetadataImpl extends ExtensibleImpl implements ContributionMetadata { - private boolean unresolved; - private List exports = new ArrayList(); - private List imports = new ArrayList(); - private List deployables = new ArrayList(); - - ContributionMetadataImpl() { - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - - public List getExports() { - return exports; - } - - public List getImports() { - return imports; - } - - public List getDeployables() { - return deployables; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java deleted file mode 100644 index d4614e5427..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java +++ /dev/null @@ -1,46 +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.contribution.impl; - -import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl; -import org.apache.tuscany.sca.contribution.DefaultExport; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * The representation of an export for the contribution - * - * @version $Rev$ $Date$ - */ -public class DefaultExportImpl extends ExtensibleImpl implements DefaultExport { - private ModelResolver modelResolver; - - protected DefaultExportImpl() { - super(); - } - - public ModelResolver getModelResolver() { - return modelResolver; - } - - public void setModelResolver(ModelResolver modelResolver) { - this.modelResolver = modelResolver; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java deleted file mode 100644 index 7ab535f916..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java +++ /dev/null @@ -1,56 +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.contribution.impl; - -import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl; -import org.apache.tuscany.sca.contribution.DefaultExport; -import org.apache.tuscany.sca.contribution.DefaultImport; -import org.apache.tuscany.sca.contribution.Export; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * The representation of an import for the contribution - * - * @version $Rev$ $Date$ - */ -public class DefaultImportImpl extends ExtensibleImpl implements DefaultImport { - private ModelResolver modelResolver; - - protected DefaultImportImpl() { - super(); - } - - public ModelResolver getModelResolver() { - return modelResolver; - } - - public void setModelResolver(ModelResolver modelResolver) { - this.modelResolver = modelResolver; - } - - - public boolean match(Export export) { - if (export instanceof DefaultExport) { - return true; - } - return false; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java deleted file mode 100644 index b5f536c431..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java +++ /dev/null @@ -1,48 +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.contribution.processor; - -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; - -/** - * Base interface for artifact processors. - * - * @version $Rev$ $Date$ - */ -public interface ArtifactProcessor { - - /** - * Resolve references from this model to other models. For example references - * from a composite to another one, or references from a composite to a WSDL - * model. - * - * @param model The model to resolve - * @param resolver The resolver to use to resolve referenced models - */ - void resolve(M model, ModelResolver resolver) throws ContributionResolveException; - - /** - * Returns the type of model handled by this artifact processor. - * - * @return The type of model handled by this artifact processor - */ - Class getModelType(); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessorExtensionPoint.java deleted file mode 100644 index 029df61f0f..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessorExtensionPoint.java +++ /dev/null @@ -1,58 +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.contribution.processor; - -/** - * An extension point for artifact processors. - * - * @version $Rev$ $Date$ - */ -public interface ArtifactProcessorExtensionPoint

{ - - /** - * Add an artifact processor. - * - * @param artifactProcessor The artifact processor to add - */ - void addArtifactProcessor(P artifactProcessor); - - /** - * Remove an artifact processor. - * - * @param artifactProcessor The artifact processor to remove - */ - void removeArtifactProcessor(P artifactProcessor); - - /** - * Returns the processor associated with the given artifact type. - * - * @param artifactType An artifact type - * @return The processor associated with the given artifact type - */ - P getProcessor(Object artifactType); - - /** - * Returns the processor associated with the given model type. - * - * @param modelType A model type - * @return The processor associated with the given model type - */ - P getProcessor(Class modelType); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java deleted file mode 100644 index a451316883..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java +++ /dev/null @@ -1,618 +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.contribution.processor; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.StringTokenizer; - -import javax.xml.XMLConstants; -import javax.xml.namespace.NamespaceContext; -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.assembly.Extensible; -import org.apache.tuscany.sca.assembly.Extension; -import org.apache.tuscany.sca.assembly.ExtensionFactory; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; - - -/** - * A base class with utility methods for the other artifact processors in this module. - * - * @version $Rev$ $Date$ - */ -public abstract class BaseStAXArtifactProcessor { - - /** - * Returns a QName from a string. - * @param reader - * @param value - * @return - */ - protected QName getQNameValue(XMLStreamReader reader, String value) { - if (value != null) { - int index = value.indexOf(':'); - String prefix = index == -1 ? "" : value.substring(0, index); - String localName = index == -1 ? value : value.substring(index + 1); - String ns = reader.getNamespaceContext().getNamespaceURI(prefix); - if (ns == null) { - ns = ""; - } - return new QName(ns, localName, prefix); - } else { - return null; - } - } - - /** - * Returns the boolean value of an attribute. - * @param reader - * @param name - * @return - */ - protected boolean getBoolean(XMLStreamReader reader, String name) { - String value = reader.getAttributeValue(null, name); - if (value == null) { - return false; - } - return Boolean.valueOf(value); - } - - /** - * Returns the QName value of an attribute. - * @param reader - * @param name - * @return - */ - protected QName getQName(XMLStreamReader reader, String name) { - String qname = reader.getAttributeValue(null, name); - return getQNameValue(reader, qname); - } - - /** - * Returns the value of an attribute as a list of QNames. - * @param reader - * @param name - * @return - */ - protected List getQNames(XMLStreamReader reader, String name) { - String value = reader.getAttributeValue(null, name); - if (value != null) { - List qnames = new ArrayList(); - for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { - qnames.add(getQName(reader, tokens.nextToken())); - } - return qnames; - } else { - return Collections.emptyList(); - } - } - - /** - * Returns the string value of an attribute. - * @param reader - * @param name - * @return - */ - protected String getString(XMLStreamReader reader, String name) { - return reader.getAttributeValue(null, name); - } - - /** - * Test if an attribute is explicitly set - * @param reader - * @param name - * @return - */ - protected boolean isSet(XMLStreamReader reader, String name) { - return reader.getAttributeValue(null, name) != null; - } - - /** - * Returns the value of xsi:type attribute - * @param reader The XML stream reader - * @return The QName of the type, if the attribute is not present, null is - * returned. - */ - protected QName getXSIType(XMLStreamReader reader) { - String qname = reader.getAttributeValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type"); - return getQNameValue(reader, qname); - } - - /** - * Parse the next child element. - * @param reader - * @return - * @throws XMLStreamException - */ - protected boolean nextChildElement(XMLStreamReader reader) throws XMLStreamException { - while (reader.hasNext()) { - int event = reader.next(); - if (event == END_ELEMENT) { - return false; - } - if (event == START_ELEMENT) { - return true; - } - } - return false; - } - - /** - * Advance the stream to the next END_ELEMENT event skipping any nested - * content. - * @param reader the reader to advance - * @throws XMLStreamException if there was a problem reading the stream - */ - protected void skipToEndElement(XMLStreamReader reader) throws XMLStreamException { - int depth = 0; - while (reader.hasNext()) { - int event = reader.next(); - if (event == XMLStreamConstants.START_ELEMENT) { - depth++; - } else if (event == XMLStreamConstants.END_ELEMENT) { - if (depth == 0) { - return; - } - depth--; - } - } - } - - /** - * - * @param writer - * @param uri - * @throws XMLStreamException - */ - private String writeElementPrefix(XMLStreamWriter writer, String uri) throws XMLStreamException { - if (uri == null) { - return null; - } - String prefix = writer.getPrefix(uri); - if (prefix != null) { - return null; - } else { - - // Find an available prefix and bind it to the given URI - NamespaceContext nsc = writer.getNamespaceContext(); - for (int i=1; ; i++) { - prefix = "ns" + i; - if (nsc.getNamespaceURI(prefix) == null) { - break; - } - } - // writer.setPrefix(prefix, uri); - return prefix; - } - - } - - /** - * Start an element. - * @param uri - * @param name - * @param attrs - * @throws XMLStreamException - */ - protected void writeStart(XMLStreamWriter writer, String uri, String name, XAttr... attrs) throws XMLStreamException { - String prefix = writeElementPrefix(writer, uri); - writer.writeStartElement(uri, name); - if (prefix != null){ - writer.writeNamespace(prefix,uri); - } - writeAttributePrefixes(writer, attrs); - writeAttributes(writer, attrs); - } - - /** - * Start an element. - * @param qname - * @param attrs - * @throws XMLStreamException - */ - protected void writeStart(XMLStreamWriter writer, QName qname, XAttr... attrs) throws XMLStreamException { - writeStart(writer, qname.getNamespaceURI(), qname.getLocalPart(), attrs); - } - - /** - * End an element. - * @param writer - * @throws XMLStreamException - */ - protected void writeEnd(XMLStreamWriter writer) throws XMLStreamException { - writer.writeEndElement(); - } - - /** - * Start a document. - * @param writer - * @throws XMLStreamException - */ - protected void writeStartDocument(XMLStreamWriter writer, String uri, String name, XAttr... attrs) throws XMLStreamException { - writer.writeStartDocument(); - writer.setDefaultNamespace(uri); - writeStart(writer, uri, name, attrs); - writer.writeDefaultNamespace(uri); - } - - /** - * Start a document. - * @param writer - * @param qname - * @param attrs - * @throws XMLStreamException - */ - protected void writeStartDocument(XMLStreamWriter writer, QName qname, XAttr... attrs) throws XMLStreamException { - writeStartDocument(writer, qname.getNamespaceURI(), qname.getLocalPart(), attrs); - } - - /** - * End a document. - * @param writer - * @throws XMLStreamException - */ - protected void writeEndDocument(XMLStreamWriter writer) throws XMLStreamException { - writer.writeEndDocument(); - } - - /** - * Write attributes to the current element. - * @param writer - * @param attrs - * @throws XMLStreamException - */ - protected void writeAttributes(XMLStreamWriter writer, XAttr... attrs) throws XMLStreamException { - for (XAttr attr : attrs) { - if (attr != null) - attr.write(writer); - } - } - - /** - * Write attribute prefixes to the current element. - * @param writer - * @param attrs - * @throws XMLStreamException - */ - protected void writeAttributePrefixes(XMLStreamWriter writer, XAttr... attrs) throws XMLStreamException { - for (XAttr attr : attrs) { - if (attr != null) - attr.writePrefix(writer); - } - } - - /** - * - * @param reader - * @param elementName - * @param extensible - * @param extensionAttributeProcessor - * @param extensionAttributeProcessor - * @param extensionFactory - * @throws ContributionReadException - * @throws XMLStreamException - */ - protected void readExtendedAttributes(XMLStreamReader reader, - Extensible extensible, - StAXAttributeProcessor extensionAttributeProcessor, - ExtensionFactory extensionFactory) throws ContributionReadException, - XMLStreamException { - QName elementName = reader.getName(); - for (int a = 0; a < reader.getAttributeCount(); a++) { - QName attributeName = reader.getAttributeName(a); - if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) { - if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) { - Object attributeValue = extensionAttributeProcessor.read(attributeName, reader); - Extension attributeExtension; - if (attributeValue instanceof Extension) { - attributeExtension = (Extension)attributeValue; - } else { - attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true); - } - extensible.getAttributeExtensions().add(attributeExtension); - } - } - } - } - - /** - * - * @param attributeModel - * @param writer - * @param extensibleElement - * @param extensionAttributeProcessor - * @throws ContributionWriteException - * @throws XMLStreamException - */ - protected void writeExtendedAttributes(XMLStreamWriter writer, - Extensible extensibleElement, - StAXAttributeProcessor extensionAttributeProcessor) - throws ContributionWriteException, XMLStreamException { - for (Extension extension : extensibleElement.getAttributeExtensions()) { - if (extension.isAttribute()) { - extensionAttributeProcessor.write(extension, writer); - } - } - } - - protected void readExtendedElement(XMLStreamReader reader, - Extensible extensible, - StAXArtifactProcessor extensionProcessor) throws ContributionReadException, - XMLStreamException { - Object ext = extensionProcessor.read(reader); - if (extensible != null) { - extensible.getExtensions().add(ext); - } - } - - protected void writeExtendedElements(XMLStreamWriter writer, - Extensible extensible, - StAXArtifactProcessor extensionProcessor) throws ContributionWriteException, - XMLStreamException { - for (Object ext : extensible.getExtensions()) { - extensionProcessor.write(ext, writer); - } - } - - /** - * Represents an XML attribute that needs to be written to a document. - */ - public static class XAttr { - - private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0"; - - private String uri = SCA10_NS; - private String name; - private Object value; - - public XAttr(String uri, String name, String value) { - this.uri = uri; - this.name = name; - this.value = value; - } - - public XAttr(String name, String value) { - this(null, name, value); - } - - public XAttr(String uri, String name, List values) { - this.uri = uri; - this.name = name; - this.value = values; - } - - public XAttr(String name, List values) { - this(null, name, values); - } - - public XAttr(String uri, String name, Boolean value) { - this.uri = uri; - this.name = name; - this.value = value; - } - - public XAttr(String name, Boolean value) { - this(null, name, value); - } - - public XAttr(String uri, String name, Integer value) { - this.uri = uri; - this.name = name; - this.value = value; - } - - public XAttr(String name, Integer value) { - this(null, name, value); - } - - public XAttr(String uri, String name, Double value) { - this.uri = uri; - this.name = name; - this.value = value; - } - - public XAttr(String name, Double value) { - this(null, name, value); - } - - public XAttr(String uri, String name, QName value) { - this.uri = uri; - this.name = name; - this.value = value; - } - - public XAttr(String name, QName value) { - this(null, name, value); - } - - /** - * Writes a string from a QName and registers a prefix for its namespace. - * @param reader - * @param value - * @return - */ - private String writeQNameValue(XMLStreamWriter writer, QName qname) throws XMLStreamException { - if (qname != null) { - String prefix = qname.getPrefix(); - String uri = qname.getNamespaceURI(); - prefix = writer.getPrefix(uri); - if (prefix != null) { - - // Use the prefix already bound to the given URI - if (prefix.length() > 0) { - return prefix + ":" + qname.getLocalPart(); - } else { - - // Empty prefix, just return the local part of the given qname - return qname.getLocalPart(); - } - - } else { - - // Find an available prefix and bind it to the given URI - NamespaceContext nsc = writer.getNamespaceContext(); - for (int i=1; ; i++) { - prefix = "ns" + i; - if (nsc.getNamespaceURI(prefix) == null) { - break; - } - } - // writer.setPrefix(prefix, uri); - writer.writeNamespace(prefix, uri); - return prefix + ":" + qname.getLocalPart(); - } - } else { - return null; - } - } - - /** - * Registers a prefix for the namespace of a QName. - * @param reader - * @param value - * @return - */ - private void writeQNamePrefix(XMLStreamWriter writer, QName qname) throws XMLStreamException { - if (qname != null) { - String prefix = qname.getPrefix(); - String uri = qname.getNamespaceURI(); - prefix = writer.getPrefix(uri); - if (prefix != null) { - return; - } else { - - // Find an available prefix and bind it to the given URI - NamespaceContext nsc = writer.getNamespaceContext(); - for (int i=1; ; i++) { - prefix = "ns" + i; - if (nsc.getNamespaceURI(prefix) == null) { - break; - } - } - // writer.setPrefix(prefix, uri); - writer.writeNamespace(prefix, uri); - } - } - } - - /** - * Write to document - * @param writer - * @throws XMLStreamException - */ - public void write(XMLStreamWriter writer) throws XMLStreamException { - String str; - if (value instanceof QName) { - - // Write a QName - str = writeQNameValue(writer, (QName)value); - - } else if (value instanceof List) { - - // Write a list of values - List values = (List)value; - if (values.isEmpty()) { - return; - } - StringBuffer buffer = new StringBuffer(); - for (Object v: values) { - if (v == null) { - // Skip null values - continue; - } - - if (v instanceof XAttr) { - // Write an XAttr value - ((XAttr)v).write(writer); - continue; - } - - if (buffer.length() != 0) { - buffer.append(' '); - } - if (v instanceof QName) { - // Write a QName value - buffer.append(writeQNameValue(writer, (QName)v)); - } else { - // Write value as a string - buffer.append(String.valueOf(v)); - } - } - str = buffer.toString(); - - } else { - - // Write a string - if (value == null) { - return; - } - str = String.valueOf(value); - } - if (str.length() == 0) { - return; - } - - // Write the attribute - if (uri != null && !uri.equals(SCA10_NS)) { - writer.writeAttribute(uri, name, str); - } else { - writer.writeAttribute(name,str); - } - } - - /** - * Registers a prefix for the namespace of a QName or list of QNames - * @param writer - * @throws XMLStreamException - */ - public void writePrefix(XMLStreamWriter writer) throws XMLStreamException { - if (value instanceof QName) { - - // Write prefix for a single QName value - writeQNamePrefix(writer, (QName)value); - - } else if (value instanceof List) { - - // Write prefixes for a list of values - for (Object v: (List)value) { - if (v instanceof QName) { - // Write prefix for a QName value - writeQNamePrefix(writer, (QName)v); - - } else if (v instanceof XAttr) { - // Write prefix for an XAttr value - ((XAttr)v).writePrefix(writer); - } - } - } - } - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java deleted file mode 100644 index 3c67a8c550..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java +++ /dev/null @@ -1,66 +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.contribution.processor; - -import java.util.HashMap; -import java.util.Map; - -/** - * The default implementation of an artifact processor extension point. - * - * @version $Rev$ $Date$ - */ -abstract class DefaultArtifactProcessorExtensionPoint

{ - protected final Map processorsByArtifactType = new HashMap(); - protected final Map, P> processorsByModelType = new HashMap, P>(); - - /** - * Constructs a new loader registry. - */ - DefaultArtifactProcessorExtensionPoint() { - } - - /** - * Returns the processor associated with the given artifact type. - * - * @param artifactType An artifact type - * @return The processor associated with the given artifact type - */ - public P getProcessor(Object artifactType) { - return processorsByArtifactType.get(artifactType); - } - - /** - * Returns the processor associated with the given model type. - * - * @param modelType A model type - * @return The processor associated with the given model type - */ - public P getProcessor(Class modelType) { - Class[] classes = modelType.getInterfaces(); - for (Class c : classes) { - P processor = processorsByModelType.get(c); - if (processor != null) { - return processor; - } - } - return processorsByModelType.get(modelType); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java deleted file mode 100644 index 3c25424325..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java +++ /dev/null @@ -1,129 +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.contribution.processor; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.sca.contribution.service.ContributionException; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; - -/** - * Default implementation of a package processor extension point. - * - * @version $Rev$ $Date$ - */ -public class DefaultPackageProcessorExtensionPoint implements PackageProcessorExtensionPoint { - - private Map processors = new HashMap(); - private boolean loaded; - - public DefaultPackageProcessorExtensionPoint() { - } - - public void addPackageProcessor(PackageProcessor processor) { - processors.put(processor.getPackageType(), processor); - } - - public void removePackageProcessor(PackageProcessor processor) { - processors.remove(processor.getPackageType()); - } - - public PackageProcessor getPackageProcessor(String contentType) { - loadProcessors(); - return processors.get(contentType); - } - - private synchronized void loadProcessors() { - if (loaded) - return; - - // Get the processor service declarations - Set processorDeclarations; - try { - processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(PackageProcessor.class); - } catch (IOException e) { - throw new IllegalStateException(e); - } - - for (ServiceDeclaration processorDeclaration: processorDeclarations) { - Map attributes = processorDeclaration.getAttributes(); - - // Load a URL artifact processor - String packageType = attributes.get("type"); - - // Create a processor wrapper and register it - PackageProcessor processor = new LazyPackageProcessor(packageType, processorDeclaration); - addPackageProcessor(processor); - } - - loaded = true; - } - - /** - * A facade for package processors. - */ - private static class LazyPackageProcessor implements PackageProcessor { - - private ServiceDeclaration processorDeclaration; - private String packageType; - private PackageProcessor processor; - - private LazyPackageProcessor(String packageType, ServiceDeclaration processorDeclaration) { - this.processorDeclaration = processorDeclaration; - this.packageType = packageType; - } - - public URL getArtifactURL(URL packageSourceURL, URI artifact) throws MalformedURLException { - return getProcessor().getArtifactURL(packageSourceURL, artifact); - } - - public List getArtifacts(URL packageSourceURL, InputStream inputStream) throws ContributionException, IOException { - return getProcessor().getArtifacts(packageSourceURL, inputStream); - } - - public String getPackageType() { - return packageType; - } - - @SuppressWarnings("unchecked") - private PackageProcessor getProcessor() { - if (processor == null) { - try { - Class processorClass = (Class)processorDeclaration.loadClass(); - Constructor constructor = processorClass.getConstructor(); - processor = constructor.newInstance(); - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - return processor; - } - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java deleted file mode 100644 index a390c61eec..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java +++ /dev/null @@ -1,392 +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.contribution.processor; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.util.Map; -import java.util.Set; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ExtensionFactory; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -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.monitor.impl.ProblemImpl; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * The default implementation of an extension point for StAX artifact processors. - * - * @version $Rev$ $Date$ - */ -public class DefaultStAXArtifactProcessorExtensionPoint extends - DefaultArtifactProcessorExtensionPoint implements StAXArtifactProcessorExtensionPoint { - - private ExtensionPointRegistry extensionPoints; - private ModelFactoryExtensionPoint modelFactories; - private MonitorFactory monitorFactory; - private boolean loaded; - private StAXArtifactProcessor extensibleStAXProcessor; - private StAXAttributeProcessor extensibleStAXAttributeProcessor; - private Monitor monitor = null; - - /** - * Constructs a new extension point. - */ - public DefaultStAXArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) { - this.extensionPoints = extensionPoints; - this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); - XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); - UtilityExtensionPoint utilities = this.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - if (monitorFactory != null) - this.monitor = monitorFactory.createMonitor(); - this.extensibleStAXProcessor = new ExtensibleStAXArtifactProcessor(this, inputFactory, outputFactory, this.monitor); - - StAXAttributeProcessorExtensionPoint attributeExtensionPoint = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class); - this.extensibleStAXAttributeProcessor = new ExtensibleStAXAttributeProcessor(attributeExtensionPoint ,inputFactory, outputFactory, this.monitor); - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - public void addArtifactProcessor(StAXArtifactProcessor artifactProcessor) { - if (artifactProcessor.getArtifactType() != null) { - processorsByArtifactType.put((Object)artifactProcessor.getArtifactType(), artifactProcessor); - } - if (artifactProcessor.getModelType() != null) { - processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor); - } - } - - public void removeArtifactProcessor(StAXArtifactProcessor artifactProcessor) { - if (artifactProcessor.getArtifactType() != null) { - processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType()); - } - if (artifactProcessor.getModelType() != null) { - processorsByModelType.remove(artifactProcessor.getModelType()); - } - } - - @Override - public StAXArtifactProcessor getProcessor(Class modelType) { - loadArtifactProcessors(); - return super.getProcessor(modelType); - } - - @Override - public StAXArtifactProcessor getProcessor(Object artifactType) { - loadArtifactProcessors(); - return super.getProcessor(artifactType); - } - - /** - * Returns a QName object from a QName expressed as {ns}name - * or ns#name. - * - * @param qname - * @return - */ - private static QName getQName(String qname) { - if (qname == null) { - return null; - } - qname = qname.trim(); - if (qname.startsWith("{")) { - int h = qname.indexOf('}'); - if (h != -1) { - return new QName(qname.substring(1, h), qname.substring(h + 1)); - } - } else { - int h = qname.indexOf('#'); - if (h != -1) { - return new QName(qname.substring(0, h), qname.substring(h + 1)); - } - } - throw new IllegalArgumentException("Invalid qname: "+qname); - } - - /** - * Lazily load artifact processors registered in the extension point. - */ - private synchronized void loadArtifactProcessors() { - if (loaded) - return; - - // Get the processor service declarations - Set processorDeclarations; - try { - processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(StAXArtifactProcessor.class); - } catch (IOException e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", extensibleStAXProcessor, ie); - throw ie; - } - - for (ServiceDeclaration processorDeclaration : processorDeclarations) { - Map attributes = processorDeclaration.getAttributes(); - - // Load a StAX artifact processor - - // Get the model QName - QName artifactType = getQName(attributes.get("qname")); - - // Get the model class name - String modelTypeName = attributes.get("model"); - - // Get the model factory class name - String factoryName = attributes.get("factory"); - - // Create a processor wrapper and register it - StAXArtifactProcessor processor = - new LazyStAXArtifactProcessor(artifactType, modelTypeName, factoryName, - processorDeclaration, extensionPoints, modelFactories, - extensibleStAXProcessor,extensibleStAXAttributeProcessor, monitor); - addArtifactProcessor(processor); - } - - loaded = true; - } - - /** - * A wrapper around an Artifact processor class allowing lazy loading and - * initialization of artifact processors. - */ - private static class LazyStAXArtifactProcessor implements StAXArtifactProcessor { - - private ExtensionPointRegistry extensionPoints; - private QName artifactType; - private String modelTypeName; - private String factoryName; - private ServiceDeclaration processorDeclaration; - private StAXArtifactProcessor processor; - private Class modelType; - private StAXArtifactProcessor extensionProcessor; - private StAXAttributeProcessor extensionAttributeProcessor; - private Monitor monitor; - - LazyStAXArtifactProcessor(QName artifactType, - String modelTypeName, - String factoryName, - ServiceDeclaration processorDeclaration, - ExtensionPointRegistry extensionPoints, - ModelFactoryExtensionPoint modelFactories, - StAXArtifactProcessor extensionProcessor, - StAXAttributeProcessor extensionAttributeProcessor, - Monitor monitor) { - - this.extensionPoints = extensionPoints; - this.artifactType = artifactType; - this.modelTypeName = modelTypeName; - this.factoryName = factoryName; - this.processorDeclaration = processorDeclaration; - this.extensionProcessor = extensionProcessor; - this.extensionAttributeProcessor = extensionAttributeProcessor; - this.monitor = monitor; - } - - public QName getArtifactType() { - return artifactType; - } - - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - @SuppressWarnings("unchecked") - private StAXArtifactProcessor getProcessor() { - if (processor == null) { - - if (processorDeclaration.getClassName() - .equals("org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor")) { - - // Specific initialization for the DefaultBeanModelProcessor - ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - ExtensionFactory extensionFactory = modelFactories.getFactory(ExtensionFactory.class); - PolicyFactory policyFactory = modelFactories.getFactory(PolicyFactory.class); - try { - Class processorClass = - (Class)processorDeclaration.loadClass(); - Object modelFactory; - if (factoryName != null) { - Class factoryClass = (Class)processorDeclaration.loadClass(factoryName); - modelFactory = modelFactories.getFactory(factoryClass); - } else { - modelFactory = null; - } - Constructor constructor = - processorClass.getConstructor(AssemblyFactory.class, - ExtensionFactory.class, - PolicyFactory.class, - QName.class, - Class.class, - Object.class, - Monitor.class); - processor = - constructor.newInstance(assemblyFactory, - extensionFactory, - policyFactory, - artifactType, - getModelType(), - modelFactory, - monitor); - } catch (Exception e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", processor, ie); - throw ie; - } - } else { - ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - - // Load and instantiate the processor class - try { - Class processorClass = - (Class)processorDeclaration.loadClass(); - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class, Monitor.class); - processor = constructor.newInstance(modelFactories, monitor); - } catch (NoSuchMethodException e) { - try { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class, Monitor.class); - processor = constructor.newInstance(extensionPoints, monitor); - } catch (NoSuchMethodException e1) { - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class, StAXArtifactProcessor.class, Monitor.class); - processor = constructor.newInstance(modelFactories, extensionProcessor, monitor); - } catch (NoSuchMethodException e2) { - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class, StAXArtifactProcessor.class, StAXAttributeProcessor.class, Monitor.class); - processor = constructor.newInstance(modelFactories, extensionProcessor, extensionAttributeProcessor, monitor); - } catch (NoSuchMethodException e2a) { - try { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class, StAXArtifactProcessor.class, Monitor.class); - processor = constructor.newInstance(extensionPoints, extensionProcessor, monitor); - } catch (NoSuchMethodException e3) { - try { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class, StAXArtifactProcessor.class, StAXAttributeProcessor.class, Monitor.class); - processor = constructor.newInstance(extensionPoints, extensionProcessor, extensionAttributeProcessor, monitor); - } catch (NoSuchMethodException e3a) { - - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class); - processor = constructor.newInstance(modelFactories); - } catch (NoSuchMethodException e4) { - try { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class); - processor = constructor.newInstance(extensionPoints); - } catch (NoSuchMethodException e4a) { - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class, StAXArtifactProcessor.class); - processor = constructor.newInstance(modelFactories, extensionProcessor); - } catch (NoSuchMethodException e5) { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class, StAXArtifactProcessor.class); - processor = constructor.newInstance(extensionPoints, extensionProcessor); - } - } - } - } - } - } - } - } - } - } catch (Exception e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", processor, ie); - throw ie; - } - } - } - return processor; - } - - public Object read(XMLStreamReader inputSource) throws ContributionReadException, XMLStreamException { - return getProcessor().read(inputSource); - } - - @SuppressWarnings("unchecked") - public void write(Object model, XMLStreamWriter outputSource) throws ContributionWriteException, - XMLStreamException { - getProcessor().write(model, outputSource); - } - - public Class getModelType() { - if (modelTypeName != null && modelType == null) { - try { - modelType = processorDeclaration.loadClass(modelTypeName); - } catch (Exception e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", processorDeclaration, ie); - throw ie; - } - } - return modelType; - } - - @SuppressWarnings("unchecked") - public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException { - getProcessor().resolve(model, resolver); - } - - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java deleted file mode 100644 index 3699a09f00..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java +++ /dev/null @@ -1,327 +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.contribution.processor; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.util.Map; -import java.util.Set; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -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.monitor.impl.ProblemImpl; - -/** - * The default implementation of an extension point for StAX artifact processors. - * - * @version $Rev$ $Date$ - */ -public class DefaultStAXAttributeProcessorExtensionPoint extends - DefaultArtifactProcessorExtensionPoint implements StAXAttributeProcessorExtensionPoint { - - private ExtensionPointRegistry extensionPoints; - private ModelFactoryExtensionPoint modelFactories; - private StAXAttributeProcessor extensibleStAXAttributeProcessor; - private boolean loaded; - private Monitor monitor = null; - - /** - * Constructs a new extension point. - */ - public DefaultStAXAttributeProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) { - this.extensionPoints = extensionPoints; - this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); - XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); - UtilityExtensionPoint utilities = this.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - if (monitorFactory != null) { - this.monitor = monitorFactory.createMonitor(); - } - this.extensibleStAXAttributeProcessor = new ExtensibleStAXAttributeProcessor(this, inputFactory, outputFactory, this.monitor); - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - public void addArtifactProcessor(StAXAttributeProcessor artifactProcessor) { - if (artifactProcessor.getArtifactType() != null) { - processorsByArtifactType.put((Object)artifactProcessor.getArtifactType(), artifactProcessor); - } - if (artifactProcessor.getModelType() != null) { - processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor); - } - } - - public void removeArtifactProcessor(StAXAttributeProcessor artifactProcessor) { - if (artifactProcessor.getArtifactType() != null) { - processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType()); - } - if (artifactProcessor.getModelType() != null) { - processorsByModelType.remove(artifactProcessor.getModelType()); - } - } - - @Override - public StAXAttributeProcessor getProcessor(Class modelType) { - loadArtifactProcessors(); - return super.getProcessor(modelType); - } - - @Override - public StAXAttributeProcessor getProcessor(Object artifactType) { - loadArtifactProcessors(); - return super.getProcessor(artifactType); - } - - /** - * Returns a QName object from a QName expressed as {ns}name - * or ns#name. - * - * @param qname - * @return - */ - private static QName getQName(String qname) { - if (qname == null) { - return null; - } - qname = qname.trim(); - if (qname.startsWith("{")) { - int h = qname.indexOf('}'); - if (h != -1) { - return new QName(qname.substring(1, h), qname.substring(h + 1)); - } - } else { - int h = qname.indexOf('#'); - if (h != -1) { - return new QName(qname.substring(0, h), qname.substring(h + 1)); - } - } - throw new IllegalArgumentException("Invalid qname: "+qname); - } - - /** - * Lazily load artifact processors registered in the extension point. - */ - private synchronized void loadArtifactProcessors() { - if (loaded) - return; - - // Get the processor service declarations - Set processorDeclarations; - try { - processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(StAXAttributeProcessor.class); - } catch (IOException e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", extensibleStAXAttributeProcessor, ie); - throw ie; - } - - for (ServiceDeclaration processorDeclaration : processorDeclarations) { - Map attributes = processorDeclaration.getAttributes(); - - // Load a StAX artifact processor - - // Get the model QName - QName artifactType = getQName(attributes.get("qname")); - - // Get the model class name - String modelTypeName = attributes.get("model"); - - // Get the model factory class name - String factoryName = attributes.get("factory"); - - // Create a processor wrapper and register it - StAXAttributeProcessor processor = - new LazyStAXAttributeProcessor(artifactType, modelTypeName, factoryName, - processorDeclaration, extensionPoints, modelFactories, - extensibleStAXAttributeProcessor, monitor); - addArtifactProcessor(processor); - } - - loaded = true; - } - - /** - * A wrapper around an Artifact processor class allowing lazy loading and - * initialization of artifact processors. - */ - private static class LazyStAXAttributeProcessor implements StAXAttributeProcessor { - - private ExtensionPointRegistry extensionPoints; - private QName artifactType; - private String modelTypeName; - private String factoryName; - private ServiceDeclaration processorDeclaration; - private StAXAttributeProcessor processor; - private Class modelType; - private StAXAttributeProcessor extensionProcessor; - private Monitor monitor; - - LazyStAXAttributeProcessor(QName artifactType, - String modelTypeName, - String factoryName, - ServiceDeclaration processorDeclaration, - ExtensionPointRegistry extensionPoints, - ModelFactoryExtensionPoint modelFactories, - StAXAttributeProcessor extensionProcessor, - Monitor monitor) { - - this.extensionPoints = extensionPoints; - this.artifactType = artifactType; - this.modelTypeName = modelTypeName; - this.factoryName = factoryName; - this.processorDeclaration = processorDeclaration; - this.extensionProcessor = extensionProcessor; - this.monitor = monitor; - } - - public QName getArtifactType() { - return artifactType; - } - - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - @SuppressWarnings("unchecked") - private StAXAttributeProcessor getProcessor() { - if (processor == null) { - ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - - // Load and instantiate the processor class - try { - Class processorClass = - (Class)processorDeclaration.loadClass(); - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class, Monitor.class); - processor = constructor.newInstance(modelFactories, monitor); - } catch (NoSuchMethodException e) { - try { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class, Monitor.class); - processor = constructor.newInstance(extensionPoints, monitor); - } catch (NoSuchMethodException e1) { - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class, StAXArtifactProcessor.class, Monitor.class); - processor = constructor.newInstance(modelFactories, extensionProcessor, monitor); - } catch (NoSuchMethodException e2) { - try { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class, StAXArtifactProcessor.class, Monitor.class); - processor = constructor.newInstance(extensionPoints, extensionProcessor, monitor); - } catch (NoSuchMethodException e3) { - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class); - processor = constructor.newInstance(modelFactories); - } catch (NoSuchMethodException e4) { - try { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class); - processor = constructor.newInstance(extensionPoints); - } catch (NoSuchMethodException e4a) { - try { - Constructor constructor = - processorClass.getConstructor(ModelFactoryExtensionPoint.class, StAXArtifactProcessor.class); - processor = constructor.newInstance(modelFactories, extensionProcessor); - } catch (NoSuchMethodException e5) { - Constructor constructor = - processorClass.getConstructor(ExtensionPointRegistry.class, StAXArtifactProcessor.class); - processor = constructor.newInstance(extensionPoints, extensionProcessor); - } - } - } - } - } - } - } - } catch (Exception e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", processor, ie); - throw ie; - } - - } - return processor; - } - - public Object read(QName attributeName, XMLStreamReader inputSource) throws ContributionReadException, XMLStreamException { - return getProcessor().read(attributeName, inputSource); - } - - @SuppressWarnings("unchecked") - public void write(Object model, XMLStreamWriter outputSource) throws ContributionWriteException, XMLStreamException { - getProcessor().write(model, outputSource); - } - - public Class getModelType() { - if (modelTypeName != null && modelType == null) { - try { - modelType = processorDeclaration.loadClass(modelTypeName); - } catch (Exception e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", processorDeclaration, ie); - throw ie; - } - } - return modelType; - } - - @SuppressWarnings("unchecked") - public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException { - getProcessor().resolve(model, resolver); - } - - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java deleted file mode 100644 index 7725360f6f..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java +++ /dev/null @@ -1,244 +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.contribution.processor; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.net.URI; -import java.net.URL; -import java.util.Map; -import java.util.Set; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -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.monitor.impl.ProblemImpl; - - -/** - * The default implementation of a URL artifact processor extension point. - * - * @version $Rev$ $Date$ - */ -public class DefaultURLArtifactProcessorExtensionPoint - extends DefaultArtifactProcessorExtensionPoint - implements URLArtifactProcessorExtensionPoint { - - private ExtensionPointRegistry extensionPoints; - private StAXArtifactProcessor staxProcessor; - private boolean loaded; - private Monitor monitor = null; - - /** - * Constructs a new extension point. - */ - public DefaultURLArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) { - this.extensionPoints = extensionPoints; - ModelFactoryExtensionPoint modelFactories = this.extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); - XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); - UtilityExtensionPoint utilities = this.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - if (monitorFactory != null) { - this.monitor = monitorFactory.createMonitor(); - } - StAXArtifactProcessorExtensionPoint staxProcessors = - extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, this.monitor); - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - public void addArtifactProcessor(URLArtifactProcessor artifactProcessor) { - if (artifactProcessor.getArtifactType() != null) { - processorsByArtifactType.put((Object)artifactProcessor.getArtifactType(), artifactProcessor); - } - if (artifactProcessor.getModelType() != null) { - processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor); - } - } - - public void removeArtifactProcessor(URLArtifactProcessor artifactProcessor) { - if (artifactProcessor.getArtifactType() != null) { - processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType()); - } - if (artifactProcessor.getModelType() != null) { - processorsByModelType.remove(artifactProcessor.getModelType()); - } - } - - @Override - public URLArtifactProcessor getProcessor(Class modelType) { - loadProcessors(); - return super.getProcessor(modelType); - } - - @Override - public URLArtifactProcessor getProcessor(Object artifactType) { - loadProcessors(); - return super.getProcessor(artifactType); - } - - /** - * Lazily load artifact processors registered in the extension point. - */ - private synchronized void loadProcessors() { - if (loaded) - return; - - // Get the processor service declarations - Set processorDeclarations; - try { - processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(URLArtifactProcessor.class); - } catch (IOException e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", staxProcessor, ie); - throw ie; - } - - for (ServiceDeclaration processorDeclaration: processorDeclarations) { - Map attributes = processorDeclaration.getAttributes(); - // Load a URL artifact processor - String artifactType = attributes.get("type"); - String modelTypeName = attributes.get("model"); - - // Create a processor wrapper and register it - URLArtifactProcessor processor = new LazyURLArtifactProcessor(artifactType, modelTypeName, - processorDeclaration, extensionPoints, staxProcessor, monitor); - addArtifactProcessor(processor); - } - - loaded = true; - } - - /** - * A wrapper around an Artifact processor class allowing lazy loading and - * initialization of artifact processors. - */ - private static class LazyURLArtifactProcessor implements URLArtifactProcessor { - - private ExtensionPointRegistry extensionPoints; - private String artifactType; - private String modelTypeName; - private ServiceDeclaration processorDeclaration; - private URLArtifactProcessor processor; - private Class modelType; - private StAXArtifactProcessor staxProcessor; - private Monitor monitor; - - LazyURLArtifactProcessor(String artifactType, - String modelTypeName, - ServiceDeclaration processorDeclaration, - ExtensionPointRegistry extensionPoints, - StAXArtifactProcessor staxProcessor, - Monitor monitor) { - this.artifactType = artifactType; - this.modelTypeName = modelTypeName; - this.processorDeclaration = processorDeclaration; - this.extensionPoints = extensionPoints; - this.staxProcessor = staxProcessor; - this.monitor = monitor; - } - - public String getArtifactType() { - return artifactType; - } - - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - @SuppressWarnings("unchecked") - private URLArtifactProcessor getProcessor() { - if (processor == null) { - try { - ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - Class processorClass = (Class)processorDeclaration.loadClass(); - try { - Constructor constructor = processorClass.getConstructor(ModelFactoryExtensionPoint.class, Monitor.class); - processor = constructor.newInstance(modelFactories, monitor); - } catch (NoSuchMethodException e) { - try { - Constructor constructor = processorClass.getConstructor(ModelFactoryExtensionPoint.class, StAXArtifactProcessor.class, Monitor.class); - processor = constructor.newInstance(modelFactories, staxProcessor, monitor); - } catch (NoSuchMethodException e2) { - Constructor constructor = processorClass.getConstructor(ExtensionPointRegistry.class, Monitor.class); - processor = constructor.newInstance(extensionPoints, monitor); - } - } - } catch (Exception e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", processor, ie); - throw ie; - } - } - return processor; - } - - public Object read(URL contributionURL, URI artifactURI, URL artifactURL) throws ContributionReadException { - return getProcessor().read(contributionURL, artifactURI, artifactURL); - } - - public Class getModelType() { - if (modelTypeName != null && modelType == null) { - try { - modelType = processorDeclaration.loadClass(modelTypeName); - } catch (ClassNotFoundException e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", processorDeclaration, ie); - throw ie; - } - } - return modelType; - } - - @SuppressWarnings("unchecked") - public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException { - getProcessor().resolve(model, resolver); - } - - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java deleted file mode 100644 index 6fc32d4e70..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java +++ /dev/null @@ -1,317 +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.contribution.processor; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.net.URL; -import java.net.URLConnection; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.XMLConstants; -import javax.xml.stream.EventFilter; -import javax.xml.stream.StreamFilter; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLReporter; -import javax.xml.stream.XMLResolver; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.util.XMLEventAllocator; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; - -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -/** - * Default implementation of an XMLInputFactory that creates validating - * XMLStreamReaders. - * - * @version $Rev$ $Date$ - */ -public class DefaultValidatingXMLInputFactory extends ValidatingXMLInputFactory { - private static final Logger logger = Logger.getLogger(DefaultValidatingXMLInputFactory.class.getName()); - private XMLInputFactory inputFactory; - private ValidationSchemaExtensionPoint schemas; - private Monitor monitor; - private boolean initialized; - private boolean hasSchemas; - private Schema aggregatedSchema; - - /** - * Constructs a new XMLInputFactory. - * - * @param inputFactory - * @param schemas - */ - public DefaultValidatingXMLInputFactory(XMLInputFactory inputFactory, ValidationSchemaExtensionPoint schemas, Monitor monitor) { - this.inputFactory = inputFactory; - this.schemas = schemas; - this.monitor = monitor; - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = - new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, - message, ex); - monitor.problem(problem); - } - } - - /** - * Initialize the registered schemas and create an aggregated schema for - * validation. - */ - private void initializeSchemas() { - if (initialized) { - return; - } - initialized = true; - - // Load the XSDs registered in the validation schema extension point - try { - List uris = schemas.getSchemas(); - int n = uris.size(); - if (n ==0) { - return; - } else { - hasSchemas = true; - } - final Source[] sources = new Source[n]; - for (int i =0; i < n; i++) { - final String uri = uris.get(i); - // Allow privileged access to open URL stream. Requires FilePermission in security policy. - final URL url = new URL( uri ); - InputStream urlStream; - try { - urlStream = AccessController.doPrivileged(new PrivilegedExceptionAction() { - public InputStream run() throws IOException { - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - return connection.getInputStream(); - } - }); - } catch (PrivilegedActionException e) { - error("PrivilegedActionException", url, (IOException)e.getException()); - throw (IOException)e.getException(); - } - sources[i] = new StreamSource(urlStream, uri); - } - - // Create an aggregated validation schemas from all the XSDs - final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - // Allow privileged access to check files. Requires FilePermission - // in security policy. - try { - aggregatedSchema = AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Schema run() throws SAXException { - return schemaFactory.newSchema(sources); - } - }); - } catch (PrivilegedActionException e) { - error("PrivilegedActionException", schemaFactory, (SAXException)e.getException()); - throw (SAXException)e.getException(); - } - - } catch (Error e) { - // FIXME Log this, some old JDKs don't support XMLSchema validation - logger.log(Level.WARNING, "XML Schema validation is not supported: " + e.getMessage()); - } catch (SAXParseException e) { - IllegalStateException ie = new IllegalStateException(e); - error("IllegalStateException", schemas, ie); - throw ie; - } catch (Exception e) { - //FIXME Log this, some old JDKs don't support XMLSchema validation - logger.log(Level.WARNING, "XML Schema validation is not supported: " + e.getMessage()); - } - } - - @Override - public XMLEventReader createFilteredReader(XMLEventReader arg0, EventFilter arg1) throws XMLStreamException { - return inputFactory.createFilteredReader(arg0, arg1); - } - - @Override - public XMLStreamReader createFilteredReader(XMLStreamReader arg0, StreamFilter arg1) throws XMLStreamException { - return inputFactory.createFilteredReader(arg0, arg1); - } - - @Override - public XMLEventReader createXMLEventReader(InputStream arg0, String arg1) throws XMLStreamException { - return inputFactory.createXMLEventReader(arg0, arg1); - } - - @Override - public XMLEventReader createXMLEventReader(InputStream arg0) throws XMLStreamException { - return inputFactory.createXMLEventReader(arg0); - } - - @Override - public XMLEventReader createXMLEventReader(Reader arg0) throws XMLStreamException { - return inputFactory.createXMLEventReader(arg0); - } - - @Override - public XMLEventReader createXMLEventReader(Source arg0) throws XMLStreamException { - return inputFactory.createXMLEventReader(arg0); - } - - @Override - public XMLEventReader createXMLEventReader(String arg0, InputStream arg1) throws XMLStreamException { - return inputFactory.createXMLEventReader(arg0, arg1); - } - - @Override - public XMLEventReader createXMLEventReader(String arg0, Reader arg1) throws XMLStreamException { - return inputFactory.createXMLEventReader(arg0, arg1); - } - - @Override - public XMLEventReader createXMLEventReader(XMLStreamReader arg0) throws XMLStreamException { - return inputFactory.createXMLEventReader(arg0); - } - - @Override - public XMLStreamReader createXMLStreamReader(InputStream arg0, String arg1) throws XMLStreamException { - initializeSchemas(); - if (hasSchemas) { - return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0, arg1), aggregatedSchema, monitor); - }else { - return inputFactory.createXMLStreamReader(arg0, arg1); - } - } - - @Override - public XMLStreamReader createXMLStreamReader(InputStream arg0) throws XMLStreamException { - initializeSchemas(); - if (hasSchemas) { - return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0), aggregatedSchema, monitor); - } else { - return inputFactory.createXMLStreamReader(arg0); - } - } - - @Override - public XMLStreamReader createXMLStreamReader(Reader arg0) throws XMLStreamException { - initializeSchemas(); - if (hasSchemas) { - return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0), aggregatedSchema, monitor); - } else { - return inputFactory.createXMLStreamReader(arg0); - } - } - - @Override - public XMLStreamReader createXMLStreamReader(Source arg0) throws XMLStreamException { - initializeSchemas(); - if (hasSchemas) { - return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0), aggregatedSchema, monitor); - } else { - return inputFactory.createXMLStreamReader(arg0); - } - } - - @Override - public XMLStreamReader createXMLStreamReader(String arg0, InputStream arg1) throws XMLStreamException { - initializeSchemas(); - if (hasSchemas) { - return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0, arg1), aggregatedSchema, monitor); - } else { - return inputFactory.createXMLStreamReader(arg0, arg1); - } - } - - @Override - public XMLStreamReader createXMLStreamReader(String arg0, Reader arg1) throws XMLStreamException { - initializeSchemas(); - if (hasSchemas) { - return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0, arg1), aggregatedSchema, monitor); - } else { - return inputFactory.createXMLStreamReader(arg0, arg1); - } - } - - @Override - public XMLEventAllocator getEventAllocator() { - return inputFactory.getEventAllocator(); - } - - @Override - public Object getProperty(String arg0) throws IllegalArgumentException { - return inputFactory.getProperty(arg0); - } - - @Override - public XMLReporter getXMLReporter() { - return inputFactory.getXMLReporter(); - } - - @Override - public XMLResolver getXMLResolver() { - return inputFactory.getXMLResolver(); - } - - @Override - public boolean isPropertySupported(String arg0) { - return inputFactory.isPropertySupported(arg0); - } - - @Override - public void setEventAllocator(XMLEventAllocator arg0) { - inputFactory.setEventAllocator(arg0); - } - - @Override - public void setProperty(String arg0, Object arg1) throws IllegalArgumentException { - inputFactory.setProperty(arg0, arg1); - } - - @Override - public void setXMLReporter(XMLReporter arg0) { - inputFactory.setXMLReporter(arg0); - } - - @Override - public void setXMLResolver(XMLResolver arg0) { - inputFactory.setXMLResolver(arg0); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java deleted file mode 100644 index 9f4094aa12..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java +++ /dev/null @@ -1,95 +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.contribution.processor; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; - -/** - * Default implementation of an extension point for XML schemas. - * - * @version $Rev$ $Date$ - */ -public class DefaultValidationSchemaExtensionPoint implements ValidationSchemaExtensionPoint { - - private List schemas = new ArrayList(); - private boolean loaded; - - public void addSchema(String uri) { - schemas.add(uri); - } - - public void removeSchema(String uri) { - schemas.remove(uri); - } - - /** - * Load schema declarations from META-INF/services/ - * org.apache.tuscany.sca.contribution.processor.ValidationSchema files - */ - private synchronized void loadSchemas() { - if (loaded) - return; - - // Get the schema declarations - Set schemaDeclarations; - try { - schemaDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations("org.apache.tuscany.sca.contribution.processor.ValidationSchema"); - } catch (IOException e) { - throw new IllegalStateException(e); - } - - // TODO - temp fix to ensure that the schema tuscany-sca.xsd always comes first - String tuscanyScaXsd = null; - - // Find each schema - for (ServiceDeclaration schemaDeclaration: schemaDeclarations) { - URL url = schemaDeclaration.getResource(schemaDeclaration.getClassName()); - if (url == null) { - throw new IllegalArgumentException(new FileNotFoundException(schemaDeclaration.getClassName())); - } - - if (url.toString().contains("tuscany-sca.xsd")){ - tuscanyScaXsd = url.toString(); - } else { - schemas.add(url.toString()); - } - } - - if (tuscanyScaXsd != null){ - schemas.add(0, tuscanyScaXsd); - } - - loaded = true; - } - - public List getSchemas() { - loadSchemas(); - return schemas; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java deleted file mode 100644 index 2e24477f35..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java +++ /dev/null @@ -1,99 +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.contribution.processor; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.util.List; - -import org.apache.tuscany.sca.contribution.service.ContributionException; -import org.apache.tuscany.sca.contribution.service.TypeDescriber; -import org.apache.tuscany.sca.contribution.service.UnsupportedPackageTypeException; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; - -/** - * Implementation of an extensible package processor. - * - * Takes a package processor extension point and delegates to the proper package - * processor from the extension point based on the package's content type. - * - * @version $Rev$ $Date$ - */ -public class ExtensiblePackageProcessor implements PackageProcessor { - - private PackageProcessorExtensionPoint processors; - private TypeDescriber packageTypeDescriber; - private Monitor monitor; - - public ExtensiblePackageProcessor(PackageProcessorExtensionPoint processors, - TypeDescriber packageTypeDescriber, - Monitor monitor) { - this.processors = processors; - this.packageTypeDescriber = packageTypeDescriber; - this.monitor = monitor; - } - - /** - * Marshals errors into the monitor - * - * @param problems - * @param message - * @param model - */ - protected void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - public List getArtifacts(URL packageSourceURL, InputStream inputStream) - throws ContributionException, IOException { - String packageType = this.packageTypeDescriber.getType(packageSourceURL, null); - if (packageType == null) { - error("UnsupportedPackageTypeException", packageTypeDescriber, packageSourceURL.toString()); - throw new UnsupportedPackageTypeException("Unsupported contribution package type: " + packageSourceURL.toString()); - } - - PackageProcessor packageProcessor = this.processors.getPackageProcessor(packageType); - if (packageProcessor == null) { - error("UnsupportedPackageTypeException", packageTypeDescriber, packageType); - throw new UnsupportedPackageTypeException("Unsupported contribution package type: " + packageType); - } - - return packageProcessor.getArtifacts(packageSourceURL, inputStream); - } - - public URL getArtifactURL(URL packageSourceURL, URI artifact) throws MalformedURLException { - String contentType = this.packageTypeDescriber.getType(packageSourceURL, null); - PackageProcessor packageProcessor = this.processors.getPackageProcessor(contentType); - return packageProcessor.getArtifactURL(packageSourceURL, artifact); - } - - public String getPackageType() { - return null; - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java deleted file mode 100644 index cc3eaf9379..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java +++ /dev/null @@ -1,264 +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.contribution.processor; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -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.Constants; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.contribution.service.UnrecognizedElementException; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; - -/** - * Implementation of an extensible StAX artifact processor. - * - * Takes a StAXArtifactProcessorExtensionPoint and delegates to the proper - * StAXArtifactProcessor by element QName - * - * @version $Rev$ $Date$ - */ -public class ExtensibleStAXArtifactProcessor implements StAXArtifactProcessor { - - private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS, "anyElement"); - - private static final Logger logger = Logger.getLogger(ExtensibleStAXArtifactProcessor.class.getName()); - private XMLInputFactory inputFactory; - private XMLOutputFactory outputFactory; - private StAXArtifactProcessorExtensionPoint processors; - private Monitor monitor; - - /** - * Constructs a new ExtensibleStAXArtifactProcessor. - * @param processors - * @param inputFactory - * @param outputFactory - */ - public ExtensibleStAXArtifactProcessor(StAXArtifactProcessorExtensionPoint processors, - XMLInputFactory inputFactory, - XMLOutputFactory outputFactory, - Monitor monitor) { - super(); - this.processors = processors; - this.inputFactory = inputFactory; - this.outputFactory = outputFactory; - if (this.outputFactory != null) { - this.outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE); - } - this.monitor = monitor; - } - - /** - * Report a warning. - * - * @param problems - * @param message - * @param model - */ - private void warning(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - - public Object read(XMLStreamReader source) throws ContributionReadException, XMLStreamException { - - // Delegate to the processor associated with the element QName - int event = source.getEventType(); - if (event == XMLStreamConstants.START_DOCUMENT) { - source.nextTag(); - } - QName name = source.getName(); - StAXArtifactProcessor processor = (StAXArtifactProcessor)processors.getProcessor(name); - if (processor == null) { - Location location = source.getLocation(); - if (logger.isLoggable(Level.WARNING)) { - logger.warning("Element " + name + " cannot be processed. (" + location + ")"); - } - warning("ElementCannotBeProcessed", processors, name, location); - - StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT); - if(anyElementProcessor != null) { - return anyElementProcessor.read(source); - } else { - return null; - } - - } - return processor.read(source); - } - - @SuppressWarnings("unchecked") - public void write(Object model, XMLStreamWriter outputSource) throws ContributionWriteException, XMLStreamException { - - // Delegate to the processor associated with the model type - if (model != null) { - StAXArtifactProcessor processor = processors.getProcessor(model.getClass()); - if (processor != null) { - processor.write(model, outputSource); - } else { - if (logger.isLoggable(Level.WARNING)) { - logger.warning("No StAX processor is configured to handle " + model.getClass()); - } - warning("NoStaxProcessor", processors, model.getClass()); - StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT); - if(anyElementProcessor != null) { - anyElementProcessor.write(model, outputSource); - } - } - } - } - - @SuppressWarnings("unchecked") - public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException { - - // Delegate to the processor associated with the model type - if (model != null) { - StAXArtifactProcessor processor = processors.getProcessor(model.getClass()); - if (processor != null) { - processor.resolve(model, resolver); - } - } - } - - /** - * Read a model from an InputStream. - * @param is The artifact InputStream - * @param type Model type - * @return The model - * @throws ContributionReadException - */ - public M read(InputStream is, Class type) throws ContributionReadException { - try { - XMLStreamReader reader; - try { - reader = inputFactory.createXMLStreamReader(is); - try { - reader.nextTag(); - QName name = reader.getName(); - Object mo = read(reader); - if (type.isInstance(mo)) { - return type.cast(mo); - } else { - error("UnrecognizedElementException", reader, name); - UnrecognizedElementException e = new UnrecognizedElementException(name); - throw e; - } - } catch (ContributionReadException e) { - Location location = reader.getLocation(); - e.setLine(location.getLineNumber()); - e.setColumn(location.getColumnNumber()); - error("ContributionReadException", reader, e); - throw e; - } finally { - try { - reader.close(); - } catch (XMLStreamException e) { - // ignore - } - } - } finally { - try { - is.close(); - } catch (IOException e) { - // ignore - } - } - } catch (XMLStreamException e) { - ContributionReadException ce = new ContributionReadException(e); - error("ContributionReadException", inputFactory, ce); - throw ce; - } - } - - /** - * Write a model to an OutputStream. - * @param model - * @param os - * @throws ContributionWriteException - */ - public void write(Object model, OutputStream os) throws ContributionWriteException { - try { - XMLStreamWriter writer = outputFactory.createXMLStreamWriter(os); - write(model, writer); - writer.flush(); - writer.close(); - } catch (XMLStreamException e) { - ContributionWriteException cw = new ContributionWriteException(e); - error("ContributionWriteException", outputFactory, cw); - throw cw; - } - } - - public QName getArtifactType() { - return null; - } - - public Class getModelType() { - return null; - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java deleted file mode 100644 index f2ee8bc786..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java +++ /dev/null @@ -1,247 +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.contribution.processor; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -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.Constants; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; - -/** - * Implementation of an extensible StAX attribute processor. - * - * Takes a StAXAttributeProcessorExtensionPoint and delegates to the proper - * StAXAttributeProcessor by attribute QName - * - * @version $Rev$ $Date$ - */ -public class ExtensibleStAXAttributeProcessor - implements StAXAttributeProcessor { - - private static final Logger logger = Logger.getLogger(ExtensibleStAXAttributeProcessor.class.getName()); - - private static final QName ANY_ATTRIBUTE = new QName(Constants.XMLSCHEMA_NS, "anyAttribute"); - - private XMLInputFactory inputFactory; - private XMLOutputFactory outputFactory; - private StAXAttributeProcessorExtensionPoint processors; - private Monitor monitor; - - /** - * Constructs a new ExtensibleStAXArtifactProcessor. - * @param processors - * @param inputFactory - * @param outputFactory - */ - public ExtensibleStAXAttributeProcessor(StAXAttributeProcessorExtensionPoint processors, - XMLInputFactory inputFactory, - XMLOutputFactory outputFactory, - Monitor monitor) { - super(); - this.processors = processors; - this.inputFactory = inputFactory; - this.outputFactory = outputFactory; - if (this.outputFactory != null) { - this.outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE); - } - this.monitor = monitor; - } - - /** - * Report a warning. - * - * @param problems - * @param message - * @param model - */ - private void warning(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - - public Object read(QName attributeName, XMLStreamReader source) throws ContributionReadException, XMLStreamException { - - // Delegate to the processor associated with the attribute QName - int event = source.getEventType(); - if (event == XMLStreamConstants.START_DOCUMENT) { - source.nextTag(); - } - - StAXAttributeProcessor processor = null; - - //lookup for registered attribute processors - processor = (StAXAttributeProcessor)processors.getProcessor(attributeName); - if (processor == null) { - Location location = source.getLocation(); - if (logger.isLoggable(Level.WARNING)) { - logger.warning("Attribute " + attributeName + " cannot be processed. (" + location + ")"); - } - warning("AttributeCannotBeProcessed", processors, attributeName, location); - } else { - return processor.read(attributeName, source); - } - - - //handle extension attributes without processors - processor = (StAXAttributeProcessor)processors.getProcessor(ANY_ATTRIBUTE); - if (processor == null) { - Location location = source.getLocation(); - if (logger.isLoggable(Level.WARNING)) { - logger.warning("Could not find Default Attribute processor !"); - } - warning("DefaultAttributeProcessorNotAvailable", processors, ANY_ATTRIBUTE, location); - } - - return processor == null ? null : processor.read(attributeName, source); - } - - @SuppressWarnings("unchecked") - public void write(Object model, XMLStreamWriter outputSource) throws ContributionWriteException, XMLStreamException { - - if(model == null) { - return; - } - - // Delegate to the processor associated with the model type - StAXAttributeProcessor processor = processors.getProcessor(model.getClass()); - if(processor == null) { - if (logger.isLoggable(Level.WARNING)) { - logger.warning("No StAX processor is configured to handle " + model.getClass()); - } - warning("NoStaxProcessor", processors, model.getClass()); - } else { - processor.write(model, outputSource); - return; - } - - //handle extension attributes without processors - processor = (StAXAttributeProcessor)processors.getProcessor(ANY_ATTRIBUTE); - if(processor == null) { - if (logger.isLoggable(Level.WARNING)) { - logger.warning("No Default StAX processor is configured to handle " + model.getClass()); - } - warning("NoDefaultStaxProcessor", processors, model.getClass()); - } else { - processor.write(model, outputSource); - return; - } - } - - - - @SuppressWarnings("unchecked") - public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException { - - // Delegate to the processor associated with the model type - if (model != null) { - StAXAttributeProcessor processor = processors.getProcessor(model.getClass()); - if (processor != null) { - processor.resolve(model, resolver); - } - } - } - - /** - * Read a model from an InputStream. - * @param is The artifact InputStream - * @param type Model type - * @return The model - * @throws ContributionReadException - */ - public M read(InputStream is, Class type) throws ContributionReadException { - return null; - } - - /** - * Write a model to an OutputStream. - * @param model - * @param os - * @throws ContributionWriteException - */ - public void write(Object model, OutputStream os) throws ContributionWriteException { - try { - XMLStreamWriter writer = outputFactory.createXMLStreamWriter(os); - write(model, writer); - writer.flush(); - writer.close(); - } catch (XMLStreamException e) { - ContributionWriteException cw = new ContributionWriteException(e); - error("ContributionWriteException", outputFactory, cw); - throw cw; - } - } - - public QName getArtifactType() { - return null; - } - - public Class getModelType() { - return null; - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java deleted file mode 100644 index 8427098035..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java +++ /dev/null @@ -1,143 +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.contribution.processor; - -import java.net.URI; -import java.net.URL; - -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.UnrecognizedElementException; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; - -/** - * Implementation of an extensible URL artifact processor. - * - * Takes a URLArtifactProcessorExtensionPoint and delegates to the proper URLArtifactProcessor - * by either fileName or fileExtention - * - * @version $Rev$ $Date$ - */ -public class ExtensibleURLArtifactProcessor - implements URLArtifactProcessor { - - private URLArtifactProcessorExtensionPoint processors; - private Monitor monitor; - - /** - * Constructs a new ExtensibleURLArtifactProcessor. - * - * @param processors - */ - public ExtensibleURLArtifactProcessor(URLArtifactProcessorExtensionPoint processors, Monitor monitor) { - this.processors = processors; - this.monitor = monitor; - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - @SuppressWarnings("unchecked") - public Object read(URL contributionURL, URI sourceURI, URL sourceURL) throws ContributionReadException { - URLArtifactProcessor processor = null; - - // Delegate to the processor associated with file extension - String fileName = getFileName(sourceURL); - - //try to retrieve a processor for the specific filename - processor = (URLArtifactProcessor)processors.getProcessor(fileName); - - if (processor == null) { - //try to find my file type (extension) - String extension = sourceURL.getPath(); - - int extensionStart = extension.lastIndexOf('.'); - //handle files without extension (e.g NOTICE) - if (extensionStart > 0) { - extension = extension.substring(extensionStart); - processor = (URLArtifactProcessor)processors.getProcessor(extension); - } - } - - if (processor == null) { - return null; - } - return processor.read(contributionURL, sourceURI, sourceURL); - } - - @SuppressWarnings("unchecked") - public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException { - - // Delegate to the processor associated with the model type - if (model != null) { - URLArtifactProcessor processor = processors.getProcessor(model.getClass()); - if (processor != null) { - processor.resolve(model, resolver); - } - } - } - - public M read(URL contributionURL, URI artifactURI, URL artifactUrl, Class type) - throws ContributionReadException { - Object mo = read(contributionURL, artifactURI, artifactUrl); - if (type.isInstance(mo)) { - return type.cast(mo); - } else { - UnrecognizedElementException e = new UnrecognizedElementException(null); - e.setResourceURI(artifactURI.toString()); - error("UnrecognizedElementException", processors, artifactURI.toString()); - throw e; - } - } - - public String getArtifactType() { - return null; - } - - public Class getModelType() { - return null; - } - - /** - * Returns the file name from a URL. - * @param url - * @return - */ - private static String getFileName(URL url){ - String fileName = url.getPath(); - int pos = fileName.lastIndexOf("/"); - - return fileName.substring(pos +1); - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java deleted file mode 100644 index f17f31edb1..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java +++ /dev/null @@ -1,70 +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.contribution.processor; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.util.List; - -import org.apache.tuscany.sca.contribution.service.ContributionException; - -/** - * Interface for contribution package processors - * - * Package processors understand the format of the contribution and how to get the - * artifacts in the contribution. - * - * @version $Rev$ $Date$ - */ -public interface PackageProcessor { - - /** - * Returns the type of package supported by this package processor. - * - * @return the package type - */ - String getPackageType(); - - /** - * Returns a list of artifacts in the contribution. - * - * @param packageSourceURL Contribution package location URL - * @param inputStream Optional content of the package - * @return List of artifact URIs - * @throws ContributionException - * @throws IOException - */ - List getArtifacts(URL packageSourceURL, InputStream inputStream) throws ContributionException, IOException; - - /** - * Return the URL for an artifact in the package. - * - * This is needed for archives such as jar files that have specific URL schemes - * for the artifacts they contain. - * - * @param packageSourceURL Contribution package location URL - * @param artifact The relative URI for the artifact - * @return The artifact URL - */ - URL getArtifactURL(URL packageSourceURL, URI artifact) throws MalformedURLException; - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java deleted file mode 100644 index ed99239b19..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java +++ /dev/null @@ -1,50 +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.contribution.processor; - -/** - * An extension point for package processors - * - * @version $Rev$ $Date$ - */ -public interface PackageProcessorExtensionPoint { - - /** - * Register a PackageProcessor using the package type as the key. - * - * @param processor The package processor - */ - void addPackageProcessor(PackageProcessor processor); - - /** - * Unregister a PackageProcessor. - * - * @param processor The package processor - */ - void removePackageProcessor(PackageProcessor processor); - - /** - * Returns the PackageProcessor for the given package type. - * - * @param packageType The package type - * @return The package processor - */ - PackageProcessor getPackageProcessor(String packageType); - -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java deleted file mode 100644 index fcf9347564..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.contribution.processor; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; - -/** - * An artifact processor that can read models from a StAX XMLStreamReader. - * - * @version $Rev$ $Date$ - */ -public interface StAXArtifactProcessor extends ArtifactProcessor { - - /** - * Reads a model from an XMLStreamReader. - * - * @param reader The XMLStreamReader - * @return A model representation of the input. - */ - M read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException; - - /** - * Writes a model to an XMLStreamWriter. - * - * @param model A model representing the source - * @param writer The XML stream writer - * @throws ContributionWriteException - * @throws XMLStreamException - */ - void write(M model, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException; - - /** - * Returns the type of artifact handled by this artifact processor. - * - * @return The type of artifact handled by this artifact processor - */ - QName getArtifactType(); -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java deleted file mode 100644 index 9700e2bc60..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java +++ /dev/null @@ -1,29 +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.contribution.processor; - -/** - * An extension point for StAX artifact processors. - * - * @version $Rev$ $Date$ - */ -public interface StAXArtifactProcessorExtensionPoint extends - ArtifactProcessorExtensionPoint { - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java deleted file mode 100644 index e8edb743a4..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java +++ /dev/null @@ -1,63 +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.contribution.processor; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; - - -/** - * An artifact processor that can read attributes from a StAX XMLStreamReader. - * - * @version $Rev$ $Date$ - */ -public interface StAXAttributeProcessor extends ArtifactProcessor{ - - /** - * Reads a model from an XMLStreamReader. - * - * @param reader The XMLStreamReader - * @return A model representation of the input. - */ - M read(QName attributeName, XMLStreamReader reader) throws ContributionReadException, XMLStreamException; - - /** - * Writes a model to an XMLStreamWriter. - * - * @param model A model representing the source - * @param writer The XML stream writer - * @throws ContributionWriteException - * @throws XMLStreamException - */ - void write(M model, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException; - - /** - * Returns the type of artifact handled by this artifact processor. - * - * @return The type of artifact handled by this artifact processor - */ - QName getArtifactType(); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java deleted file mode 100644 index ebad243c1c..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java +++ /dev/null @@ -1,29 +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.contribution.processor; - -/** - * An extension point for StAX artifact processors. - * - * @version $Rev$ $Date$ - */ -public interface StAXAttributeProcessorExtensionPoint extends - ArtifactProcessorExtensionPoint { - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyNamespaceContext.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyNamespaceContext.java deleted file mode 100644 index 2adebb9f33..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyNamespaceContext.java +++ /dev/null @@ -1,111 +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.contribution.processor; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import javax.xml.namespace.NamespaceContext; - -public class TuscanyNamespaceContext implements NamespaceContext { - - private Stack[]> context = null; - - public TuscanyNamespaceContext(Stack[]> context) { - this.context = context; - } - - public String getNamespaceURI(String prefix) { - if (prefix == null) { - throw new IllegalArgumentException(); - } - return (String)getResult("getNSUri", prefix); - } - - public String getPrefix(String namespaceURI) { - if (namespaceURI == null) { - throw new IllegalArgumentException(); - } - return (String)getResult("getPrefix", namespaceURI); - } - - @SuppressWarnings("unchecked") - public Iterator getPrefixes(String namespaceURI) { - if (namespaceURI == null) { - throw new IllegalArgumentException(); - } - - Iterator iterator = (Iterator)getResult("getPrefixes", namespaceURI); - return iterator; - } - - /* - * Generic method to Iterate through the Stack and return required result(s) - */ - private Object getResult(String operation, String arg) { - - List[] contextList = null; - Iterator prefItr = null; - Iterator uriItr = null; - - List list = new ArrayList(); - - String toCompare = null; - - String tempPrefix = null; - String tempUri = null; - - for (int i = context.size() - 1; i >= 0; i--) { - contextList = context.get(i); - prefItr = contextList[0].iterator(); - uriItr = contextList[1].iterator(); - while (uriItr.hasNext()) { - tempPrefix = prefItr.next(); - tempUri = uriItr.next(); - if (operation.equalsIgnoreCase("getNSUri")) { - toCompare = tempPrefix; - } else if (operation.equalsIgnoreCase("getPrefix")) { - toCompare = tempUri; - } else if (operation.equalsIgnoreCase("getPrefixes")) { - toCompare = tempUri; - } - if (toCompare != null && arg.equalsIgnoreCase(toCompare)) { - if (operation.equalsIgnoreCase("getNSUri")) { - return tempUri; - } else if (operation.equalsIgnoreCase("getPrefix")) { - return tempPrefix; - } else if (operation.equalsIgnoreCase("getPrefixes")) { - list.add(tempPrefix); - } - - } - } - } - - if (operation.equalsIgnoreCase("getPrefixes")) { - return Collections.unmodifiableList(list).iterator(); - } - - return null; - } - -} //end of Class diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java deleted file mode 100644 index e1b218d9f4..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.apache.tuscany.sca.contribution.processor; - -/* - * 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. - */ -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; - -import javax.xml.XMLConstants; -import javax.xml.namespace.NamespaceContext; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.util.StreamReaderDelegate; - -/* - * Custom implementaion of the XMLStreamReader to keep track of the namespace context for each element - */ -public class TuscanyXMLStreamReader extends StreamReaderDelegate implements XMLStreamReader { - - Stack[]> context = new Stack[]>(); - - String characterEncodingScheme; - List[] contextList; - List prefixList; - List uriList; - - public TuscanyXMLStreamReader(XMLStreamReader reader) { - super(reader); - this.saveCharacterEncodingScheme(); - } - - public void pushContext() throws XMLStreamException { - contextList = new List[2]; - prefixList = new ArrayList(); - uriList = new ArrayList(); - int namespaceCount = this.getNamespaceCount(); - for (int i = 0; i < namespaceCount; i++) { - prefixList.add(checkString(this.getNamespacePrefix(i))); - uriList.add(this.getNamespaceURI(i)); - } - contextList[0] = prefixList; - contextList[1] = uriList; - context.push(contextList); - } - - private String checkString(String namespacePrefix) { - if (namespacePrefix == null) { - return XMLConstants.DEFAULT_NS_PREFIX; - } else { - return namespacePrefix; - } - } - - public void popContext() throws XMLStreamException { - context.pop(); - } - - public void saveCharacterEncodingScheme() { - this.characterEncodingScheme = super.getCharacterEncodingScheme(); - } - - // A flag to indicate if the next() is called from nextTag() - private boolean withinNextTagMethod = false; - - /* - * Overriding the next() method to perform PUSH and POP operations - * for the NamespaceContext for the current element - */ - @Override - public int next() throws XMLStreamException { - // POP the namespaces if the reader leaves the end element - if (!withinNextTagMethod && this.getEventType() == END_ELEMENT) { - popContext(); - } - - // get the next event - int nextEvent = super.next(); - - // PUSH the namespaces onto the stack as the reader enters the start element - if (!withinNextTagMethod && nextEvent == START_ELEMENT) { - pushContext(); - } - return nextEvent; - } - - @Override - public int nextTag() throws XMLStreamException { - withinNextTagMethod = true; - // POP the namespaces out of the stack if the reader leaves the end element - if (this.getEventType() == END_ELEMENT) { - popContext(); - } - - // REVIEW: what if nextTag() calls next()? - int event = super.nextTag(); - - // PUSH the namespaces onto the stack as the reader enters the start element - if (event == START_ELEMENT) { - pushContext(); - } - withinNextTagMethod = false; - return event; - } - - @Override - public NamespaceContext getNamespaceContext() { - return new TuscanyNamespaceContext((Stack[]>)context.clone()); - } - - - @Override - public String getCharacterEncodingScheme() { - return characterEncodingScheme; - } -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java deleted file mode 100644 index 2ecddf5465..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java +++ /dev/null @@ -1,51 +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.contribution.processor; - -import java.net.URI; -import java.net.URL; - -import org.apache.tuscany.sca.contribution.service.ContributionReadException; - -/** - * An artifact processor that can read models from a URL. - * - * @version $Rev$ $Date$ - */ -public interface URLArtifactProcessor extends ArtifactProcessor { - - /** - * Reads a model from a URL. - * - * @param contributionURL Contribution location URL - * @param artifactURI Artifact URI - * @param artifactURL Artifact location URL - * @return A model representation of the input. - */ - M read(URL contributionURL, URI artifactURI, URL artifactURL) throws ContributionReadException; - - /** - * Returns the type of artifact handled by this artifact processor. - * - * @return The type of artifact handled by this artifact processor - */ - String getArtifactType(); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java deleted file mode 100644 index 7714586951..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java +++ /dev/null @@ -1,29 +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.contribution.processor; - -/** - * An extension point for URL artifact processors. - * - * @version $Rev$ $Date$ - */ -public interface URLArtifactProcessorExtensionPoint extends - ArtifactProcessorExtensionPoint { - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java deleted file mode 100644 index da249a09e4..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java +++ /dev/null @@ -1,42 +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.contribution.processor; - -import javax.xml.stream.XMLInputFactory; - -/** - * Base marker class for validating XML input factories. - * - * @version $Rev$ $Date$ - */ -public abstract class ValidatingXMLInputFactory extends XMLInputFactory { - - /** - * Create a new default validating XML input factory. - * @return - */ - public static ValidatingXMLInputFactory newInstance() { - return new DefaultValidatingXMLInputFactory( - XMLInputFactory.newInstance(), - new DefaultValidationSchemaExtensionPoint(), - null); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java deleted file mode 100644 index 9b4a4938d1..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java +++ /dev/null @@ -1,396 +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.contribution.processor; - -import java.util.logging.Logger; - -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.validation.Schema; -import javax.xml.validation.ValidatorHandler; - -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; -import org.xml.sax.Attributes; -import org.xml.sax.ErrorHandler; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.helpers.AttributesImpl; - -/** - * - * A validating XMLStreamReader that reports XMLSchema validation errors. - * - * @version $Rev$ $Date$ - */ -class ValidatingXMLStreamReader extends TuscanyXMLStreamReader implements XMLStreamReader { - - private static final Logger logger = Logger.getLogger(ValidatingXMLStreamReader.class.getName()); - - private int level; - private ValidatorHandler handler; - private final Monitor monitor; - - /** - * Constructs a new ValidatingXMLStreamReader. - * - * @param reader - * @param schema - * @throws XMLStreamException - */ - ValidatingXMLStreamReader(XMLStreamReader reader, Schema schema, Monitor monitor) throws XMLStreamException { - super(reader); - this.monitor = monitor; - if (schema == null) { - return; - } - - handler = schema.newValidatorHandler(); - handler.setDocumentLocator(new LocatorAdapter()); - try { - handler.setFeature("http://xml.org/sax/features/namespace-prefixes", true); - } catch (SAXException e) { - XMLStreamException xse = new XMLStreamException(e); - error("XMLStreamException", handler, xse); - throw xse; - } - - // These validation errors are just warnings for us as we want to support - // running from an XML document with XSD validation errors, as long as we can - // get the metadata we need from the document - handler.setErrorHandler(new ErrorHandler() { - private String getMessage(SAXParseException e) { - return "XMLSchema validation problem in: " + e.getSystemId() + ", line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + "\n" + e.getMessage(); - } - - public void error(SAXParseException exception) throws SAXException { - if (ValidatingXMLStreamReader.this.monitor == null) - logger.warning(getMessage(exception)); - else - ValidatingXMLStreamReader.this.error("SchemaError", ValidatingXMLStreamReader.this.getClass(), exception.getSystemId(), - exception.getLineNumber(), exception.getColumnNumber(), exception.getMessage()); - } - - public void fatalError(SAXParseException exception) throws SAXException { - if (ValidatingXMLStreamReader.this.monitor == null) - logger.warning(getMessage(exception)); - else - ValidatingXMLStreamReader.this.error("SchemaFatalError", ValidatingXMLStreamReader.this.getClass(), exception.getSystemId(), - exception.getLineNumber(), exception.getColumnNumber(), exception.getMessage()); - } - - public void warning(SAXParseException exception) throws SAXException { - if (ValidatingXMLStreamReader.this.monitor == null) - logger.warning(getMessage(exception)); - else - ValidatingXMLStreamReader.this.warning("SchemaWarning", ValidatingXMLStreamReader.this.getClass(), exception.getSystemId(), - exception.getLineNumber(), exception.getColumnNumber(), exception.getMessage()); - } - }); - } - - /** - * Report a warning. - * - * @param problems - * @param message - * @param model - */ - private void warning(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - @Override - public int next() throws XMLStreamException { - if (handler == null) { - return super.next(); - } - - int event = super.next(); - try { - switch (event) { - case XMLStreamConstants.START_DOCUMENT: - level++; - handler.startDocument(); - break; - case XMLStreamConstants.START_ELEMENT: - level++; - handleStartElement(); - break; - case XMLStreamConstants.PROCESSING_INSTRUCTION: - handler.processingInstruction(super.getPITarget(), super.getPIData()); - break; - case XMLStreamConstants.CHARACTERS: - case XMLStreamConstants.CDATA: - case XMLStreamConstants.SPACE: - case XMLStreamConstants.ENTITY_REFERENCE: - handler.characters(super.getTextCharacters(), super.getTextStart(), super.getTextLength()); - break; - case XMLStreamConstants.END_ELEMENT: - handleEndElement(); - level--; - break; - case XMLStreamConstants.END_DOCUMENT: - handler.endDocument(); - break; - } - } catch (SAXException e) { - XMLStreamException xse = new XMLStreamException(e.getMessage(), e); - error("XMLStreamException", handler, xse); - throw xse; - } - return event; - } - - @Override - public int nextTag() throws XMLStreamException { - if (handler == null) { - return super.nextTag(); - } - - for (;;) { - int event = super.getEventType(); - try { - switch (event) { - case XMLStreamConstants.START_DOCUMENT: - level++; - handler.startDocument(); - break; - case XMLStreamConstants.START_ELEMENT: - level++; - handleStartElement(); - pushContext(); - return event; - case XMLStreamConstants.PROCESSING_INSTRUCTION: - handler.processingInstruction(super.getPITarget(), super.getPIData()); - break; - case XMLStreamConstants.CHARACTERS: - case XMLStreamConstants.CDATA: - case XMLStreamConstants.SPACE: - case XMLStreamConstants.ENTITY_REFERENCE: - handler.characters(super.getTextCharacters(), super.getTextStart(), super.getTextLength()); - break; - case XMLStreamConstants.END_ELEMENT: - handleEndElement(); - level--; - popContext(); - return event; - case XMLStreamConstants.END_DOCUMENT: - handler.endDocument(); - return event; - } - } catch (SAXException e) { - XMLStreamException xse = new XMLStreamException(e); - error("XMLStreamException", handler, xse); - throw xse; - } - super.next(); - } - } - - @Override - public String getElementText() throws XMLStreamException { - if (handler == null) { - return super.getElementText(); - } - - if (getEventType() != XMLStreamConstants.START_ELEMENT) { - return super.getElementText(); - } - StringBuffer text = new StringBuffer(); - - for (;;) { - int event = next(); - switch (event) { - case XMLStreamConstants.END_ELEMENT: - return text.toString(); - - case XMLStreamConstants.COMMENT: - case XMLStreamConstants.PROCESSING_INSTRUCTION: - continue; - - case CHARACTERS: - case CDATA: - case SPACE: - case ENTITY_REFERENCE: - text.append(getText()); - break; - - default: - break; - } - } - } - - @Override - public NamespaceContext getNamespaceContext(){ - return super.getNamespaceContext(); - } - - /** - * Handle a start element event. - * - * @throws SAXException - */ - private void handleStartElement() throws SAXException { - - // send startPrefixMapping events immediately before startElement event - int nsCount = super.getNamespaceCount(); - for (int i = 0; i < nsCount; i++) { - String prefix = super.getNamespacePrefix(i); - if (prefix == null) { // true for default namespace - prefix = ""; - } - handler.startPrefixMapping(prefix, super.getNamespaceURI(i)); - } - - // fire startElement - QName qname = super.getName(); - String prefix = qname.getPrefix(); - String rawname; - if (prefix == null || prefix.length() == 0) { - rawname = qname.getLocalPart(); - } else { - rawname = prefix + ':' + qname.getLocalPart(); - } - Attributes attrs = getAttributes(); - handler.startElement(qname.getNamespaceURI(), qname.getLocalPart(), rawname, attrs); - } - - /** - * Handle an endElement event. - * - * @throws SAXException - */ - private void handleEndElement() throws SAXException { - - // fire endElement - QName qname = super.getName(); - handler.endElement(qname.getNamespaceURI(), qname.getLocalPart(), qname.toString()); - - // send endPrefixMapping events immediately after endElement event - // we send them in the opposite order to that returned but this is not - // actually required by SAX - int nsCount = super.getNamespaceCount(); - for (int i = nsCount - 1; i >= 0; i--) { - String prefix = super.getNamespacePrefix(i); - if (prefix == null) { // true for default namespace - prefix = ""; - } - handler.endPrefixMapping(prefix); - } - } - - /** - * Get the attributes associated with the current START_ELEMENT event. - * - * @return the StAX attributes converted to org.xml.sax.Attributes - */ - private Attributes getAttributes() { - AttributesImpl attrs = new AttributesImpl(); - - // add namespace declarations - for (int i = 0; i < super.getNamespaceCount(); i++) { - String prefix = super.getNamespacePrefix(i); - String uri = super.getNamespaceURI(i); - if (prefix == null) { - attrs.addAttribute("", "", "xmlns", "CDATA", uri); - } else { - attrs.addAttribute("", "", "xmlns:" + prefix, "CDATA", uri); - } - } - - // Regular attributes - for (int i = 0; i < super.getAttributeCount(); i++) { - String uri = super.getAttributeNamespace(i); - if (uri == null) { - uri = ""; - } - String localName = super.getAttributeLocalName(i); - String prefix = super.getAttributePrefix(i); - String qname; - if (prefix == null || prefix.length() == 0) { - qname = localName; - } else { - qname = prefix + ':' + localName; - } - String type = super.getAttributeType(i); - String value = super.getAttributeValue(i); - - attrs.addAttribute(uri, localName, qname, type, value); - } - - return attrs; - } - - /** - * Adapter for mapping Locator information. - */ - private final class LocatorAdapter implements Locator { - - private LocatorAdapter() { - } - - public int getColumnNumber() { - Location location = getLocation(); - return location == null ? 0 : location.getColumnNumber(); - } - - public int getLineNumber() { - Location location = getLocation(); - return location == null ? 0 : location.getLineNumber(); - } - - public String getPublicId() { - Location location = getLocation(); - return location == null ? "" : location.getPublicId(); - } - - public String getSystemId() { - Location location = getLocation(); - return location == null ? "" : location.getSystemId(); - } - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java deleted file mode 100644 index cc3bb59a5b..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java +++ /dev/null @@ -1,52 +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.contribution.processor; - -import java.util.List; - - -/** - * An extension point for XML schemas used for validation. - * - * @version $Rev$ $Date$ - */ -public interface ValidationSchemaExtensionPoint { - - /** - * Add a schema. - * - * @param uri the URI of the schema - */ - void addSchema(String uri); - - /** - * Remove a schema. - * - * @param uri the URI of the schema - */ - void removeSchema(String uri); - - /** - * Returns the list of schemas registered in the extension point. - * @return the list of schemas - */ - List getSchemas(); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java deleted file mode 100644 index f3555ee71e..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.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.contribution.resolver; - -import java.lang.ref.WeakReference; - -import org.apache.tuscany.sca.assembly.Base; - -/** - * A weak reference to a class, which should be used to register classes - * with an ArtifactResolver and resolve these classes later. - * - * FIXME The core contribution model should not have dependencies on classes - * and ClassLoaders. This should move to the Java import support module. - * - * @version $Rev$ $Date$ - */ -public class ClassReference implements Base { - - private WeakReference> clazz; - private String className; - - /** - * Constructs a new ClassReference. - * - * @param clazz The class reference - */ - public ClassReference(Class clazz) { - this.clazz = new WeakReference>(clazz); - this.className = clazz.getName(); - } - - /** - * Constructs a new ClassReference. - * - * @param className The class name - */ - public ClassReference(String className) { - this.className = className; - } - - /** - * Get the referenced class. - * - * @return The referenced class - */ - public Class getJavaClass() { - if (clazz != null) { - return clazz.get(); - } else { - return null; - } - } - - /** - * Get the referenced class name. - * - * @return The class name - */ - public String getClassName() { - return className; - } - - public boolean isUnresolved() { - return clazz == null; - } - - public void setUnresolved(boolean unresolved) { - throw new IllegalStateException(); - } - - @Override - public int hashCode() { - return className.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else { - if (obj instanceof ClassReference) { - return className.equals(((ClassReference)obj).className); - } else { - return false; - } - } - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java deleted file mode 100644 index 13c622adf0..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java +++ /dev/null @@ -1,68 +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.contribution.resolver; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Base; - -/** - * A model resolver implementation that delegates to a list of model resolvers. - * - * @version $Rev$ $Date$ - */ -public class DefaultDelegatingModelResolver implements ModelResolver { - - private List resolvers; - - public DefaultDelegatingModelResolver(List resolvers) { - this.resolvers = resolvers; - } - - public void addModel(Object resolved) { - throw new IllegalStateException(); - } - - public Object removeModel(Object resolved) { - throw new IllegalStateException(); - } - - public T resolveModel(Class modelClass, T unresolved) { - - //TODO optimize and cache results of the resolution later - - // Go over all resolvers - for (ModelResolver resolver: resolvers) { - - Object resolved = resolver.resolveModel(modelClass, unresolved); - - // Return the resolved model object - if (resolved instanceof Base) { - if (!((Base)resolved).isUnresolved()) { - return modelClass.cast(resolved); - } - } - } - - // Model object was not resolved - return unresolved; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java deleted file mode 100644 index c6facd2b02..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.contribution.resolver; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Base; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.Export; -import org.apache.tuscany.sca.contribution.Import; - -/** - * A model resolver implementation that considers Exports in a list of contributions. - * - * @version $Rev: 560435 $ $Date: 2007-07-27 18:26:55 -0700 (Fri, 27 Jul 2007) $ - */ -public class DefaultImportAllModelResolver implements ModelResolver { - - private Import import_; - private List contributions; - - public DefaultImportAllModelResolver(Import import_, List contributions) { - this.import_ = import_; - this.contributions = contributions; - } - - public void addModel(Object resolved) { - throw new IllegalStateException(); - } - - public Object removeModel(Object resolved) { - throw new IllegalStateException(); - } - - public T resolveModel(Class modelClass, T unresolved) { - - //TODO optimize and cache results of the resolution later - - // Go over all available contributions - for (Contribution contribution : contributions) { - - // Go over all exports in the contribution - for (Export export : contribution.getExports()) { - - // If the export matches the export, try to resolve the model object - if (import_.match(export)) { - Object resolved = export.getModelResolver().resolveModel(modelClass, unresolved); - - // Return the resolved model object - if (resolved instanceof Base) { - if (!((Base)resolved).isUnresolved()) { - return modelClass.cast(resolved); - } - } - } - } - } - - // Model object was not resolved - return unresolved; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java deleted file mode 100644 index 9ae57c41d0..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java +++ /dev/null @@ -1,69 +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.contribution.resolver; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Base; -import org.apache.tuscany.sca.contribution.Export; - -/** - * A model resolver implementation that delegates to a list of exports. - * - * @version $Rev$ $Date$ - */ -public class DefaultImportModelResolver implements ModelResolver { - - private List exports; - - public DefaultImportModelResolver(List exports) { - this.exports = exports; - } - - public void addModel(Object resolved) { - throw new IllegalStateException(); - } - - public Object removeModel(Object resolved) { - throw new IllegalStateException(); - } - - public T resolveModel(Class modelClass, T unresolved) { - - //TODO optimize and cache results of the resolution later - - // Go over all exports - for (Export export: exports) { - - Object resolved = export.getModelResolver().resolveModel(modelClass, unresolved); - - // Return the resolved model object - if (resolved instanceof Base) { - if (!((Base)resolved).isUnresolved()) { - return modelClass.cast(resolved); - } - } - } - - // Model object was not resolved - return unresolved; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java deleted file mode 100644 index bf175813f3..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java +++ /dev/null @@ -1,66 +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.contribution.resolver; - -import java.util.HashMap; -import java.util.Map; - - -/** - * A default implementation of a model resolver based on a map. - * - * @version $Rev$ $Date$ - */ -public class DefaultModelResolver implements ModelResolver { - - private Map map = new HashMap(); - - public DefaultModelResolver() { - } - - public T resolveModel(Class modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - // Return the resolved object - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved) { - return map.remove(resolved); - } - - // FIXME: TUSCANY-2499: temporarily give access to the models to get the jms binding - // use of definitions.xml working while the definitions.xml processing is being refactored - public Map getModels() { - return map; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java deleted file mode 100644 index 61a6d084f2..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java +++ /dev/null @@ -1,117 +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.contribution.resolver; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; - - -/** - * The default implementation of a model resolver extension point. - * - * @version $Rev$ $Date$ - */ -public class DefaultModelResolverExtensionPoint implements ModelResolverExtensionPoint { - private final ExtensionPointRegistry registry; - private final Map, Class> resolvers = new HashMap, Class>(); - private Map loadedResolvers; - - /** - * Constructs a new DefaultModelResolverExtensionPoint. - * @param registry The ExtensionPointRegistry - */ - public DefaultModelResolverExtensionPoint(ExtensionPointRegistry registry) { - this.registry = registry; - } - - public void addResolver(Class modelType, Class resolver) { - resolvers.put(modelType, resolver); - } - - public void removeResolver(Class modelType) { - resolvers.remove(modelType); - } - - @SuppressWarnings("unchecked") - public Class getResolver(Class modelType) { - loadModelResolvers(); - - Class[] classes = modelType.getInterfaces(); - for (Class c : classes) { - Class resolver = resolvers.get(c); - if (resolver == null) { - ServiceDeclaration resolverClass = loadedResolvers.get(c.getName()); - if (resolverClass != null) { - try { - return (Class)resolverClass.loadClass(); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(e); - } - } - } else { - return resolver; - } - } - - Class resolver = resolvers.get(modelType); - if (resolver == null) { - ServiceDeclaration resolverClass = loadedResolvers.get(modelType.getName()); - if (resolverClass != null) { - try { - return (Class)resolverClass.loadClass(); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(e); - } - } - } - return resolver; - } - - /** - * Dynamically load model resolvers declared under META-INF/services - */ - private synchronized void loadModelResolvers() { - if (loadedResolvers != null) - return; - loadedResolvers = new HashMap(); - - // Get the model resolver service declarations - Set modelResolverDeclarations; - try { - modelResolverDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ModelResolver.class); - } catch (IOException e) { - throw new IllegalStateException(e); - } - - // Load model resolvers - for (ServiceDeclaration modelResolverDeclaration: modelResolverDeclarations) { - Map attributes = modelResolverDeclaration.getAttributes(); - String model = attributes.get("model"); - - loadedResolvers.put(model, modelResolverDeclaration); - } - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java deleted file mode 100644 index 04352fd242..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java +++ /dev/null @@ -1,213 +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.contribution.resolver; - -import java.lang.reflect.Constructor; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; - -/** - * An implementation of an extensible model resolver which delegates to the - * proper resolver extension based on the class of the model to resolve. - * - * @version $Rev$ $Date$ - */ -public class ExtensibleModelResolver implements ModelResolver { - private ExtensionPointRegistry extensionPoints; - private final ModelResolverExtensionPoint resolverExtensions; - private final ModelFactoryExtensionPoint modelFactories; - private final Contribution contribution; - private ModelResolver defaultResolver; - private final Map, ModelResolver> resolversByModelType = new HashMap, ModelResolver>(); - private final Map, ModelResolver> resolversByImplementationClass = new HashMap, ModelResolver>(); - private Map map = new HashMap(); - private Object lastUnresolved; - - /** - * Constructs an extensible model resolver - * - * @param contribution - * @param extensionPoints TODO - * @param resolverExtensions - * @param modelFactories - * @param defaultResolver - */ - @Deprecated - public ExtensibleModelResolver(Contribution contribution, - ExtensionPointRegistry extensionPoints, - ModelResolverExtensionPoint resolverExtensions, - ModelFactoryExtensionPoint modelFactories, ModelResolver defaultResolver) { - this.contribution = contribution; - this.extensionPoints = extensionPoints; - this.resolverExtensions = resolverExtensions; - this.modelFactories = modelFactories; - //FIXME Remove this default resolver, this is currently used to resolve policy declarations - // but they should be handled by the contribution import/export mechanism instead of this - // defaultResolver hack. - this.defaultResolver = defaultResolver; - } - - /** - * @param contribution - * @param extensionPoints - */ - public ExtensibleModelResolver(Contribution contribution, ExtensionPointRegistry extensionPoints) { - this.contribution = contribution; - this.extensionPoints = extensionPoints; - this.resolverExtensions = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); - this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - } - - /** - * Returns the proper resolver instance based on the interfaces of the model - * If one is not available on the registry, instantiate on demand - * - * @param modelType - * @return - */ - private ModelResolver getModelResolverInstance(Class modelType) { - // Look up a model resolver instance for the model class or - // each implemented interface - Class[] interfaces = modelType.getInterfaces(); - Class[] classes = new Class[interfaces.length + 1]; - classes[0] = modelType; - if (interfaces.length != 0) { - System.arraycopy(interfaces, 0, classes, 1, interfaces.length); - } - for (Class c : classes) { - - // Look up an existing model resolver instance - ModelResolver resolverInstance = resolversByModelType.get(c); - if (resolverInstance != null) { - return resolverInstance; - } - - // We don't have an instance, lookup a model resolver class - // and instantiate it - Class resolverClass = resolverExtensions.getResolver(c); - if (resolverClass != null) { - - // Construct the model resolver instance and cache it - resolverInstance = resolversByImplementationClass.get(resolverClass); - if (resolverInstance != null) { - resolversByModelType.put(c, resolverInstance); - return resolverInstance; - } - try { - try { - Constructor constructor = - resolverClass.getConstructor(new Class[] {Contribution.class, - ModelFactoryExtensionPoint.class}); - if (constructor != null) { - - resolverInstance = constructor.newInstance(contribution, modelFactories); - resolversByImplementationClass.put(resolverClass, resolverInstance); - resolversByModelType.put(c, resolverInstance); - return resolverInstance; - } - } catch (NoSuchMethodException e) { - Constructor constructor = - resolverClass.getConstructor(new Class[] {Contribution.class, - ExtensionPointRegistry.class}); - if (constructor != null) { - - resolverInstance = constructor.newInstance(contribution, extensionPoints); - resolversByImplementationClass.put(resolverClass, resolverInstance); - resolversByModelType.put(c, resolverInstance); - return resolverInstance; - } - } - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - } - - return null; - } - - public void addModel(Object resolved) { - ModelResolver resolver = getModelResolverInstance(resolved.getClass()); - if (resolver != null) { - resolver.addModel(resolved); - } else { - map.put(resolved, resolved); - } - } - - public Object removeModel(Object resolved) { - ModelResolver resolver = getModelResolverInstance(resolved.getClass()); - if (resolver != null) { - return resolver.removeModel(resolved); - } else { - return map.remove(resolved); - } - } - - public T resolveModel(Class modelClass, T unresolved) { - // Protect against dependency cycles causing infinite recursion - // Save the current unresolved object and check later if we are trying - // to resolve the same object again - if (unresolved == lastUnresolved) { - return unresolved; - } - lastUnresolved = unresolved; - - ModelResolver resolver = getModelResolverInstance(unresolved.getClass()); - if (resolver != null) { - Object resolved = resolver.resolveModel(modelClass, unresolved); - if (resolved != null && resolved != unresolved) { - lastUnresolved = null; - return modelClass.cast(resolved); - } - } else { - //FIXME Remove this default resolver, this is currently used to resolve policy declarations - // but they should be handled by the contribution import/export mechanism instead of this - // defaultResolver hack. - if (defaultResolver != null) { - Object resolved = defaultResolver.resolveModel(modelClass, unresolved); - if (resolved != null && resolved != unresolved) { - lastUnresolved = null; - return modelClass.cast(resolved); - } - } - - Object resolved = map.get(unresolved); - if (resolved != null) { - // Return the resolved object - lastUnresolved = null; - return modelClass.cast(resolved); - } - } - - return unresolved; - } - - // FIXME: TUSCANY-2499: temporarily give access to the defaultResolver to get the jms binding - // use of definitions.xml working while the definitions.xml processing is being refactored - public ModelResolver getDefaultModelResolver() { - return defaultResolver; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java deleted file mode 100644 index 2831bebbc4..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java +++ /dev/null @@ -1,69 +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.contribution.resolver; - -/** - * A model resolver, responsible for resolving models in the scope of an - * SCA contribution. - * - * SCA Assemblies reference artifacts of a wide variety of types. These - * include: - *
    - *
  • Reference from one SCA composite to another SCA composite - *
  • Reference to PolicySet files - *
  • Reference to interface definition files, either WSDL or Java interfaces - *
  • Reference to XSD files - *
  • Reference to any of a wide variety of implementation artifact files, - * including Java classes, BPEL scripts, C++ DLLs and classes, PHP scripts - *
- * - * In the SCA assemblies, these various artifacts are referenced using either - * QNames or logical URIs. Model resolvers are used to resolve these references - * and get the in-memory models representing the referenced artifacts. - * - * @version $Rev$ $Date$ - */ -public interface ModelResolver { - - /** - * Resolve the model representing an artifact. - * - * @param modelClass the type of artifact - * @param unresolved the unresolved model - * @return the resolved model - */ - T resolveModel(Class modelClass, T unresolved); - - /** - * Add a resolved model. - * - * @param resolved The model - */ - void addModel(Object resolved); - - /** - * Remove a resolved model. - * - * @param resolved - * @return The removed model, or null if the model was not removed - */ - Object removeModel(Object resolved); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java deleted file mode 100644 index 4a25059792..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java +++ /dev/null @@ -1,52 +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.contribution.resolver; - - -/** - * An extension point for model resolvers - * - * @version $Rev$ $Date$ - */ -public interface ModelResolverExtensionPoint { - - /** - * Register a model resolver class using the model type as the key - * - * @param modelType The model type - * @param resolver The model resolver Class - */ - void addResolver(Class modelType, Class resolver); - - /** - * Remove the model resolver class for a specific model type - * - * @param modelType The model type - */ - void removeResolver(Class modelType); - - /** - * Retrieve a model resolver class for a specific model type - * - * @param modelType The model artifact type - * @return The model resolver Class - */ - Class getResolver(Class modelType); -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java deleted file mode 100644 index 74f0f2d71d..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java +++ /dev/null @@ -1,45 +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.contribution.resolver; - -/** - * Extension to assembly model implementations to provide a model resolver. - * - * @version $Rev$ $Date$ - */ -public interface ResolverExtension { - - /** - * Returns the model resolver for the models representing the artifacts - * visible in the scope of this contribution. - * - * @return The model resolver - */ - ModelResolver getModelResolver(); - - /** - * Sets the model resolver for the models representing the artifacts - * visible in the scope of this contribution. - * - * @param modelResolver The model resolver - */ - void setModelResolver(ModelResolver modelResolver); - -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java deleted file mode 100644 index 2394f4510b..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java +++ /dev/null @@ -1,103 +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.contribution.resolver; - -import java.net.URL; - -/** - * A resource URL, which should be used to register resources - * with an ArtifactResolver and resolve these resources later. - * - * FIXME Don't use as its deprecated, use Artifact instead. - * - * @version $Rev$ $Date$ - */ -@Deprecated -public class ResourceReference { - - private URL resourceURL; - private String resourceName; - - /** - * Constructs a new ResourceReference. - * - * @param resourceName Name of resource - * @param resourceURL The resource URL - */ - public ResourceReference(String resourceName, URL resourceURL) { - this.resourceURL = resourceURL; - this.resourceName = resourceName; - } - - /** - * Constructs a new ResourceReference. - * - * @param resourceName Name of resource - */ - public ResourceReference(String resourceName) { - this.resourceName = resourceName; - } - - /** - * Get the resource URL. - * - * @return The resource URL - */ - public URL getResource() { - return resourceURL; - } - - /** - * Get the resource name. - * - * @return The resource name - */ - public String getResourceName() { - return resourceName; - } - - /** - * Returns true if the resource reference is unresolved. - * - * @return Whether or not the resource has been resolved - */ - public boolean isUnresolved() { - return resourceURL == null; - } - - @Override - public int hashCode() { - return resourceName.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else { - if (obj instanceof ResourceReference) { - return resourceName.equals(((ResourceReference)obj).resourceName); - } else { - return false; - } - } - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java deleted file mode 100644 index 2d03381c8a..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.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.contribution.scanner; - -import java.net.URL; -import java.util.List; - -import org.apache.tuscany.sca.contribution.service.ContributionReadException; - -/** - * Interface for contribution package scanners - * - * Contribution scanners understand the format of the contribution and how to get the - * artifacts in the contribution. - * - * @version $Rev$ $Date$ - */ -public interface ContributionScanner { - - /** - * Returns the type of package supported by this package scanner. - * - * @return the package type - */ - String getContributionType(); - - /** - * Returns a list of artifacts in the contribution. - * - * @param contributionURL Contribution URL - * @return List of artifact URIs - * @throws ContributionException - * @throws IOException - */ - List getArtifacts(URL contributionURL) throws ContributionReadException; - - /** - * Return the URL for an artifact in the contribution. - * - * This is needed for archives such as jar files that have specific URL schemes - * for the artifacts they contain. - * - * @param contributionURL Contribution URL - * @param artifact The relative URI for the artifact - * @return The artifact URL - */ - URL getArtifactURL(URL contributionURL, String artifact) throws ContributionReadException; - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java deleted file mode 100644 index 1ca9def4ea..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java +++ /dev/null @@ -1,50 +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.contribution.scanner; - -/** - * An extension point for contribution scanners - * - * @version $Rev$ $Date$ - */ -public interface ContributionScannerExtensionPoint { - - /** - * Add a ContributionScanner using the contribution type as the key. - * - * @param scanner The contribution scanner - */ - void addContributionScanner(ContributionScanner scanner); - - /** - * Remove a ContributionScanner. - * - * @param scanner The contribution scanner - */ - void removeContributionScanner(ContributionScanner scanner); - - /** - * Returns the ContributionScanner for the given contribution type. - * - * @param contributionType The contribution type - * @return The contribution scanner - */ - ContributionScanner getContributionScanner(String contributionType); - -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java deleted file mode 100644 index cca1ae7a30..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java +++ /dev/null @@ -1,125 +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.contribution.scanner; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.net.URL; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; - -/** - * Default implementation of a contribution scanner extension point. - * - * @version $Rev$ $Date$ - */ -public class DefaultContributionScannerExtensionPoint implements ContributionScannerExtensionPoint { - - private Map scanners = new HashMap(); - private boolean loaded; - - public DefaultContributionScannerExtensionPoint() { - } - - public void addContributionScanner(ContributionScanner scanner) { - scanners.put(scanner.getContributionType(), scanner); - } - - public void removeContributionScanner(ContributionScanner scanner) { - scanners.remove(scanner.getContributionType()); - } - - public ContributionScanner getContributionScanner(String contentType) { - loadScanners(); - return scanners.get(contentType); - } - - private synchronized void loadScanners() { - if (loaded) - return; - - // Get the scanner service declarations - Set scannerDeclarations; - try { - scannerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionScanner.class); - } catch (IOException e) { - throw new IllegalStateException(e); - } - - for (ServiceDeclaration scannerDeclaration: scannerDeclarations) { - Map attributes = scannerDeclaration.getAttributes(); - - // Load a URL artifact scanner - String contributionType = attributes.get("type"); - - // Create a scanner wrapper and register it - ContributionScanner scanner = new LazyContributionScanner(contributionType, scannerDeclaration); - addContributionScanner(scanner); - } - - loaded = true; - } - - /** - * A facade for contribution scanners. - */ - private static class LazyContributionScanner implements ContributionScanner { - - private ServiceDeclaration scannerDeclaration; - private String contributionType; - private ContributionScanner scanner; - - private LazyContributionScanner(String contributionType, ServiceDeclaration scannerDeclaration) { - this.scannerDeclaration = scannerDeclaration; - this.contributionType = contributionType; - } - - public URL getArtifactURL(URL contributionSourceURL, String artifact) throws ContributionReadException { - return getScanner().getArtifactURL(contributionSourceURL, artifact); - } - - public List getArtifacts(URL contributionSourceURL) throws ContributionReadException { - return getScanner().getArtifacts(contributionSourceURL); - } - - public String getContributionType() { - return contributionType; - } - - private ContributionScanner getScanner() { - if (scanner == null) { - try { - Class scannerClass = (Class)scannerDeclaration.loadClass(); - Constructor constructor = scannerClass.getConstructor(); - scanner = constructor.newInstance(); - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - return scanner; - } - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java deleted file mode 100644 index e183206894..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java +++ /dev/null @@ -1,45 +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.contribution.service; - -/** - * Base class for exceptions raised by contribution services. - * - * @version $Rev$ $Date$ - */ -public class ContributionException extends Exception { - - private static final long serialVersionUID = 4432880414927652578L; - - protected ContributionException() { - super(); - } - - protected ContributionException(String message) { - super(message); - } - - protected ContributionException(String message, Throwable cause) { - super(message, cause); - } - - public ContributionException(Throwable cause) { - super(cause); - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java deleted file mode 100644 index 5158eaf85c..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java +++ /dev/null @@ -1,58 +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.contribution.service; - -import java.util.EventListener; - -import org.apache.tuscany.sca.contribution.Contribution; - -/** - * A listener interface used to listen to contribution repository events. - * - * @version $Rev$ $Date$ - */ -public interface ContributionListener extends EventListener { - - /** - * Notifies the listener that a contribution has been added. - * - * @param repository The contribution repository - * @param contribution The new contribution - */ - void contributionAdded(ContributionRepository repository, Contribution contribution); - - /** - * Notifies the listener that a contribution has been removed. - * - * @param repository The contribution repository - * @param contribution The removed contribution. - */ - void contributionRemoved(ContributionRepository repository, Contribution contribution); - - /** - * Notifies the listener that a contribution has been updated. - * - * @param repository The contribution repository - * @param oldContribution The old contribution - * @param contribution The new contribution - */ - void contributionUpdated(ContributionRepository repository, Contribution oldContribution, Contribution contribution); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java deleted file mode 100644 index ce2b4b13c3..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java +++ /dev/null @@ -1,44 +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.contribution.service; - -import java.util.List; - -public interface ContributionListenerExtensionPoint { - - /** - * Adds a contribution repository listener extension. - * @param listener The listener to add - */ - void addContributionListener(ContributionListener listener); - - /** - * Removes a contribution repository listener extension. - * @param listener The listener to remove - */ - void removeContributionListener(ContributionListener listener); - - /** - * Returns the contribution repository listeners. - * @return - */ - List getContributionListeners(); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java deleted file mode 100644 index 33399dcc2f..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.contribution.service; - -/** - * Denotes an exception while reading artifacts inside an SCA contribution. - * - * @version $Rev$ $Date$ - */ -public class ContributionReadException extends ContributionException { - public static final int UNDEFINED = -1; - private static final long serialVersionUID = -7459051598906813461L; - private String resourceURI; - private int line = UNDEFINED; - private int column = UNDEFINED; - - public ContributionReadException(String message) { - super(message); - } - - public ContributionReadException(String message, Throwable cause) { - super(message, cause); - } - - public ContributionReadException(Throwable cause) { - super(cause); - } - - /** - * Returns the location of the resource that was being read. - * - * @return the location of the resource that was being read - */ - public String getResourceURI() { - return resourceURI; - } - - /** - * Sets the location of the resource that was being read. - * - * @param resourceURI the location of the resource that was being read - */ - public void setResourceURI(String resourceURI) { - this.resourceURI = resourceURI; - } - - /** - * Returns the line inside the resource that was being read. - * @return the line inside the resource that was being read - */ - public int getLine() { - return line; - } - - /** - * Sets the line inside the resource that was being read. - * @param line the line inside the resource that was being read - */ - public void setLine(int line) { - this.line = line; - } - - /** - * Returns the column inside the resource that was being read. - * @return the column inside the resource that was being read - */ - public int getColumn() { - return column; - } - - /** - * Sets the column inside the resource that was being read. - * @param column the column inside the resource that was being read - */ - public void setColumn(int column) { - this.column = column; - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java deleted file mode 100644 index d7d8216f66..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java +++ /dev/null @@ -1,128 +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.contribution.service; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; -import java.util.List; - -import org.apache.tuscany.sca.contribution.Contribution; - -/** - * Contribution repository - * - * @version $Rev$ $Date$ - */ -public interface ContributionRepository { - - /** - * Get the URI of the SCA domain - * - * @return The domain URI - */ - URI getDomain(); - - /** - * Copies a contribution to the repository. - * - * @param contribution A URl pointing to the contribution being copied to - * the repository - * @param sourceURL URL of the source. this would be used to calculate the right - * filename to be stored on the repository when a inputStream is being - * provided - * @param contributionStream InputStream with the content of the - * distribution - * @return A URL pointing to the content of the contribution in the - * repository - * @throws IOException - */ - URL store(String contribution, URL sourceURL, InputStream contributionStream) throws IOException; - /** - * Copy a contribution from the source URL to the repository - * - * @param contribution A URl pointing to the contribution being copied to - * the repository - * @param sourceURL URL of the source. this would be used to calculate the right - * filename to be stored on the repository when a inputStream is being - * provided - * @return A URL pointing to the content of the contribution in the - * repository - * @throws IOException - */ - URL store(String contribution, URL sourceURL) throws IOException; - - /** - * Look up the contribution by URI - * - * @param contribution The URI of the contribution - * @return A URL pointing to the content of the contribution in the - * repository, it will be null if the contribution cannot be found - * in the repository - */ - URL find(String contribution); - - /** - * Remove a contribution from the repository - * - * @param contribution The URI of the contribution to be removed - */ - void remove(String contribution); - - /** - * Get list of URIs for all the contributions in the repository - * - * @return A list of contribution URIs - */ - List list(); - - /** - * Returns the contributions available in the repository. - * @return The list of contributions. - */ - List getContributions(); - - /** - * Adds a contribution to the repository. - * @param contribution The new contribution. - */ - void addContribution(Contribution contribution); - - /** - * Removes a contribution from the repository. - * @param contribution The contribution to remove - */ - void removeContribution(Contribution contribution); - - /** - * Updates a contribution in the repository - * @param contribution The contribution to update - */ - void updateContribution(Contribution contribution); - - /** - * Returns the contribution with the given URI. - * @param uri the URI of the contribution - * @return The contribution - */ - Contribution getContribution(String uri); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java deleted file mode 100644 index ecb774ac0c..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.contribution.service; - -/** - * Denotes a problem while resolving models inside an SCA contribution. - * - * @version $Rev$ $Date$ - */ -public class ContributionResolveException extends ContributionException { - private static final long serialVersionUID = -7459051598906813461L; - - public ContributionResolveException(String message) { - super(message); - } - - public ContributionResolveException(String message, Throwable cause) { - super(message, cause); - } - - public ContributionResolveException(Throwable cause) { - super(cause); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java deleted file mode 100644 index 4bf29a3993..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java +++ /dev/null @@ -1,44 +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.contribution.service; - -/** - * Base class for runtime exceptions raised by contribution services. - * - * @version $Rev$ $Date$ - */ -public class ContributionRuntimeException extends RuntimeException { - private static final long serialVersionUID = 7711215366287498896L; - - protected ContributionRuntimeException() { - super(); - } - - protected ContributionRuntimeException(String message) { - super(message); - } - - protected ContributionRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public ContributionRuntimeException(Throwable cause) { - super(cause); - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java deleted file mode 100644 index dcdb8733b8..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java +++ /dev/null @@ -1,137 +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.contribution.service; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * Service interface that manages artifacts contributed to a Tuscany runtime. - * - * @version $Rev$ $Date$ - */ -public interface ContributionService { - /** - * Contribute an artifact to the SCA Domain. The type of the contribution is - * determined by the Content-Type of the resource or, if that is undefined, - * by some implementation-specific means (such as mapping an extension in - * the URL's path). - * - * @param contributionURI The URI that is used as the contribution unique ID. - * @param sourceURL The location of the resource containing the artifact - * @param storeInRepository Flag that identifies if you want to copy the - * contribution to the repository - * @return The contribution model representing the contribution - * @throws ContributionException if there was a problem with the contribution - * @throws IOException if there was a problem reading the resource - */ - Contribution contribute(String contributionURI, URL sourceURL, boolean storeInRepository) throws ContributionException, - IOException; - - /** - * Contribute an artifact to the SCA Domain. The type of the contribution is - * determined by the Content-Type of the resource or, if that is undefined, - * by some implementation-specific means (such as mapping an extension in - * the URL's path). - * - * @param contributionURI The URI that is used as the contribution unique ID. - * @param sourceURL The location of the resource containing the artifact - * @param modelResolver The model resolver to use to resolve models in the - * scope of this contribution - * @param storeInRepository Flag that identifies if you want to copy the - * contribution to the repository - * @return The contribution model representing the contribution - * @throws ContributionException if there was a problem with the contribution - * @throws IOException if there was a problem reading the resource - */ - Contribution contribute(String contributionURI, URL sourceURL, ModelResolver modelResolver, boolean storeInRepository) throws ContributionException, - IOException; - - /** - * Contribute an artifact to the SCA Domain. - * - * @param contributionURI The URI that is used as the contribution unique ID. - * @param sourceURL The location of the resource containing the artifact. - * This is used to identify what name should be used when storing - * the contribution on the repository - * @param contributionContent A stream containing the resource being - * contributed; the stream will not be closed but the read - * position after the call is undefined - * @return The contribution model representing the contribution - * @throws ContributionException if there was a problem with the contribution - * @throws IOException if there was a problem reading the stream - */ - Contribution contribute(String contributionURI, URL sourceURL, InputStream contributionContent) - throws ContributionException, IOException; - - /** - * Contribute an artifact to the SCA Domain. - * - * @param contributionURI The URI that is used as the contribution unique ID. - * @param sourceURL The location of the resource containing the artifact. - * This is used to identify what name should be used when storing - * the contribution on the repository - * @param modelResolver The model resolver to use to resolve models in the - * scope of this contribution - * @param contributionContent A stream containing the resource being - * contributed; the stream will not be closed but the read - * position after the call is undefined - * @return The contribution model representing the contribution - * @throws ContributionException if there was a problem with the contribution - * @throws IOException if there was a problem reading the stream - */ - Contribution contribute(String contributionURI, URL sourceURL, InputStream contributionContent, ModelResolver modelResolver) - throws ContributionException, IOException; - - /** - * Get the model for an installed contribution - * - * @param contribution The URI of an installed contribution - * @return The model for the contribution or null if there is no such - * contribution - */ - Contribution getContribution(String contribution); - - /** - * Adds or updates a deployment composite using a supplied composite - * ("composite by value" - a data structure, not an existing resource in the - * domain) to the contribution identified by a supplied contribution URI. - * The added or updated deployment composite is given a relative URI that - * matches the "name" attribute of the composite, with a ".composite" - * suffix. - * - * @param contribution The contribution to where - * @param composite - * @throws ContributionException - */ - void addDeploymentComposite(Contribution contribution, Composite composite) throws ContributionException; - - /** - * Remove a contribution from the SCA domain - * - * @param contribution The URI of the contribution - * @throws DeploymentException - */ - void remove(String contribution) throws ContributionException; -} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java deleted file mode 100644 index 8bfdedf180..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.contribution.service; - - -/** - * Denotes an exception while writing artifacts inside an SCA contribution. - * - * @version $Rev$ $Date$ - */ -public class ContributionWriteException extends ContributionException { - private static final long serialVersionUID = -7459051598906813461L; - private String resourceURI; - - public ContributionWriteException(String message) { - super(message); - } - - public ContributionWriteException(String message, Throwable cause) { - super(message, cause); - } - - public ContributionWriteException(Throwable cause) { - super(cause); - } - - /** - * Returns the location of the resource that was being written. - * - * @return the location of the resource that was being written - */ - public String getResourceURI() { - return resourceURI; - } - - /** - * Sets the location of the resource that was being written. - * - * @param resourceURI the location of the resource that was being written - */ - public void setResourceURI(String resourceURI) { - this.resourceURI = resourceURI; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java deleted file mode 100644 index 1ab80e344b..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java +++ /dev/null @@ -1,118 +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.contribution.service; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; - -/** - * Default implementation of a contribution listener extension point. - * - * @version $Rev$ $Date$ - */ -public class DefaultContributionListenerExtensionPoint implements ContributionListenerExtensionPoint { - - private List listeners = new CopyOnWriteArrayList(); - private boolean loadedListeners; - private ModelFactoryExtensionPoint modelFactories; - - /** - * Constructs a new DefaultContributionListenerExtensionPoint. - * - */ - public DefaultContributionListenerExtensionPoint(ModelFactoryExtensionPoint modelFactories) { - this.modelFactories = modelFactories; - } - - /** - * Constructs a new DefaultContributionListenerExtensionPoint. - * - */ - public DefaultContributionListenerExtensionPoint(ExtensionPointRegistry extensionPoints) { - this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - } - - public void addContributionListener(ContributionListener listener) { - listeners.add(listener); - } - - public List getContributionListeners() { - loadListeners(); - return listeners; - } - - public void removeContributionListener(ContributionListener listener) { - listeners.remove(listener); - } - - /** - * Dynamically load listeners declared under META-INF/services - */ - @SuppressWarnings("unchecked") - private synchronized void loadListeners() { - if (loadedListeners) - return; - - // Get the listener service declarations - Set listenerDeclarations; - try { - listenerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionListener.class); - } catch (IOException e) { - throw new IllegalStateException(e); - } - - // Load and instantiate the listeners - for (ServiceDeclaration listenerDeclaration: listenerDeclarations) { - ContributionListener listener; - try { - Class listenerClass = (Class)listenerDeclaration.loadClass(); - try { - Constructor constructor = listenerClass.getConstructor(ModelFactoryExtensionPoint.class); - try { - listener = constructor.newInstance(modelFactories); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(e); - } - } catch (NoSuchMethodException e) { - listener = listenerClass.newInstance(); - } - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(e); - } catch (InstantiationException e) { - throw new IllegalArgumentException(e); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(e); - } - addContributionListener(listener); - } - - loadedListeners = true; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java deleted file mode 100644 index fc0dc3aa99..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java +++ /dev/null @@ -1,77 +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.contribution.service; - -import org.apache.tuscany.sca.contribution.Contribution; - -public class ExtensibleContributionListener implements ContributionListener { - private final ContributionListenerExtensionPoint listeners; - - /** - * Default constructor receiving the listener extension point - * - * @param listeners - */ - public ExtensibleContributionListener(ContributionListenerExtensionPoint listeners) { - this.listeners = listeners; - } - - /** - * Process "contributionAdded" event to all registered listeners - */ - public void contributionAdded(ContributionRepository repository, Contribution contribution) { - for (ContributionListener listener : listeners.getContributionListeners()) { - try { - listener.contributionAdded(repository, contribution); - } catch (Exception e) { - // ignore, continue to the next listener - } - } - } - - /** - * Process "contributionRemoved" event to all registered listeners - */ - public void contributionRemoved(ContributionRepository repository, Contribution contribution) { - for (ContributionListener listener : listeners.getContributionListeners()) { - try { - listener.contributionRemoved(repository, contribution); - } catch (Exception e) { - // ignore, continue to the next listener - } - - } - } - - /** - * Process "contributionUpdated" event to all registered listeners - */ - public void contributionUpdated(ContributionRepository repository, Contribution oldContribution, Contribution contribution) { - for (ContributionListener listener : listeners.getContributionListeners()) { - try { - listener.contributionUpdated(repository, oldContribution, contribution); - } catch (Exception e) { - // ignore, continue to the next listener - } - - } - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java deleted file mode 100644 index 74f303a5a5..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java +++ /dev/null @@ -1,38 +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.contribution.service; - -import java.net.URL; - -/** - * Provide content type for a given resource - * - * @version $Rev$ $Date$ - */ -public interface TypeDescriber { - /** - * Get the content type for the specified resource - * - * @param resourceURL The resource URL - * @param defaultType The default content type - * @return The content type - */ - String getType(URL resourceURL, String defaultType); -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java deleted file mode 100644 index ff21c894de..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java +++ /dev/null @@ -1,48 +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.contribution.service; - -import javax.xml.namespace.QName; - -/** - * Exception that indicates an element was encountered that could not be handled. - * - * @version $Rev$ $Date$ - */ -public class UnrecognizedElementException extends ContributionReadException { - private static final long serialVersionUID = 2549543622209829032L; - private final QName element; - - /** - * Constructor that indicates which element could not be handled. - * @param element the element that could not be handled - */ - public UnrecognizedElementException(QName element) { - super("Unrecognized element: " + element); - this.element = element; - } - - /** - * Returns the element that could not be handled. - * @return the element that could not be handled. - */ - public QName getElement() { - return element; - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java deleted file mode 100644 index 0660d69897..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java +++ /dev/null @@ -1,42 +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.contribution.service; - -/** - * Exception thrown to indicate that a Content-Type is not supported by this SCA Domain. - * The Content-Type value supplied will be returned as the message text for this exception. - * - * FIXME Don't use as it's deprecated and replaced by UnsupportedPackageTypeException. - * - * @version $Rev$ $Date$ - */ -@Deprecated -public class UnsupportedContentTypeException extends ContributionException { - private static final long serialVersionUID = -1831797280021355672L; - - /** - * Constructs a new UnsupportedContentTypeException. - * - * @param message - */ - public UnsupportedContentTypeException(String message) { - super(message); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java deleted file mode 100644 index 33c847a049..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.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.contribution.service; - -/** - * Exception thrown to indicate that a Content-Type is not supported by this SCA Domain. - * The Content-Type value supplied will be returned as the message text for this exception. - * - * @version $Rev$ $Date$ - */ -public class UnsupportedPackageTypeException extends ContributionException { - private static final long serialVersionUID = -1831797280021355672L; - - /** - * Constructs a new UnsupportedPackageTypeException. - * - * @param message - */ - public UnsupportedPackageTypeException(String message) { - super(message); - } - -} -- cgit v1.2.3