Ejemplo n.º 1
0
 @Override
 protected Object createTest() throws Exception {
   Instance<?> select = CDI.current().select(getTestClass().getJavaClass());
   if (select.isUnsatisfied()) {
     return getTestClass().getJavaClass().newInstance();
   } else {
     return select.get();
   }
 }
Ejemplo n.º 2
0
 /**
  * {@link IdentityManager} instances are produced accordingly to the current {@link Partition} in
  * use. If no partition is provided, the default partition will be used.
  *
  * @return
  */
 @Produces
 @RequestScoped
 public IdentityManager createIdentityManager() {
   if (defaultPartition.isUnsatisfied() || defaultPartition.get() == null) {
     return new SecuredIdentityManager(this.partitionManager.createIdentityManager());
   } else {
     return new SecuredIdentityManager(
         this.partitionManager.createIdentityManager(defaultPartition.get()));
   }
 }
 @Produces
 public ServletDescriptor jerseyServlet() {
   String urlPattern = restServerConfiguration.getRestServletMapping();
   if (!applicationInstance.isUnsatisfied() && !applicationInstance.isAmbiguous()) {
     ApplicationPath annotation =
         ClassUtils.getAnnotation(applicationInstance.get().getClass(), ApplicationPath.class);
     if (annotation != null) {
       String path = annotation.value();
       urlPattern = path.endsWith("/") ? path + "*" : path + "/*";
     }
   }
   return new ServletDescriptor(
       SERVLET_NAME, null, new String[] {urlPattern}, 1, null, true, ServletContainer.class);
 }
  @Override
  public <T> void validateField(
      final String factType,
      final String fieldName,
      final T value,
      final Callback<Set<ConstraintViolation<T>>> callback) {
    if (factType == null || factType.isEmpty()) {
      callback.callback(Collections.emptySet());
      return;
    }
    if (fieldName == null || fieldName.isEmpty()) {
      callback.callback(Collections.emptySet());
      return;
    }
    if (callback == null) {
      return;
    }

    if (validatorInstance.isUnsatisfied()) {
      callback.callback(Collections.emptySet());
      return;

    } else if (validator == null) {
      validator = validatorInstance.get();
    }

    getTypeFieldsAnnotations(
        factType,
        (Map<String, Set<Annotation>> result) -> {
          final Set<ConstraintViolation<T>> violations = new HashSet<>();
          final Set<Annotation> fieldAnnotations = result.get(fieldName);
          if (fieldAnnotations == null || fieldAnnotations.isEmpty()) {
            callback.callback(violations);
            return;
          }

          for (Annotation fieldAnnotation : fieldAnnotations) {
            final Map<String, Object> fieldAnnotationAttributes = fieldAnnotation.getParameters();
            violations.addAll(
                validator.validate(
                    fieldAnnotation.getQualifiedTypeName(), fieldAnnotationAttributes, value));
          }
          callback.callback(violations);
        });
  }
  @Override
  public Map<String, Object> getAttributes() {
    final ResourceConfig resourceConfig;
    if (!applicationInstance.isUnsatisfied() && !applicationInstance.isAmbiguous()) {
      resourceConfig = ResourceConfig.forApplication(applicationInstance.get());
    } else {
      resourceConfig = new ResourceConfig();
    }

    if (resourceConfig.getClasses().isEmpty()) {
      resourceConfig
          .registerClasses(jerseyCdiExtension.getProviders())
          .registerClasses(jerseyCdiExtension.getResources());
    }

    final String attributeName = RESOURCE_CONFIG + SERVLET_NAME;
    return singletonMap(attributeName, resourceConfig);
  }
Ejemplo n.º 6
0
  @Override
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
      addJBossDirURLSystemProperties();
      String ldapPropertiesURL =
          StringUtils.replaceSystemProperties(
                  System.getProperty(
                      "org.dcm4chee.proxy.ldapPropertiesURL",
                      config.getInitParameter("ldapPropertiesURL")))
              .replace('\\', '/');
      String deviceName =
          System.getProperty(
              "org.dcm4chee.proxy.deviceName", config.getInitParameter("deviceName"));
      String jmxName =
          System.getProperty("org.dcm4chee.proxy.jmxName", config.getInitParameter("jmxName"));
      InputStream ldapConf = null;
      try {
        ldapConf = new URL(ldapPropertiesURL).openStream();
        Properties p = new Properties();
        p.load(ldapConf);
        LOG.info("Using LDAP Configuration Backend");
        LdapDicomConfiguration ldapConfig = new LdapDicomConfiguration(p);
        LdapHL7Configuration hl7Conf = new LdapHL7Configuration();
        ldapConfig.addDicomConfigurationExtension(hl7Conf);
        ldapConfig.addDicomConfigurationExtension(new LdapProxyConfigurationExtension());
        ldapConfig.addDicomConfigurationExtension(new LdapAuditLoggerConfiguration());
        ldapConfig.addDicomConfigurationExtension(new LdapAuditRecordRepositoryConfiguration());
        dicomConfig = ldapConfig;
        this.hl7Config = hl7Conf;
      } catch (FileNotFoundException e) {
        // check if there is an implementation of PrefsFactory provided and construct
        // DicomConfiguration accordingly
        PreferencesDicomConfiguration prefsConfig;
        if (!prefsFactoryInstance.isUnsatisfied()) {
          Preferences prefs = prefsFactoryInstance.get().getPreferences();
          LOG.info("Using custom Preferences implementation {}", prefs.getClass().toString());
          prefsConfig = new PreferencesDicomConfiguration(prefs);
        } else {
          prefsConfig = new PreferencesDicomConfiguration();
          LOG.info(
              "Using default Preferences implementation {}",
              prefsConfig.getRootPrefs().getClass().toString());
        }

        PreferencesHL7Configuration hl7Conf = new PreferencesHL7Configuration();
        prefsConfig.addDicomConfigurationExtension(hl7Conf);
        prefsConfig.addDicomConfigurationExtension(new PreferencesProxyConfigurationExtension());
        prefsConfig.addDicomConfigurationExtension(new PreferencesAuditLoggerConfiguration());
        prefsConfig.addDicomConfigurationExtension(
            new PreferencesAuditRecordRepositoryConfiguration());
        dicomConfig = prefsConfig;
        this.hl7Config = hl7Conf;
      } finally {
        SafeClose.close(ldapConf);
      }
      proxy = new Proxy(dicomConfig, hl7Config, deviceName);
      proxy.start();
      ProxyDeviceExtension proxyDev =
          proxy.getDevice().getDeviceExtension(ProxyDeviceExtension.class);
      mbean =
          ManagementFactory.getPlatformMBeanServer().registerMBean(proxy, new ObjectName(jmxName));
    } catch (Exception e) {
      if (LOG.isDebugEnabled()) e.printStackTrace();
      destroy();
      throw new ServletException(e);
    }
  }
Ejemplo n.º 7
0
 @Inject
 public void setExecutorService(Instance<ExecutorService> executorService) {
   if (!executorService.isUnsatisfied()) {
     super.setExecutorService(executorService.get());
   }
 }