package org.glassfish.pfl.tf.spi;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public abstract class MethodMonitorBase extends Named
implements MethodMonitor {
private final Class<?> cls;
private final MethodMonitorFactory mmf;
private final Collection<MethodMonitor> myContents;
public static class MethodMonitorFactorySelfImpl extends
MethodMonitorFactoryBase {
private MethodMonitor mm ;
public MethodMonitorFactorySelfImpl( String name ) {
super( name ) ;
}
public void init( MethodMonitor mm ) {
this.mm = mm ;
}
public MethodMonitor create(Class<?> cls) {
return mm ;
}
}
protected MethodMonitorBase(final String name, final Class<?> cls ) {
this( name, cls, new MethodMonitorFactorySelfImpl( name )) ;
((MethodMonitorFactorySelfImpl)factory()).init(this);
}
protected MethodMonitorBase(final String name, final Class<?> cls,
final MethodMonitorFactory mmf) {
super("MethodMonitor", name);
this.cls = cls;
this.mmf = mmf;
final Set<MethodMonitor> temp = new HashSet<MethodMonitor>();
temp.add(this);
this.myContents = Collections.unmodifiableSet(temp);
}
protected MethodMonitorBase(final String name, final Class<?> cls,
final MethodMonitorFactory mmf, Set<MethodMonitor> contents) {
super("MethodMonitor", name);
this.cls = cls;
this.mmf = mmf;
this.myContents = Collections.unmodifiableSet(contents);
}
public final Class<?> myClass() {
return cls;
}
public final MethodMonitorFactory factory() {
return mmf;
}
public final Collection<MethodMonitor> contents() {
return myContents;
}
}