Java 类java.util.Dictionary 实例源码

项目:neoscada    文件:ObjectPoolImpl.java   
@Override
public synchronized void removeService ( final String id, final S service )
{
    if ( this.disposed )
    {
        return;
    }

    logger.debug ( "Removing service: {} -> {}", id, service );

    final Map<S, Dictionary<?, ?>> serviceMap = this.services.get ( id );
    if ( serviceMap == null )
    {
        return;
    }
    final Dictionary<?, ?> properties = serviceMap.remove ( service );
    if ( properties != null )
    {
        if ( serviceMap.isEmpty () )
        {
            this.services.remove ( id );
        }
        fireRemoveService ( id, service, properties );
    }
}
项目:athena    文件:ClusterIpManager.java   
@Modified
protected void modified(ComponentContext context) {
    log.info("Received configuration change...");
    Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
    String newIp = get(properties, "aliasIp");
    String newMask = get(properties, "aliasMask");
    String newAdapter = get(properties, "aliasAdapter");

    // Process any changes in the parameters...
    if (!Objects.equals(newIp, aliasIp) ||
            !Objects.equals(newMask, aliasMask) ||
            !Objects.equals(newAdapter, aliasAdapter)) {
        synchronized (this) {
            log.info("Reconfiguring with aliasIp={}, aliasMask={}, aliasAdapter={}, wasLeader={}",
                     newIp, newMask, newAdapter, wasLeader);
            if (wasLeader) {
                removeIpAlias(aliasIp, aliasMask, aliasAdapter);
                addIpAlias(newIp, newMask, newAdapter);
            }
            aliasIp = newIp;
            aliasMask = newMask;
            aliasAdapter = newAdapter;
        }
    }
}
项目:neoscada    文件:Activator.java   
private void activate ( final DataSourceFactory dataSourceFactory ) throws Exception
{
    logger.debug ( "Activate storage" );
    this.scheduler = ScheduledExportedExecutorService.newSingleThreadExportedScheduledExecutor ( "org.eclipse.scada.ae.server.storage.postgresql/ScheduledExecutor" );

    final Properties dbProperties = DataSourceHelper.getDataSourceProperties ( SPECIFIC_PREFIX, DataSourceHelper.DEFAULT_PREFIX );

    final String schema = getSchema ();
    final String instance = getInstance ();
    this.jdbcStorage = new JdbcStorage ( dataSourceFactory, this.scheduler, dbProperties, DataSourceHelper.isConnectionPool ( SPECIFIC_PREFIX, DataSourceHelper.DEFAULT_PREFIX, false ), schema, instance );
    this.jdbcStorage.start ();

    final Dictionary<String, Object> properties = new Hashtable<String, Object> ( 2 );
    properties.put ( Constants.SERVICE_DESCRIPTION, "PostgreSQL specific JDBC implementation for org.eclipse.scada.ae.server.storage.Storage" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.jdbcStorageHandle = context.registerService ( new String[] { JdbcStorage.class.getName (), Storage.class.getName () }, this.jdbcStorage, properties );
    logger.debug ( "Storage activated - {}", this.jdbcStorageHandle );
}
项目:neoscada    文件:EventPoolManager.java   
private void createPool ( final Storage storage, final EventManager eventManager )
{
    logger.info ( "Create pool: {}", this.id );
    try
    {
        this.pool = new EventPoolImpl ( this.executor, storage, eventManager, this.filter, this.size );

        this.pool.start ();

        logger.info ( "pool {} created", this.id );

        final Dictionary<String, String> properties = new Hashtable<String, String> ();
        properties.put ( Constants.SERVICE_PID, this.id );
        this.poolHandle = this.context.registerService ( EventQuery.class.getName (), this.pool, properties );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to create event pool: " + this.id, e );
    }
}
项目:OpenJSharp    文件:ImageView.java   
/**
 * Loads the image from the URL <code>getImageURL</code>. This should
 * only be invoked from <code>refreshImage</code>.
 */
private void loadImage() {
    URL src = getImageURL();
    Image newImage = null;
    if (src != null) {
        Dictionary cache = (Dictionary)getDocument().
                                getProperty(IMAGE_CACHE_PROPERTY);
        if (cache != null) {
            newImage = (Image)cache.get(src);
        }
        else {
            newImage = Toolkit.getDefaultToolkit().createImage(src);
            if (newImage != null && getLoadsSynchronously()) {
                // Force the image to be loaded by using an ImageIcon.
                ImageIcon ii = new ImageIcon();
                ii.setImage(newImage);
            }
        }
    }
    image = newImage;
}
项目:aries-jpa    文件:PersistenceProviderTracker.java   
@Override
public StoredPerProvider addingService(ServiceReference<PersistenceProvider> reference) {
    String providerName = (String)reference.getProperty(JAVAX_PERSISTENCE_PROVIDER);
    // FIXME should be set when creating the EMF was successful
    if (punit.getPersistenceProviderClassName() == null) {
        punit.setProviderClassName(providerName);
    }
    StoredPerProvider stored = new StoredPerProvider();
    LOGGER.info("Found provider for " + punit.getPersistenceUnitName() + " " + punit.getPersistenceProviderClassName());

    PersistenceProvider provider = context.getService(reference);

    createAndCloseDummyEMF(provider);

    stored.builder = new AriesEntityManagerFactoryBuilder(context, provider, reference.getBundle(), punit);
    Dictionary<String, ?> props = AriesEntityManagerFactoryBuilder.createBuilderProperties(punit, punit.getBundle());
    stored.reg = context.registerService(EntityManagerFactoryBuilder.class, stored.builder , props);
    return stored;
}
项目:gemini.blueprint    文件:OsgiServiceReferenceUtilsTest.java   
protected void setUp() throws Exception {
    classes = new String[] { Object.class.getName(), Cloneable.class.getName(), Serializable.class.getName() };

    // lowest service reference
    Dictionary dict1 = new Hashtable();
    dict1.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
    ref1 = new MockServiceReference(null, dict1, null);

    // neutral service reference
    Dictionary dict2 = new Hashtable();
    dict2.put(Constants.SERVICE_ID, (long) 20);

    ref2 = new MockServiceReference(null, dict2, null);

    // neutral service reference
    Dictionary dict3 = new Hashtable();
    dict3.put(Constants.SERVICE_ID, (long) 30);

    ref3 = new MockServiceReference(null, dict3, null);

    ctrl = createStrictControl();
    context = ctrl.createMock(BundleContext.class);

}
项目:MapAnalyst    文件:SliderUtils.java   
public static void addSuffixToSliderLabels(JSlider slider, String suffix) {

        assert (slider != null && suffix != null);

        Dictionary oldLabels = slider.getLabelTable();
        Enumeration oldKeys = oldLabels.keys();
        Hashtable newLabelTable = new Hashtable();
        while (oldKeys.hasMoreElements()) {
            Object key = oldKeys.nextElement();
            Object value = oldLabels.get(key);
            assert (value instanceof String);
            String str = ((String)value).concat(suffix);
            JLabel label = new JLabel(str);
            newLabelTable.put(key, label);
        }

        slider.setLabelTable(newLabelTable);
    }
项目:parabuild-ci    文件:InvocationContextImpl.java   
/**
 * Constructs a servlet invocation context for a specified servlet container,
 * request, and cookie headers.
 **/
InvocationContextImpl( ServletUnitClient client, ServletRunner runner, String target, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException {
    _client      = client;
    _application = runner.getApplication();
    _requestURL  = request.getURL();
    _target      = target;

    final ServletUnitHttpRequest suhr = new ServletUnitHttpRequest( _application.getServletRequest( _requestURL ), request, runner.getContext(),
                                                   clientHeaders, messageBody );
    _request = suhr;
    Cookie[] cookies = getCookies( clientHeaders );
    for (int i = 0; i < cookies.length; i++) suhr.addCookie( cookies[i] );

    if (_application.usesBasicAuthentication()) suhr.readBasicAuthentication();
    else if (_application.usesFormAuthentication()) suhr.readFormAuthentication();

    HttpSession session = _request.getSession( /* create */ false );
    if (session != null) ((ServletUnitHttpSession) session).access();
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;
    this.context = context;

    this.executor = Executors.newSingleThreadExecutor ( new NamedThreadFactory ( context.getBundle ().getSymbolicName () ) );
    this.factory = new SumSourceFactory ( context, this.executor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A summary data source" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () );

    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );
}
项目:jdk8u-jdk    文件:BasicSliderUI.java   
/**
 * Returns the biggest value that has an entry in the label table.
 *
 * @return biggest value that has an entry in the label table, or
 *         null.
 * @since 1.6
 */
protected Integer getHighestValue() {
    Dictionary dictionary = slider.getLabelTable();

    if (dictionary == null) {
        return null;
    }

    Enumeration keys = dictionary.keys();

    Integer max = null;

    while (keys.hasMoreElements()) {
        Integer i = (Integer) keys.nextElement();

        if (max == null || i > max) {
            max = i;
        }
    }

    return max;
}
项目:aries-jpa    文件:Activator.java   
private void handlePotentialEclipseLink(Bundle b) {
    if (!ECLIPSELINK_JPA_PROVIDER_BUNDLE_SYMBOLIC_NAME.equals(b.getSymbolicName())) {
        return;
    }
    if (registeredProviders.containsKey(b)) {
        return;
    }

    PersistenceProvider provider = createEclipselinkProvider(b);
    if (provider == null) {
        return;
    }

    LOG.debug("Adding new EclipseLink provider for bundle {}", b);
    PersistenceProvider proxiedProvider = new EclipseLinkPersistenceProvider(provider, b);

    Dictionary<String, Object> props = new Hashtable<String, Object>(); // NOSONAR
    props.put("org.apache.aries.jpa.container.weaving.packages", getJPAPackages(b));
    props.put("javax.persistence.provider", ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
    ServiceRegistration<?> reg = context.registerService(PersistenceProvider.class, proxiedProvider, props);

    ServiceRegistration<?> old = registeredProviders.putIfAbsent(b, reg);
    if (old != null) {
        reg.unregister();
    }
}
项目:neoscada    文件:BeanConfigurationFactory.java   
public Dictionary<String, ?> getProperties ()
{
    try
    {
        final Dictionary<String, Object> result = new Hashtable<String, Object> ();

        final Map<?, ?> properties = new BeanUtilsBean2 ().describe ( this.targetBean );
        for ( final Map.Entry<?, ?> entry : properties.entrySet () )
        {
            if ( entry.getValue () != null )
            {
                result.put ( entry.getKey ().toString (), entry.getValue () );
            }
        }
        return result;
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to get dictionary", e );
        return new Hashtable<String, Object> ( 1 );
    }
}
项目:neoscada    文件:AbstractMasterItemMonitor.java   
private synchronized void connect () throws InvalidSyntaxException
{
    if ( this.configuration.masterId == null )
    {
        setUnsafe ();
        throw new RuntimeException ( String.format ( "'%s' is not set", MasterItem.MASTER_ID ) );
    }

    logger.debug ( "Setting up for master item: {}", this.configuration.masterId );

    this.tracker = new SingleObjectPoolServiceTracker<MasterItem> ( this.poolTracker, this.configuration.masterId, new ServiceListener<MasterItem> () {

        @Override
        public void serviceChange ( final MasterItem service, final Dictionary<?, ?> properties )
        {
            AbstractMasterItemMonitor.this.setMasterItem ( service );
        }
    } );

    this.tracker.open ();
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.context = context;
    this.scheduler = ScheduledExportedExecutorService.newSingleThreadExportedScheduledExecutor ( context.getBundle ().getSymbolicName () + ".scheduler" );
    this.factory = new MovingAverageDataSourceFactory ( context, this.scheduler );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "An averaging data source over time" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () );

    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );
}
项目:gemini.blueprint    文件:MockServiceReferenceTest.java   
private MockServiceReference createReference(Long id, Integer ranking) {
    Dictionary dict = new Properties();
    dict.put(Constants.SERVICE_ID, id);
    if (ranking != null)
        dict.put(Constants.SERVICE_RANKING, ranking);

    return new MockServiceReference(null, dict, null);
}
项目:openjdk-jdk10    文件:BasicSliderUI.java   
/**
 * Returns the width of the widest label.
 * @return the width of the widest label
 */
protected int getWidthOfWidestLabel() {
    @SuppressWarnings("rawtypes")
    Dictionary dictionary = slider.getLabelTable();
    int widest = 0;
    if ( dictionary != null ) {
        Enumeration<?> keys = dictionary.keys();
        while ( keys.hasMoreElements() ) {
            JComponent label = (JComponent) dictionary.get(keys.nextElement());
            widest = Math.max( label.getPreferredSize().width, widest );
        }
    }
    return widest;
}
项目:neoscada    文件:Activator.java   
public void start ( final BundleContext context ) throws Exception
{
    this.factory = new ProxyDataSourceFactory ( context );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "Proxy data sources" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, "da.datasource.proxy" );

    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );
}
项目:gemini.blueprint    文件:ApplicationContextConfigurationTest.java   
public void tstConfigLocationsInMetaInfWithHeaderAndDependencies() throws Exception {
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "META-INF/spring/context.xml;wait-for-dependencies:=false");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    String[] configFiles = config.getConfigurationLocations();
    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("2 config files", 1, configFiles.length);
    assertEquals("osgibundle:META-INF/spring/context.xml", configFiles[0]);
}
项目:improved-journey    文件:TFIDFMeasure.java   
private void GenerateTermFrequency()
{
    for(int i=0; i < _numDocs  ; i++)
    {                               
        String curDoc=_docs[i];
        Dictionary freq=GetWordFrequency(curDoc);
        Enumeration enums=freq.keys();

        while(enums.hasMoreElements()){
            String word=(String) enums.nextElement();
            int wordFreq=(Integer)freq.get(word);
            int termIndex=GetTermIndex(word);
                  if(termIndex == -1)
                      continue;
            _termFreq [termIndex][i]=wordFreq;
            _docFreq[termIndex] ++;

            if (wordFreq > _maxTermFreq[i]) _maxTermFreq[i]=wordFreq;   
        }
        //DictionaryEnumerator enums=freq.GetEnumerator() ;
        _maxTermFreq[i]=Integer.MIN_VALUE ;
        /*freq.elements()
        Object ele=null;
        while ((ele=enums.nextElement())!=null)
        {

            String word=(String)ele.
            int wordFreq=(int)enums.Value ;
            int termIndex=GetTermIndex(word);
                  if(termIndex == -1)
                      continue;
            _termFreq [termIndex][i]=wordFre/q;
            _docFreq[termIndex] ++;

            if (wordFreq > _maxTermFreq[i]) _maxTermFreq[i]=wordFreq;                   
        }*/
    }
}
项目:gemini.blueprint    文件:ApplicationContextConfigurationTest.java   
public void testCreateAsynchronouslyDefaultTrueIfGarbage() {
    // *;flavour
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "*;favour:=false");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle should have create-asynchronously = true", config.isCreateAsynchronously());
}
项目:OpenJSharp    文件:BasicSliderUI.java   
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
项目:neoscada    文件:DataItemFactory.java   
protected void registerItem ( final DataItem newItem, final String localId, final Map<String, Variant> properties )
{
    final Dictionary<String, String> props = new Hashtable<String, String> ();

    fillProperties ( properties, props );

    final ServiceRegistration<DataItem> handle = this.context.registerService ( DataItem.class, newItem, props );
    this.items.put ( localId, newItem );
    this.itemRegs.put ( localId, handle );
}
项目:gemini.blueprint    文件:ServiceReferenceComparatorTest.java   
private ServiceReference createReference(Long id, Integer ranking) {
    Dictionary dict = new Properties();
    dict.put(Constants.SERVICE_ID, id);
    if (ranking != null)
        dict.put(Constants.SERVICE_RANKING, ranking);

    return new MockServiceReference(null, dict, null);
}
项目:gemini.blueprint    文件:ApplicationContextConfigurationTest.java   
public void testCreateAsynchronouslyDefaultTrueIfAbsent() {
    // *;flavour
    Dictionary headers = new Hashtable();
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle should have create-asynchronously = true", config.isCreateAsynchronously());
}
项目:neoscada    文件:Activator.java   
private void registerRemoteExporter ( final BundleContext context )
{
    // TODO: create clientConnection
    final Dictionary<String, Object> props = new Hashtable<String, Object> ( 1 );
    props.put ( Constants.SERVICE_RANKING, 10 );
    context.registerService ( HttpExporter.class.getName (), new RemoteHttpExporter (), props );
}
项目:gemini.blueprint    文件:OsgiEventDispatcher.java   
public void refreshFailure(BlueprintEvent event) {
    Dictionary<String, Object> props = init(event);

    Throwable th = event.getCause();
    props.put(EXCEPTION, th);
    props.put(CAUSE, th);
    props.put(EXCEPTION_CLASS, th.getClass().getName());
    String msg = th.getMessage();
    props.put(EXCEPTION_MESSAGE, (msg != null ? msg : ""));
    initDependencies(props, event);
    sendEvent(new Event(TOPIC_FAILURE, props));
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.factory = new DriverFactoryImpl ();

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "da" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "sfp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA DA SFP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
项目:gemini.blueprint    文件:BlueprintEditorRegistrar.java   
public void registerCustomEditors(PropertyEditorRegistry registry) {
    // Date
    registry.registerCustomEditor(Date.class, new DateEditor());
    // Collection concrete types
    registry.registerCustomEditor(Stack.class, new BlueprintCustomCollectionEditor(Stack.class));
    registry.registerCustomEditor(Vector.class, new BlueprintCustomCollectionEditor(Vector.class));

    // Spring creates a LinkedHashSet for Collection, RFC mandates an ArrayList
    // reinitialize default editors
    registry.registerCustomEditor(Collection.class, new BlueprintCustomCollectionEditor(Collection.class));
    registry.registerCustomEditor(Set.class, new BlueprintCustomCollectionEditor(Set.class));
    registry.registerCustomEditor(SortedSet.class, new BlueprintCustomCollectionEditor(SortedSet.class));
    registry.registerCustomEditor(List.class, new BlueprintCustomCollectionEditor(List.class));
    registry.registerCustomEditor(SortedMap.class, new CustomMapEditor(SortedMap.class));

    registry.registerCustomEditor(HashSet.class, new BlueprintCustomCollectionEditor(HashSet.class));
    registry.registerCustomEditor(LinkedHashSet.class, new BlueprintCustomCollectionEditor(LinkedHashSet.class));
    registry.registerCustomEditor(TreeSet.class, new BlueprintCustomCollectionEditor(TreeSet.class));

    registry.registerCustomEditor(ArrayList.class, new BlueprintCustomCollectionEditor(ArrayList.class));
    registry.registerCustomEditor(LinkedList.class, new BlueprintCustomCollectionEditor(LinkedList.class));

    // Map concrete types
    registry.registerCustomEditor(HashMap.class, new CustomMapEditor(HashMap.class));
    registry.registerCustomEditor(LinkedHashMap.class, new CustomMapEditor(LinkedHashMap.class));
    registry.registerCustomEditor(Hashtable.class, new CustomMapEditor(Hashtable.class));
    registry.registerCustomEditor(TreeMap.class, new CustomMapEditor(TreeMap.class));
    registry.registerCustomEditor(Properties.class, new PropertiesEditor());

    // JDK 5 types
    registry.registerCustomEditor(ConcurrentMap.class, new CustomMapEditor(ConcurrentHashMap.class));
    registry.registerCustomEditor(ConcurrentHashMap.class, new CustomMapEditor(ConcurrentHashMap.class));
    registry.registerCustomEditor(Queue.class, new BlueprintCustomCollectionEditor(LinkedList.class));

    // Legacy types
    registry.registerCustomEditor(Dictionary.class, new CustomMapEditor(Hashtable.class));
}
项目:hashsdn-controller    文件:RefreshingSCPModuleInfoRegistryTest.java   
@Test
public void testConstructor() throws Exception {
    final ModuleInfoRegistry reg = mock(ModuleInfoRegistry.class);
    final SchemaContextProvider prov = mock(SchemaContextProvider.class);
    doReturn("string").when(prov).toString();
    final BundleContext ctxt = mock(BundleContext.class);
    final ServiceRegistration<?> servReg = mock(ServiceRegistration.class);
    doReturn(servReg).when(ctxt).registerService(any(Class.class), any(SchemaContextProvider.class),
            any(Dictionary.class));
    doReturn(servReg).when(ctxt).registerService(Mockito.anyString(), any(Object.class), any(Dictionary.class));
    doNothing().when(servReg).setProperties(any(Dictionary.class));

    final ClassLoadingStrategy classLoadingStrat = mock(ClassLoadingStrategy.class);
    final BindingContextProvider codecRegistryProvider = mock(BindingContextProvider.class);
    doNothing().when(codecRegistryProvider).update(classLoadingStrat, prov);
    final BindingRuntimeContext bindingRuntimeContext = mock(BindingRuntimeContext.class);
    doReturn("B-runtime-context").when(bindingRuntimeContext).toString();
    doReturn(bindingRuntimeContext).when(codecRegistryProvider).getBindingContext();

    final RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, classLoadingStrat,
            this.sourceProvider, codecRegistryProvider, ctxt);

    doNothing().when(servReg).unregister();

    final YangModuleInfo modInfo = mock(YangModuleInfo.class);
    doReturn("").when(modInfo).toString();
    final ObjectRegistration<YangModuleInfo> ymi = mock(ObjectRegistration.class);
    doReturn(ymi).when(reg).registerModuleInfo(modInfo);

    scpreg.registerModuleInfo(modInfo);
    scpreg.updateService();

    verify(codecRegistryProvider).update(classLoadingStrat, prov);

    scpreg.close();

    Mockito.verify(servReg, Mockito.times(1)).setProperties(any(Dictionary.class));
    Mockito.verify(servReg, Mockito.times(1)).unregister();
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.context = context;
    this.executor = Executors.newSingleThreadExecutor ( new NamedThreadFactory ( context.getBundle ().getSymbolicName () ) );
    this.factory = new AverageDataSourceFactory ( context, this.executor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "An averaging data source over multiple sources" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () );

    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );
}
项目:neoscada    文件:Activator.java   
public void start ( final BundleContext context ) throws Exception
{
    this.executor = Executors.newSingleThreadExecutor ( new NamedThreadFactory ( context.getBundle ().getSymbolicName () ) );
    this.factory = new MemorySourceFactory ( context, this.executor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A memory data source" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () );

    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );
}
项目:elasticsearch_my    文件:Settings.java   
/**
 * Sets all the provided settings.
 */
