@SuppressWarnings("unchecked")
 private void retrieveContextValues() {
   Properties properties = getInstanceProperties();
   bagNames = (ArrayList<String>) properties.get(BAG_NAMES_PROPERTY);
   bagNameToJoinKeyPrefix = (Map<String, String>) properties.get(BAG_NAME_TO_JOIN_PREFIX_PROPERTY);
   bagNameToSize = (Map<String, Integer>) properties.get(BAG_NAME_TO_SIZE_PROPERTY);
 }
Example #2
0
  public static void loadParams() {
    InputStream is = null;
    if (JMupenUtils.getConf().exists()) {
      // First try loading from the current directory
      try {
        is = new FileInputStream(JMupenUtils.getConf());
      } catch (Exception e) {
        is = null;
      }

      try {
        props.load(is);
        JMupenUtils.setFullscreen(props.get("Fullscreen").equals("true"));
        JMupenUtils.setUsingLegacyVersion(props.get("UsingLegacy").equals("true"));
        JMupenUtils.setSaveFolder(
            !props.get("SaveFolder").equals("")
                ? new File((String) props.get("SaveFolder"))
                : null);
      } catch (Exception e) {
        saveParamChanges();
      }
    } else {
      saveParamChanges();
    }
  }
  @Test
  public void testWithMessageHistory() throws Exception {
    GemfireMessageStore store = new GemfireMessageStore(this.cache);
    store.afterPropertiesSet();

    store.getMessageGroup(1);

    Message<?> message = new GenericMessage<String>("Hello");
    DirectChannel fooChannel = new DirectChannel();
    fooChannel.setBeanName("fooChannel");
    DirectChannel barChannel = new DirectChannel();
    barChannel.setBeanName("barChannel");

    message = MessageHistory.write(message, fooChannel);
    message = MessageHistory.write(message, barChannel);
    store.addMessageToGroup(1, message);

    message = store.getMessageGroup(1).getMessages().iterator().next();

    MessageHistory messageHistory = MessageHistory.read(message);
    assertNotNull(messageHistory);
    assertEquals(2, messageHistory.size());
    Properties fooChannelHistory = messageHistory.get(0);
    assertEquals("fooChannel", fooChannelHistory.get("name"));
    assertEquals("channel", fooChannelHistory.get("type"));
  }
Example #4
0
  private void initConfigure(Properties properties) {
    String applyChildren = (String) properties.get("applyChildren");
    if (applyChildren != null) {
      conf.applyChildren = Boolean.parseBoolean(applyChildren);
    } else {
      conf.applyChildren = false;
    }
    String childrenKeys = (String) properties.get("childrenKeys");
    if (childrenKeys != null) {
      for (String key : childrenKeys.split(",")) {
        conf.childrenKeys.add(key);
      }
    }

    String applyLayer = (String) properties.get("applyLayer");
    if (applyLayer != null) {
      conf.applyLayer = Boolean.parseBoolean(applyLayer);
    } else {
      conf.applyLayer = false;
    }

    String layer = (String) properties.get("layer");
    if (layer != null && layer.length() > 0) {
      conf.layer = Integer.parseInt(layer);
    }
  }
 public void readWebProperties(Properties properties) {
   this.properties.putAll(properties);
   if (properties != null) {
     resultTablesLib = (String) properties.get("ws.imtables.provider");
     baseUrl = properties.get("webapp.baseurl") + "/" + properties.get("webapp.path") + "/";
   }
 }
  public ServerMain() {
    try {
      PropertyConfigurator.configure(getClass().getResource(loggerPropsFile));
      /*
       * Load server properties.
       */
      Properties props = new Properties();
      InputStream in = getClass().getResourceAsStream(serverPropsFile);
      props.load(in);
      in.close();
      String rootDir = (String) props.get("server.path");
      String serverName = (String) props.get("server.name");
      String serverIp = (String) props.get("server.ip");
      int serverPort = Integer.parseInt((String) props.get("server.port"));
      /*
       * Register factory object in registry.
       */
      ServerFactory stub = new ServerFactory(InetAddress.getByName(serverIp), serverPort, rootDir);
      Registry registry = LocateRegistry.createRegistry(serverPort);
      registry.rebind(serverName, stub);
      Server.log.info("Server bound [port=" + serverPort + "]");

    } catch (java.io.FileNotFoundException e) {
      System.err.println("Server error: " + serverPropsFile + " file not found.");
    } catch (java.io.IOException e) {
      System.err.println("Server error: IO exception.");
    } catch (Exception e) {
      Server.log.severe("Server exception:");
      e.printStackTrace();
    }
  }
