diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:07:53 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:07:53 +0000 |
commit | 89d72264d0af4c65c9bf0b7a6f823f13d69162aa (patch) | |
tree | f6a4ea43b576d56a43adf10ccbed4cd75a9eb827 /branches/sca-java-1.3/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/ImplementationsActivator.java | |
parent | 6a3ca6736c808c1647854e405ef379b609f276db (diff) |
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835127 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/ImplementationsActivator.java')
-rw-r--r-- | branches/sca-java-1.3/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/ImplementationsActivator.java | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/branches/sca-java-1.3/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/ImplementationsActivator.java b/branches/sca-java-1.3/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/ImplementationsActivator.java deleted file mode 100644 index d156d835ad..0000000000 --- a/branches/sca-java-1.3/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/ImplementationsActivator.java +++ /dev/null @@ -1,138 +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.extension.helper.impl; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; -import org.apache.tuscany.sca.databinding.TransformerExtensionPoint; -import org.apache.tuscany.sca.databinding.impl.MediatorImpl; -import org.apache.tuscany.sca.extension.helper.ImplementationActivator; -import org.apache.tuscany.sca.extension.helper.utils.DefaultPropertyValueObjectFactory; -import org.apache.tuscany.sca.extension.helper.utils.PropertyValueObjectFactory; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * A Tuscany ModuleActivator which activates all the ImplementationActivators - * - * @version $Rev$ $Date$ - */ -public class ImplementationsActivator implements ModuleActivator { - - protected List<ImplementationActivator> implementationActivators; - - public void start(ExtensionPointRegistry registry) { - - ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); - - DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class); - TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class); - MediatorImpl mediator = new MediatorImpl(dataBindings, transformers); - - //FIXME Pass this factory differently as it's not an extension point - PropertyValueObjectFactory propertyFactory = new DefaultPropertyValueObjectFactory(mediator); - registry.addExtensionPoint(propertyFactory); - - this.implementationActivators = DiscoveryUtils.discoverActivators(ImplementationActivator.class, registry); - - StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); - - for (final ImplementationActivator implementationActivator : implementationActivators) { - - Class<Implementation> implClass = implementationActivator.getImplementationClass(); - QName scdlQName = getSCDLQName(implClass); - staxProcessors.addArtifactProcessor(new SCDLProcessor(assemblyFactory, scdlQName, implClass, registry, factories)); - - if (implementationActivator.getImplementationClass() != null && providerFactories != null) { - addImplementationProvider(implementationActivator, providerFactories); - } - } - } - - public void stop(ExtensionPointRegistry registry) { - StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - - for (final ImplementationActivator implementationActivator : implementationActivators) { - if (staxProcessors != null) { - StAXArtifactProcessor processor = staxProcessors.getProcessor(getSCDLQName(implementationActivator.getImplementationClass())); - if (processor != null) { - staxProcessors.removeArtifactProcessor(processor); - } - } - } - } - - private void addImplementationProvider(final ImplementationActivator implementationActivator, ProviderFactoryExtensionPoint providerFactories) { - - providerFactories.addProviderFactory(new ImplementationProviderFactory() { - public ImplementationProvider createImplementationProvider(final RuntimeComponent rc, final Implementation impl) { - if (impl instanceof PojoImplementation) { - return new ImplementationImplementationProvider(implementationActivator, rc, impl, ((PojoImplementation)impl).getUserImpl()); - } else { - return new ImplementationImplementationProvider(implementationActivator, rc, impl, impl); - } - } - public Class getModelType() { - Class c = implementationActivator.getImplementationClass(); - - if (Implementation.class.isAssignableFrom(c)) { - return c; - } else { - return PojoImplementation.class; - } - } - }); - } - - protected QName getSCDLQName(Class implementationClass) { - String localName = implementationClass.getName(); - if (localName.lastIndexOf('.') > -1) { - localName = localName.substring(localName.lastIndexOf('.') + 1); - } - if (localName.endsWith("Implementation")) { - localName = localName.substring(0, localName.length() - 14); - } - StringBuilder sb = new StringBuilder(localName); - for (int i=0; i<sb.length(); i++) { - if (Character.isUpperCase(sb.charAt(i))) { - sb.setCharAt(i, Character.toLowerCase(sb.charAt(i))); - } else { - break; - } - } - return new QName(Constants.SCA10_TUSCANY_NS, "implementation." + sb.toString()); - } - -} |