List of usage examples for java.util Hashtable Hashtable
public Hashtable()
From source file:arena.translation.TranslationSetSelectorBean.java
public TranslationSet getTranslationSet(Locale locale) { String language = locale.getLanguage(); synchronized (this.translationSets) { TranslationSet translationSet = (TranslationSet) this.translationSets.get(language.toLowerCase()); if (translationSet == null) { Object translationSheet = null; if (this.translationSheets != null) { translationSheet = this.translationSheets.get(language); }/*from w w w . java2 s. com*/ if (translationSheet == null) { translationSheet = this.defaultBasePath + language + ".xml"; } if (this.servletContext != null) { translationSheet = servletContext.getRealPath(translationSheet.toString()); } File file = new File(translationSheet.toString()); if (!file.isFile()) { log.warn("Translation file not found: " + translationSheet); } Document doc = XMLUtils.parseFileToXML(file); NodeList items = doc.getDocumentElement().getChildNodes(); Map<String, String> translations = new Hashtable<String, String>(); for (int n = 0; n < items.getLength(); n++) { Node node = items.item(n); if (node.getNodeType() == Node.ELEMENT_NODE) { String key = XMLUtils.getAttributeByName(node, "key"); String text = XMLUtils.extractStringFromElement(node); if ((key != null) && (text != null)) { translations.put(key, text); } } } log.info("Loaded " + translations.size() + " translations for " + language + " from " + translationSheet); translationSet = new FixedTranslationSet(translations); this.translationSets.put(language.toLowerCase(), translationSet); } return translationSet; } }
From source file:org.apache.cxf.dosgi.dsw.Activator.java
private RemoteServiceadminFactory registerRemoteServiceAdminService() { RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(bc); Hashtable<String, Object> props = new Hashtable<String, Object>(); // TODO .... RemoteAdminService.XXX // props.put(DistributionProvider.PRODUCT_NAME, getHeader("Bundle-Name")); // props.put(DistributionProvider.PRODUCT_VERSION, getHeader("Bundle-Version")); // props.put(DistributionProvider.VENDOR_NAME, getHeader("Bundle-Vendor")); String[] supportedIntents = getIntentMap().getIntents().keySet().toArray(new String[] {}); String siString = OsgiUtils.formatIntents(supportedIntents); props.put("remote.intents.supported", siString); // // TODO make this a little smarter String[] supportedConfigs = { org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE, org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE_OLD, org.apache.cxf.dosgi.dsw.Constants.RS_CONFIG_TYPE }; props.put("remote.configs.supported", supportedConfigs); LOG.info("Registering RemoteServiceAdminFactory..."); rsaFactoryReg = bc.registerService(RemoteServiceAdmin.class.getName(), rsaf, props); return rsaf;/*www . ja va2 s . c o m*/ }
From source file:com.adito.language.LanguagePackManager.java
/** * Although this call is used as a singleton, it has this package * protected constructor for junit tests. *//*from w ww . java2 s .c om*/ public LanguagePackManager() { super(); languagePackDefinitions = new HashMap<String, LanguagePackDefinition>(); categories = new ArrayList<LanguageCategory>(); haCategories = new Hashtable<String, LanguageCategory>(); }
From source file:com.mascova.solus.ui.ClientApplication.java
public ClientApplication(String[] argv) { System.out.println(System.getProperty("user.dir")); ac = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext-jpa.xml", "/META-INF/spring/applicationContext.xml"); loginService = ac.getBean(LoginService.class); authService = ac.getBean(AuthService.class); systemLookupService = ac.getBean(SystemLookupService.class); clientFacade = new DeskClientFacade(ac); // BEGIN Create dummy data // SqlUtil.importCsvData(); // DataGenerator dg = ac.getBean(DataGenerator.class); // PersonDataOnDemand pdod = ac.getBean(PersonDataOnDemand.class); // dg.insertMenuData(); // pdod.init(); // END Create dummy data Hashtable domains = new Hashtable(); List<SystemLookup> genderSystemLookup = systemLookupService.findByType("GNDR"); Domain genderDomain = new Domain("GNDR"); for (SystemLookup systemLookup : genderSystemLookup) { genderDomain.addDomainPair(systemLookup.getCode(), systemLookup.getLiteral()); }// w w w. j av a 2 s . com List<SystemLookup> statusSystemLookup = systemLookupService.findByType("STATUS"); Domain statusDomain = new Domain("STATUS"); for (SystemLookup systemLookup : statusSystemLookup) { statusDomain.addDomainPair(systemLookup.getType(), systemLookup.getLiteral()); } domains.put(genderDomain.getDomainId(), genderDomain); domains.put(statusDomain.getDomainId(), statusDomain); Properties licenseProp = new Properties(); licenseProp.put("systemTextFont", "Arial PLAIN 8"); licenseProp.put("controlTextFont", "Arial PLAIN 8"); licenseProp.put("menuTextFont", "Arial PLAIN 8"); licenseProp.put("userTextFont", "Arial PLAIN 8"); licenseProp.put("subTextFont", "Arial PLAIN 8"); ClientSettings clientSettings = new ClientSettings(new EnglishOnlyResourceFactory("E", licenseProp, true), domains); // ClientSettings clientSettings = new ClientSettings( // new IndonesiaOnlyResourceFactory("E", licenseProp, true), // domains); // Enumeration k = System.getProperties().keys(); // while(k.hasMoreElements()) { // String kk = k.nextElement().toString(); // System.out.println(kk+"="+System.getProperty(kk)); // } // System.out.println(ClientSettings.LOOK_AND_FEEL_CLASS_NAME); // ClientSettings.LOOK_AND_FEEL_CLASS_NAME = // "javax.swing.plaf.nimbus.NimbusLookAndFeel"; ClientSettings.LOOK_AND_FEEL_CLASS_NAME = "com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"; Properties props = new Properties(); props.put("logoString", "Solus"); String color = "220 220 220"; props.put("selectionBackgroundColor", color); props.put("menuSelectionBackgroundColor", color); props.put("backgroundColor", "232 232 232"); props.put("disabledBackgroundColor", color); props.put("systemTextFont", "Arial PLAIN 11"); props.put("controlTextFont", "Arial PLAIN 11"); props.put("menuTextFont", "Arial PLAIN 11"); props.put("userTextFont", "Arial PLAIN 11"); props.put("subTextFont", "Arial PLAIN 11"); try { try { try { Class.forName(ClientSettings.LOOK_AND_FEEL_CLASS_NAME) .getMethod("setCurrentTheme", new Class[] { Properties.class }) .invoke(null, new Object[] { props }); } catch (NoSuchMethodException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } catch (SecurityException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } } catch (IllegalAccessException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalArgumentException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } catch (InvocationTargetException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } } catch (ClassNotFoundException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } try { UIManager.setLookAndFeel(ClientSettings.LOOK_AND_FEEL_CLASS_NAME); } catch (ClassNotFoundException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedLookAndFeelException ex) { Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex); } ClientSettings.BACKGROUND = "background3.jpg"; ClientSettings.TREE_BACK = "treeback2.jpg"; ClientSettings.ICON_FILENAME = "appicon1.png"; ClientSettings.AUTO_EXPAND_TREE_MENU = true; ClientSettings.MIN_MENU_WIDTH = 300; ClientSettings.FILTER_PANEL_ON_GRID = true; ClientSettings.SHOW_NAVIGATOR_BAR_IN_LOOKUP = true; ClientSettings.LOOKUP_FRAME_CONTENT = LookupController.GRID_AND_FILTER_FRAME; // ClientSettings.AUTO_EXPAND_SUBTREE_MENU = "Folder3"; // ClientSettings.MAX_MENU_WIDTH = 300; // ClientSettings.MENU_WIDTH = 300; if (argv.length == 1) { ClientSettings.LOOK_AND_FEEL_CLASS_NAME = argv[0]; } // instantiateLoginDialog(); MDIFrame mdi = new MDIFrame(this); }
From source file:com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilterTest.java
@Before @SuppressWarnings("rawtypes") public void setup() throws Exception { properties = new Hashtable<String, Object>(); String[] patterns = new String[] { pattern }; properties.put(AbstractDispatcherCacheHeaderFilter.PROP_FILTER_PATTERN, patterns); params = new HashMap(); agents = new HashSet<String>(); filter = new AbstractDispatcherCacheHeaderFilter() { @Override/* w ww . j a v a 2 s .co m*/ protected String getHeaderName() { return headerName; } @Override protected String getHeaderValue() { return headerValue; } @Override protected void doActivate(ComponentContext context) throws Exception { } }; when(componentContext.getProperties()).thenReturn(properties); when(componentContext.getBundleContext()).thenReturn(bundleContext); when(bundleContext.registerService(anyString(), any(), (Dictionary) any())).thenReturn(serviceRegistration); when(request.getMethod()).thenReturn("GET"); when(request.getParameterMap()).thenReturn(params); final Map<String, Object> attributes = new HashMap<>(); doAnswer(i -> attributes.put(i.getArgumentAt(0, String.class), i.getArgumentAt(1, Object.class))) .when(request).setAttribute(any(), any()); when(request.getAttribute(any())).thenAnswer(i -> attributes.get(i.getArgumentAt(0, String.class))); }
From source file:com.ibm.jaggr.service.impl.config.BundleVersionsHashTest.java
@Test public void testBundleVersionsHash() throws Exception { URI tmpDir = new File(System.getProperty("user.dir")).toURI(); IAggregator mockAggregator = TestUtils.createMockAggregator(); InitParams initParams = new InitParams(Arrays .asList(new InitParam[] { new InitParam("propName", "getBundleVersionsHash", mockAggregator) })); BundleVersionsHash bvh = new BundleVersionsHash(); IServiceReference mockServiceReference = EasyMock.createNiceMock(IServiceReference.class); IServiceReference[] serviceReferences = new IServiceReference[] { mockServiceReference }; IPlatformServices mockPlatformServices = EasyMock.createNiceMock(IPlatformServices.class); IAggregatorExtension mockExtension = EasyMock.createMock(IAggregatorExtension.class); EasyMock.expect(mockAggregator.getPlatformServices()).andReturn(mockPlatformServices).anyTimes(); EasyMock.replay(mockAggregator);/*from w w w. j a va2s. co m*/ Dictionary<String, String> dict = new Hashtable<String, String>(); dict.put("name", mockAggregator.getName()); EasyMock.expect(mockPlatformServices.getService(mockServiceReference)).andReturn(bvh).anyTimes(); EasyMock.expect(mockExtension.getInitParams()).andReturn(initParams).anyTimes(); EasyMock.expect(mockPlatformServices.getServiceReferences(IConfigScopeModifier.class.getName(), "(name=" + mockAggregator.getName() + ")")).andReturn(serviceReferences).anyTimes(); EasyMock.replay(mockServiceReference, mockPlatformServices, mockExtension); bvh.initialize(mockAggregator, mockExtension, null); EasyMock.verify(mockPlatformServices); Bundle mockBundle1 = EasyMock.createMock(Bundle.class); Bundle mockBundle2 = EasyMock.createMock(Bundle.class); PowerMock.mockStatic(Platform.class); EasyMock.expect(Platform.getBundle("com.test.bundle1")).andReturn(mockBundle1).anyTimes(); EasyMock.expect(Platform.getBundle("com.test.bundle2")).andReturn(mockBundle2).anyTimes(); EasyMock.expect(Platform.getBundle("com.test.bundle3")).andReturn(null).anyTimes(); final Dictionary<String, String> bundle1Headers = new Hashtable<String, String>(); final Dictionary<String, String> bundle2Headers = new Hashtable<String, String>(); EasyMock.expect(mockBundle1.getHeaders()).andAnswer(new IAnswer<Dictionary<String, String>>() { @Override public Dictionary<String, String> answer() throws Throwable { return bundle1Headers; } }).anyTimes(); EasyMock.expect(mockBundle2.getHeaders()).andAnswer(new IAnswer<Dictionary<String, String>>() { @Override public Dictionary<String, String> answer() throws Throwable { return bundle2Headers; } }).anyTimes(); PowerMock.replay(Platform.class, mockBundle1, mockBundle2); bundle1Headers.put("Bnd-LastModified", "123456789"); bundle2Headers.put("Bnd-LastModified", "234567890"); bundle1Headers.put("Bundle-Version", "1.2.3.20140414"); bundle2Headers.put("Bundle-Version", "1.2.3.20140412"); String config = "{cacheBust:getBundleVersionsHash(['Bundle-Version', 'Bnd-LastModified'], 'com.test.bundle1', 'com.test.bundle2')}"; ConfigImpl cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); String cacheBust = cfg.getCacheBust(); bundle1Headers.put("Bnd-LastModified", "123456780"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertFalse(cacheBust.equals(cfg.getCacheBust())); bundle1Headers.put("Bnd-LastModified", "123456789"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); bundle2Headers.put("Bundle-Version", "1.2.4"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertFalse(cacheBust.equals(cfg.getCacheBust())); bundle2Headers.put("Bundle-Version", "1.2.3.20140412"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); // Test that when header names are not specified, it defaults to 'Bundle-Version'. config = "{cacheBust:getBundleVersionsHash('com.test.bundle1', 'com.test.bundle2')}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); cacheBust = cfg.getCacheBust(); bundle1Headers.put("Bnd-LastModified", "123456780"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); bundle2Headers.put("Bundle-Version", "1.2.4"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertFalse(cacheBust.equals(cfg.getCacheBust())); bundle2Headers.put("Bundle-Version", "1.2.3.20140412"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); // Ensure exception thrown if a specified bundle is not found config = "{cacheBust:getBundleVersionsHash('com.test.bundle1', 'com.test.bundle2', 'com.test.bundle3')}"; try { cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.fail("Expected exception"); } catch (WrappedException ex) { Assert.assertTrue(NotFoundException.class.isInstance(ex.getCause())); } // ensure exception thrown if argument is wrong type config = "{cacheBust:getBundleVersionsHash({})}"; try { cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.fail("Expected exception"); } catch (WrappedException ex) { Assert.assertTrue(IllegalArgumentException.class.isInstance(ex.getCause())); } // ensure value is null if no bundle names specified config = "{cacheBust:getBundleVersionsHash()}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertNull(cfg.getCacheBust()); config = "{cacheBust:getBundleVersionsHash(['Bundle-Version'])}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertNull(cfg.getCacheBust()); config = "{}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertNull(cfg.getCacheBust()); // Ensure that cacheBust is a base64 encoded array of 16 bytes. byte[] bytes = Base64.decodeBase64(cacheBust); Assert.assertEquals(16, bytes.length); }
From source file:com.alfaariss.oa.util.saml2.binding.BindingProperties.java
/** * Create new <code>BindingProperties</code> from configuration. * * @param config The configuration manager. * @param eBindings The bindings configuration section. * @throws ConfigurationException If reading from configuration fails * @throws OAException If configuration is invalid *///from ww w . j av a 2s . c om public BindingProperties(IConfigurationManager config, Element eBindings) throws OAException { _bindingProperties = new Hashtable<String, Properties>(); _bindings = new Vector<String>(); Element eBinding = config.getSection(eBindings, "binding"); if (eBinding == null) { _logger.error("Not one 'binding' section found in 'bindings' section in configuration"); throw new OAException(SystemErrors.ERROR_CONFIG_READ); } _bindingProperties = readBindings(config, eBinding); //DD added specific check for required path config item for HTTP-POST if (isSupported(SAMLConstants.SAML2_POST_BINDING_URI)) { String sPath = getProperty(SAMLConstants.SAML2_POST_BINDING_URI, "path"); if (sPath == null) { _logger.error( "No 'path' parameter configured for binding: " + SAMLConstants.SAML2_POST_BINDING_URI); throw new OAException(SystemErrors.ERROR_INIT); } } //DD added specific check for required path config item for HTTP-Artifact when in `post` mode if (isSupported(SAMLConstants.SAML2_ARTIFACT_BINDING_URI)) { if (getBooleanProperty(SAMLConstants.SAML2_ARTIFACT_BINDING_URI, "post", false)) { String sPath = getProperty(SAMLConstants.SAML2_ARTIFACT_BINDING_URI, "path"); if (sPath == null) { _logger.error("No 'path' parameter configured for binding: " + SAMLConstants.SAML2_ARTIFACT_BINDING_URI); throw new OAException(SystemErrors.ERROR_INIT); } } } _sDefault = config.getParam(eBindings, "default"); if (_sDefault == null) { _logger.error("No 'default' item found in 'bindings' section in configuration"); throw new OAException(SystemErrors.ERROR_CONFIG_READ); } if (!_bindingProperties.keySet().contains(_sDefault)) { _logger.error("Invalid 'default' binding configured: " + _sDefault); throw new OAException(SystemErrors.ERROR_CONFIG_READ); } }
From source file:eu.eubrazilcc.lvl.service.cache.StatisticsCache.java
public static Map<String, List<SimpleStat>> sandflyStats() { Optional<Map<String, List<SimpleStat>>> stats = absent(); try {//from w w w . j a va 2s .com stats = CACHE.get(SANDFLY_COLLECTION); } catch (ExecutionException e) { LOGGER.error("Failed to get collection statistics from cache", e); } return stats.or(new Hashtable<String, List<SimpleStat>>()); }
From source file:de.filiberry.bathcontrol.Activator.java
/** * /*from w w w . j av a 2 s . c o m*/ */ public void start(BundleContext context) { LOGGER.info("Start Bundle " + BUNDLE_ID); mqttHost = ""; mqttTopic = ""; this.context = context; bathControlContext = new BathControlContext(); bathControlWorker.setBathControlContext(bathControlContext); Hashtable<String, Object> properties = new Hashtable<String, Object>(); properties.put(Constants.SERVICE_PID, BUNDLE_ID); serviceReg = context.registerService(ManagedService.class.getName(), this, properties); }
From source file:org.hdiv.filter.RequestWrapper.java
/** * Constructs a request object wrapping the given request. * //w w w .j a v a 2 s . co m * @param servletRequest * request */ public RequestWrapper(HttpServletRequest servletRequest) { super(servletRequest); this.elementsText = new Hashtable(); this.elementsFile = new Hashtable(); this.isMultipart = false; if (log.isDebugEnabled()) { log.debug("New RequestWrapper instance."); } }