/** * Creates a new builder using the given component name and implementation class. * * @param name the component name name * @param clazz the implementation class * @return the builder */ public static JavaComponentBuilder newBuilder(String name, Class<?> clazz) { return new JavaComponentBuilder(name, clazz).implementation(clazz); }
public Component<JavaImplementation> build() { checkState(); freeze(); return component; }
public void deploy(String name, Object instance, Class<?>... interfaces) throws Fabric3Exception { Component<?> definition = JavaComponentBuilder.newBuilder(name, instance).build(); if (interfaces == null) { // if no interfaces are specified, check if the implementation class implements one or more interfaces Class<?>[] implementedInterfaces = getClass().getInterfaces(); if (implementedInterfaces.length == 0) { // use the implementation class as the service interface addService(instance.getClass(), definition); } else { // use all of the implemented interfaces as service interfaces for (Class<?> interfaze : implementedInterfaces) { addService(interfaze, definition); } } } else { for (Class<?> interfaze : interfaces) { addService(interfaze, definition); } } deploy(definition); }
/** * Creates a new builder. * * @param name the component name * @param instance the component instance * @return the builder */ public static JavaComponentBuilder newBuilder(String name, Object instance) { return new JavaComponentBuilder(name, instance); }
public void deploy(String name, Object instance, Class<?>... interfaces) throws Fabric3Exception { Component<?> definition = JavaComponentBuilder.newBuilder(name, instance).build(); if (interfaces == null) { // if no interfaces are specified, check if the implementation class implements one or more interfaces Class<?>[] implementedInterfaces = getClass().getInterfaces(); if (implementedInterfaces.length == 0) { // use the implementation class as the service interface addService(instance.getClass(), definition); } else { // use all of the implemented interfaces as service interfaces for (Class<?> interfaze : implementedInterfaces) { addService(interfaze, definition); } } } else { for (Class<?> interfaze : interfaces) { addService(interfaze, definition); } } deploy(definition); }
/** * Creates a new builder using the given implementation class. If the implementation class implements a single interface, its simple name will be used as * the component name. Otherwise, the implementation class name will be used. * * @param clazz the implementation class * @return the builder */ public static JavaComponentBuilder newBuilder(Class<?> clazz) { // derive the name: the interface name if there is one interface or the implementation name String name = clazz.getInterfaces().length == 1 ? clazz.getInterfaces()[0].getSimpleName() : clazz.getSimpleName(); return new JavaComponentBuilder(name, clazz).implementation(clazz); }