Example #7
0
 /**
  * Sets a System property. This is also active in deployment mode because one might want to change
  * a System property at runtime. Synopsis:<br>
  * pw=<i>aPassword</i>&key=<i>someSystemPropertyKey</i>&value=<i>someSystemPropertyValue</i>
  *
  * @return either null when the password is wrong or a new page showing the System properties
  */
 public WOActionResults systemPropertyAction() {
   if (canPerformActionWithPasswordKey(
       "er.extensions.ERXDirectAction.ChangeSystemPropertyPassword")) {
     String key = request().stringFormValueForKey("key");
     ERXResponse r = new ERXResponse();
     if (ERXStringUtilities.stringIsNullOrEmpty(key)) {
       String user = request().stringFormValueForKey("user");
       Properties props = ERXConfigurationManager.defaultManager().defaultProperties();
       if (user != null) {
         System.setProperty("user.name", user);
         props = ERXConfigurationManager.defaultManager().applyConfiguration(props);
       }
       r.appendContentString(ERXProperties.logString(props));
     } else {
       String value = request().stringFormValueForKey("value");
       value = ERXStringUtilities.stringIsNullOrEmpty(value) ? "" : value;
       java.util.Properties p = System.getProperties();
       p.put(key, value);
       System.setProperties(p);
       ERXLogger.configureLoggingWithSystemProperties();
       for (java.util.Enumeration e = p.keys(); e.hasMoreElements(); ) {
         Object k = e.nextElement();
         if (k.equals(key)) {
           r.appendContentString(
               "<b>'" + k + "=" + p.get(k) + "'     <= you changed this</b><br>");
         } else {
           r.appendContentString("'" + k + "=" + p.get(k) + "'<br>");
         }
       }
       r.appendContentString("</body></html>");
     }
     return r;
   }
   return forbiddenResponse();
 }
  public void setBeanInfo() {
    BeanInfo info = null;
    try {
      info = Introspector.getBeanInfo(bean.getClass());
    } catch (IntrospectionException ex) {
      ex.printStackTrace();
    }

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
      if (!pd.getName().equals("class")) {
        try {
          Object value = null;
          if (properties.get(pd.getName()) != null) {
            value = properties.get(pd.getName());
            if (value.equals("false") || value.equals("true")) {
              pd.getWriteMethod().invoke(bean, new Object[] {Boolean.valueOf((String) value)});
            } else {
              pd.getWriteMethod().invoke(bean, new Object[] {value});
            }
          } else {
            value = pd.getReadMethod().invoke(bean, new Object[] {});
            pd.getWriteMethod().invoke(bean, new Object[] {value});
          }
        } catch (IllegalArgumentException ex) {
          ex.printStackTrace();
        } catch (IllegalAccessException ex) {
          ex.printStackTrace();
        } catch (InvocationTargetException ex) {
          ex.printStackTrace();
        }
      }
    }
  }
  private void sendEmail(String to, String subject, String body, Boolean htmlEmail)
      throws Exception {
    try {
      JavaMailSenderImpl mailSender = (JavaMailSenderImpl) appContext.getBean("mailSender");
      Properties javaMailProperties = mailSender.getJavaMailProperties();
      if (null != javaMailProperties) {
        if (javaMailProperties.get("mail.smtp.localhost") == null
            || ((String) javaMailProperties.get("mail.smtp.localhost")).equalsIgnoreCase("")) {
          javaMailProperties.put("mail.smtp.localhost", "localhost");
        }
      }

      MimeMessage mimeMessage = mailSender.createMimeMessage();

      MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, htmlEmail);
      helper.setFrom(EmailEngine.getAdminEmail());
      helper.setTo(processMultipleImailAddresses(to.trim()));
      helper.setSubject(subject);
      helper.setText(body, true);

      mailSender.send(mimeMessage);

      logger.debug("Email sent successfully on {}", new Date());
    } catch (MailException me) {
      logger.error("Email could not be sent on {} due to: {}", new Date(), me.getMessage());
    }
  }
  private void initControls() {
    IConnectionProfile profile = getConnectionProfile();
    Properties props = profile.getBaseProperties();
    if (null != props.get(IWSProfileConstants.PARAMETER_MAP)
        & !props.get(IWSProfileConstants.PARAMETER_MAP).equals(StringUtilities.EMPTY_STRING)) {
      this.parameterMap = ((Map) props.get(IWSProfileConstants.PARAMETER_MAP));
    }
    if (null != props.get(ICredentialsCommon.USERNAME_PROP_ID)) {
      usernameText.setText((String) props.get(ICredentialsCommon.USERNAME_PROP_ID));
    }
    if (null != props.get(ICredentialsCommon.PASSWORD_PROP_ID)) {
      passwordText.setText((String) props.get(ICredentialsCommon.PASSWORD_PROP_ID));
    }
    String url = ConnectionInfoHelper.readEndPointProperty(props);
    if (null != url) {
      urlText.setText(url);
    }
    if (null != props.get(ICredentialsCommon.SECURITY_TYPE_ID)) {
      securityText.setText((String) props.get(ICredentialsCommon.SECURITY_TYPE_ID));
    }

    for (Object key : props.keySet()) {
      String keyStr = (String) key;
      if (ICredentialsCommon.PASSWORD_PROP_ID.equalsIgnoreCase(keyStr)
          || ICredentialsCommon.SECURITY_TYPE_ID.equalsIgnoreCase(keyStr)
          || ICredentialsCommon.USERNAME_PROP_ID.equalsIgnoreCase(keyStr)
          || IWSProfileConstants.END_POINT_URI_PROP_ID.equalsIgnoreCase(keyStr)) {
        // do nothing;
      } else {
        extraProperties.put(key, props.get(key));
      }
    }
  }
  @Override
  public synchronized Object get(Object key) {
    String columnName = getColumnName(key);
    if (columnName == null) {
      return ctx.get(key);
    }

    // Case: no row
    // (we are using it from a custom window, e.g. VAccountDialog)
    if (row < 0) {
      return ctx.get(key);
    }

    final int col = gridTable.findColumn(columnName);
    if (col == -1) {
      return ctx.get(key);
    }
    Object value = gridTable.getValueAt(row, col);
    if (value == null) {
      return null;
    }

    if (value instanceof KeyNamePair) {
      value = ((KeyNamePair) value).getKey();
    } else if (value instanceof ValueNamePair) {
      value = ((ValueNamePair) value).getID();
    } else if (value instanceof Boolean) {
      value = ((Boolean) value).booleanValue() ? "Y" : "N";
    }
    return value.toString();
  }
 /*
  * (non-Javadoc)
  *
  * @see org.jajuk.base.Observer#update(org.jajuk.base.Event)
  */
 public void update(Event event) {
   synchronized (getLock()) {
     EventSubject subject = event.getSubject();
     if (EventSubject.EVENT_FILE_NAME_CHANGED.equals(subject)) {
       Properties properties = event.getDetails();
       File fNew = (File) properties.get(DETAIL_NEW);
       File fileOld = (File) properties.get(DETAIL_OLD);
       // search references in playlists
       Iterator it = hmItems.values().iterator();
       for (int i = 0; it.hasNext(); i++) {
         Playlist plf = (Playlist) it.next();
         if (plf.isReady()) { // check only in mounted
           // playlists, note that we can't
           // change unmounted playlists
           try {
             if (plf.getFiles().contains(fileOld)) {
               plf.replaceFile(fileOld, fNew);
             }
           } catch (Exception e) {
             Log.error(17, e);
           }
         }
       }
     }
   }
 }
  public static String getCorrection(String text) {

    // All uppercase normalization HONG KONG => Hong Kong
    String noPunc = text.replaceAll("[^A-Z0-9]*", "");

    if (StringUtils.isAllUpperCase(noPunc) && noPunc.length() > 3) {
      char[] letters = text.toLowerCase().toCharArray();
      for (int i = 0; i < letters.length; i++) {
        if (i == 0 || !Character.isLetter(letters[i - 1]) && Character.isLetter(letters[i])) {
          letters[i] = Character.toUpperCase(letters[i]);
        }
      }
      return new String(letters);
    }

    // Spell check
    if (correctionCache.get(text) != null) {
      return String.valueOf(correctionCache.get(text));
    } else {
      if (caching) {
        String correction = getGoogleCorrection(text);
        correctionCache.put(text, correction);
        return correction;
      }
    }

    return text;
  }
