java.util.Properties#put ( )源码实例Demo

下面列出了java.util.Properties#put ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gemfirexd-oss   文件: DistributedSystem.java
/**
 * Returns a connection to the distributed system that is
 * appropriate for administration.  This method is for internal use
 * only by the admin API.
 *
 * @since 4.0
 */
protected static DistributedSystem connectForAdmin(Properties props,
                                                   LogWriterI18n logger) {
  DistributedSystem existing = getConnection(props);
  if (existing != null) {
    return existing;

  } else {
    //logger.info("creating new distributed system for admin");
    //for (java.util.Enumeration en=props.propertyNames(); en.hasMoreElements(); ) {
    //  String prop=(String)en.nextElement();
    //  logger.info(prop + "=" + props.getProperty(prop));
    //}
    props.setProperty(DistributionConfig.CONSERVE_SOCKETS_NAME, "true");
    props.put(DistributionConfig.LOG_WRITER_NAME, logger);
    if (logger instanceof LogWriterImpl) {
      LogWriterImpl loggerImpl = (LogWriterImpl)logger;
      props.put(DistributionConfig.SECURITY_LOG_WRITER_NAME,
          new SecurityLogWriter(loggerImpl.getLevel(), loggerImpl));
    }
    return connect(props);
  }
}
 
源代码2 项目: jkube   文件: ClusterConfigurationTest.java
@Test
public void should_load_configuration_from_multiple_properties() {
  // Given
  final Properties props1 = new Properties();
  props1.put("jkube.namespace", "not-the-default");
  props1.put("jkube.username", "won't make it");
  props1.put("jkube.password", "won't make it either");
  final Properties props2 = new Properties();
  props2.put("jkube.clientKeyPassphrase", "notchanged");
  props2.put("jkube.username", "user name");
  props2.put("jkube.password", "I don't think you can make it either");
  final Properties props3 = new Properties();
  props3.put("jkube.apiVersion", "v1337");
  props3.put("jkube.password", "the pa$$w*rd");
  // When
  final Config config = ClusterConfiguration.from(props1, props2, props3).build().getConfig();
  // Then
  assertThat(config.getApiVersion()).isEqualTo("v1337");
  assertThat(config.getClientKeyPassphrase()).isEqualTo("notchanged");
  assertThat(config.getNamespace()).isEqualTo("not-the-default");
  assertThat(config.getUsername()).isEqualTo("user name");
  assertThat(config.getPassword()).isEqualTo("the pa$$w*rd");
}
 
源代码3 项目: sql-layer   文件: ReadCommittedIsolationDT.java
@Before
public void populate() throws SQLException {
    createTable(SCHEMA_NAME, "t1", "id INT PRIMARY KEY, n INT");
    Properties props = new Properties();
    props.put("user", SCHEMA_NAME);
    props.put("constraintCheckTime", "DELAYED_WITH_RANGE_CACHE_ALWAYS_UNTIL_COMMIT");
    try (Connection conn = DriverManager.getConnection(CONNECTION_URL, props);
         PreparedStatement stmt = conn.prepareStatement("INSERT INTO t1 VALUES(?,?)")) {
        conn.setAutoCommit(false);
        for (int i = 0; i < NROWS; i++) {
            stmt.setInt(1, i);
            stmt.setInt(2, i);
            stmt.executeUpdate();
        }
        conn.commit();
    }
}
 
