How to use TFC

For using TFC we usually require someone to publish an object and someone to look and use that object.

This chapter we will see how to publish an object and how to retrieve one from a friend network.

How to publish TFC objects

To use TFC we need that someone we are connected to share an application we know. In our case the application is a POP object.

Let’s use the class below as an example.

public class A {

        private int n;

        public A() { }

        @POPObjectDescription(url = "localhost", protocols = "ssl")
        public A(int n) {
                this.n = n;

        public int get() {
                return n;

The A is a very basic one, at its creation a number is set and the only operation we can do afterwards is retrieve the value.

Now let’s make an application use which will publish an instance of A to our network.


We assume the unique identifier of the network is abc-123-def for simplicity, see user-configuration to know how to create networks.

@POPClass(isDistributable = false)
public class TFCPublish {
        private static final String NET = "abc-123-def";
        public static void main(String[] args) throws IOException {
                A a = new A();
                System.out.println("Object at " + PopJava.getAccessPoint(a));

                System.out.println("Publishing via JMC...");
                JobManagerConfig jmc = new JobManagerConfig();
                jmc.publishTFCObject(a, NET, "mysecret");

                System.out.println("Press enter to destroy the object...");

In the snippet above we can see a standard POP object creation at line 5. At line 9 we connect to the Job Manager using its configuration API class. At line 10 we publish the previously created object by giving it to the Job Manager and telling it which network should be able to search the object. A secret is given in case we want to remove the object from the published list without killing it.

Looking for a TFC object

To look for an object we require to know its interface, not necessarily its implementation. In our case we have its implementation.

It’s important to notice than friend nodes may be offline at the time of research, this means that multiple research of the same type can yield different results.

Retrieving objects require multiple steps:
  1. A setup of the research parameters, lines 6,7
  2. Initialization of the research, line 8
  3. Connection to the yield results, 12
@POPClass(isDistributable = false)
public class TFCRetrieve {
        private static final String NET = "abc-123-def";
        public static void main(String[] args) {
                System.out.println("Retrieving from network...");
                ObjectDescription od = new ObjectDescription();
                POPAccessPoint[] aps = PopJava.newTFCSearch(A.class, 10, od);
                System.out.println("Got " + Arrays.toString(aps));

                for (POPAccessPoint ap : aps) {
                        A r = PopJava.connect(A.class, NET, ap);
                        System.out.println(ap + " -> " + r.get());

The ObjectDescriptor at line 6,7 set the network in which we will look for objects, here can also specify options like the depth of the research by using setSearch or discriminate hosts by asking giving a list of the hosts we want to answer us by using setSearchHosts.

The API call to PopJava.newTFCSearch require the class we are looking for, the maximum number of instances we want and the search parameters.

For connecting to an already existing object the use the PopJava.connect method which require the network the remote object is using and its address.


As of now the way to publish and retrieve require APIs calls which isn’t in the best POP model spirit (KISS). It may be simplified in the future.