Example #14
0
  public static TopicConnection getTopicConnection(Properties props)
      throws IOException, NamingException, JMSException {
    fixProviderUrl(props);
    String cnnFactoryName = props.getProperty(JNDI_TOPIC_CONECTION_NAME_PROPERTY);
    if (cnnFactoryName == null) {
      throw new IOException(
          "You must set the property "
              + DEFAULT_JNDI_CONECTION_NAME_PROPERTY
              + "in the JNDI property file");
    }
    Context ctx = new InitialContext(props);

    TopicConnectionFactory tcf = (TopicConnectionFactory) lookupObject(ctx, cnnFactoryName);
    TopicConnection cnn;
    String username = (String) props.get("username");

    if (username != null) {
      String password = (String) props.get("password");
      cnn = tcf.createTopicConnection(username, password);
    } else {
      cnn = tcf.createTopicConnection();
    }
    cnn.start();
    return cnn;
  }
  private void init() throws Exception {
    for (Object language : StringTranslate.getInstance().getLanguageList().keySet()) {
      CoreLoadingPlugin.log.fine(
          "[LanguageEngine] Loading language array for " + (String) language);
      lang.put((String) language, new HashMap<String, String>());
    }

    CoreLoadingPlugin.log.info("[LanguageEngine] Scanning for and loading language XML files...");

    for (Object file : lang.keySet()) {
      String fle1 = LANG_RESOURCE_LOCATION + (String) file + ".xml";
      fle1 = fle1.trim();
      CoreLoadingPlugin.log.fine("[LanguageEngine] Loading xml: " + fle1);
      Properties langPack = new Properties();
      URL urlResource = this.getClass().getResource(fle1);
      try {
        InputStream langStream = urlResource.openStream();
        langPack.loadFromXML(langStream);
        for (Object key : langPack.keySet()) {
          CoreLoadingPlugin.log.fine(
              "[LanguageEngine] Placing " + key + " in lang map as " + langPack.get(key));
          lang.get(file).put((String) key, (String) langPack.get(key));
        }
      } catch (Exception e) {
        CoreLoadingPlugin.log.warning(
            "[LanguageEngine] File " + fle1 + " does not exist or is causing an error!");
      }
    }
  }