源代码4 项目: entando-core   文件: TestApiI18nLabelInterface.java
protected JAXBI18nLabel testGetLabel(MediaType mediaType, String username, String key) throws Throwable {
	ApiResource contentResource = 
			this.getApiCatalogManager().getResource("core", "i18nlabel");
	ApiMethod getMethod = contentResource.getGetMethod();
	
	Properties properties = super.createApiProperties(username, "en", mediaType);
	properties.put("key", key);
	Object result = this.getResponseBuilder().createResponse(getMethod, properties);
	assertNotNull(result);
	ApiI18nLabelInterface apiLabelInterface = (ApiI18nLabelInterface) this.getApplicationContext().getBean("ApiI18nLabelInterface");
	Object singleResult = apiLabelInterface.getLabel(properties);
	assertNotNull(singleResult);
	String toString = this.marshall(singleResult, mediaType);
	InputStream stream = new ByteArrayInputStream(toString.getBytes());
	JAXBI18nLabel jaxbLabel = (JAXBI18nLabel) UnmarshalUtils.unmarshal(super.getApplicationContext(), JAXBI18nLabel.class, stream, mediaType);
	assertNotNull(jaxbLabel);
	return jaxbLabel;
}
 
源代码5 项目: dragonwell8_jdk   文件: DriverManagerTests.java
/**
 * Validate that a Connection object is returned when a valid URL is
 * specified to getConnection
 *
 */
@Test
public void test14() throws Exception {

    DriverManager.registerDriver(new StubDriver());
    assertTrue(
            DriverManager.getConnection(StubDriverURL) != null);
    assertTrue(DriverManager.getConnection(StubDriverURL,
            "LuckyDog", "tennisanyone") != null);
    Properties props = new Properties();
    props.put("user", "LuckyDog");
    props.put("password", "tennisanyone");
    assertTrue(
            DriverManager.getConnection(StubDriverURL,
                    props) != null);
}
 
源代码6 项目: kafka_book_demo   文件: ConsumerTTL.java
public static void main(String[] args) {
    Properties props = new Properties();
    props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
            StringDeserializer.class.getName());
    props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
            StringDeserializer.class.getName());
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList);
    props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
    props.put(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG,
            ConsumerInterceptorTTL.class.getName());

    KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
    consumer.subscribe(Collections.singletonList(topic));

    while (true) {
        ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(1000));
        for (ConsumerRecord<String, String> record : records) {
            System.out.println(record.partition() + ":" + record.offset() + ":" + record.value());
        }
    }
}
 
@Test
public void testCustomCharset() throws Throwable {
  // given
  Properties p = new Properties();
  p.put("type", "log4j");
  p.put("pattern", "TIMESTAMP LEVEL [THREAD]  MESSAGE");
  p.put("dateFormat", "yyyy-MM-dd HH:mm:ss,SSS");
  p.put("name", "windows-1250");
  p.put("charset", "windows-1250");
  InputStream in = loadLog("log4j/log4j_pl.txt");
  Log4jPatternMultilineLogParser logParser = new Log4jPatternMultilineLogParser();
  LogImporterUsingParser importerUsingParser = new LogImporterUsingParser(logParser);
  importerUsingParser.init(p);
  ParsingContext context = new ParsingContext();
  importerUsingParser.initParsingContext(context);

  // when
  ProxyLogDataCollector dataCollector = new ProxyLogDataCollector();
  importerUsingParser.importLogs(in, dataCollector, context);

  // then

  assertEquals("windows-1250", logParser.getParserDescription().getCharset());
  LogData[] logDatas = dataCollector.getLogData();
  assertEquals(6, logDatas.length);
  assertEquals('a', logDatas[2].getMessage().toCharArray()[0]);
  assertEquals(261, logDatas[2].getMessage().toCharArray()[1]);

  assertEquals('e', logDatas[3].getMessage().toCharArray()[0]);
  assertEquals(281, logDatas[3].getMessage().toCharArray()[1]);

  assertEquals('z', logDatas[4].getMessage().toCharArray()[0]);
  assertEquals(380, logDatas[4].getMessage().toCharArray()[1]);

  assertEquals('l', logDatas[5].getMessage().toCharArray()[0]);
  assertEquals(322, logDatas[5].getMessage().toCharArray()[1]);
}
 
