use of org.apache.openejb.monitoring.StatsInterceptor in project tomee by apache.
the class SingletonInstanceManager method deploy.
public void deploy(final BeanContext beanContext) throws OpenEJBException {
final Data data = new Data(beanContext);
beanContext.setContainerData(data);
beanContext.set(EJBContext.class, this.sessionContext);
// Create stats interceptor
if (StatsInterceptor.isStatsActivated()) {
final StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass());
beanContext.addFirstSystemInterceptor(stats);
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
jmxName.set("J2EEServer", "openejb");
jmxName.set("J2EEApplication", null);
jmxName.set("EJBModule", beanContext.getModuleID());
jmxName.set("SingletonSessionBean", beanContext.getEjbName());
jmxName.set("name", beanContext.getEjbName());
jmxName.set("j2eeType", "Invocations");
// register the invocation stats interceptor
final MBeanServer server = LocalMBeanServer.get();
try {
final ObjectName objectName = jmxName.build();
if (server.isRegistered(objectName)) {
server.unregisterMBean(objectName);
}
server.registerMBean(new ManagedMBean(stats), objectName);
data.add(objectName);
} catch (final Exception e) {
logger.error("Unable to register MBean ", e);
}
}
try {
final Context context = beanContext.getJndiEnc();
context.bind("comp/EJBContext", sessionContext);
context.bind("comp/WebServiceContext", webServiceContext);
context.bind("comp/TimerService", new TimerServiceWrapper());
} catch (final NamingException e) {
throw new OpenEJBException("Failed to bind EJBContext/WebServiceContext/TimerService", e);
}
}
use of org.apache.openejb.monitoring.StatsInterceptor in project tomee by apache.
the class StatelessContainer method deploy.
@Override
public void deploy(final BeanContext beanContext) throws OpenEJBException {
final String id = (String) beanContext.getDeploymentID();
deploymentRegistry.put(id, beanContext);
beanContext.setContainer(this);
// add it before starting the timer (@PostCostruct)
if (StatsInterceptor.isStatsActivated()) {
final StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass());
beanContext.addFirstSystemInterceptor(stats);
}
}
use of org.apache.openejb.monitoring.StatsInterceptor in project tomee by apache.
the class ManagedContainer method deploy.
@Override
public synchronized void deploy(final BeanContext beanContext) throws OpenEJBException {
final Map<Method, MethodType> methods = getLifecycleMethodsOfInterface(beanContext);
deploymentsById.put(beanContext.getDeploymentID(), beanContext);
beanContext.setContainer(this);
final Data data = new Data(new Index<Method, MethodType>(methods));
beanContext.setContainerData(data);
// Create stats interceptor
if (StatsInterceptor.isStatsActivated()) {
final StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass());
beanContext.addFirstSystemInterceptor(stats);
final MBeanServer server = LocalMBeanServer.get();
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
jmxName.set("J2EEServer", "openejb");
jmxName.set("J2EEApplication", null);
jmxName.set("EJBModule", beanContext.getModuleID());
jmxName.set("StatelessSessionBean", beanContext.getEjbName());
jmxName.set("j2eeType", "");
jmxName.set("name", beanContext.getEjbName());
// register the invocation stats interceptor
try {
final ObjectName objectName = jmxName.set("j2eeType", "Invocations").build();
if (server.isRegistered(objectName)) {
server.unregisterMBean(objectName);
}
server.registerMBean(new ManagedMBean(stats), objectName);
data.jmxNames.add(objectName);
} catch (final Exception e) {
logger.error("Unable to register MBean ", e);
}
}
try {
final Context context = beanContext.getJndiEnc();
context.bind("comp/EJBContext", sessionContext);
} catch (final NamingException e) {
throw new OpenEJBException("Failed to bind EJBContext", e);
}
beanContext.set(EJBContext.class, this.sessionContext);
}
use of org.apache.openejb.monitoring.StatsInterceptor in project tomee by apache.
the class MdbContainer method deploy.
public void deploy(final BeanContext beanContext) throws OpenEJBException {
final Object deploymentId = beanContext.getDeploymentID();
if (!beanContext.getMdbInterface().equals(messageListenerInterface)) {
throw new OpenEJBException("Deployment '" + deploymentId + "' has message listener interface " + beanContext.getMdbInterface().getName() + " but this MDB container only supports " + messageListenerInterface);
}
// create the activation spec
final ActivationSpec activationSpec = createActivationSpec(beanContext);
if (inboundRecovery != null) {
inboundRecovery.recover(resourceAdapter, activationSpec, containerID.toString());
}
final Options options = new Options(beanContext.getProperties());
final int instanceLimit = options.get("InstanceLimit", this.instanceLimit);
// create the message endpoint
final MdbInstanceFactory instanceFactory = new MdbInstanceFactory(beanContext, securityService, instanceLimit);
final EndpointFactory endpointFactory = new EndpointFactory(activationSpec, this, beanContext, instanceFactory, xaResourceWrapper);
// update the data structures
// this must be done before activating the endpoint since the ra may immedately begin delivering messages
beanContext.setContainer(this);
beanContext.setContainerData(endpointFactory);
deployments.put(deploymentId, beanContext);
// Create stats interceptor
if (StatsInterceptor.isStatsActivated()) {
final StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass());
beanContext.addFirstSystemInterceptor(stats);
final MBeanServer server = LocalMBeanServer.get();
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
jmxName.set("J2EEServer", "openejb");
jmxName.set("J2EEApplication", null);
jmxName.set("EJBModule", beanContext.getModuleID());
jmxName.set("StatelessSessionBean", beanContext.getEjbName());
jmxName.set("j2eeType", "");
jmxName.set("name", beanContext.getEjbName());
// register the invocation stats interceptor
try {
final ObjectName objectName = jmxName.set("j2eeType", "Invocations").build();
if (server.isRegistered(objectName)) {
server.unregisterMBean(objectName);
}
server.registerMBean(new ManagedMBean(stats), objectName);
endpointFactory.jmxNames.add(objectName);
} catch (final Exception e) {
logger.error("Unable to register MBean ", e);
}
}
// activate the endpoint
CURRENT.set(beanContext);
try {
resourceAdapter.endpointActivation(endpointFactory, activationSpec);
} catch (final ResourceException e) {
// activation failed... clean up
beanContext.setContainer(null);
beanContext.setContainerData(null);
deployments.remove(deploymentId);
throw new OpenEJBException(e);
} finally {
CURRENT.remove();
}
}
use of org.apache.openejb.monitoring.StatsInterceptor in project tomee by apache.
the class StatefulContainer method deploy.
@Override
public synchronized void deploy(final BeanContext beanContext) throws OpenEJBException {
final Map<Method, MethodType> methods = getLifecycleMethodsOfInterface(beanContext);
deploymentsById.put(beanContext.getDeploymentID(), beanContext);
beanContext.setContainer(this);
final Data data = new Data(new Index<Method, MethodType>(methods));
beanContext.setContainerData(data);
// Create stats interceptor
if (StatsInterceptor.isStatsActivated()) {
final StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass());
beanContext.addFirstSystemInterceptor(stats);
final MBeanServer server = LocalMBeanServer.get();
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
jmxName.set("J2EEServer", "openejb");
jmxName.set("J2EEApplication", null);
jmxName.set("EJBModule", beanContext.getModuleID());
jmxName.set("StatefulSessionBean", beanContext.getEjbName());
jmxName.set("j2eeType", "");
jmxName.set("name", beanContext.getEjbName());
// register the invocation stats interceptor
try {
final ObjectName objectName = jmxName.set("j2eeType", "Invocations").build();
if (server.isRegistered(objectName)) {
server.unregisterMBean(objectName);
}
server.registerMBean(new ManagedMBean(stats), objectName);
data.jmxNames.add(objectName);
} catch (final Exception e) {
logger.error("Unable to register MBean ", e);
}
}
try {
final Context context = beanContext.getJndiEnc();
context.bind("comp/EJBContext", sessionContext);
} catch (final NamingException e) {
throw new OpenEJBException("Failed to bind EJBContext", e);
}
beanContext.set(EJBContext.class, this.sessionContext);
}
Aggregations