本文整理汇总了Java中net.jini.core.discovery.LookupLocator类的典型用法代码示例。如果您正苦于以下问题:Java LookupLocator类的具体用法?Java LookupLocator怎么用?Java LookupLocator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LookupLocator类属于net.jini.core.discovery包,在下文中一共展示了LookupLocator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findTransactionManager
import net.jini.core.discovery.LookupLocator; //导入依赖的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;
}
示例2: addOne
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
private void addOne(ServiceRegistrar registrar) {
LookupLocator loc;
try {
loc = registrar.getLocator();
} catch (Throwable t) {
logger.log(Level.INFO, "obtaining locator failed", t);
return;
}
String host = loc.getHost();
if (loc.getPort() != Constants.discoveryPort) {
host += ":" + loc.getPort();
}
JRadioButtonMenuItem reg =
new RegistrarMenuItem(host, registrar.getServiceID());
reg.addActionListener(wrap(new Lookup(registrar)));
if (!(registrars.getMenuComponent(0) instanceof JRadioButtonMenuItem)) {
registrars.removeAll();
}
registrars.add(reg);
}
示例3: addItems
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
protected void addItems(String[] items) {
LookupLocator[] locs = new LookupLocator[items.length];
for(int i = 0; i < items.length; i++) {
try {
locs[i] = new LookupLocator(items[i]);
} catch (MalformedURLException e) {
JOptionPane.showMessageDialog(LocatorLister.this,
"\"" + items[i] + "\": " +
e.getMessage(),
"Bad Locator",
JOptionPane.WARNING_MESSAGE);
return;
}
}
try {
((JoinAdmin) admin).addLookupLocators(locs);
} catch (Throwable t){
logger.log(Level.INFO, "adding locators failed", t);
}
}
示例4: getLL
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
public LookupLocator[] getLL() throws RemoteException {
LookupLocator[] specificLocators = null;
String sls = getProperty(P_LOCATORS);
if (sls != null)
locators = SorcerUtil.tokenize(sls, ",");
try {
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]);
}
}
return specificLocators;
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
示例5: getAllLocators
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
private LookupLocator[] getAllLocators(String[] locs) {
List<LookupLocator> locList = null;
LookupLocator[] allLocs = new LookupLocator[0];
if (_initialLookupLocators.length > 0) {
allLocs = _initialLookupLocators;
if (locs.length > 0) {
locList = Arrays.asList(_initialLookupLocators);
for (int i = 0; i < locs.length; i++) {
try {
locList.add(new LookupLocator(locs[i]));
} catch (MalformedURLException ex) {
_logger.error("Malformed URL for: " + locs[i] + " "
+ ex.getMessage());
}
}
allLocs = (LookupLocator[]) locList.toArray();
}
}
System.out.println("all lookup locators: " + Arrays.toString(allLocs));
return allLocs;
}
示例6: ServiceNode
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
ServiceNode(ServiceItem item){
try{
_serviceItem=item;
_atts=item.attributeSets;
if(_serviceItem.service instanceof ServiceRegistrar){
ServiceRegistrar reggie=(ServiceRegistrar)_serviceItem.service;
LookupLocator ll=reggie.getLocator();
_strValue=ll.getHost()+":"+ll.getPort();
}else{
setName();
//_serviceItem.service.toString();
}
}catch(Exception ex){
ex.printStackTrace();
_strValue=_serviceItem.service.toString();
}
}
示例7: getService
import net.jini.core.discovery.LookupLocator; //导入依赖的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);
}
示例8: getLookupLocators
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
/**
* Returns a list of lookup locators with the URLs defined in the SORCER
* environment
*
* @see sorcer.util.Sorcer
*
* @return a list of locators for unicast lookup discovery
*/
private LookupLocator[] getLookupLocators() {
String[] locURLs = SorcerEnv.getLookupLocators();
if (locURLs == null || locURLs.length == 0) {
return null;
}
List<LookupLocator> locators = new ArrayList<>(locURLs.length);
logger.debug("ProviderAccessor Locators: {}", Arrays.toString(locURLs));
for (String locURL : locURLs)
try {
locators.add(new LookupLocator(locURL));
} catch (Exception e) {
logger.warn("Invalid Lookup URL: {}", locURL, e);
}
if (locators.isEmpty())
return null;
return locators.toArray(new LookupLocator[locators.size()]);
}
示例9: toString
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
private static String toString(LookupLocator[] locators) {
final String[] locatorsToString = new String[locators.length];
for (int i = 0 ; i < locators.length ; i ++) {
locatorsToString[i]=locators[i].getHost() + ":" + locators[i].getPort();
}
return toString(locatorsToString);
}
示例10: getLocators
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
public LookupLocator[] getLocators() {
LookupLocator[] result;
if (!isDynamicLocatorsEnabled()) {
result = getInitialLocators();
} else {
result = getDynamicLocators();
}
return result;
}
示例11: getDynamicLocators
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
/**
* @return If the service discovery manager is using initial locators
* of lookup services with dynamic locators enabled, this will return
* the currently discovered locators, otherwise, it will return the initial locators.
*/
private LookupLocator[] getDynamicLocators() {
try {
return ((DiscoveryLocatorManagement)sdm.getDiscoveryManager()).getLocators();
} catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn("Failed retrieving dynamic locators from admin, returning initial locators", e);
}
return getInitialLocators();
}
}
示例12: getInitialLocators
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
private LookupLocator[] getInitialLocators() {
if (locators == null) {
String locatorsProperty = SystemInfo.singleton().lookup().locators();
if (locatorsProperty != null) {
locators = locatorsProperty;
}
}
return BootUtil.toLookupLocators(locators);
}
示例13: getLookupLocator
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
public LookupLocator getLookupLocator() {
try {
return registrar.getLocator();
} catch (RemoteException e) {
throw new AdminException("Failed to get locator", e);
}
}
示例14: find
import net.jini.core.discovery.LookupLocator; //导入依赖的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;
}
示例15: getLocators
import net.jini.core.discovery.LookupLocator; //导入依赖的package包/类
public LookupLocator[] getLocators() {
if (locators == null) {
String locatorsProperty = SystemInfo.singleton().lookup().locators();
if (locatorsProperty != null) {
locators = BootUtil.toLookupLocators(locatorsProperty);
}
}
return locators;
}