Example #16
0
  /**
   * Transmit a request to ValueLink
   *
   * @param url override URL from what is defined in the properties
   * @param request request Map of request parameters
   * @return Map of response parameters
   * @throws HttpClientException
   */
  public Map<String, Object> send(String url, Map<String, Object> request)
      throws HttpClientException {
    if (debug) {
      Debug.logInfo("Request : " + url + " / " + request, module);
    }

    // read the timeout value
    String timeoutString = (String) props.get("payment.valuelink.timeout");
    int timeout = 34;
    try {
      timeout = Integer.parseInt(timeoutString);
    } catch (NumberFormatException e) {
      Debug.logError(e, "Unable to set timeout to " + timeoutString + " using default " + timeout);
    }

    // create the HTTP client
    HttpClient client = new HttpClient(url, request);
    client.setTimeout(timeout * 1000);
    client.setDebug(debug);

    client.setClientCertificateAlias((String) props.get("payment.valuelink.certificateAlias"));
    String response = client.post();

    // parse the response and return a map
    return this.parseResponse(response);
  }
  public SunSSLTransportFactory(Properties properties) throws GeneralSecurityException {
    X509TrustManager trustManager;
    HostnameVerifier hostnameVerifier;
    SSLContext sslContext;

    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    url = (URL) properties.get(XmlRpcTransportFactory.TRANSPORT_URL);
    auth = properties.getProperty(XmlRpcTransportFactory.TRANSPORT_AUTH);

    trustManager = (X509TrustManager) properties.get(TRANSPORT_TRUSTMANAGER);
    if (trustManager == null) {
      trustManager = openTrustManager;
    }

    hostnameVerifier = (HostnameVerifier) properties.get(TRANSPORT_HOSTNAMEVERIFIER);
    if (hostnameVerifier == null) {
      hostnameVerifier = openHostnameVerifier;
    }

    sslContext = SSLContext.getInstance(SecurityTool.getSecurityProtocol());
    X509TrustManager[] tmArray = new X509TrustManager[] {trustManager};
    sslContext.init(null, tmArray, new SecureRandom());

    // Set the default SocketFactory and HostnameVerifier
    // for javax.net.ssl.HttpsURLConnection
    if (sslContext != null) {
      HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
    }
    HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
  }
