001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.bus.extension;
019:
020: import java.util.ArrayList;
021: import java.util.Collection;
022:
023: public class Extension {
024:
025: private String className;
026: private String interfaceName;
027: private boolean deferred;
028: private Collection<String> namespaces = new ArrayList<String>();
029:
030: public String toString() {
031: StringBuffer buf = new StringBuffer();
032: buf.append("class: ");
033: buf.append(className);
034: buf.append(", interface: ");
035: buf.append(interfaceName);
036: buf.append(", deferred: ");
037: buf.append(deferred ? "true" : "false");
038: buf.append(", namespaces: (");
039: int n = 0;
040: for (String ns : namespaces) {
041: if (n > 0) {
042: buf.append(", ");
043: }
044: buf.append(ns);
045: n++;
046: }
047: buf.append(")");
048: return buf.toString();
049: }
050:
051: String getClassname() {
052: return className;
053: }
054:
055: void setClassname(String i) {
056: className = i;
057: }
058:
059: public String getInterfaceName() {
060: return interfaceName;
061: }
062:
063: public void setInterfaceName(String i) {
064: interfaceName = i;
065: }
066:
067: boolean isDeferred() {
068: return deferred;
069: }
070:
071: void setDeferred(boolean d) {
072: deferred = d;
073: }
074:
075: Collection<String> getNamespaces() {
076: return namespaces;
077: }
078:
079: Object load(ClassLoader cl) {
080: Object obj = null;
081: try {
082: Class<?> cls = cl.loadClass(className);
083: obj = cls.newInstance();
084: } catch (ClassNotFoundException ex) {
085: throw new ExtensionException(ex);
086: } catch (IllegalAccessException ex) {
087: throw new ExtensionException(ex);
088: } catch (InstantiationException ex) {
089: throw new ExtensionException(ex);
090: }
091:
092: return obj;
093: }
094:
095: Class loadInterface(ClassLoader cl) {
096: Class<?> cls = null;
097: try {
098: cls = cl.loadClass(interfaceName);
099: } catch (ClassNotFoundException ex) {
100: throw new ExtensionException(ex);
101: }
102: return cls;
103: }
104:
105: }
|