源代码8 项目: java-study   文件: TestConsumer.java
public static void main(String[] args) {
    Properties props = new Properties();

    props.put("bootstrap.servers", "192.169.0.23:9092");
    System.out.println("this is the group part test 1");
    //消费者的组id
    props.put("group.id", "GroupA");//这里是GroupA或者GroupB

    props.put("enable.auto.commit", "true");
    props.put("auto.commit.interval.ms", "1000");

    //从poll(拉)的回话处理时长
    props.put("session.timeout.ms", "30000");
    //poll的数量限制
    //props.put("max.poll.records", "100");

    props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

    props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

    KafkaConsumer<String, String> consumer = new KafkaConsumer<String, String>(props);
    //订阅主题列表topic
    consumer.subscribe(Arrays.asList("foo"));
    while (true) {
        ConsumerRecords<String, String> records =consumer.poll(100);
        for (ConsumerRecord<String, String> record : records)
            // 正常这里应该使用线程池处理,不应该在这里处理
            System.out.printf("offset = %d, key = %s, value = %s", record.offset(), record.key(), record.value()+"\n");
    }
}
 
源代码9 项目: gsn   文件: TestVSensorLoader.java
@Before
public void setUp() throws Exception {
  Properties p = new Properties();
  p.put("mock-test", "ch.epfl.gsn.wrappers.MockWrapper");
  p.put("system-time", "ch.epfl.gsn.wrappers.SystemTime");
  Main.getInstance();
}
 
源代码10 项目: ranger   文件: TestAuditQueue.java
@Test
public void testAuditSummaryByInfra() {
	logger.debug("testAuditSummaryByInfra()...");

	Properties props = new Properties();
	// Destination
	String propPrefix = AuditProviderFactory.AUDIT_DEST_BASE + ".test";
	props.put(propPrefix, "enable");
	props.put(BaseAuditHandler.PROP_DEFAULT_PREFIX + "." + "summary" + "."
			+ "enabled", "true");
	props.put(propPrefix + "." + BaseAuditHandler.PROP_NAME, "test");
	props.put(propPrefix + "." + AuditQueue.PROP_QUEUE, "none");

	props.put(BaseAuditHandler.PROP_DEFAULT_PREFIX + "."
			+ AuditSummaryQueue.PROP_SUMMARY_INTERVAL, "" + 300);
	props.put(propPrefix + "." + BaseAuditHandler.PROP_CLASS_NAME,
			TestConsumer.class.getName());

	AuditProviderFactory factory = AuditProviderFactory.getInstance();
	factory.init(props, "test");
	AuditQueue queue = (AuditQueue) factory.getAuditProvider();
	BaseAuditHandler consumer = (BaseAuditHandler) queue.getConsumer();
	while (consumer != null && consumer instanceof AuditQueue) {
		AuditQueue cQueue = (AuditQueue) consumer;
		consumer = (BaseAuditHandler) cQueue.getConsumer();
	}
	assertTrue("Consumer should be TestConsumer. class="
			+ consumer.getClass().getName(),
			consumer instanceof TestConsumer);
	TestConsumer testConsumer = (TestConsumer) consumer;
	commonTestSummary(testConsumer, queue);
}
 
源代码11 项目: lucene-solr   文件: DriverImpl.java
private void loadParams(URI uri, Properties props) throws SQLException {
  List<NameValuePair> parsedParams = URLEncodedUtils.parse(uri, "UTF-8");
  for (NameValuePair pair : parsedParams) {
    if (pair.getValue() != null) {
      props.put(pair.getName(), pair.getValue());
    } else {
      props.put(pair.getName(), "");
    }
  }
}
 
