本文整理匯總了Java中org.osgi.framework.ServiceReference.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceReference.getProperty方法的具體用法?Java ServiceReference.getProperty怎麽用?Java ServiceReference.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.framework.ServiceReference
的用法示例。
在下文中一共展示了ServiceReference.getProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compareTo
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
public int compareTo(Object reference) {
ServiceReference other = (ServiceReference) reference;
// compare based on service ranking
Object ranking = this.getProperty(Constants.SERVICE_RANKING);
// if the property is not supplied or of incorrect type, use the default
int rank1 = ((ranking != null && ranking instanceof Integer) ? ((Integer) ranking).intValue() : 0);
ranking = other.getProperty(Constants.SERVICE_RANKING);
int rank2 = ((ranking != null && ranking instanceof Integer) ? ((Integer) ranking).intValue() : 0);
int result = rank1 - rank2;
if (result == 0) {
long id1 = serviceId;
long id2 = ((Long) other.getProperty(Constants.SERVICE_ID)).longValue();
// when comparing IDs, make sure to return inverse results (i.e. lower
// id, means higher service)
return (int) (id2 - id1);
}
return result;
}
示例2: addingService
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
@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;
}
示例3: update
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
/**
* Gather all ConnectionInformation objects and set them as connections
*/
private void update ()
{
final Set<ConnectionDescriptor> infos = new HashSet<ConnectionDescriptor> ();
for ( final ServiceReference<?> ref : this.references )
{
final ConnectionInformation ci = fromReference ( ref );
if ( ci != null )
{
final Object o = ref.getProperty ( Constants.SERVICE_PID );
final String id = o != null ? o.toString () : null;
final Object description = ref.getProperty ( Constants.SERVICE_DESCRIPTION );
final ConnectionDescriptor cd = new ConnectionDescriptor ( ci, id, description == null ? null : description.toString () );
infos.add ( cd );
}
}
setConnections ( infos );
}
示例4: getServiceTypes
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private String[] getServiceTypes ( final ServiceReference<AuthorizationService> reference )
{
final Object t = reference.getProperty ( AuthorizationService.RULE_TYPES );
if ( t instanceof String[] )
{
return (String[])t;
}
else if ( t instanceof String )
{
return new String[] { (String)t };
}
else
{
return null;
}
}
示例5: removedService
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
@Override
public void removedService ( final ServiceReference<HistoricalItem> reference, final HistoricalItem service )
{
final String itemId = (String)reference.getProperty ( Constants.SERVICE_PID );
synchronized ( this )
{
final HistoricalItem item = this.items.remove ( itemId );
if ( item != null )
{
this.context.ungetService ( reference );
this.itemInformations.remove ( item.getInformation () );
fireListChanged ( null, new HashSet<String> ( Arrays.asList ( itemId ) ), false );
}
}
}
示例6: setServiceReference
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private void setServiceReference(ServiceReference<Object> reference) {
String objectClass = ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0]; // TODO: 16.03.2017 when will this array have more than one element?
if (RandomStringGenerator.class.getName().equals(objectClass))
randomStringGeneratorServiceReference = reference;
else if (RandomNumberGenerator.class.getName().equals(objectClass))
randomNumberGeneratorServiceReference = reference;
}
示例7: unsetServiceReference
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private void unsetServiceReference(ServiceReference<Object> reference) {
String objectClass = ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0]; // TODO: 16.03.2017 when will this array have more than one element?
if (RandomStringGenerator.class.getName().equals(objectClass))
randomStringGeneratorServiceReference = null;
else if (RandomNumberGenerator.class.getName().equals(objectClass))
randomNumberGeneratorServiceReference = null;
}
示例8: getRequiredConfigModuleProperty
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
@Nullable
private String getRequiredConfigModuleProperty(final String propName, final Object moduleNamespace,
final ServiceReference<?> reference) {
Object value = reference.getProperty(propName);
if (value == null) {
LOG.warn(
"OSGi service with {} property is missing property {} therefore the config module can't be restarted",
CONFIG_MODULE_NAMESPACE_PROP, propName);
return null;
}
return value.toString();
}
示例9: addingService
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public Object addingService(ServiceReference reference) {
String unitName = (String)reference.getProperty(JPA_UNIT_NAME);
if (unitName == null) {
return null;
}
BundleContext puContext = reference.getBundle().getBundleContext();
TrackedEmf tracked = new TrackedEmf();
tracked.emf = (EntityManagerFactory)puContext.getService(reference);
tracked.emSupplier = new EMSupplierImpl(unitName, tracked.emf, coordinator);
tracked.emSupplierReg = puContext.registerService(EmSupplier.class, tracked.emSupplier,
getEmSupplierProps(unitName));
EntityManager emProxy = createProxy(tracked.emSupplier);
tracked.emProxyReg = puContext.registerService(EntityManager.class, emProxy,
getEmSupplierProps(unitName));
if (getTransactionType(tracked.emf) == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
JpaTemplate txManager = new ResourceLocalJpaTemplate(tracked.emSupplier, coordinator);
tracked.rlTxManagerReg = puContext.registerService(JpaTemplate.class, txManager,
rlTxManProps(unitName));
} else {
tracked.tmTracker = new TMTracker(puContext, tracked.emSupplier, unitName, coordinator);
tracked.tmTracker.open();
}
return tracked;
}
示例10: makeAddress
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private String makeAddress ( final ServiceReference<?> reference, final Object service, final WebService webService )
{
String serviceName = webService.serviceName ();
if ( serviceName == null )
{
if ( reference.getProperty ( Constants.SERVICE_PID ) != null )
{
serviceName = reference.getProperty ( Constants.SERVICE_PID ).toString ();
}
}
return this.baseAddress + "/" + serviceName;
}
示例11: fromReference
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private ConnectionInformation fromReference ( final ServiceReference<?> ref )
{
final Object o = ref.getProperty ( ConnectionService.CONNECTION_URI );
if ( o instanceof String )
{
final String uri = (String)o;
return ConnectionInformation.fromURI ( uri );
}
return null;
}
示例12: makeId
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private static String makeId ( final ServiceReference<?> reference )
{
final Object id = reference.getProperty ( Constants.SERVICE_PID );
if ( id instanceof String )
{
return (String)id;
}
return "" + reference.getProperty ( Constants.SERVICE_ID );
}
示例13: getFactoryId
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private static String getFactoryId ( final ServiceReference<EventHandlerFactory> reference )
{
final Object o = reference.getProperty ( EventHandlerFactory.FACTORY_ID );
if ( o instanceof String )
{
return (String)o;
}
return null;
}
示例14: nullSafeToString
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
/**
* Returns a String representation of the given <code>ServiceReference</code>.
*
* @param reference OSGi service reference (can be <code>null</code>)
* @return String representation of the given service reference
*/
public static String nullSafeToString(ServiceReference reference) {
if (reference == null)
return NULL_STRING;
StringBuilder buf = new StringBuilder();
Bundle owningBundle = reference.getBundle();
buf.append("ServiceReference [").append(OsgiStringUtils.nullSafeSymbolicName(owningBundle)).append("] ");
String clazzes[] = (String[]) reference.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
buf.append(ObjectUtils.nullSafeToString(clazzes));
buf.append("={");
String[] keys = reference.getPropertyKeys();
for (int i = 0; i < keys.length; i++) {
if (!org.osgi.framework.Constants.OBJECTCLASS.equals(keys[i])) {
buf.append(keys[i]).append('=').append(reference.getProperty(keys[i]));
if (i < keys.length - 1) {
buf.append(',');
}
}
}
buf.append('}');
return buf.toString();
}
示例15: getService
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
public Object getService(ServiceReference reference) {
if (reference != null) {
Object service = reference.getProperty(SERVICE_PROPERTY);
if (service != null) {
return service;
}
}
return super.getService(reference);
}