Java Code Examples for java.util.Dictionary

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agile, under directory /agile-web/src/main/java/org/headsupdev/agile/web/.

Source file: WebActivator.java

  22 
vote

/** 
 * Called whenever the OSGi framework starts our bundle
 */
public void start(BundleContext bc) throws Exception {
  WebManager impl=new WebManagerImpl();
  WebManager.setInstance(impl);
  Dictionary props=new Properties();
  bc.registerService(WebManager.class.getName(),impl,props);
}
 

Example 2

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ui/.

Source file: Startup.java

  22 
vote

/** 
 * Returns a map of plugin versions, keyed by their plugin ID, representing installed plugins which contribute to the AWS Toolkit Overview view through the core plugin's extension point.
 * @return A map of plugin versions, keyed by their plugin ID, representinginstalled plugins which contribute to the AWS Toolkit Overview view.
 */
private Map<String,String> findOverviewContributors(){
  Map<String,String> plugins=new HashMap<String,String>();
  IExtensionPoint extensionPoint=Platform.getExtensionRegistry().getExtensionPoint(AwsToolkitCore.OVERVIEW_EXTENSION_ID);
  IExtension[] extensions=extensionPoint.getExtensions();
  for (  IExtension extension : extensions) {
    String pluginName=extension.getContributor().getName();
    Dictionary headers=Platform.getBundle(pluginName).getHeaders();
    String pluginVersion=(String)headers.get("Bundle-Version");
    if (pluginVersion == null)     pluginVersion="";
    plugins.put(pluginName,pluginVersion);
  }
  return plugins;
}
 

Example 3

From project cellar, under directory /config/src/main/java/net/cellar/config/.

Source file: ConfigurationSupport.java

  22 
vote

/** 
 * Prepares a dictionary for push
 * @param dictionary
 * @return
 */
public Dictionary preparePush(Dictionary dictionary){
  Dictionary properties=new Properties();
  Enumeration keys=dictionary.keys();
  while (keys.hasMoreElements()) {
    String key=(String)keys.nextElement();
    if (key != null && dictionary.get(key) != null) {
      String value=(String)dictionary.get(key);
      value=convertStrings(value,HOME,RELATIVE_HOME);
      properties.put(key,dictionary.get(key));
    }
  }
  return properties;
}
 

Example 4

From project cellar, under directory /config/src/main/java/net/cellar/config/.

Source file: ConfigurationSupport.java

  22 
vote

/** 
 * Prepares a dictionary for Pull
 * @param dictionary
 * @return
 */
public Dictionary preparePull(Dictionary dictionary){
  Dictionary properties=new Properties();
  Enumeration keys=dictionary.keys();
  while (keys.hasMoreElements()) {
    String key=(String)keys.nextElement();
    if (key != null && dictionary.get(key) != null) {
      String value=(String)dictionary.get(key);
      value=convertStrings(value,RELATIVE_HOME,HOME);
      properties.put(key,dictionary.get(key));
    }
  }
  return properties;
}
 

Example 5

From project Cilia_1, under directory /components/ea-adapter/src/main/java/fr/liglab/adele/cilia/ea/.

Source file: EABindingService.java

  22 
vote

public Dictionary getProperties(Dictionary collectorProperties,Dictionary senderProperties,Binding b){
  Dictionary properties=new Properties();
  String topic=getTopic(b);
  topic=topic.replace(" ","_");
  if (collectorProperties != null) {
    collectorProperties.put(TOPIC_PROPERTY,topic);
    properties.put(CILIA_COLLECTOR_PROPERTIES,collectorProperties);
  }
  if (senderProperties != null) {
    senderProperties.put(TOPIC_PROPERTY,topic);
    properties.put(CILIA_SENDER_PROPERTIES,senderProperties);
  }
  return properties;
}
 

Example 6

From project Cilia_1, under directory /components/ea-adapter/src/main/java/fr/liglab/adele/cilia/ea/.

Source file: EventAdminCollector.java

  22 
vote

/** 
 * Handle the OSGi Event
 */
public void handleEvent(Event event){
  Dictionary dico=new Hashtable();
  String[] keys=event.getPropertyNames();
  if (keys != null) {
    for (int i=0; i < keys.length; i++) {
      log.debug("received value:" + event.getProperty(keys[i]));
      if (!keys[i].equalsIgnoreCase("event.topics")) {
        dico.put(keys[i],event.getProperty(keys[i]));
      }
    }
  }
  Data data=new Data(dico.get(Data.DATA_CONTENT),String.valueOf(dico.get(Data.DATA_NAME)),dico);
  notifyDataArrival(data);
}
 

Example 7

From project CIShell, under directory /clients/remoting/org.cishell.reference.remoting/src/org/cishell/reference/remoting/.

Source file: CIShellClient.java

  22 
vote

private void setupEventQueue(){
  q=new EventQueue(bContext,false);
  String filter="(&(reply=*)" + "(" + CIShellEventConstants.SESSION_ID + "="+ sessionID+ "))";
  Dictionary dict=new Hashtable();
  dict.put(EventConstants.EVENT_TOPIC,new String[]{CIShellEventConstants.BASE_TOPIC});
  dict.put(EventConstants.EVENT_FILTER,filter);
  bContext.registerService(EventHandler.class.getName(),q,dict);
}
 

Example 8

From project CIShell, under directory /clients/remoting/org.cishell.reference.remoting/src/org/cishell/reference/remoting/.

Source file: CIShellClient.java

  22 
vote

private void publishAlg(String servicePID){
  Dictionary props=algFactoryReg.getProperties(servicePID);
  String label=(String)props.get(AlgorithmProperty.LABEL);
  props.put(AlgorithmProperty.LABEL,label + " (remote)");
  String pid=(String)props.get(Constants.SERVICE_PID);
  props.put(Constants.SERVICE_PID,pid + ".remote." + host);
  props.put(AlgorithmProperty.REMOTE,host);
  AlgorithmFactory factory=algFactoryReg.getAlgorithmFactory(servicePID);
  if (props != null && factory != null) {
    ServiceRegistration reg=bContext.registerService(AlgorithmFactory.class.getName(),factory,props);
    algToRegMap.put(servicePID,reg);
  }
}
 

Example 9

From project agile, under directory /agile-framework/src/main/java/org/headsupdev/agile/framework/.

Source file: HeadsUpActivator.java

  21 
vote

/** 
 * Called whenever the OSGi framework starts our bundle
 */
public void start(BundleContext bc) throws Exception {
  String defaultTimeZoneId=System.getProperty("agile.runtime.timezone");
  if (defaultTimeZoneId != null) {
    Manager.getLogger(getClass().getName()).info("Detected system timezone " + defaultTimeZoneId);
    TimeZone defaultTimeZone=TimeZone.getTimeZone(defaultTimeZoneId);
    Manager.getStorageInstance().getGlobalConfiguration().setDefaultTimeZone(defaultTimeZone);
  }
  Manager.getLogger(getClass().getName()).info("Default timezone set to " + Manager.getStorageInstance().getGlobalConfiguration().getDefaultTimeZone().getID());
  Dictionary props=new Hashtable();
  props.put("alias","/");
  props.put("servlet-name","Wicket Servlet");
  bc.registerService(Servlet.class.getName(),new HeadsUpServlet(),props);
  props=new Hashtable();
  String[] urls={"/*"};
  props.put("filter-name","Wicket Filter");
  props.put("urlPatterns",urls);
  bc.registerService(Filter.class.getName(),new HeadsUpFilter(),props);
  props=new Hashtable();
  props.put("alias","/repository/*");
  bc.registerService(Servlet.class.getName(),new RepositoryServlet(),props);
  props=new Hashtable();
  props.put("alias","/favicon.ico");
  bc.registerService(Servlet.class.getName(),new FaviconServlet(),props);
  HomeApplication homeApp=new HomeApplication();
  homeApp.setContext(bc);
  props=new Properties();
  bc.registerService(Application.class.getName(),homeApp,props);
  DefaultErrorPageMapping error=new DefaultErrorPageMapping();
  error.setError("404");
  error.setLocation("/filenotfound");
  bc.registerService(ErrorPageMapping.class.getName(),error,null);
  System.out.println("Started version " + Manager.getStorageInstance().getGlobalConfiguration().getBuildVersion() + " at "+ Manager.getStorageInstance().getGlobalConfiguration().getBaseUrl());
  webTracker=new WebTracker(bc);
  webTracker.open();
  appTracker=new AppTracker(bc);
  appTracker.open();
}
 

Example 10

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/.

Source file: AwsClientUtils.java

  21 
vote

/** 
 * Forms a user-agent string for clients to send when making service calls, indicating the name and version of this client.
 * @param pluginName The name of the plugin to use in the user agent string.
 * @param plugin The plugin from which to pull version information.
 * @return A user-agent string indicating what client and version areaccessing AWS.
 */
public String formUserAgentString(String pluginName,Plugin plugin){
  String version="???";
  if (plugin != null) {
    Dictionary headers=plugin.getBundle().getHeaders();
    version=(String)headers.get("Bundle-Version");
  }
  String userAgentValue=pluginName + "/" + version;
  Bundle runtimeCore=Platform.getBundle("org.eclipse.core.runtime");
  if (runtimeCore != null) {
    Dictionary headers=runtimeCore.getHeaders();
    version=(String)headers.get("Bundle-Version");
    userAgentValue+=", Eclipse/" + version;
  }
  return userAgentValue;
}
 

Example 11

From project blueprint-namespaces, under directory /blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/.

Source file: CmManagedServiceFactory.java

  21 
vote

protected void updated(String pid,Dictionary props){
  LOGGER.debug("Updated configuration {} with props {}",pid,props);
  ServiceRegistration reg=pids.get(pid);
  if (reg == null) {
    updateComponentProperties(props);
    Object component=blueprintContainer.getComponentInstance(managedComponentName);
    Hashtable regProps=getRegistrationProperties(pid);
    CmProperties cm=findServiceProcessor();
    if (cm != null) {
      if ("".equals(cm.getPersistentId())) {
        JavaUtils.copy(regProps,props);
      }
      cm.updateProperties(new PropertiesUpdater(pid),regProps);
    }
    Set<String> classes=getClasses(component);
    String[] classArray=classes.toArray(new String[classes.size()]);
    reg=blueprintContainer.getBundleContext().registerService(classArray,component,regProps);
    LOGGER.debug("Service {} registered with interfaces {} and properties {}",new Object[]{component,classes,regProps});
    services.put(reg,component);
    pids.put(pid,reg);
    if (listeners != null) {
      for (      ServiceListener listener : listeners) {
        listener.register(component,regProps);
      }
    }
  }
 else {
    updateComponentProperties(props);
    CmProperties cm=findServiceProcessor();
    if (cm != null && "".equals(cm.getPersistentId())) {
      Dictionary regProps=getRegistrationProperties(pid);
      JavaUtils.copy(regProps,props);
      cm.updated(regProps);
    }
  }
}
 

Example 12

From project blueprint-namespaces, under directory /blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/.

Source file: AggregateConverter.java

  21 
vote

private Object convertToDictionary(Object obj,ReifiedType type) throws Exception {
  ReifiedType keyType=type.getActualTypeArgument(0);
  ReifiedType valueType=type.getActualTypeArgument(1);
  Dictionary newDic=new Hashtable();
  if (obj instanceof Dictionary) {
    Dictionary dic=(Dictionary)obj;
    for (Enumeration keyEnum=dic.keys(); keyEnum.hasMoreElements(); ) {
      Object key=keyEnum.nextElement();
      try {
        newDic.put(convert(key,keyType),convert(dic.get(key),valueType));
      }
 catch (      Exception t) {
        throw new Exception("Unable to convert from " + obj + " to "+ type+ "(error converting map entry)",t);
      }
    }
  }
 else {
    for (    Map.Entry e : ((Map<Object,Object>)obj).entrySet()) {
      try {
        newDic.put(convert(e.getKey(),keyType),convert(e.getValue(),valueType));
      }
 catch (      Exception t) {
        throw new Exception("Unable to convert from " + obj + " to "+ type+ "(error converting map entry)",t);
      }
    }
  }
  return newDic;
}
 

Example 13

From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/binding/internal/.

Source file: RangeEditor.java

  20 
vote

private Dictionary<Integer,JLabel> createSliderLabelTable(){
  Dictionary<Integer,JLabel> sliderLabelTable=new Hashtable<Integer,JLabel>();
  sliderLabelTable.put(0,createSliderLabel("0%"));
  sliderLabelTable.put(50,createSliderLabel("50%"));
  sliderLabelTable.put(100,createSliderLabel("100%"));
  return sliderLabelTable;
}
 

Example 14

From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.

Source file: RegistrySharedObject.java

  19 
vote

public IRemoteServiceRegistration registerRemoteService(String[] clazzes,Object service,Dictionary properties){
  if (service == null) {
    throw new NullPointerException(Messages.RegistrySharedObject_EXCEPTION_SERVICE_CANNOT_BE_NULL);
  }
  final int size=clazzes.length;
  if (size == 0) {
    throw new IllegalArgumentException(Messages.RegistrySharedObject_EXCEPTION_SERVICE_CLASSES_LIST_EMPTY);
  }
  final String[] copy=new String[clazzes.length];
  for (int i=0; i < clazzes.length; i++) {
    copy[i]=new String(clazzes[i].getBytes());
  }
  clazzes=copy;
  final String invalidService=checkServiceClass(clazzes,service);
  if (invalidService != null) {
    throw new IllegalArgumentException(Messages.RegistrySharedObject_7 + invalidService);
  }
  final RemoteServiceRegistrationImpl reg=new RemoteServiceRegistrationImpl();
  reg.publish(this,localRegistry,service,clazzes,properties);
  final ID[] targets=getTargetsFromProperties(properties);
  if (targets == null)   sendAddRegistration(null,reg);
 else   for (int i=0; i < targets.length; i++)   sendAddRegistration(targets[i],reg);
  fireRemoteServiceListeners(createRegisteredEvent(reg));
  return reg;
}
 

Example 15

From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.

Source file: RemoteServiceRegistrationImpl.java

  19 
vote

public void publish(RegistrySharedObject sharedObject1,RemoteServiceRegistryImpl registry,Object svc,String[] clzzes,Dictionary props){
  this.sharedObject=sharedObject1;
  this.service=svc;
  this.clazzes=clzzes;
  this.reference=new RemoteServiceReferenceImpl(this);
synchronized (registry) {
    this.remoteServiceID=registry.createRemoteServiceID(registry.getNextServiceId());
    this.properties=createProperties(props);
    registry.publishService(this);
  }
}
 

Example 16

From project arkadiko, under directory /src/com/liferay/arkadiko/util/.

Source file: AKFrameworkFactory.java

  19 
vote

public static boolean isFragment(Bundle bundle){
  Dictionary<String,String> headers=bundle.getHeaders();
  Enumeration<String> keys=headers.keys();
  while (keys.hasMoreElements()) {
    if (keys.nextElement().equals(Constants.FRAGMENT_HOST)) {
      return true;
    }
  }
  return false;
}
 

Example 17

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/mail/imapsync/.

Source file: ImapHelper.java

  19 
vote

/** 
 * Synchronizes all folders of an IMAP  {@link Account} with a database usingthe  {@link EntityManager}. The current implementation is only able to add new messages, but NOT deleted or moved messages.
 * @param account the  {@link Account} to use to connect
 * @param debug enable/disable IMAP debugging
 * @param protocol the protocol to create the  {@link Store} from. See{@link Session#getStore(String)}
 * @param properties a key-value Map to override properties (i.e. for another port).
 * @throws SynchronizationException
 */
public static void syncAllFoldersToAccount(final Account account,IProgressMonitor monitor,Dictionary<String,String> properties,String protocol) throws SynchronizationException {
  try {
    Properties props=combineProperties(properties);
    Session session=Session.getInstance(props);
    Store store=session.getStore(protocol);
    try {
      store.connect(account.getHost(),account.getUsername(),account.getPassword());
      debug(store.toString());
      IMAPFolder imapFolder=(IMAPFolder)store.getDefaultFolder();
      int totalNumberOfFolders=caculateTotalNumberOfFolders(imapFolder);
      monitor.beginTask("Syncing " + totalNumberOfFolders + " IMAP Folders",totalNumberOfFolders);
      for (      javax.mail.Folder subFolder : imapFolder.list()) {
        if (monitor.isCanceled()) {
          break;
        }
        Folder syncedFolder=syncFolderInternal(account,monitor,(IMAPFolder)subFolder,null);
        if (!account.getFolders().contains(syncedFolder)) {
          account.getFolders().add(syncedFolder);
          syncedFolder.setAccount(account);
        }
      }
      merge(account);
    }
  finally {
      monitor.done();
      store.close();
    }
  }
 catch (  final Exception e) {
    Display.getDefault().syncExec(new Runnable(){
      @Override public void run(){
        Status status=new Status(Status.ERROR,Activator.PLUGIN_ID,"Synchronization of Account '" + account.getName() + "' failed",e.getCause());
        ExceptionDetailsErrorDialog.openError(Display.getDefault().getActiveShell(),status.getMessage(),null,status);
      }
    }
);
  }
}
 

Example 18

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/mail/imapsync/.

Source file: ImapHelper.java

  19 
vote

private static Properties combineProperties(Dictionary<String,String> properties){
  Properties props=System.getProperties();
  props.setProperty(JAVA_MAIL_STORE_PROTOCOL,JAVA_MAIL_IMAPS);
  Enumeration<String> keys=properties.keys();
  while (keys.hasMoreElements()) {
    String nextKey=keys.nextElement();
    props.setProperty(nextKey,properties.get(nextKey));
  }
  return props;
}
 

Example 19