public Builder put(Dictionary<Object,Object> properties) {
    for (Object key : Collections.list(properties.keys())) {
        map.put(Objects.toString(key), Objects.toString(properties.get(key)));
    }
    return this;
}
项目:gemini.blueprint    文件:BlueprintConfigUtils.java   
/**
 * Shortcut method for retrieving the directive values. Different then
 * {@link #getDirectiveValue(Dictionary, String)} since it looks at the Bundle-Symbolic header and not at
 * Spring-Context.
 * 
 * @param headers
 * @param directiveName
 * @return
 */
private static String getBlueprintDirectiveValue(Dictionary headers, String directiveName) {
    String header = getSymNameHeader(headers);
    if (header != null) {
        String directive = ConfigUtils.getDirectiveValue(header, directiveName);
        if (directive != null)
            return directive;
    }
    return null;
}
项目:neoscada    文件:AbstractDataSourceFactory.java   
@Override
public synchronized void update ( final UserInformation userInformation, final String configurationId, final Map<String, String> properties ) throws Exception
{
    DefaultDataSource source = this.dataSources.get ( configurationId );
    if ( source == null )
    {
        source = createDataSource ();
        this.dataSources.put ( configurationId, source );
        final Dictionary<String, String> props = new Hashtable<String, String> ();
        props.put ( DataSource.DATA_SOURCE_ID, configurationId );

        this.regs.put ( configurationId, this.context.registerService ( DataSource.class, source, props ) );
    }
    source.update ( properties );
}
项目:neoscada    文件:QueryServiceFactory.java   
@Override
protected Entry<BundleMonitorQuery> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception
{
    final BundleMonitorQuery query = new BundleMonitorQuery ( this.executor, context, this.poolTracker );
    query.update ( parameters );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_PID, configurationId );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );

    return new Entry<BundleMonitorQuery> ( configurationId, query, context.registerService ( MonitorQuery.class, query, properties ) );
}
项目:aries-jpa    文件:PropsConfigurationTest.java   
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {

    when(punit.getPersistenceUnitName()).thenReturn("test-props");
    when(punit.getPersistenceProviderClassName())
        .thenReturn(ECLIPSE_PERSISTENCE_PROVIDER);
    when(punit.getTransactionType()).thenReturn(PersistenceUnitTransactionType.JTA);
    when(punit.getBundle()).thenReturn(punitBundle);
    when(punit.getProperties()).thenReturn(punitProperties);

    when(punitBundle.getBundleContext()).thenReturn(punitContext);
    when(punitBundle.getVersion()).thenReturn(Version.parseVersion("1.2.3"));

    when(containerContext.registerService(eq(ManagedService.class), 
            any(ManagedService.class), any(Dictionary.class))).thenReturn(msReg);
    when(containerContext.getService(dsfRef)).thenReturn(dsf);
    when(containerContext.getService(dsRef)).thenReturn(ds);
    when(containerContext.createFilter(Mockito.anyString()))
        .thenAnswer(new Answer<Filter>() {
            @Override
            public Filter answer(InvocationOnMock i) throws Throwable {
                return FrameworkUtil.createFilter(i.getArguments()[0].toString());
            }
        });

    when(punitContext.registerService(eq(EntityManagerFactory.class), any(EntityManagerFactory.class), 
            any(Dictionary.class))).thenReturn(emfReg);

    when(emf.isOpen()).thenReturn(true);


    Properties jdbcProps = new Properties();
    jdbcProps.setProperty("url", JDBC_URL);
    jdbcProps.setProperty("user", JDBC_USER);
    jdbcProps.setProperty("password", JDBC_PASSWORD);

    when(dsf.createDataSource(jdbcProps)).thenReturn(ds);

}
项目:athena    文件:Tools.java   
/**
 * Check property name is defined as set to true.
 *
 * @param properties   properties to be looked up
 * @param propertyName the name of the property to look up
 * @param defaultValue the default value that to be assigned
 * @return value when the propertyName is defined or return the default value
 */
public static boolean isPropertyEnabled(Dictionary<?, ?> properties,
                                        String propertyName,
                                        boolean defaultValue) {
    try {
        String s = get(properties, propertyName);
        return Strings.isNullOrEmpty(s) ? defaultValue : Boolean.valueOf(s);
    } catch (ClassCastException e) {
        return defaultValue;
    }
}
项目:gemini.blueprint    文件:ConfigurationAdminManagerTest.java   
public void testManagedServiceProperties() {
    assertTrue(services.isEmpty());
    assertNotNull(cam.getConfiguration());

    Dictionary props = (Dictionary) services.values().iterator().next();
    assertEquals(pid, props.get(Constants.SERVICE_PID));
}
项目:Moenagade    文件:Baseline.java   
private static Integer getMaxSliderValue(JSlider slider) {
    Dictionary dictionary = slider.getLabelTable();
    if (dictionary != null) {
        Enumeration keys = dictionary.keys();
        int max = slider.getMinimum() - 1;
        while (keys.hasMoreElements()) {
            max = Math.max(max, ((Integer)keys.nextElement()).intValue());
        }
        if (max == slider.getMinimum() - 1) {
            return null;
        }
        return new Integer(max);
    }
    return null;
}