/** {@inheritDoc} */ @Override public void start() throws GridException { customInjector = new GridResourceCustomInjector(log, ioc); customInjector.setExecutorInjector(execInjector); customInjector.setGridgainHomeInjector(ggHomeInjector); customInjector.setGridNameInjector(ggNameInjector); customInjector.setGridInjector(gridInjector); customInjector.setMbeanServerInjector(mbeanSrvInjector); customInjector.setNodeIdInjector(nodeIdInjector); customInjector.setMarshallerInjector(marshInjector); customInjector.setSpringContextInjector(springCtxInjector); customInjector.setSpringBeanInjector(springBeanInjector); customInjector.setLogInjector(logInjector); customInjector.setSrvcInjector(srvcInjector); if (log.isDebugEnabled()) log.debug("Started resource processor."); }
List<Method> finalizers = getMethodsWithAnnotation(rsrc.getResource().getClass(), GridUserResourceOnUndeployed.class); cleanup(rsrc, GridLoggerResource.class); cleanup(rsrc, GridInstanceResource.class); cleanup(rsrc, GridExecutorServiceResource.class); cleanup(rsrc, GridLocalNodeIdResource.class); cleanup(rsrc, GridMBeanServerResource.class); cleanup(rsrc, GridHomeResource.class); cleanup(rsrc, GridMarshallerResource.class); cleanup(rsrc, GridSpringApplicationContextResource.class); cleanup(rsrc, GridSpringResource.class);
/** {@inheritDoc} */ @Override public void inject(GridResourceMethod mtd, Object target, Class<?> depCls, GridDeployment dep) throws GridException { assert dep != null; GridUserResource ann = (GridUserResource)mtd.getAnnotation(); if (mtd.getMethod().getParameterTypes().length != 1) throw new GridException("Method injection setter must have only one parameter: " + mtd.getMethod()); Class<?> rsrcCls = !ann.resourceClass().equals(Void.class) ? ann.resourceClass() : mtd.getMethod().getParameterTypes()[0]; String rsrcName = ann.resourceName(); GridResourceUtils.inject(mtd.getMethod(), target, getResource(dep, depCls, rsrcCls, rsrcName)); }
rsrc = createResource(rsrcCls, dep, depCls);
ioc.inject(rsrc, GridServiceResource.class, srvcInjector, dep, depCls); for (Method mtd : getMethodsWithAnnotation(rsrcCls, GridUserResourceOnDeployed.class)) { mtd.setAccessible(true);
/** {@inheritDoc} */ @Override public void inject(GridResourceField field, Object target, Class<?> depCls, GridDeployment dep) throws GridException { assert dep != null; GridUserResource ann = (GridUserResource)field.getAnnotation(); assert ann != null; if (!Modifier.isTransient(field.getField().getModifiers())) { throw new GridException("@GridUserResource must only be used with 'transient' fields: " + field.getField()); } Class<?> rsrcCls = !ann.resourceClass().equals(Void.class) ? ann.resourceClass() : field.getField().getType(); String rsrcName = ann.resourceName(); GridResourceUtils.inject(field.getField(), target, getResource(dep, depCls, rsrcCls, rsrcName)); }