update copyright
[fedora-idea.git] / xml / dom-impl / src / com / intellij / util / xml / reflect / DomExtenderEP.java
blob45ee3aa8c158d64a4e592b7ddec74a4a00bf11ed
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.util.xml.reflect;
18 import com.intellij.openapi.diagnostic.Logger;
19 import com.intellij.openapi.extensions.AbstractExtensionPointBean;
20 import com.intellij.openapi.extensions.ExtensionPointName;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.util.xml.DomElement;
23 import com.intellij.util.xmlb.annotations.Attribute;
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
27 /**
28 * @author peter
30 public class DomExtenderEP extends AbstractExtensionPointBean {
31 private static final Logger LOG = Logger.getInstance("#com.intellij.util.xml.reflect.DomExtenderEP");
32 public static final ExtensionPointName<DomExtenderEP> EP_NAME = ExtensionPointName.create("com.intellij.dom.extender");
34 @Attribute("domClass")
35 public String domClassName;
36 @Attribute("extenderClass")
37 public String extenderClassName;
39 private Class<?> myDomClass;
40 private DomExtender myExtender;
43 @Nullable
44 public DomExtensionsRegistrarImpl extend(@NotNull final Project project, @NotNull final DomElement element, @Nullable DomExtensionsRegistrarImpl registrar) {
45 if (myExtender == null) {
46 try {
47 myDomClass = findClass(domClassName);
48 myExtender = instantiate(extenderClassName, project.getPicoContainer());
50 catch(Exception e) {
51 LOG.error(e);
52 return null;
55 if (myDomClass.isInstance(element)) {
56 if (registrar == null) {
57 registrar = new DomExtensionsRegistrarImpl();
59 myExtender.registerExtensions(element, registrar);
61 return registrar;