Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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.definitions.xml;
 
 import java.net.URI;
 import java.net.URL;
 import java.util.List;
 import java.util.Set;
 
Default implementation of an extension point for XML definitionss.

Version:
$Rev: 830738 $ $Date: 2009-10-28 21:29:50 +0200 (Wed, 28 Oct 2009) $
 
     private static final Logger logger = Logger.getLogger(DefaultDefinitionsExtensionPoint.class.getName());
     private static final URI DEFINITIONS_URI = URI.create("META-INF/definitions.xml");
     private ExtensionPointRegistry registry;
     private MonitorFactory monitorFactory;
     private Set<URLdocuments = new HashSet<URL>();
     private List<Definitionsdefinitions = new ArrayList<Definitions>();
     private boolean documentsLoaded;
     private boolean loaded;
 
         this. = registry;
         this. = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
     }
 
     public void addDefinitionsDocument(URL url) {
         .add(url);
     }
 
     public void removeDefinitionsDocument(URL url) {
         .remove(url);
     }

    
Load definitions declarations from META-INF/services/ org.apache.tuscany.sca.contribution.processor.Definitions files
 
     private synchronized void loadDefinitionsDocuments() {
         if ()
             return;
 
         // Get the definitions declarations
         Collection<ServiceDeclarationdefinitionsDeclarations;
         try {
             definitionsDeclarations = .getServiceDiscovery().getServiceDeclarations();
         } catch (IOException e) {
             throw new IllegalStateException(e);
         }
 
         // Find each definitions
         for (ServiceDeclaration definitionsDeclaration : definitionsDeclarations) {
             URL url = definitionsDeclaration.getResource(definitionsDeclaration.getClassName());
             if (url == null) {
                 throw new IllegalArgumentException(definitionsDeclaration.getClassName() + " cannot be found");
             }
             .add(url);
         }
 
          = true;
     }
 
    public synchronized List<DefinitionsgetDefinitions() {
        if (!) {
            loadDefinitionsDocuments();
            URLArtifactProcessorExtensionPoint processors =
                .getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
            URLArtifactProcessor<Definitionsprocessor = processors.getProcessor(Definitions.class);
            ProcessorContext context = new ProcessorContext(.createMonitor());
            for (URL url : ) {
                Definitions def;
                try {
                    def = processor.read(nullurlcontext);
                    .add(def);
                } catch (ContributionReadException e) {
                    .log(.e.getMessage(), e);
                }
            }
             = true;
        }
        return ;
    }
    public void addDefinitions(Definitions def) {
        this..add(def);
    }
    public void removeDefinitions(Definitions def) {
        this..remove(def);
    }
New to GrepCode? Check out our FAQ X