Method from org.apache.geronimo.gjndi.binding.GBeanBinding Detail: |
protected synchronized void addBinding(AbstractName abstractName) throws NamingException {
if (bindings.containsKey(abstractName)) {
// previously bound
return;
}
// get the gbean
Object instance;
try {
instance = kernel.getGBean(abstractName);
} catch (GBeanNotFoundException e) {
throw (NamingException)new NamingException("GBean not found: " + abstractName).initCause(e);
}
// preprocess the instance
instance = preprocessVaue(abstractName, instance);
addBinding(abstractName, instance);
}
Binds the specified gbean. This method uses createBindingName and preprocessValue before binding the object. |
public void doFail() {
destroy();
}
|
public synchronized void doStart() {
kernel.getLifecycleMonitor().addLifecycleListener(listener, abstractNameQuery);
Set< AbstractName > set = kernel.listGBeans(abstractNameQuery);
for (AbstractName abstractName : set) {
try {
if (kernel.isRunning(abstractName)) {
addBinding(abstractName);
}
} catch (NamingException e) {
log.error("Error adding binding for " + abstractName, e);
}
}
}
|
public void doStop() {
destroy();
}
|
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
|
protected Object preprocessVaue(AbstractName abstractName,
Object value) throws NamingException {
return value;
}
Preprocess the value before it is bound. This is usefult for wrapping values with reference objects.
By default, this method simply return the value. |
protected synchronized void removeBinding(AbstractName abstractName) {
Map.Entry entry = first(bindings);
if (entry != null && entry.getKey().equals(abstractName)) {
Object oldValue = bindings.remove(abstractName);
entry = first(bindings);
if (entry != null) {
Object newAbstractName = entry.getValue();
Object newValue = entry.getValue();
try {
context.rebind(name, newValue);
} catch (NamingException e) {
boolean unbound = unbind(abstractName, oldValue);
// avoid double logging
if (unbound) log.error("Unable to rebind binding " + name + " to " + newAbstractName);
}
} else {
unbind(abstractName, oldValue);
}
} else {
bindings.remove(abstractName);
}
}
Unbinds the specified gbean. |