public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException { viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader())); } });
/** {@inheritDoc} */ public void uninject() { final ThreadLocalValue<Object> injectedValue = Values.injectedValue(); final ThreadLocalValue<Object> thisValue = Values.thisValue(); final Value<?> oldTarget = injectedValue.getAndSetValue(this.injectedValue); try { final Value<?> oldThis = thisValue.getAndSetValue(targetValue); try { method.invoke(targetValue.getValue(), Values.getValues(parameterList)); } catch (Throwable t) { InjectorLogger.INSTANCE.uninjectFailed(t, method); } finally { thisValue.setValue(oldThis); } } finally { injectedValue.setValue(oldTarget); } } }
/** * Get an object array from the result of an iterable series of values. * * @param i the iterable series * @return the values array */ public static Object[] getValues(Iterable<? extends Value<?>> i) { return getValues(i.iterator(), 0); }
/** {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public T getValue() throws IllegalStateException { final ThreadLocalValue<Object> thisValue = Values.thisValue(); final Value<?> targetValue = this.targetValue; try { final Value<?> old = thisValue.getAndSetValue(targetValue); try { return (T) methodValue.getValue().invoke(targetValue.getValue(), Values.getValues(parameters)); } finally { thisValue.setValue(old); } } catch (IllegalAccessException e) { throw new IllegalStateException("Method is not accessible", e); } catch (InvocationTargetException e) { throw new IllegalStateException("Failed to invoke method", e); } } }
/** {@inheritDoc} */ public void uninject() { final ThreadLocalValue<Object> injectedValue = Values.injectedValue(); final ThreadLocalValue<Object> thisValue = Values.thisValue(); final Value<?> oldTarget = injectedValue.getAndSetValue(this.injectedValue); try { final Value<?> oldThis = thisValue.getAndSetValue(targetValue); try { method.invoke(targetValue.getValue(), Values.getValues(parameterList)); } catch (Throwable t) { InjectorLogger.INSTANCE.uninjectFailed(t, method); } finally { thisValue.setValue(oldThis); } } finally { injectedValue.setValue(oldTarget); } } }
/** * Get a typed object array from the result of an iterable series of values. * * @param i the iterable series * @param clazz the resultant array type * @return the values array */ public static <T> T[] getValues(Iterable<? extends Value<? extends T>> i, Class<T> clazz) { return getValues(i.iterator(), clazz, 0); }
/** {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public T getValue() throws IllegalStateException { final ThreadLocalValue<Object> thisValue = Values.thisValue(); final Value<?> targetValue = this.targetValue; try { final Value<?> old = thisValue.getAndSetValue(targetValue); try { return (T) methodValue.getValue().invoke(targetValue.getValue(), Values.getValues(parameters)); } finally { thisValue.setValue(old); } } catch (IllegalAccessException e) { throw new IllegalStateException("Method is not accessible", e); } catch (InvocationTargetException e) { throw new IllegalStateException("Failed to invoke method", e); } } }
public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException { injector.inject(new ValueManagedReferenceFactory(Values.immediateValue(value))); }
/** {@inheritDoc} */ public void inject(final T value) throws InjectionException { final ThreadLocalValue<Object> injectedValue = Values.injectedValue(); final ThreadLocalValue<Object> tlsThisValue = Values.thisValue(); final Value<?> thisValue = targetValue; final Value<?> oldInjectedValue = injectedValue.getAndSetValue((Value<?>) new ImmediateValue<T>(value)); try { final Value<?> oldThis = tlsThisValue.getAndSetValue(thisValue); try { method.invoke(thisValue.getValue(), Values.getValues(parameterList)); } catch (InvocationTargetException e) { try { throw e.getCause(); } catch (InjectionException e2) { throw e2; } catch (Throwable throwable) { throw new InjectionException("Injection failed", e); } } catch (Exception e) { throw new InjectionException("Injection failed", e); } finally { tlsThisValue.setValue(oldThis); } } finally { injectedValue.setValue(oldInjectedValue); } }
/** * Get an object array from the result of an iterable series of values. * * @param i the iterable series * @return the values array */ public static Object[] getValues(Iterable<? extends Value<?>> i) { return getValues(i.iterator(), 0); }
private void bindServices(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName contextServiceName) { BinderService inAppClientContainerService = new BinderService("InAppClientContainer"); final ServiceName inAppClientServiceName = contextServiceName.append("InAppClientContainer"); inAppClientContainerService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(Values.immediateValue(appclient))); serviceTarget.addService(inAppClientServiceName, inAppClientContainerService) .addDependency(contextServiceName, ServiceBasedNamingStore.class, inAppClientContainerService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, inAppClientServiceName); }
/** {@inheritDoc} */ public void inject(final T value) throws InjectionException { final ThreadLocalValue<Object> injectedValue = Values.injectedValue(); final ThreadLocalValue<Object> tlsThisValue = Values.thisValue(); final Value<?> thisValue = targetValue; final Value<?> oldInjectedValue = injectedValue.getAndSetValue((Value<?>) new ImmediateValue<T>(value)); try { final Value<?> oldThis = tlsThisValue.getAndSetValue(thisValue); try { method.invoke(thisValue.getValue(), Values.getValues(parameterList)); } catch (InvocationTargetException e) { try { throw e.getCause(); } catch (InjectionException e2) { throw e2; } catch (Throwable throwable) { throw new InjectionException("Injection failed", e); } } catch (Exception e) { throw new InjectionException("Injection failed", e); } finally { tlsThisValue.setValue(oldThis); } } finally { injectedValue.setValue(oldInjectedValue); } }
/** * Get a typed object array from the result of an iterable series of values. * * @param i the iterable series * @param clazz the resultant array type * @return the values array */ public static <T> T[] getValues(Iterable<? extends Value<? extends T>> i, Class<T> clazz) { return getValues(i.iterator(), clazz, 0); }
/** * <p> * Adds a {@code BinderService} to the specified target. The service binds the specified value to JNDI under the * {@code java:/jboss/contextName} context. * </p> * * @param target the {@code ServiceTarget} where the service will be added. * @param contextName the JNDI context name where the value will be bound. * @param value the value to be bound. */ public static void bindObject(final ServiceTarget target, final String contextName, final Object value) { final BinderService binderService = new BinderService(contextName); binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(Values.immediateValue(value))); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, contextName), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install(); } }
/** {@inheritDoc} */ public T getValue() throws IllegalStateException { try { return constructor.newInstance(Values.getValues(parameters)); } catch (IllegalAccessException e) { throw new IllegalStateException("Field is not accessible", e); } catch (InvocationTargetException e) { throw new IllegalStateException("Failed to invoke constructor", e); } catch (InstantiationException e) { throw new IllegalStateException("Failed to construct instance", e); } } }
private void setupPolicyRegistration(final StartContext context) { ServiceTarget target = context.getChildTarget(); final BinderService binderService = new BinderService(POLICY_REGISTRATION); binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory( Values.immediateValue(new JBossPolicyRegistration()))); target.addService(ContextNames.buildServiceName(ContextNames.JAVA_CONTEXT_SERVICE_NAME, POLICY_REGISTRATION), binderService) .addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install(); }
/** {@inheritDoc} */ public T getValue() throws IllegalStateException { try { return constructor.newInstance(Values.getValues(parameters)); } catch (IllegalAccessException e) { throw new IllegalStateException("Field is not accessible", e); } catch (InvocationTargetException e) { throw new IllegalStateException("Failed to invoke constructor", e); } catch (InstantiationException e) { throw new IllegalStateException("Failed to construct instance", e); } } }
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { boolean appclient = context.getDeploymentUnit().getAttachment(Attachments.EE_MODULE_DESCRIPTION).isAppClient(); // Create view bindings final List<BindingConfiguration> bindingConfigurations = configuration.getBindingConfigurations(); for (String bindingName : description.getBindingNames()) { bindingConfigurations.add(new BindingConfiguration(bindingName, description.createInjectionSource(description.getServiceName(), Values.immediateValue(componentConfiguration.getModuleClassLoader()), appclient))); } } }