
org.apache.geronimo.gbean.GBeanInfo Maven / Gradle / Ivy
The newest version!
/**
* 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.geronimo.gbean;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.geronimo.kernel.management.NotificationType;
import org.osgi.framework.Bundle;
/**
* Describes a GBean. This class should never be constructed directly. Insted use GBeanInfoBuilder.
*
* @version $Rev: 1144307 $ $Date: 2011-07-08 21:24:09 +0800 (Fri, 08 Jul 2011) $
*/
public final class GBeanInfo implements Serializable {
private static final long serialVersionUID = -6198804067155550221L;
public static final int PRIORITY_CLASSLOADER = 1;
public static final int PRIORITY_NORMAL = 5;
private static final Set DEFAULT_NOTIFICATIONS = Collections.unmodifiableSet(new HashSet(Arrays.asList(NotificationType.TYPES)));
/**
* Static helper to try to get the GBeanInfo from the class supplied.
*
* @param className name of the class to get the GBeanInfo from
* @param bundle the bundle used to load the specifiec class
* @return GBeanInfo generated by supplied class
* @throws InvalidConfigurationException
* if there is a problem getting the GBeanInfo from the class
*/
public static GBeanInfo getGBeanInfo(String className, Bundle bundle) throws InvalidConfigurationException {
GBeanInfoFactory infoFactory = new MultiGBeanInfoFactory();
try {
return infoFactory.getGBeanInfo(className, bundle);
} catch (GBeanInfoFactoryException e) {
throw new InvalidConfigurationException("See nested", e);
}
}
private final String sourceClass;
private final String name;
private final String className;
private final String j2eeType;
private final Set attributes;
private final Map attributesByName;
private final GConstructorInfo constructor;
private final Set operations;
private final Set notifications;
private final Set references;
private final Map referencesByName;
private final Set interfaces;
private final int priority;
private final boolean osgiService;
private final String[] serviceInterfaces;
/**
* @deprecated use GBeanInfoBuilder
*/
public GBeanInfo(String name, String className, String j2eeType, Collection attributes, GConstructorInfo constructor, Collection operations, Set references, Set interfaces) {
this(null, name, className, j2eeType, attributes, constructor, operations, references, interfaces, DEFAULT_NOTIFICATIONS, PRIORITY_NORMAL, false, null);
}
/**
* @deprecated use GBeanInfoBuilder
*/
public GBeanInfo(String className, String j2eeType, Collection attributes, GConstructorInfo constructor, Collection operations, Set references, Set interfaces) {
this(null, className, className, j2eeType, attributes, constructor, operations, references, interfaces, DEFAULT_NOTIFICATIONS, PRIORITY_NORMAL, false, null);
}
/**
* @deprecated use GBeanInfoBuilder
*/
public GBeanInfo(String className, String j2eeType, Collection attributes, GConstructorInfo constructor, Collection operations, Set references, Set interfaces, Set notifications) {
this(null, className, className, j2eeType, attributes, constructor, operations, references, interfaces, notifications, PRIORITY_NORMAL, false, null);
}
/**
* @deprecated use GBeanInfoBuilder
*/
public GBeanInfo(String name, String className, String j2eeType, Collection attributes, GConstructorInfo constructor, Collection operations, Set references, Set interfaces, Set notifications) {
this(null, name, className, j2eeType, attributes, constructor, operations, references, interfaces, notifications, PRIORITY_NORMAL, false, null);
}
public GBeanInfo(String sourceClass, String name, String className, String j2eeType, Collection attributes, GConstructorInfo constructor, Collection operations, Set references, Set interfaces, int priority, boolean osgiService, String[] serviceInterfaces) {
this(sourceClass, name, className, j2eeType, attributes, constructor, operations, references, interfaces, DEFAULT_NOTIFICATIONS, priority, osgiService, serviceInterfaces);
}
GBeanInfo(String sourceClass,
String name,
String className,
String j2eeType,
Collection attributes,
GConstructorInfo constructor,
Collection operations,
Set references,
Set interfaces,
Set notifications,
int priority,
boolean osgiService,
String[] serviceInterfaces) {
this.sourceClass = sourceClass;
this.name = name;
this.className = className;
this.j2eeType = j2eeType;
if (attributes == null) {
this.attributes = Collections.emptySet();
this.attributesByName = Collections.emptyMap();
} else {
Map map = new HashMap();
for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
GAttributeInfo attribute = (GAttributeInfo) iterator.next();
map.put(attribute.getName(), attribute);
}
this.attributesByName = Collections.unmodifiableMap(map);
this.attributes = Collections.unmodifiableSet(new HashSet(map.values()));
}
if (constructor == null) {
this.constructor = new GConstructorInfo(Collections.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy