Refine search
private Dictionary<Integer, Integer> listViewItemHeights = new Hashtable<Integer, Integer>(); private int getScroll() { View c = listView.getChildAt(0); //this is the first visible row int scrollY = -c.getTop(); listViewItemHeights.put(listView.getFirstVisiblePosition(), c.getHeight()); for (int i = 0; i < listView.getFirstVisiblePosition(); ++i) { if (listViewItemHeights.get(i) != null) // (this is a sanity check) scrollY += listViewItemHeights.get(i); //add all heights of the views that are gone } return scrollY; }
public void start(BundleContext context) throws Exception { Dictionary<String, Object> properties = new Hashtable<String, Object>(); properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, Driver.class.getName()); properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, org.postgresql.util.DriverInfo.DRIVER_NAME); properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION, org.postgresql.util.DriverInfo.DRIVER_VERSION); try { _registration = context.registerService(DataSourceFactory.class.getName(), new PGDataSourceFactory(), properties); } catch (NoClassDefFoundError e) { String msg = e.getMessage(); if (msg != null && msg.contains("org/osgi/service/jdbc/DataSourceFactory")) { if (!Boolean.getBoolean("pgjdbc.osgi.debug")) { return; } new IllegalArgumentException("Unable to load DataSourceFactory. " + "Will ignore DataSourceFactory registration. If you need one, " + "ensure org.osgi.enterprise is on the classpath", e).printStackTrace(); // just ignore. Assume OSGi-enterprise is not loaded return; } throw e; } }
private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) { if (properties == null) properties = new Hashtable<>(7); Dictionary<String, String> headers = context.getBundle().getHeaders(); properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); if (setRanking) { properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE)); } properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$ registrations.add(context.registerService(serviceClass, service, properties)); } }
@Override @SuppressWarnings("unchecked") public void start(BundleContext context) throws Exception { osgiServiceUtil = new OsgiServiceUtil( context ); // Build a JtaPlatform specific for this OSGi context final OsgiJtaPlatform osgiJtaPlatform = new OsgiJtaPlatform( osgiServiceUtil ); final Dictionary properties = new Hashtable(); // In order to support existing persistence.xml files, register using the legacy provider name. properties.put( "javax.persistence.provider", HibernatePersistenceProvider.class.getName() ); persistenceProviderService = context.registerService( PersistenceProvider.class.getName(), new OsgiPersistenceProviderService( osgiJtaPlatform, osgiServiceUtil ), properties ); sessionFactoryService = context.registerService( SessionFactory.class.getName(), new OsgiSessionFactoryService( osgiJtaPlatform, osgiServiceUtil ), new Hashtable() ); }
private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) { if (properties == null) properties = new Hashtable<String, Object>(7); Dictionary<String, String> headers = context.getBundle().getHeaders(); properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); if (setRanking) { properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE)); } properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$ registrations.add(context.registerService(serviceClass, service, properties)); } }
private Dictionary<Integer, Integer> listViewItemHeights = new Hashtable<Integer, Integer>(); private int getScroll() { View c = listView.getChildAt(0); //this is the first visible row int scrollY = -c.getTop(); listViewItemHeights.put(listView.getFirstVisiblePosition(), c.getHeight()); for (int i = 0; i < listView.getFirstVisiblePosition(); ++i) { if (listViewItemHeights.get(i) != null) // (this is a sanity check) scrollY += listViewItemHeights.get(i); //add all heights of the views that are gone } return scrollY; }
/** * Exports the Ignite instance onto the OSGi Service Registry. * * @param ignite Ignite. */ private void exportOsgiService(Ignite ignite) { Dictionary<String, String> dict = new Hashtable<>(); // Only add the service property if the Ignite instance name != null. if (ignite.name() != null) dict.put(OSGI_SERVICE_PROP_IGNITE_NAME, ignite.name()); bundleCtx.registerService(Ignite.class, ignite, dict); if (log.isInfoEnabled()) log.info("Exported OSGi service for Ignite with properties: " + dict); } }
private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) { if (properties == null) properties = new Hashtable<String, Object>(7); Dictionary<String, String> headers = context.getBundle().getHeaders(); properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); if (setRanking) { properties.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE)); } properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$ registrations.add(context.registerService(serviceClass, service, properties)); } }
/** * Dictionary does not know the putAll method. Please use Map.putAll(). * @param m1 the to directory. * @param m2 the from directory. * @param <K> type of the key * @param <V> type of the value * @since Ant 1.6 * @deprecated since 1.6.x. */ @Deprecated public static <K, V> void putAll(Dictionary<? super K, ? super V> m1, Dictionary<? extends K, ? extends V> m2) { StreamUtils.enumerationAsStream(m2.keys()).forEach(key -> m1.put(key, m2.get(key))); }
public void start(BundleContext context) throws Exception { bundleContext = context; Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("osgi.command.function", new String[] {"deploy", "install", "uninstall", "start", "stop", "list",}); props.put("osgi.command.scope", "subsystem"); context.registerService(getClass().getName(), this, props); }
private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) { if (properties == null) properties = new Hashtable<>(7); Dictionary<String, String> headers = context.getBundle().getHeaders(); properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); if (setRanking) { properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE)); } properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$ registrations.add(context.registerService(serviceClass, service, properties)); } }
public static int getScrollY(RecyclerView rv) { View c = rv.getChildAt(0); if (c == null) { return 0; } LinearLayoutManager layoutManager = (LinearLayoutManager)rv.getLayoutManager(); int firstVisiblePosition = layoutManager.findFirstVisibleItemPosition(); int scrollY = -(c.getTop()); sRecyclerViewItemHeights.put(layoutManager.findFirstVisibleItemPosition(), c.getHeight()); if(scrollY<0) scrollY = 0; for (int i = 0; i < firstVisiblePosition; ++i) { if (sRecyclerViewItemHeights.get(i) != null) // (this is a sanity check) scrollY += sRecyclerViewItemHeights.get(i); //add all heights of the views that are gone } return scrollY; }
public void start(BundleContext context) throws Exception { bundleContext = context; Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("osgi.command.function", new String[] {"start"}); props.put("osgi.command.scope", "obr"); context.registerService(getClass().getName(), this, props); }
private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary<String, Object> properties) { if (properties == null) properties = new Hashtable<String, Object>(7); Dictionary<String, String> headers = context.getBundle().getHeaders(); properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); if (setRanking) { properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE)); } properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$ registrations.add(context.registerService(serviceClass, service, properties)); } }
private void registerEnhancementGraph(UriRef graphUri, MGraph enhancementGraph) { Dictionary<String,Object> props = new Hashtable<String,Object>(); props.put("graph.uri", graphUri); props.put("graph.name", "Enhancement Graph"); props.put("graph.description", "This graph stores enhancements of all content items stored within Contenthub."); props.put(org.osgi.framework.Constants.SERVICE_RANKING, Integer.MAX_VALUE); enhancementGraphRegistry = bundleContext.registerService(TripleCollection.class.getName(), enhancementGraph, props); log.debug("Enhancement graph is registered to the OSGi environment"); }
private ServiceRegistration<?> registerPerformanceLog(BundleContext context) { Object service = createPerformanceLog(context.getBundle()); String serviceName = FrameworkLog.class.getName(); Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>(7); Dictionary<String, String> headers = context.getBundle().getHeaders(); serviceProperties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); serviceProperties.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE)); serviceProperties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + '.' + service.getClass().getName()); serviceProperties.put(FrameworkLog.SERVICE_PERFORMANCE, Boolean.TRUE.toString()); return context.registerService(serviceName, service, serviceProperties); }
public synchronized void start () throws Exception { final BundleContext context = FrameworkUtil.getBundle ( EventInjectorManager.class ).getBundleContext (); this.impl = new EventInjectorImpl ( context, this.evaluator ); final Dictionary<String, Object> properties = new Hashtable<> (); properties.put ( Constants.SERVICE_DESCRIPTION, "Event injector manager" ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); properties.put ( "osgi.command.scope", "ein" ); properties.put ( "osgi.command.function", new String[] { "rules", "state" } ); properties.put ( ConfigurationAdministrator.FACTORY_ID, "org.eclipse.scada.ae.server.injector" ); context.registerService ( ConfigurationFactory.class, this.impl, properties ); }
private ServiceRegistration<?> registerPerformanceLog(BundleContext context) { Object service = createPerformanceLog(context.getBundle()); String serviceName = FrameworkLog.class.getName(); Dictionary<String, Object> serviceProperties = new Hashtable<>(7); Dictionary<String, String> headers = context.getBundle().getHeaders(); serviceProperties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); serviceProperties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MIN_VALUE)); serviceProperties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + '.' + service.getClass().getName()); serviceProperties.put(FrameworkLog.SERVICE_PERFORMANCE, Boolean.TRUE.toString()); return context.registerService(serviceName, service, serviceProperties); }