Example #18
0
  static {
    try {
      final Properties properties = new Properties();
      try (InputStream byteSource =
          ShopConnector.class.getResourceAsStream("shop-mysql.properties")) {
        properties.load(byteSource);
      }

      final Class<?> dataSourceClass =
          Class.forName(
              "com.mysql.jdbc.jdbc2.optional.MysqlDataSource",
              true,
              Thread.currentThread().getContextClassLoader());
      final DataSource dataSource = (DataSource) dataSourceClass.newInstance();
      dataSourceClass
          .getMethod("setURL", String.class)
          .invoke(dataSource, properties.get("connectionUrl"));
      dataSourceClass
          .getMethod("setCharacterEncoding", String.class)
          .invoke(dataSource, properties.get("characterEncoding"));
      dataSourceClass
          .getMethod("setUser", String.class)
          .invoke(dataSource, properties.get("alias"));
      dataSourceClass
          .getMethod("setPassword", String.class)
          .invoke(dataSource, properties.get("password"));
      DATA_SOURCE = dataSource;
    } catch (final Exception exception) {
      throw new ExceptionInInitializerError(exception);
    }
  }
Example #19
0
  private static String readVersionNrFromProperties() {
    try {
      Properties prop = loadVersionProperties();
      String version = ""; // $NON-NLS-1$
      String major = (String) prop.get("build.major.number"); // $NON-NLS-1$
      String minor = (String) prop.get("build.minor.number"); // $NON-NLS-1$
      String patch = (String) prop.get("build.patch.number"); // $NON-NLS-1$
      String revision = (String) prop.get("build.revision.number"); // $NON-NLS-1$

      version =
          "Version "
              + major
              + "."
              + minor
              + "."
              + patch
              + " Build("
              + revision
              + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
      return version;
    } catch (Exception e) {
      logger.info("no version file found");
      return "NO_VERSION_FILE";
    }
  }
  public void testFindComponentsInClasspath() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
      return;
    }

    MBeanServer mbeanServer = getMBeanServer();

    ObjectName on =
        ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=context,name=\"camel-1\"");

    assertTrue("Should be registered", mbeanServer.isRegistered(on));

    @SuppressWarnings("unchecked")
    Map<String, Properties> info =
        (Map<String, Properties>) mbeanServer.invoke(on, "findComponents", null, null);
    assertNotNull(info);

    assertEquals(23, info.size());
    Properties prop = info.get("seda");
    assertNotNull(prop);
    assertEquals("seda", prop.get("name"));
    assertEquals("org.apache.camel", prop.get("groupId"));
    assertEquals("camel-core", prop.get("artifactId"));
  }
 @Override
 protected void doPost(HttpServletRequest request, HttpServletResponse response) {
   try (InputStream inputStream =
       getClass().getClassLoader().getResourceAsStream("Aconfig/adminconfig.properties")) {
     String S_error = "";
     HttpSession session;
     String _uname = request.getParameter("adusnam");
     String _pass = request.getParameter("adpass");
     Properties properties = new Properties();
     if (inputStream != null) {
       properties.load(inputStream);
     }
     if (_uname.equals(properties.get("adus")) && _pass.equals(properties.get("adpas"))) {
       session = request.getSession(true);
       session.setAttribute("username", _uname);
       response.sendRedirect("WriteConfig");
     } else {
       session = request.getSession(true);
       session.setAttribute("status", "The username and password did not match");
       response.sendRedirect("AdminAuth");
     }
   } catch (IOException e) {
     Logger.getLogger(AdminAuthServlet.class.getName()).log(Level.SEVERE, null, e);
     response.setStatus(500);
   }
 }
