Search in sources :

Example 1 with ServiceTemplate

use of net.jini.core.lookup.ServiceTemplate in project camel by apache.

the class JiniSpaceAccessor method findSpace.

public static JavaSpace findSpace(String url, String spaceName) throws Exception {
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }
    Class<?>[] classes = new Class<?>[] { net.jini.space.JavaSpace.class };
    Name sn = new Name(spaceName);
    ServiceTemplate tmpl = new ServiceTemplate(null, /* serviceID */
    classes, new Entry[] { sn });
    // <protocol>://<hostname>
    LookupLocator locator = new LookupLocator(url);
    ServiceRegistrar sr = locator.getRegistrar();
    JavaSpace space = (JavaSpace) sr.lookup(tmpl);
    return space;
}
Also used : ServiceRegistrar(net.jini.core.lookup.ServiceRegistrar) JavaSpace(net.jini.space.JavaSpace) ServiceTemplate(net.jini.core.lookup.ServiceTemplate) LookupLocator(net.jini.core.discovery.LookupLocator) RMISecurityManager(java.rmi.RMISecurityManager) Name(net.jini.lookup.entry.Name)

Example 2 with ServiceTemplate

use of net.jini.core.lookup.ServiceTemplate in project camel by apache.

the class TransactionHelper method findTransactionManager.

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;
}
Also used : ServiceRegistrar(net.jini.core.lookup.ServiceRegistrar) TransactionManager(net.jini.core.transaction.server.TransactionManager) ServiceTemplate(net.jini.core.lookup.ServiceTemplate) LookupLocator(net.jini.core.discovery.LookupLocator) RMISecurityManager(java.rmi.RMISecurityManager)

Aggregations

RMISecurityManager (java.rmi.RMISecurityManager)2 LookupLocator (net.jini.core.discovery.LookupLocator)2 ServiceRegistrar (net.jini.core.lookup.ServiceRegistrar)2 ServiceTemplate (net.jini.core.lookup.ServiceTemplate)2 TransactionManager (net.jini.core.transaction.server.TransactionManager)1 Name (net.jini.lookup.entry.Name)1 JavaSpace (net.jini.space.JavaSpace)1