源代码12 项目: hottub   文件: ServerMain.java
private void registerCallback( Class serverClass )
{
    Method installMethod = getNamedMethod( serverClass, "install" ) ;
    Method uninstallMethod = getNamedMethod( serverClass, "uninstall" ) ;
    Method shutdownMethod = getNamedMethod( serverClass, "shutdown" ) ;

    Properties props = new Properties() ;
    props.put( "org.omg.CORBA.ORBClass",
        "com.sun.corba.se.impl.orb.ORBImpl" ) ;
    // NOTE: Very important to pass this property, otherwise the
    // Persistent Server registration will be unsucessfull.
    props.put( ORBConstants.ACTIVATED_PROPERTY, "false" );
    String args[] = null ;
    ORB orb = ORB.init( args, props ) ;

    ServerCallback serverObj = new ServerCallback( orb,
        installMethod, uninstallMethod, shutdownMethod ) ;

    int serverId = getServerId() ;

    try {
        Activator activator = ActivatorHelper.narrow(
            orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
        activator.active(serverId, serverObj);
    } catch (Exception ex) {
        logTerminal( "exception " + ex.getMessage(),
            REGISTRATION_FAILED ) ;
    }
}
 
源代码13 项目: jaybird   文件: TestFBResultSetMetaData.java
/**
 * Tests if the columnLabelForName strategy allows com.sun.rowset.CachedRowSetImpl to
 * access rows by their columnLabel.
 */
@Test
public void cachedRowSetImpl_columnLabelForName() throws Exception {
    Properties props = getDefaultPropertiesForConnection();
    props.put("columnLabelForName", "true");

    try (Connection con = DriverManager.getConnection(getUrl(), props)) {
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(
                "SELECT id, simple_field AS column2, int_field AS column3, 2 - 1 AS column4 FROM test_rs_metadata");

        RowSetFactory aFactory = RowSetProvider.newFactory();
        CachedRowSet rowSet = aFactory.createCachedRowSet();
        rowSet.populate(rs);

        assertEquals(1, rowSet.findColumn("id"));
        assertEquals(2, rowSet.findColumn("column2"));
        assertEquals(3, rowSet.findColumn("column3"));
        assertEquals(4, rowSet.findColumn("column4"));

        try {
            rowSet.findColumn("simple_field");
            fail("Looking up column with original column name should fail with columnLabelForName strategy");
        } catch (SQLException ex) {
            // expected
        }
        rowSet.close();
        stmt.close();
    }
}
 
源代码14 项目: java-study   文件: KafkaConsumerTest.java
public KafkaConsumerTest(String topicName) {
		Properties props = new Properties();
		//kafka消费的的地址
		props.put("bootstrap.servers", servers);
		//组名 不同组名可以重复消费
		props.put("group.id", GROUPID);
		//是否自动提交
		props.put("enable.auto.commit", "false");
		//从poll(拉)的回话处理时长
		props.put("auto.commit.interval.ms", "1000");
		//超时时间
		props.put("session.timeout.ms", "30000");
		props.put("max.poll.records", "1000");
//		earliest当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,从头开始消费 
//		latest 
//		当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,消费新产生的该分区下的数据 
//		none 
//		topic各分区都存在已提交的offset时,从offset后开始消费;只要有一个分区不存在已提交的offset,则抛出异常
		props.put("auto.offset.reset", "earliest");
		//序列化
		props.put("key.deserializer", StringDeserializer.class.getName());
		props.put("value.deserializer", StringDeserializer.class.getName());
		this.consumer = new KafkaConsumer<String, String>(props);
		this.topic = topicName;
		//订阅者主题
		this.consumer.subscribe(Arrays.asList(topic));
	}
 
源代码15 项目: metrics   文件: IntegrateUtilsTest.java
@Test
public void testConfigMetricLevel() {
    Properties properties = new Properties();
    properties.put("com.alibaba.metrics.jvm.class_load.level", "CRITICAL");
    MetricsIntegrateUtils.registerJvmMetrics(properties);
    Map<MetricName, Gauge> gauges = MetricManager.getIMetricManager().getGauges("jvm", new MetricFilter() {
        @Override
        public boolean matches(MetricName name, Metric metric) {
            return name.getKey().equals("jvm.class_load.loaded");
        }
    });
    Assert.assertEquals(1, gauges.size());
    Assert.assertEquals(MetricLevel.CRITICAL, gauges.entrySet().iterator().next().getKey().getMetricLevel());
}
 
/**
 * Binds an EMF to the thread and tests if EM with different properties
 * generate new EMs or not.
 */
@Test
public void testPropertiesForSharedEntityManager1() {
	Properties props = new Properties();
	props.put("foo", "bar");
	EntityManager em = mock(EntityManager.class);
	// only one call made  - the first EM definition wins (in this case the one w/ the properties)
	given(mockEmf.createEntityManager(props)).willReturn(em);
	given(em.getDelegate()).willReturn(new Object());
	given(em.isOpen()).willReturn(true);

	PersistenceAnnotationBeanPostProcessor pabpp = new MockPersistenceAnnotationBeanPostProcessor();
	DefaultPrivatePersistenceContextFieldWithProperties transactionalFieldWithProperties =
			new DefaultPrivatePersistenceContextFieldWithProperties();
	DefaultPrivatePersistenceContextField transactionalField = new DefaultPrivatePersistenceContextField();

	pabpp.postProcessProperties(null, transactionalFieldWithProperties, "bean1");
	pabpp.postProcessProperties(null, transactionalField, "bean2");

	assertNotNull(transactionalFieldWithProperties.em);
	assertNotNull(transactionalField.em);
	// the EM w/ properties will be created
	assertNotNull(transactionalFieldWithProperties.em.getDelegate());
	// bind em to the thread now since it's created
	try {
		TransactionSynchronizationManager.bindResource(mockEmf, new EntityManagerHolder(em));
		assertNotNull(transactionalField.em.getDelegate());
		verify(em).close();
	}
	finally {
		TransactionSynchronizationManager.unbindResource(mockEmf);
	}
}
 
源代码17 项目: cxf   文件: DumpJavaDoc.java
@Override
public boolean run(DocletEnvironment docEnv) {
    final Elements utils = docEnv.getElementUtils();
    final DocTrees docTrees = docEnv.getDocTrees();
    
    try (OutputStream os = Files.newOutputStream(Paths.get(dumpFileName))) {
        final Properties javaDocMap = new Properties();
        for (Element element : docEnv.getIncludedElements()) {
            if (element.getKind() == ElementKind.CLASS) {
                final TypeElement classDoc = (TypeElement) element;
                final DocCommentTree classCommentTree = docTrees.getDocCommentTree(classDoc);
                
                if (classCommentTree != null) {
                    javaDocMap.put(classDoc.toString(), getAllComments(classCommentTree.getFullBody()));
                }
                
                for (Element member: classDoc.getEnclosedElements()) {
                    // Skip all non-public methods
                    if (!member.getModifiers().contains(Modifier.PUBLIC)) {
                        continue;
                    }
                    
                    if (member.getKind() == ElementKind.METHOD) {
                        final ExecutableElement method = (ExecutableElement) member;
                        final DocCommentTree methodCommentTree = docTrees.getDocCommentTree(method);
                        final String qualifiedName = utils.getBinaryName(classDoc) + "." + method.getSimpleName();
                        
                        if (methodCommentTree == null) {
                            javaDocMap.put(qualifiedName, "");
                        } else  {
                            javaDocMap.put(qualifiedName, getAllComments(methodCommentTree.getFullBody()));
                            for (DocTree tree: methodCommentTree.getBlockTags()) {
                                if (tree.getKind() == DocTree.Kind.RETURN) {
                                    final ReturnTree returnTree = (ReturnTree) tree;
                                    javaDocMap.put(qualifiedName + ".returnCommentTag", 
                                        getAllComments(returnTree.getDescription()));
                                } else if (tree.getKind() == DocTree.Kind.PARAM) {
                                    final ParamTree paramTree = (ParamTree) tree;
                                    final int index = getParamIndex(method, paramTree);
                                    if (index >= 0) {
                                        javaDocMap.put(qualifiedName + ".paramCommentTag." + index, 
                                            getAllComments(paramTree.getDescription()));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        
        javaDocMap.store(os, "");
        os.flush();
    } catch (final IOException ex) {
        reporter.print(Diagnostic.Kind.ERROR, ex.getMessage());
    }
    
    return true;
}
 
源代码18 项目: phoenix   文件: QueryPlanTest.java
@Test
public void testTenantSpecificConnWithLimit() throws Exception {
    String baseTableDDL = "CREATE TABLE BASE_MULTI_TENANT_TABLE(\n " + 
            "  tenant_id VARCHAR(5) NOT NULL,\n" + 
            "  userid INTEGER NOT NULL,\n" + 
            "  username VARCHAR NOT NULL,\n" +
            "  col VARCHAR\n " + 
            "  CONSTRAINT pk PRIMARY KEY (tenant_id, userid, username)) MULTI_TENANT=true";
    Connection conn = DriverManager.getConnection(getUrl());
    conn.createStatement().execute(baseTableDDL);
    conn.close();
    
    String tenantId = "tenantId";
    String tenantViewDDL = "CREATE VIEW TENANT_VIEW AS SELECT * FROM BASE_MULTI_TENANT_TABLE";
    Properties tenantProps = new Properties();
    tenantProps.put(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
    conn = DriverManager.getConnection(getUrl(), tenantProps);
    conn.createStatement().execute(tenantViewDDL);
    
    String query = "EXPLAIN SELECT * FROM TENANT_VIEW LIMIT 1";
    ResultSet rs = conn.createStatement().executeQuery(query);
    assertEquals("CLIENT SERIAL 1-WAY RANGE SCAN OVER BASE_MULTI_TENANT_TABLE ['tenantId']\n" + 
            "    SERVER FILTER BY PageFilter 1\n" + 
            "    SERVER 1 ROW LIMIT\n" + 
            "CLIENT 1 ROW LIMIT", QueryUtil.getExplainPlan(rs));
    query = "EXPLAIN SELECT * FROM TENANT_VIEW LIMIT " + Integer.MAX_VALUE;
    rs = conn.createStatement().executeQuery(query);
    assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER BASE_MULTI_TENANT_TABLE ['tenantId']\n" + 
            "    SERVER FILTER BY PageFilter " + Integer.MAX_VALUE + "\n" + 
            "    SERVER " + Integer.MAX_VALUE + " ROW LIMIT\n" + 
            "CLIENT " + Integer.MAX_VALUE + " ROW LIMIT", QueryUtil.getExplainPlan(rs));
    query = "EXPLAIN SELECT * FROM TENANT_VIEW WHERE username = 'Joe' LIMIT 1";
    rs = conn.createStatement().executeQuery(query);
    assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER BASE_MULTI_TENANT_TABLE ['tenantId']\n" + 
            "    SERVER FILTER BY USERNAME = 'Joe'\n" + 
            "    SERVER 1 ROW LIMIT\n" + 
            "CLIENT 1 ROW LIMIT", QueryUtil.getExplainPlan(rs));
    query = "EXPLAIN SELECT * FROM TENANT_VIEW WHERE col = 'Joe' LIMIT 1";
    rs = conn.createStatement().executeQuery(query);
    assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER BASE_MULTI_TENANT_TABLE ['tenantId']\n" + 
            "    SERVER FILTER BY COL = 'Joe'\n" + 
            "    SERVER 1 ROW LIMIT\n" + 
            "CLIENT 1 ROW LIMIT", QueryUtil.getExplainPlan(rs));
}
 
源代码19 项目: kfs   文件: BudgetConstructionAction.java
/**
 * Calls the single line benefits impact screen by setting up the required parameters and feeding them to the temporary list
 * lookup action for the expenditure line selected. This is called from the ShowBenefits button on the BC document screen when
 * an expenditure line is associated with benefits and benefits calculation is enabled.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward performShowBenefits(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

    BudgetConstructionForm tForm = (BudgetConstructionForm) form;
    BudgetConstructionDocument tDoc = tForm.getBudgetConstructionDocument();
    int selectIndex = this.getSelectedLine(request);
    PendingBudgetConstructionGeneralLedger expLine = tDoc.getPendingBudgetConstructionGeneralLedgerExpenditureLines().get(selectIndex);

    // when we return from the lookup, our next request's method to call is going to be refresh
    tForm.registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER);

    Properties parameters = new Properties();
    parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.START_METHOD);

    String basePath = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KFSConstants.APPLICATION_URL_KEY);
    parameters.put(KFSConstants.BACK_LOCATION, basePath + mapping.getPath() + ".do");

    if (StringUtils.isNotEmpty(((KualiForm) form).getAnchor())) {
        parameters.put(BCConstants.RETURN_ANCHOR, ((KualiForm) form).getAnchor());
    }

    // this hack sets the return anchor we want to return too after the inquiry
    // do this here so it gets into the session stored form version
    // refresh checks for this after and resets the anchor
    if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getAnchor())) {
        tForm.setBalanceInquiryReturnAnchor(((KualiForm) form).getAnchor());
    }

    parameters.put(KRADConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(form, BCConstants.FORMKEY_PREFIX));
    parameters.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, BCConstants.REQUEST_BENEFITS_BO);
    parameters.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, "true");
    parameters.put(KFSConstants.SUPPRESS_ACTIONS, "true");
    parameters.put(BCConstants.SHOW_INITIAL_RESULTS, "true");
    parameters.put(BCConstants.TempListLookupMode.TEMP_LIST_LOOKUP_MODE, Integer.toString(BCConstants.TempListLookupMode.SHOW_BENEFITS));

    parameters.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, expLine.getUniversityFiscalYear().toString());
    parameters.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, expLine.getChartOfAccountsCode());
    parameters.put(KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME, expLine.getFinancialObjectCode());
    parameters.put(KFSPropertyConstants.ACCOUNT_LINE_ANNUAL_BALANCE_AMOUNT, expLine.getAccountLineAnnualBalanceAmount().toString());
    parameters.put(KFSPropertyConstants.ACCOUNT_NUMBER, expLine.getAccountNumber());
    parameters.put(KRADConstants.LOOKUP_READ_ONLY_FIELDS, KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR + "," + KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE + "," + KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME + "," + KFSPropertyConstants.ACCOUNT_LINE_ANNUAL_BALANCE_AMOUNT);

    String url = UrlFactory.parameterizeUrl(basePath + "/" + BCConstants.ORG_TEMP_LIST_LOOKUP, parameters);
    this.setupDocumentExit();
    return new ActionForward(url, true);
}
 
源代码20 项目: ReplicaDB   文件: SqlManager.java
protected Connection makeSinkConnection() throws SQLException {

        Connection connection;
        String driverClass = getDriverClass();

        try {
            Class.forName(driverClass);
        } catch (ClassNotFoundException cnfe) {
            throw new RuntimeException("Could not load db driver class: "
                    + driverClass);
        }

        String username = options.getSinkUser();
        String password = options.getSinkPassword();
        String connectString = options.getSinkConnect();

        Properties connectionParams = options.getSinkConnectionParams();
        if (connectionParams != null && connectionParams.size() > 0) {
            LOG.debug("User specified connection params. Using properties specific API for making connection.");

            Properties props = new Properties();
            if (username != null) {
                props.put("user", username);
            }

            if (password != null) {
                props.put("password", password);
            }

            props.putAll(connectionParams);
            connection = DriverManager.getConnection(connectString, props);
        } else {
            LOG.debug("No connection parameters specified. Using regular API for making connection.");
            if (username == null) {
                connection = DriverManager.getConnection(connectString);
            } else {
                connection = DriverManager.getConnection(connectString, username, password);
            }
        }

        // We only use this for metadata queries. Loosest semantics are okay.
        //connection.setTransactionIsolation(getMetadataIsolationLevel());
        connection.setAutoCommit(false);

        return connection;
    }