예제 #1
0
  public void registerAvailableMBeans(@Observes final AfterDeploymentValidation event) {
    MBeanManager manager = Beans.getReference(MBeanManager.class);
    JMXConfig configuration = Beans.getReference(JMXConfig.class);

    for (AnnotatedType<?> type : types) {
      final Class<?> clazz = type.getJavaClass();
      DynamicMBeanProxy beanProxy = new DynamicMBeanProxy(clazz, this.mbeanContext);

      StringBuffer name =
          new StringBuffer()
              .append(
                  configuration.getMbeanDomain() != null
                      ? configuration.getMbeanDomain()
                      : clazz.getPackage().getName())
              .append(":name=")
              .append(
                  configuration.getMbeanDomain() != null
                      ? configuration.getMbeanDomain()
                      : clazz.getSimpleName());

      if (manager.findMBeanInstance(name.toString()) == null) {
        ObjectInstance instance = MBeanHelper.register(beanProxy, name.toString());
        manager.storeRegisteredMBean(instance);
      }
    }
  }
예제 #2
0
  @ManagedOperation
  public String requestScopedOperation() {
    RequestScopeBeanClient client = Beans.getReference(RequestScopeBeanClient.class);
    client.operationOne();
    client.operationTwo();

    RequestScopedClass bean = Beans.getReference(RequestScopedClass.class);
    return bean.getInfo();
  }
예제 #3
0
  public void unregisterAvailableMBeans(@Observes final AfterShutdownProccess event) {
    MBeanManager manager = Beans.getReference(MBeanManager.class);
    for (ObjectInstance instance : manager.listRegisteredMBeans()) {
      MBeanHelper.unregister(instance.getObjectName());
    }

    manager.cleanRegisteredMBeans();
  }
예제 #4
0
  private Logger getLogger() {
    if (logger == null) {
      logger =
          Beans.getReference(Logger.class, new NameQualifier(DataSourceProducer.class.getName()));
    }

    return logger;
  }
예제 #5
0
  private ResourceBundle getBundle() {
    if (bundle == null) {
      bundle =
          Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-jdbc-bundle"));
    }

    return bundle;
  }
예제 #6
0
  public void registerNotificationMBean(@Observes final AfterDeploymentValidation event) {
    MBeanManager mbeanManager = Beans.getReference(MBeanManager.class);
    JMXConfig configuration = Beans.getReference(JMXConfig.class);

    NotificationBroadcaster notificationBroadcaster =
        Beans.getReference(NotificationBroadcaster.class);

    StringBuffer notificationMBeanName =
        new StringBuffer()
            .append(
                configuration.getNotificationDomain() != null
                    ? configuration.getNotificationDomain()
                    : "br.gov.frameworkdemoiselle.jmx")
            .append(":name=")
            .append(configuration.getNotificationMBeanName());

    if (mbeanManager.findMBeanInstance(notificationMBeanName.toString()) == null) {
      ObjectInstance instance =
          MBeanHelper.register(notificationBroadcaster, notificationMBeanName.toString());
      mbeanManager.storeRegisteredMBean(instance);
    }
  }
@FacesConverter(value = "categoriaConverter", forClass = Estado.class)
public class CategoriaConverter implements Converter {

  @Inject
  private CategoriaRepository categoriaRepository = Beans.getReference(CategoriaRepository.class);

  public Object getAsObject(FacesContext fc, UIComponent uic, String id) {
    if (id == null) return null;

    return categoriaRepository.get(new Integer(id));
  }

  public String getAsString(FacesContext fc, UIComponent uic, Object object) {
    if (object == null) return "";

    Categoria categoria = (Categoria) object;
    return "" + categoria.getId();
  }
}
예제 #8
0
 @Before
 public void fireEvent() {
   Beans.getBeanManager().fireEvent(new AfterStartupProccess() {});
 }