本文整理汇总了Java中net.jini.core.lookup.ServiceTemplate类的典型用法代码示例。如果您正苦于以下问题:Java ServiceTemplate类的具体用法?Java ServiceTemplate怎么用?Java ServiceTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceTemplate类属于net.jini.core.lookup包,在下文中一共展示了ServiceTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findTransactionManager
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
private TransactionManager findTransactionManager(String uri) throws IOException, ClassNotFoundException {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
// Creating service template to find transaction manager service by matching fields.
Class<?>[] classes = new Class<?>[] {net.jini.core.transaction.server.TransactionManager.class};
// Name sn = new Name("*");
ServiceTemplate tmpl = new ServiceTemplate(null, classes, new Entry[] {});
// Creating a lookup locator
LookupLocator locator = new LookupLocator(uri);
ServiceRegistrar sr = locator.getRegistrar();
TransactionManager tm = (TransactionManager) sr.lookup(tmpl);
return tm;
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:TransactionHelper.java
示例2: getEntryArray
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
protected Entry[] getEntryArray() {
try{
ServiceMatches matches = registrar.lookup(new ServiceTemplate(item.serviceID,
new Class[] { item.service.getClass() },
new Entry[] {}),
10);
if(matches.totalMatches != 1)
Browser.logger.log(Level.INFO, "unexpected lookup matches: {0}",
new Integer(matches.totalMatches));
else
return matches.items[0].attributeSets;
} catch (Throwable t) {
Browser.logger.log(Level.INFO, "lookup failed", t);
}
return null;
}
开发者ID:apache,项目名称:river-container,代码行数:17,代码来源:ServiceBrowser.java
示例3: getService
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
/**
* Locates a service via Unicast discovery
*
* @param lusHost
* @param serviceClass
* @param serviceName
* @return proxy or <code>null</code>
* @throws java.net.MalformedURLException
* @throws java.io.IOException
* @throws ClassNotFoundException
*/
public static Object getService(String lusHost, Class serviceClass, Class[] matchTypes,
String serviceName) throws
java.io.IOException, ClassNotFoundException {
Class[] types = new Class[] { serviceClass };
if (matchTypes != null && matchTypes.length > 0) {
operator.ParTypes allTypes = new ParTypes(serviceClass, matchTypes);
types = allTypes.parameterTypes;
}
Entry[] entry = null;
if (serviceName != null) {
entry = new Entry[] { new Name(serviceName) };
}
ServiceTemplate template = new ServiceTemplate(null, types, entry);
LookupLocator loc = new LookupLocator("jini://" + lusHost);
ServiceRegistrar reggie = loc.getRegistrar();
return reggie.lookup(template);
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:34,代码来源:ProviderLocator.java
示例4: getServiceItem
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
/**
* Returns a service item matching a service template and passing a filter
* with Jini registration groups. Note that template matching is a remote
* operation - matching is done by lookup services while passing a filter is
* done on the client side. Clients should provide a service filter, usually
* as an object of an inner class. A filter narrows the template matching by
* applying more precise, for example boolean select as required by the
* client. No lookup cache is used by this <code>getServiceItem</code>
* method.
*
* @param template
* template to match remotely.
* @param filter
* filer to use or null.
* @return a ServiceItem that matches the template and filter or null if
* none is found.
*/
public ServiceItem getServiceItem(ServiceTemplate template, ServiceItemFilter filter) {
checkNullName(template);
ServiceItem si = null;
logger.info("Lookup {}, timeout: {}, filter: {}", formatServiceTemplate(template), WAIT_FOR, filter);
try {
int tryNo = 0;
while (tryNo < LUS_REPEAT) {
si = sdManager.lookup(template, filter, WAIT_FOR);
logger.info("Found [{}] instances of {}", si == null ?
"0" :
"1", formatServiceTemplate(template), WAIT_FOR);
if (si != null)
break;
tryNo++;
}
} catch (IOException | InterruptedException ie) {
logger.error("getServiceItem", ie);
}
return si;
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:38,代码来源:ServiceAccessor.java
示例5: checkNullName
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
private void checkNullName(ServiceTemplate template) {
if (template.attributeSetTemplates == null)
return;
for (Entry attr : template.attributeSetTemplates) {
if (attr instanceof Name) {
Name name = (Name) attr;
if (ANY.equals(name.name)) {
name.name = null;
logger.warn("Requested service with name '*'", new IllegalArgumentException());
}
} else if (attr instanceof SorcerServiceInfo) {
SorcerServiceInfo info = (SorcerServiceInfo) attr;
if (ANY.equals(info.providerName)) {
info.providerName = null;
logger.warn("Requested service with name '*'", new IllegalArgumentException());
}
}
}
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:20,代码来源:ServiceAccessor.java
示例6: lookup
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
void lookup() {
if(monitor.get()!=null)
return;
final ServiceTemplate template = new ServiceTemplate(null, new Class[]{serviceType}, null);
for(ServiceRegistrar registrar : lookups) {
try {
Object service = registrar.lookup(template);
if(service!=null) {
monitor.set((DeployAdmin)((Administrable)service).getAdmin());
break;
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:17,代码来源:ProvisionMonitorCache.java
示例7: unProvision
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public void unProvision(ServiceID serviceId) throws ProvisioningException {
ServiceItem[] serviceItems = Accessor.get().getServiceItems(new ServiceTemplate(serviceId, null, null), null);
OperationalStringEntry opStringEntry = null;
if(serviceItems.length>0)
opStringEntry = AttributesUtil.getFirstByType(serviceItems[0].attributeSets, OperationalStringEntry.class);
if (opStringEntry == null)
throw new IllegalArgumentException("Service was not provisioned");
ServiceItem[] provisionMonitors = Accessor.get().getServiceItems(new ServiceTemplate(null, new Class[]{ProvisionMonitor.class}, null),
null);
for (ServiceItem monitor : provisionMonitors) {
try {
((DeployAdmin) ((ProvisionMonitor) monitor.service).getAdmin()).undeploy(opStringEntry.name);
return;
} catch (OperationalStringException ignored) {
//deploy admin does not know our service, try another one
} catch (RemoteException e) {
}
}
throw new ProvisioningException("No DeployAdmin is able to undeploy service " + serviceId);
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:21,代码来源:ServiceDirectoryProvisioner.java
示例8: find
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public static ServiceItem[] find(String name, Class type, long wait, String[] groups, LookupLocator[] locators) {
ServiceItem[] result;
BackwardsServiceDiscoveryManager sdm = null;
try {
sdm = new BackwardsServiceDiscoveryManager(
new LookupDiscoveryManager(groups, locators, null, ServiceConfigLoader.getConfiguration()),
new LeaseRenewalManager(),
ServiceConfigLoader.getConfiguration()
);
Entry[] attributes = null;
if (name != null) {
attributes = new Entry[]{
new Name(name)
};
}
ServiceTemplate template = new ServiceTemplate(
null,
new Class[]{type},
attributes
);
result = sdm.lookup(template, 1, 1, null, wait);
} catch (Exception e) {
// TODO add proper exception here
e.printStackTrace();
result = null;
}
if (sdm != null) {
sdm.terminate();
}
return result;
}
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:36,代码来源:ServiceFinder.java
示例9: init
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public void init() {
try {
LookupLocator[] specificLocators = null;
String sls = getProperty(P_LOCATORS);
if (sls != null)
locators = SorcerUtil.tokenize(sls, " ,");
if (locators != null && locators.length > 0) {
specificLocators = new LookupLocator[locators.length];
for (int i = 0; i < specificLocators.length; i++) {
specificLocators[i] = new LookupLocator(locators[i]);
}
}
String gs = getProperty(P_GROUPS);
String[] groups = (gs == null) ? Sorcer.getLookupGroups()
: SorcerUtil.tokenize(gs, ",");
lookupMgr = new ServiceDiscoveryManager(new LookupDiscoveryManager(
groups, specificLocators, null), null);
String templateMatch = Sorcer.getProperty(P_TEMPLATE_MATCH,
Provider.class.getName());
ServiceTemplate template = new ServiceTemplate(null,
new Class[] { Class.forName(templateMatch) }, null);
cache = lookupMgr.createLookupCache(template, null,
new CatalogerEventListener(cinfo));
logger.info("-----------------------------");
logger.info("Matching services that are: " + templateMatch);
logger.info(P_GROUPS + ": " + Arrays.toString(groups));
logger.info(P_LOCATORS + ": " + Arrays.toString(specificLocators));
logger.info("------------------------------");
} catch (IOException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:40,代码来源:ServiceCataloger.java
示例10: lookup
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public static ServiceItem[] lookup(ServiceRegistrar registrar,
Class[] serviceTypes, String serviceName) throws RemoteException {
ServiceRegistrar regie = null;
if (registrar == null) {
regie = DiscoCmd.getSelectedRegistrar();
if (regie == null)
return null;
} else {
regie = registrar;
}
ArrayList<ServiceItem> serviceItems = new ArrayList<ServiceItem>();
ServiceMatches matches;
Entry myAttrib[] = null;
if (serviceName != null) {
myAttrib = new Entry[1];
myAttrib[0] = new Name(serviceName);
}
ServiceTemplate myTmpl = new ServiceTemplate(null, serviceTypes,
myAttrib);
matches = regie.lookup(myTmpl, MAX_MATCHES);
for (int j = 0; j < Math.min(MAX_MATCHES, matches.totalMatches); j++) {
serviceItems.add(matches.items[j]);
}
ServiceItem[] sItems = new ServiceItem[serviceItems.size()];
return serviceItems.toArray(sItems);
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:29,代码来源:ShellCmd.java
示例11: LusTree
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public LusTree(ServiceRegistrar lus, final JTree tree, ServiceTemplate tmpl,
String[] inf, String[] names, ProxyPreparer pp,
SSBrowserFilter plugin) throws RemoteException, Exception {
_tree = tree;
_lus = lus;
_template = tmpl;
_interfaceFilters = inf;
_nameAttributes = names;
_servicePreparer = pp;
_plugin = plugin;
/*
* System.out.println("_name filters"); for(int i=0;i<names.length;i++){
* System.out.println(names[i]); }
*/
// for now
// _exporter=new JrmpExporter();
// first build tree from existing services
buildTree();
final DefaultTreeModel model = (DefaultTreeModel) _tree.getModel();
final DefaultMutableTreeNode treeRoot = (DefaultMutableTreeNode) model
.getRoot();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
model.insertNodeInto(_root, treeRoot, treeRoot.getChildCount());
tree.expandPath(new TreePath(_root.getPath()));
if (tree.getSelectionPath() == null) {
tree.setSelectionPath(new TreePath(_root.getPath()));
}
}
});
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:38,代码来源:LusTree.java
示例12: providers
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public static List<Provider> providers(Signature signature)
throws SignatureException {
ServiceTemplate st = new ServiceTemplate(null, new Class[] { signature.getServiceType() }, null);
ServiceItem[] sis = Accessor.get().getServiceItems(st, null);
if (sis == null)
throw new SignatureException("No available providers of fiType: "
+ signature.getServiceType().getName());
List<Provider> servers = new ArrayList<Provider>(sis.length);
for (ServiceItem si : sis) {
servers.add((Provider) si.service);
}
return servers;
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:14,代码来源:operator.java
示例13: getServiceItems
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
@Override
public ServiceItem[] getServiceItems(ServiceTemplate template, int minMatches, int maxMatches, ServiceItemFilter filter) {
assert template != null;
// cataloger throws NPE if attributeSetTemplates is null
assert template.attributeSetTemplates != null;
assert filter != null;
assert minMatches <= maxMatches;
if(!Arrays.asList(template.serviceTypes).contains(Cataloger.class)){
Cataloger cataloger = getLocalCataloger();
if (cataloger != null) {
try {
ServiceMatches matches = cataloger.lookup(template, maxMatches);
logger.debug("Cataloger returned {} matches for {}", matches.totalMatches, formatServiceTemplate(template));
ServiceItem[] matching = Filters.matching(matches.items, filter);
if (matching.length > 0) {
return matching;
} else {
return super.getServiceItems(template, minMatches, maxMatches, filter);
}
} catch (RemoteException e) {
logger.error( "Problem with Cataloger, falling back", e);
}
}
}
return super.getServiceItems(template, minMatches, maxMatches, filter);
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:29,代码来源:ProviderAccessor.java
示例14: getServiceTemplate
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
ServiceTemplate getServiceTemplate(ServiceID serviceID,
String providerName,
Class[] serviceTypes,
String[] publishedServiceTypes) {
Class[] types;
List<Entry> attributes = new ArrayList<>(2);
if (providerName != null && !providerName.isEmpty() && !ANY.equals(providerName))
attributes.add(new Name(providerName));
if (publishedServiceTypes != null) {
SorcerServiceInfo st = new SorcerServiceInfo();
st.publishedServices = publishedServiceTypes;
attributes.add(st);
}
if (serviceTypes == null) {
types = new Class[] { Provider.class };
} else {
types = serviceTypes;
}
logger.debug("getServiceTemplate >> \n serviceID: {}\nproviderName: {}\nserviceTypes: {}\npublishedServiceTypes: {}",
serviceID, providerName, StringUtils.arrayToString(serviceTypes), StringUtils.arrayToString(publishedServiceTypes));
return new ServiceTemplate(serviceID, types, attributes.toArray(new Entry[attributes.size()]));
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:28,代码来源:ProviderAccessor.java
示例15: getService
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
/**
* Returns a service matching serviceType, service attributes (args), and
* passes a provided filter.
*
* @param attributes attributes of the requested provider
* @param serviceType fiType of the requested provider
*
* @return The discovered service or null
*/
@SuppressWarnings("unchecked")
public <T>T getService(Class<T> serviceType, Entry[] attributes, ServiceItemFilter filter) {
if (serviceType == null) {
throw new IllegalArgumentException("Missing service fiType for a ServiceTemplate");
}
ServiceTemplate tmpl = new ServiceTemplate(null, new Class[] { serviceType }, attributes);
ServiceItem si = getServiceItem(tmpl, filter);
if (si != null)
return (T)si.service;
else
return null;
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:22,代码来源:ServiceAccessor.java
示例16: getServiceItems
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public ServiceItem[] getServiceItems(ServiceTemplate template, int minMatches, int maxMatches, ServiceItemFilter filter, int lusRepeat) {
logger.info("Lookup {}, lusRepeat: {}, timeout: {}", formatServiceTemplate(template), lusRepeat, WAIT_FOR);
for (int tryNo = 0; tryNo < lusRepeat; tryNo++) {
ServiceItem[] result = doGetServiceItems(template, minMatches, maxMatches, filter);
if (result != null && result.length > 0)
return result;
}
return new ServiceItem[0];
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:10,代码来源:ServiceAccessor.java
示例17: ProvisionMonitorCache
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
private ProvisionMonitorCache() {
try {
LookupLocator[] locators = null;
if(System.getProperty(Constants.LOCATOR_PROPERTY_NAME)!=null) {
discoveryInfo.put("locators", System.getProperty(Constants.LOCATOR_PROPERTY_NAME));
locators = JiniClient.parseLocators(System.getProperty(Constants.LOCATOR_PROPERTY_NAME));
}
StringBuilder g = new StringBuilder();
for(String group : Sorcer.getLookupGroups()) {
if(g.length()>0)
g.append(", ");
g.append(group);
}
discoveryInfo.put("groups", g.toString());
Class cl = org.rioproject.deploy.ProvisionManager.class;
listener = new Listener();
ServiceDiscoveryManager lookupMgr =
new ServiceDiscoveryManager(new LookupDiscoveryManager(Sorcer.getLookupGroups(),
locators,
listener), // DiscoveryListener
null);
cache = lookupMgr.createLookupCache(new ServiceTemplate(null, new Class[]{cl}, null),
null,
null);
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:30,代码来源:ProvisionMonitorCache.java
示例18: RemoteLoggerListener
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
public RemoteLoggerListener(List<Map<String, String>> filterMapList, PrintStream out) throws LoggerRemoteException {
this.out = out;
this.filterMapList = filterMapList;
ServiceAccessor serviceAccessor = (ServiceAccessor) Accessor.get();
ServiceTemplate serviceTemplate = new ServiceTemplate(null, new Class[] { RemoteLogger.class }, null);
try {
export();
lookupCache = serviceAccessor.getServiceDiscoveryManager().createLookupCache(serviceTemplate, null, new RemoteLoggerDiscoveryListener());
} catch (UnknownHostException | RemoteException e) {
throw new LoggerRemoteException("Exception while initializing Listener ", e);
}
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:13,代码来源:RemoteLoggerListener.java
示例19: lookup
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
void lookup() {
final ServiceTemplate template = new ServiceTemplate(null, new Class[]{serviceType}, null);
for(ServiceRegistrar registrar : lookups) {
try {
Object service = registrar.lookup(template);
if(service!=null) {
monitor.set(service);
break;
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:15,代码来源:ServiceUtil.java
示例20: getSpaceTest
import net.jini.core.lookup.ServiceTemplate; //导入依赖的package包/类
@Test
public void getSpaceTest() throws ExertionException, ContextException,
SignatureException {
logger.info("exert space:\n" + SpaceAccessor.getSpace());
ServiceTemplate tmpl = new ServiceTemplate(null,
new Class[] { JavaSpace05.class },
new Entry[] { new Name(Sorcer.getActualSpaceName())});
ServiceItem[] si = Accessor.get().getServiceItems(tmpl, null);
assertTrue(si.length>0);
logger.info("got service: serviceID=" + si[0].serviceID + " template="
+ tmpl + " groups=" + Sorcer.getSpaceGroup());
}
开发者ID:mwsobol,项目名称:SORCER,代码行数:14,代码来源:UtilTest.java
注:本文中的net.jini.core.lookup.ServiceTemplate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论