Example #22
0
 /**
  * must be called after all settings are added for loading/saving to work. loads from
  * .minecraft/mods/$backendname/guiconfig.properties if it exists. coming soon: set name of config
  * file
  *
  * @param context The context to load from.
  */
 @SuppressWarnings("rawtypes")
 public void load(String context) {
   for (; ; ) {
     try {
       if (ModSettings.contextDatadirs.get(context) == null) {
         break;
       }
       File path =
           ModSettings.getAppDir(
               "/" + ModSettings.contextDatadirs.get(context) + "/" + backendname + "/");
       if (!path.exists()) {
         break;
       }
       File file = new File(path, "guiconfig.properties");
       if (!file.exists()) {
         break;
       }
       Properties p = new Properties();
       p.load(new FileInputStream(file));
       for (int i = 0; i < Settings.size(); i++) {
         ModSettings.dbgout("setting load");
         Setting z = Settings.get(i);
         if (p.containsKey(z.backendName)) {
           ModSettings.dbgout("setting " + (String) p.get(z.backendName));
           z.fromString((String) p.get(z.backendName), context);
         }
       }
       break;
     } catch (Exception e) {
       System.out.println(e);
       break;
     }
   }
 }
 @Test
 public void testProperties() throws Exception {
   final ApplicationContext context = extraClient.createApplicationContext();
   final Properties basicProperties =
       context.getBean(ExtraClient.BEAN_NAME_EXTRA_PROPERTIES_BASIC, Properties.class);
   assertEquals("DRV", basicProperties.get("extra.mandant"));
   assertEquals("drv property content", basicProperties.get("drv.property"));
 }
 private void initControls() {
   IConnectionProfile profile = getConnectionProfile();
   Properties props = profile.getBaseProperties();
   if (null != props.get(IXmlProfileConstants.URL_PROP_ID)) {
     urlText.setText((String) props.get(IXmlProfileConstants.URL_PROP_ID));
   }
   validate();
 }
  public void testStartingWithExists() throws Exception {

    Properties p = PropertiesUtil.getPropertiesStartingWith("testprop", props);

    assertEquals(2, p.size());
    assertEquals("myname", p.get("testprop.name"));
    assertEquals("myaddress", p.get("testprop.address"));
  }
  // public SessionFactory newSessionFactory(Configuration config) throws HibernateException {
  public Configuration newConfiguration() throws HibernateException {
    Configuration config = super.newConfiguration();

    log.debug("Configuring hibernate sessionFactory properties");

    Properties moduleProperties = Context.getConfigProperties();

    // override or initialize config properties with module-provided ones
    for (Object key : moduleProperties.keySet()) {
      String prop = (String) key;
      String value = (String) moduleProperties.get(key);
      log.trace("Setting module property: " + prop + ":" + value);
      config.setProperty(prop, value);
      if (!prop.startsWith("hibernate")) config.setProperty("hibernate." + prop, value);
    }

    Properties properties = Context.getRuntimeProperties();

    // loop over runtime properties and override each in the configuration
    for (Object key : properties.keySet()) {
      String prop = (String) key;
      String value = (String) properties.get(key);
      log.trace("Setting property: " + prop + ":" + value);
      config.setProperty(prop, value);
      if (!prop.startsWith("hibernate")) config.setProperty("hibernate." + prop, value);
    }

    // load in the default hibernate properties
    try {
      InputStream propertyStream =
          ConfigHelper.getResourceAsStream("/hibernate.default.properties");
      Properties props = new Properties();
      OpenmrsUtil.loadProperties(props, propertyStream);
      propertyStream.close();

      // Only load in the default properties if they don't exist
      config.mergeProperties(props);
    } catch (IOException e) {
      log.fatal("Unable to load default hibernate properties", e);
    }

    log.debug(
        "Setting global Hibernate Session Interceptor for SessionFactory, Interceptor: "
            + chainingInterceptor);

    // make sure all autowired interceptors are put onto our chaining interceptor
    // sort on the keys so that the devs/modules have some sort of control over the order of the
    // interceptors
    List<String> keys = new ArrayList<String>(interceptors.keySet());
    Collections.sort(keys);
    for (String key : keys) {
      chainingInterceptor.addInterceptor(interceptors.get(key));
    }

    config.setInterceptor(chainingInterceptor);

    return config;
  }
 @Before
 public void before() throws IOException {
   Properties awscredentials = new Properties();
   awscredentials.load(
       new FileInputStream("./cloudify/clouds/privateEc2/privateEc2-cloud.properties"));
   String accessKey = ((String) awscredentials.get("accessKey")).replaceAll("\"", "");
   String secretKey = ((String) awscredentials.get("apiKey")).replaceAll("\"", "");
   this.s3Uploader = new AmazonS3Uploader(accessKey, secretKey, "eu-west-1");
 }
 /**
  * Set local properties
  *
  * @deprecated use {@link #setLocalMaxMemory(int)} in GemFire 5.1 and later releases
  * @param localProps those properties for the local VM
  */
 @Deprecated
 public void setLocalProperties(Properties localProps) {
   this.localProperties = localProps;
   if (localProps.get(PartitionAttributesFactory.LOCAL_MAX_MEMORY_PROPERTY) != null) {
     setLocalMaxMemory(
         Integer.parseInt(
             (String) localProps.get(PartitionAttributesFactory.LOCAL_MAX_MEMORY_PROPERTY)));
   }
 }
