Search in sources :

Example 1 with TypeDeclaration

use of org.apache.felix.ipojo.extender.TypeDeclaration in project felix by apache.

the class Arch method factories.

/**
 * Displays the list of public iPOJO factories.
 */
@Descriptor("Display iPOJO factories")
public void factories() {
    StringBuilder buffer = new StringBuilder();
    for (Factory m_factory : m_factories) {
        if (m_factory.getMissingHandlers().size() == 0) {
            buffer.append(format("Factory %s (VALID)%n", m_factory.getName()));
        } else {
            buffer.append(format("Factory %s (INVALID: %s)%n", m_factory.getName(), m_factory.getMissingHandlers()));
        }
    }
    for (TypeDeclaration type : m_types) {
        if (!type.isPublic()) {
            // give access to the underlying Factory or description (if valid)
            if (type.getStatus().isBound()) {
                buffer.append(format("Factory %s (UNKNOWN) - Private%n", type.getComponentName()));
            } else {
                // Unbound type means that required extension is not available
                // We'll say that the factory is INVALID even if in reality it's not even instantiated
                buffer.append(format("Factory %s (INVALID) - Private%n", type.getComponentName()));
                buffer.append(format("  -> %s", type.getStatus().getMessage()));
            }
        } else {
            if (!type.getStatus().isBound()) {
                buffer.append(format("Factory %s is not bound%n", type.getComponentName()));
                buffer.append(format("  -> %s%n", type.getStatus().getMessage()));
            }
        }
    }
    if (buffer.length() == 0) {
        buffer.append("No factories \n");
    }
    System.out.println(buffer.toString());
}
Also used : Factory(org.apache.felix.ipojo.Factory) HandlerFactory(org.apache.felix.ipojo.HandlerFactory) TypeDeclaration(org.apache.felix.ipojo.extender.TypeDeclaration) Descriptor(org.apache.felix.service.command.Descriptor)

Example 2 with TypeDeclaration

use of org.apache.felix.ipojo.extender.TypeDeclaration in project felix by apache.

the class Arch method handlers.

/**
 * Displays the list of available handlers.
 */
@Descriptor("Display iPOJO handlers")
public void handlers() {
    PrintStream out = System.out;
    for (HandlerFactory m_handler : m_handlers) {
        String name = m_handler.getHandlerName();
        if ("composite".equals(m_handler.getType())) {
            name = name + " [composite]";
        }
        if (m_handler.getMissingHandlers().size() == 0) {
            out.println("Handler " + name + " (VALID)");
        } else {
            out.println("Handler " + name + " (INVALID : " + m_handler.getMissingHandlers() + ")");
        }
    }
    for (TypeDeclaration type : m_types) {
        if (!type.getStatus().isBound()) {
            out.println("HandlerFactory " + type.getComponentName() + " is not bound");
            out.println("  -> " + type.getStatus().getMessage());
        }
    }
}
Also used : PrintStream(java.io.PrintStream) HandlerFactory(org.apache.felix.ipojo.HandlerFactory) TypeDeclaration(org.apache.felix.ipojo.extender.TypeDeclaration) Descriptor(org.apache.felix.service.command.Descriptor)

Example 3 with TypeDeclaration

use of org.apache.felix.ipojo.extender.TypeDeclaration in project felix by apache.

the class DeclarationLinker method addingService.

/**
 * A new type declaration was published.
 *
 * @param reference the service reference of the type declaration
 * @return the managed type object wrapping the service object.
 */
public Object addingService(ServiceReference reference) {
    TypeDeclaration declaration = (TypeDeclaration) m_bundleContext.getService(reference);
    ManagedType managedType = new ManagedType(reference.getBundle().getBundleContext(), m_queueService, declaration);
    managedType.start();
    return managedType;
}
Also used : TypeDeclaration(org.apache.felix.ipojo.extender.TypeDeclaration)

Example 4 with TypeDeclaration

use of org.apache.felix.ipojo.extender.TypeDeclaration in project felix by apache.

the class Arch method factory.

/**
 * Displays the information about a specific factory.
 * Note that factory name are not unique, so all matching
 * factories are displayed.
 * @param name the factory name
 */
@Descriptor("Display the information about a specific factory")
public void factory(@Descriptor("target factory name") String name) {
    List<Factory> factories = new ArrayList<Factory>();
    List<TypeDeclaration> types = new ArrayList<TypeDeclaration>();
    // Looking for public factories
    for (Factory factory : m_factories) {
        if (factory.getName().equalsIgnoreCase(name)) {
            factories.add(factory);
        }
    }
    // Looking for all unbound or private bound types
    for (TypeDeclaration type : m_types) {
        if (name.equalsIgnoreCase(type.getComponentName())) {
            // (Public + Unbound) or private types have no exported factories
            if (!type.isPublic() || (!type.getStatus().isBound() && type.isPublic())) {
                types.add(type);
            }
        }
    }
    if (factories.isEmpty() && types.isEmpty()) {
        System.err.println("Factory " + name + " not found");
        return;
    }
    // Display found factories and types
    for (Factory factory : factories) {
        System.out.println(factory.getComponentDescription());
    }
    for (TypeDeclaration type : types) {
        if (!type.getStatus().isBound()) {
            // Unbound: maybe private or public type
            System.out.printf("Factory %s is not bound%n", type.getComponentName());
            System.out.printf("  reason: %s%n", type.getStatus().getMessage());
            Throwable throwable = type.getStatus().getThrowable();
            if (throwable != null) {
                System.out.print("  throwable: ");
                throwable.printStackTrace(System.out);
            }
        } else {
            // Bound, this is only a private factory
            System.out.printf("Factory %s is bound - Private%n", type.getComponentName());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Factory(org.apache.felix.ipojo.Factory) HandlerFactory(org.apache.felix.ipojo.HandlerFactory) TypeDeclaration(org.apache.felix.ipojo.extender.TypeDeclaration) Descriptor(org.apache.felix.service.command.Descriptor)

Aggregations

TypeDeclaration (org.apache.felix.ipojo.extender.TypeDeclaration)4 HandlerFactory (org.apache.felix.ipojo.HandlerFactory)3 Descriptor (org.apache.felix.service.command.Descriptor)3 Factory (org.apache.felix.ipojo.Factory)2 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1