From project bundlemaker, under directory /jedit-example/bm.demo.jedit.launcher/src/bm/demo/jedit/launcher/.

Source file: Activator.java

  19 
vote

public void start(BundleContext bundleContext) throws Exception {
  System.out.println("Register jeditresource URL handler...");
  Dictionary<String,String> properties=new Hashtable<String,String>();
  properties.put(URLConstants.URL_HANDLER_PROTOCOL,"jeditresource");
  bundleContext.registerService(URLStreamHandlerService.class.getName(),new JEditResourceHandlerService(),properties);
  System.out.println("Starting JEdit...");
  jEdit.main(new String[]{"-nobackground","-noserver"});
}
 

Example 20

From project bundlemaker, under directory /main/org.bundlemaker.core.osgi/src/org/bundlemaker/core/osgi/exporter/.

Source file: AbstractManifestAwareExporter.java

  19 
vote

/** 
 * {@inheritDoc}
 */
@Override protected void preExportModule() throws CoreException {
  super.preExportModule();
  _manifestCache.clearCycleSet();
  _manifestContents=_manifestCache.getOrCreate(getCurrentModule());
  Dictionary<String,String> dictionary=null;
  try {
    dictionary=new Hashtable<String,String>();
    Properties properties=ManifestUtils.convertManifest(ManifestUtils.toManifest(_manifestContents));
    for (    String propertyName : properties.stringPropertyNames()) {
      dictionary.put(propertyName,properties.getProperty(propertyName));
    }
    StateObjectFactory.defaultFactory.createBundleDescription(null,dictionary,"internal",1);
  }
 catch (  BundleException e) {
    System.out.println(dictionary);
    e.printStackTrace();
    throw new CoreException(new Status(IStatus.ERROR,"",""));
  }
}
 

Example 21

From project camel-osgi, under directory /component/src/test/java/org/apache/camel/osgi/service/.

Source file: OsgiDefaultConsumerTest.java

  19 
vote

@Test public void testDoStop() throws Exception {
  ServiceRegistration registration=mock(ServiceRegistration.class);
  BundleContext bundleContext=mock(BundleContext.class);
  when(bundleContext.registerService(eq(OsgiComponent.OBJECT_CLASS),anyObject(),any(Dictionary.class))).thenReturn(registration);
  OsgiDefaultEndpoint endpoint=mock(OsgiDefaultEndpoint.class);
  when(endpoint.getApplicationBundleContext()).thenReturn(bundleContext);
  Service processor=mock(Service.class,withSettings().extraInterfaces(Processor.class));
  OsgiDefaultConsumer consumer=new OsgiDefaultConsumer(endpoint,(Processor)processor,Collections.<String,Object>emptyMap());
  ServiceHelper.startService(consumer);
  ServiceHelper.stopService(consumer);
  verify(processor).stop();
  verify(registration).unregister();
}
 

Example 22

From project camel-osgi, under directory /component/src/test/java/org/apache/camel/osgi/service/.

Source file: OsgiDefaultConsumerTest.java

  19 
vote

@Test public void testDoStopTwice() throws Exception {
  ServiceRegistration registration=mock(ServiceRegistration.class);
  BundleContext bundleContext=mock(BundleContext.class);
  when(bundleContext.registerService(eq(OsgiComponent.OBJECT_CLASS),anyObject(),any(Dictionary.class))).thenReturn(registration);
  OsgiDefaultEndpoint endpoint=mock(OsgiDefaultEndpoint.class);
  when(endpoint.getApplicationBundleContext()).thenReturn(bundleContext);
  Service processor=mock(Service.class,withSettings().extraInterfaces(Processor.class));
  OsgiDefaultConsumer consumer=new OsgiDefaultConsumer(endpoint,(Processor)processor,Collections.<String,Object>emptyMap());
  ServiceHelper.startService(consumer);
  ServiceHelper.stopService(consumer);
  ServiceHelper.stopService(consumer);
  verify(processor).stop();
  verify(registration).unregister();
}
 

Example 23

From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/binding/internal/.

Source file: RangeEditor.java

  19 
vote

@Override public JComponent createEditorComponent(PropertyDescriptor propertyDescriptor,BindingContext bindingContext){
  JSlider slider=new JSlider(0,100);
  Dictionary<Integer,JLabel> sliderLabelTable=createSliderLabelTable();
  slider.setLabelTable(sliderLabelTable);
  slider.setPaintLabels(true);
  ComponentAdapter adapter=new SliderAdapter(slider);
  bindingContext.bind(propertyDescriptor.getName(),adapter);
  return slider;
}