Package org.apache.aries.blueprint.di

Examples of org.apache.aries.blueprint.di.ExecutionContext


      untrackServiceReferences();
    }

    public void injectBeanInstance(BeanMetadata bmd, Object o)
        throws IllegalArgumentException, ComponentDefinitionException {
        ExecutionContext origContext
            = ExecutionContext.Holder.setContext((ExecutionContext)getRepository());
        try {
            ComponentMetadata cmd = componentDefinitionRegistry.getComponentDefinition(bmd.getId());
            if (cmd == null || cmd != bmd) {
                throw new IllegalArgumentException(bmd.getId() + " not found in blueprint container");
View Full Code Here


    private String getExtendedOsgiFilter() {
        if (filterRecipe != null) {
            Object object;
            BlueprintRepository repository = ((BlueprintContainerImpl) blueprintContainer).getRepository();
            ExecutionContext oldContext = null;
            try {
                oldContext = ExecutionContext.Holder.setContext(repository);
                object = filterRecipe.create();
            } finally {
                ExecutionContext.Holder.setContext(oldContext);
View Full Code Here

    private void createService() {
        try {
            LOGGER.debug("Creating service instance");
            //We can't use the BlueprintRepository because we don't know what interfaces
            //to use yet! We have to be a bit smarter.
            ExecutionContext old = ExecutionContext.Holder.setContext(blueprintContainer.getRepository());
          
            try {
              Object o = serviceRecipe.create();
           
              if (o instanceof Convertible) {
View Full Code Here

    private class Inconvertible {}
   
    @BeforeClass
    public static void before()
    {
        ExecutionContext.Holder.setContext(new ExecutionContext() {
            public void addFullObject(String name, Object object) {}
            public void addPartialObject(String name, Object object) {}
            public boolean containsObject(String name) { return false; }

            public Object convert(Object value, ReifiedType type) throws Exception {
View Full Code Here

            throw new ComponentDefinitionException("Unable to convert instance " + name, e);
        }
    }
       
    public Object create(String name) throws ComponentDefinitionException {
        ExecutionContext oldContext = ExecutionContext.Holder.setContext(this);
        try {
            Object instance = createInstance(name);                      
            return convert(name, instance);
        } finally {
            ExecutionContext.Holder.setContext(oldContext);
View Full Code Here

            ExecutionContext.Holder.setContext(oldContext);
        }
    }
   
    public Map<String, Object> createAll(Collection<String> names) throws ComponentDefinitionException {
        ExecutionContext oldContext = ExecutionContext.Holder.setContext(this);
        try {
            Map<String, Object> instances = createInstances(names);
            for (String name : instances.keySet()) {
                Object obj = instances.get(name);
                instances.put(name, convert(name, obj));
View Full Code Here

        }
        return recipes;
    }

    public Set<Recipe> getAllRecipes(String... names) {
        ExecutionContext oldContext = ExecutionContext.Holder.setContext(this);
        try {
            Set<Recipe> allRecipes = new HashSet<Recipe>();
            Collection<String> topLevel = names != null && names.length > 0 ? Arrays.asList(names) : recipes.keySet();
            for (String name : topLevel) {
                internalGetAllRecipes(allRecipes, getRecipe(name));
View Full Code Here

            }
            return false;
        }

        private Method findMethodWithConversion(Object value) throws ComponentDefinitionException {
            ExecutionContext ctx = ExecutionContext.Holder.getContext();
            List<Method> matchingMethods = new ArrayList<Method>();
            for (Method m : setters) {
                Type paramType = m.getGenericParameterTypes()[0];
                if (ctx.canConvert(value, new GenericType(paramType))) matchingMethods.add(m);
            }
           
            if (matchingMethods.isEmpty()) return null;
            else if (matchingMethods.size() == 1) return matchingMethods.get(0);
            else throw new ComponentDefinitionException(
View Full Code Here

      destroyComponents();
    }

    public void injectBeanInstance(BeanMetadata bmd, Object o)
        throws IllegalArgumentException, ComponentDefinitionException {
        ExecutionContext origContext
            = ExecutionContext.Holder.setContext((ExecutionContext)getRepository());
        try {
            ComponentMetadata cmd = componentDefinitionRegistry.getComponentDefinition(bmd.getId());
            if (cmd == null || cmd != bmd) {
                throw new IllegalArgumentException(bmd.getId() + " not found in blueprint container");
View Full Code Here

    private void createService() {
        try {
            LOGGER.debug("Creating service instance");
            //We can't use the BlueprintRepository because we don't know what interfaces
            //to use yet! We have to be a bit smarter.
            ExecutionContext old = ExecutionContext.Holder.setContext(blueprintContainer.getRepository());
          
            try {
              Object o = serviceRecipe.create();
           
              if (o instanceof Convertible) {
View Full Code Here

TOP

Related Classes of org.apache.aries.blueprint.di.ExecutionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.