Hi Wei Jiang,

In my understanding you should persuade them to a valid design ;)

--
Denis

On 1/26/2016 4:50 PM, 姜 为 wrote:
Hi Denis,

        Yes , I can change the way to do this.

        But my business follows MVC paradigm it will be very bloated.

        Hope can provide an option to do this.

        What do you think so?

Wei Jiang


在 2016年1月26日,下午8:10,Denis Magda <dma...@gridgain.com> 写道:

Hi Wei Jiang,

I've taken look at your code sample and in my understanding you just shouldn't 
design an app in a way when a business model object (Entity) incorporates and 
performs a business logic (Entity.doSomething()).
Ignite follows MVC paradigm thus there is no sense to inject services into 
business model objects.

I would use Entity only for storing actual data and if I it's needed to perform 
an operation on an Entity or in general using a service (ExampleService) would 
follow one of the below:
- get a reference to an instance of ExampleService 'context.getBean(...)' and 
use it if I need to do some operation locally;
- inject a reference into an Ignite Compute closure if I need to run the 
computation across the cluster

ignite.compute().broadcast(new ComputeJob());

.....

private static class ComputeJobimplements IgniteRunnable {
    @SpringResource(resourceName ="exampleService")
    private transient ExampleServiceservice;

    @Override public void run() {
        System.out.println("Executing service from compute");
        service.doSomething();
    }
}


Hope this helps you.
Denis

On 1/25/2016 4:45 PM, 姜 为 wrote:
Hi Denis,

        I create example project https://github.com/wmz7year/ignite-example 
<https://github.com/wmz7year/ignite-example>.

        Please see README file to run example.

Wei Jiang


在 2016年1月23日,上午2:40,Denis Magda <dma...@gridgain.com> 写道:

Hi Wei Jiang,

I would better review your current approach to have better understanding on 
what you're trying to implement.

Please share the code. If it's the same as being discussed in "about AOP 
development" thread that let me know, I'll take a look there.

--
Denis

On 1/22/2016 10:28 AM, 姜 为 wrote:
Hi Denis,

        How about provide an option for this?

        Ignite cache user can chose enable or disable inject resources.

Wei Jiang

在 2016年1月22日,下午3:22,Denis Magda <dma...@gridgain.com> 写道:

Hi Wei Jiang,

You can inject @SpringResource and @SpringApplicationContextResource into 
Ignite Service or Ignite Compute. This feature is not supported for individual 
cache entries, at least because of performance reasons.
@Autowired is unsupported for both Ignite services and computes.

So if you need to process the entries inside of Ignite Compute or Ignite 
Service then just inject a resource there using one of the annotations above.

The main point here is that all the nodes have to be started as a part of 
spring app context or have to have a reference to it.
Please refer to org.apache.ignite.IgniteSpring for more info.

Regards,
Denis

On 1/22/2016 10:07 AM, 姜 为 wrote:
Hi Denis,
        
        I try to use Ignite cache to store the service object.
        The object use Externalizable interface and has a @Autowired field.
        
        When different node use this object, the @Autowired field will be 
null,even @SpringResources on the field.

        The field like JPA interface , it can’t be serialization.

Wei Jiang


在 2016年1月22日,下午2:58,Denis Magda <dma...@gridgain.com> 写道:

Hi,

Spring resource injection is considered to be used only for Ignite Compute Jobs.

It's quite expensive operation to inject a resource for a CacheEntry cause this 
logic will be called for every entry stored in a cache.

Why do you need to inject the resource into a CacheEntry? What do you try to 
achieve?

Regards,
Denis

On 1/22/2016 6:26 AM, 姜 为 wrote:
Hi Igniters,
        
        I’m using Ignite cache store objects.  The object use Externalizable 
interface
         to serialization  and deserialization.
        When object has field use @SpringSource will not inject.

        Should add resource inject to Ignite cache?

        example :

        class Entey implements Externalizable {
           @SpringSource(“springSource")
            private Service service;
               public void read… and write...
        }

Reply via email to