Example #29
0
  @Override
  public void setParameterValues(Properties parameters) {
    final ParameterType reader = (ParameterType) parameters.get(PARAMETER_TYPE);

    // IMPL NOTE : be protective about not setting enumValueMapper (i.e. calling
    // treatAsNamed/treatAsOrdinal)
    // in cases where we do not have enough information.  In such cases we do additional checks
    // as part of nullSafeGet/nullSafeSet to query against the JDBC metadata to make the
    // determination.

    if (reader != null) {
      enumClass = reader.getReturnedClass().asSubclass(Enum.class);

      final boolean isOrdinal;
      final javax.persistence.EnumType enumType = getEnumType(reader);
      if (enumType == null) {
        isOrdinal = true;
      } else if (javax.persistence.EnumType.ORDINAL.equals(enumType)) {
        isOrdinal = true;
      } else if (javax.persistence.EnumType.STRING.equals(enumType)) {
        isOrdinal = false;
      } else {
        throw new AssertionFailure("Unknown EnumType: " + enumType);
      }

      if (isOrdinal) {
        treatAsOrdinal();
      } else {
        treatAsNamed();
      }
      sqlType = enumValueMapper.getSqlType();
    } else {
      String enumClassName = (String) parameters.get(ENUM);
      try {
        enumClass =
            ReflectHelper.classForName(enumClassName, this.getClass()).asSubclass(Enum.class);
      } catch (ClassNotFoundException exception) {
        throw new HibernateException("Enum class not found", exception);
      }

      final Object useNamedSetting = parameters.get(NAMED);
      if (useNamedSetting != null) {
        final boolean useNamed = ConfigurationHelper.getBoolean(NAMED, parameters);
        if (useNamed) {
          treatAsNamed();
        } else {
          treatAsOrdinal();
        }
        sqlType = enumValueMapper.getSqlType();
      }
    }

    final String type = (String) parameters.get(TYPE);
    if (type != null) {
      sqlType = Integer.decode(type);
    }
  }
  public void testProperties() throws Exception {
    TestUserBean bean = new TestUserBean();
    bean.setId("id-value");
    bean.setName("name-value");

    Properties p = proc.toProperties(bean, ANT_TYPE.COLUMN);
    assertEquals(p.get("id"), "id-value");
    assertEquals(p.get("name"), "name-value");
  }