Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 34

Thread: Any negative experience?

  1. #21
    Join Date
    Sep 2004
    Posts
    13

    Default Jacn is my answer

    I create Jacn (http://jacn.sourceforge.net) just to alleviate the XML pain. Rather than creaing a new domain language, I hijack Java for DI programming, so it is immeidately IDE friendly.

    Here is the Jacn version of the configuration sample:

    Code:
    public class Jacn_scratch extends AbstractJacnConfigFile {
    	static ScheduledThreadPoolExecutorFactoryBean indexUpdaterScheduler;
    	
    	public void wire() throws Exception {
    		indexUpdaterScheduler.setThreadFactory(new StdThreadFactory(2, indexUpdater)); 
    			
    		ScheduledWithFixedDelayRunnable fdr = new ScheduledWithFixedDelayRunnable(); {
    			MethodInvokeSequenceRunnable misr = new MethodInvokeSequenceRunnable(); {  
    				MethodInvoker mi1= new MethodInvoker(); {
    					mi1.setTargetObject(indexUpdater_image);
    					mi1.setTargetMethod("process");
    				}
    				MethodInvoker mi2= new MethodInvoker(); {
    					mi1.setTargetObject(indexReaderProviderService_image);
    					mi1.setTargetMethod("refresh");
    				}
    				MethodInvoker mi3= new MethodInvoker(); {
    					mi1.setTargetObject(indexUpdater_movie);
    					mi1.setTargetMethod("process");
    				}
    				
    				Object invokers = new Object[] {mi1, mi2, mi3};
    				
    				misr.setMethodInvokerList((List)invokers);
    			}
    			fdr.setRunnable(misr);
    			fdr.setInitialDelay(5);
    			fdr.setDelay(30);
    			fdr.setTimeUnit(SECONDS);
    		}
    		// another one omiited
    		Object list = new Object[] {fdr};
    		indexUpdaterScheduler.setScheduledWithFixedDelayRunnables((List)list);
    	}
    }
    Jacn uses bytecode techniques for extracting object dependencies and is very simple to deploy (simpler than using XML);

    Jacn is at versoin 0.3 and I'm using it in a big project with ~200 managed beans.

    Cheers

    Bing Ran

  2. #22
    Join Date
    Sep 2004
    Location
    Texas
    Posts
    155

    Default

    Quote Originally Posted by cepage
    Quote Originally Posted by Ben Alex
    If you want to see production-quality services and domain layers that reuse these concerns, check out the Acegi Security Domain subproject (in CVS). It is a simple few classes that show you how to do it properly.
    I am interested, can you point to where these classes are located?
    Ben regrettably lacks either the time or interest to continue this discussion. The only relevant example I can find in the Acegi subproject is Acegi's approach to Domain Object Instance Security.

    The approach here is to identify domain object methods that require access to application services, and isolate access to those methods to a predefined stateless service (in this case, an associated Manager service). Then the code that actually accesses the service is moved out of the domain object and into the Manager class, or into a MethodSecurityInterceptor.

    This is clearly a blatant promotion of the Anemic Domain Model antipattern that we have discussed in this thread. It seems almost disingenuous to promote this as a solution to the problem thay many users have raised here.
    Corby

  3. #23
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    When I search the Web forum for questions on chaining controllers (not discussed in Professional Java Development With the Spring Framework), Spring developers reply that 'for advanced navigation needs, you need to look at Spring Web Flow'. Huh?
    Corby,

    Just to address this one point quickly.

    If you look at the Spring MVC Controller interface, youŽll see Controller chaining really doesnt make sense. A controller is expected to broker a request and return a logical pointer to a view provisioned with all renderable model data. There is no notion of a ModelAndView that gets passed around as part of a chain.

    So the answer here, though vague, was a good general recommendation. The Spring MVC Controller interface is simply not designed for this.

    Spring Web Flow, on the other hand, is integrated with Spring MVC (see FlowController in the webflow.mvc package) and has a much more elaborate action model invokable from within an architecture based on a finite state machine, with the capability to chain command logic. So certainly, one of the reasons SWF exists is to serve this chaining (CoR) need, and we consider use of a FlowController to delegate to a webflow to achieve this a good solution. You could also have a MVC Controller delegate to a more generic CoR framework, like commons-chain, but you will find SWF more capable.

    So to give you an example of what SWF can do, take the following code snippet:

    Code:
    public class MySimpleFlowBuilder extends AbstractFlowBuilder {
        public String flowId() {
            return "simpleFlow";     
        }
    
        public void buildStates() {
            addEndState("doSomeStuffThenDisplayAPage", "thePageName").setEntryAction(
                new CompositeAction(new Action[] {
                method("method1", action("myFlowAction")),
                method("method2", action("myFlowAction")),
                method("method3š, action("myFlowAction") }));
        }
    }
    A very simple flow definition, that when invoked (by hitting the url /flowcontroller.htm?_flowId=simpleFlow) will enter the "doSomeStuffThenDisplayAPage" state, execute those action methods in an ordered chain ("method1", "method2", "method3"), and request the rendering of "aPage" which is resolved to a renderable template using a standard Spring MVC ViewResolver.

    You gain additional benefits here in that your action logic is now decoupled from the underlying HTTP API, so it can be run in a Portlet environment, for example. In addition, with the upcoming WebFlow RC1, you can invoke command logic encapsulated directly within standard POJOs with no dependencies on webflow at all. In this case, youŽre typically telling webflow to invoke your business logic directly, and webflow handles the necessary controller glue.

    So while this is a very trivial flow that lives only for a single request (is essentially stateless) & does nothing more than execute some logic in a chain and display a results page, it shows some of what webflow is capable of, invokable directly from Spring MVC (or Struts for that matter).

    An aside: if you dont like looking up your actions by name like in the flow definition above, and instead prefer lookup by type or by direct reference, you can do that as well.

    Keith
    Keith Donald
    Core Spring Development Team

  4. #24
    Join Date
    Sep 2004
    Location
    Texas
    Posts
    155

    Default

    Thanks, Keith. I will take a closer look at SWF as it nears final release.
    Corby

  5. #25
    Join Date
    Aug 2005
    Posts
    8

    Default Re: Any negative experience?

    Quote Originally Posted by hucmuc
    Quote Originally Posted by cepage
    Quote Originally Posted by ivom2gi
    Before jumping into the next, ten times bigger project I would like to know about IRL limitations faced by developers using spring. I have read different books, manuals and APIs so I should be aware of all the theoretical aspects, but still ... it cannot be as good as it seems ...
    I'm very happy with Spring, but there are two big problems I run into.

    First, Spring does not have a consistent philosophy for dealing with stateful objects, domain objects in particular. The main Spring guys tend to promote the Anemic Domain Model antipattern as a solution to this, which is just sweeping the problem under the rug.

    You can get a sense from this http://forum.springframework.org/showthread.php?t=15294 as to how much confusion there exists on how to properly manage rich domain objects within a Spring application. I have not yet encountered any unsolvable problems in this area, but there tends to be a lot of wailing and gnashing of teeth in the absence of best practices.
    I too have not been satisfied with how the Spring developers try to explain the philosophy on stateful objects. If you look at the spring code it is conveniently swept under the rug. For example, the BeanWrapper class. The spring source code always instantiates with a BeanWrapperImpl class. Why isn't this injected? I wish it were since I could implement my own version and could write an ant task to validate configuration files.

    Since I've been using Spring, I sometimes change the way I implement things. Instead of using stateful objects, I would use singletons and pass in variables as arguments. Why? It is much easier to inject singleton based objects than prototypes.

    There's something missing here and I can't find a consistent and explainable solution.

    Dino
    I personally agree with you.
    Our company is running away from Stateful EJB and we are only using singletons passing them variables as arguments.
    very simple and understandable and very fast (using Spring or not)

    Leo
    Last edited by robyn; May 14th, 2006 at 08:18 PM.

  6. #26
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Quote Originally Posted by cepage
    Quote Originally Posted by cepage
    Quote Originally Posted by Ben Alex
    If you want to see production-quality services and domain layers that reuse these concerns, check out the Acegi Security Domain subproject (in CVS). It is a simple few classes that show you how to do it properly.
    I am interested, can you point to where these classes are located?
    Ben regrettably lacks either the time or interest to continue this discussion. The only relevant example I can find in the Acegi subproject is Acegi's approach to Domain Object Instance Security.

    The approach here is to identify domain object methods that require access to application services, and isolate access to those methods to a predefined stateless service (in this case, an associated Manager service). Then the code that actually accesses the service is moved out of the domain object and into the Manager class, or into a MethodSecurityInterceptor.

    This is clearly a blatant promotion of the Anemic Domain Model antipattern that we have discussed in this thread. It seems almost disingenuous to promote this as a solution to the problem thay many users have raised here.
    I apologise to the Spring community for not replying sooner. As suggested by Corby, I have been extremely busy. I certainly have an interest in the subject.

    The Domain subproject aims to separate functionality into:

    - DOs that can be used in persistence and form backing objects.

    - DOs that shift validation responsibilities to a Validator.

    - Manager and DAO objects that work with a DO, but the DO uses associations to avoid needing to have a separate Manager and DAO for each and every DO.

    - You override methods on the Manager to coordinate workflow.

    - Because each DO uses associations, logic can be added to the domain object itself. So your Order DO can manage the totals for its associated LineItems.

    I have used the Domain Subproject in several projects, and had excellent results. I am aware of several others who have also used it and materially reduced their lines of code. In the end your DO model is 100% Java, totally separated from Spring, easily unit tested, and reflecting as much functionality as is reasonably possible to put into the DO (ie functionality that is not coordinating functionality, which belongs in a services layer method).

    The anemic domain model is having DOs with nothing more than JavaBean getters and setters. The Acegi Security Domain subproject does not promote or encourage this.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  7. #27
    Join Date
    Sep 2004
    Location
    Texas
    Posts
    155

    Default

    Quote Originally Posted by Ben Alex
    - Because each DO uses associations, logic can be added to the domain object itself. So your Order DO can manage the totals for its associated LineItems.
    We are in agreement here. Our primary point of disagreement is whether domain objects should ever be allowed to access application services, not just other domain collaborators.

    This is over a year old, so let me know if your view has changed, but in http://forum.springframework.org/showthread.php?t=9846 you state your position pretty clearly:

    But it seems easier to me to just stick with what Spring makes easy... If you need a singleton collaborator... it's probably application logic. [and doesn't belong in a domain object]

    Some simple examples. When an operation is performed on a domain object that will trigger a change in workflow state, I like for my domain object to directly message my OSWorkflow service to effect the change. When a delete operation needs to be performed on a single domain object, I like the domain object to be issued the delete operation, and allow him to in turn pass the message onto the DAO.

    I am not saying there is one right answer here. As you have mentioned, the approach you have taken has worked for you on successful projects. But right now, Spring only supports your approach, not mine.

    Thankfully, that will change. As Rod has noted elsewhere, Adrian's AspectJ 5 integration will make it easy to inject collaborating services into domain objects, or any other stateful objects for that matter. Each of us will have the ability to adopt the architectural approach that we are most comfortable with.
    Last edited by robyn; May 14th, 2006 at 08:03 PM.
    Corby

  8. #28
    Join Date
    Aug 2005
    Location
    Boston, United States
    Posts
    45

    Default Acegi Security Domain subproject (in CVS)

    Quote Originally Posted by Ben Alex
    5. The domain model matters are not "swept under the carpet" at all. In the Spring Training courses we advocate first focusing on your domain objects and their relationship with service layer interfaces, only dealing with implementation issues like Spring and concrete implementations after those preliminary steps have been completed. The reality is that domain objects need to have certain concessions made to permit their reuse in ORM tools and MVC forms. If you want to see production-quality services and domain layers that reuse these concerns, check out the Acegi Security Domain subproject (in CVS). It is a simple few classes that show you how to do it properly. It's not part of core Spring or even core Acegi Security because developers will typically introduce similar classes and interfaces within their own application if appropriate. Feel free to cut 'n' copy it into your codebase and customise further.
    Here is a quick link to the Acegi Security source tree in CVS
    http://cvs.sourceforge.net/viewcvs.py/acegisecurity

    Navigate to the domain folder under the link above. HTH.

    -Eric

  9. #29
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    Quote Originally Posted by Alarmnummer
    If I remove the XML syntax and introduce a domain language, I can guarantee that the config files will be a lot shorter.
    I doubt it. Even in the example you posted, while the domain language version is shorter in the sense of number of lines, it's not materially simpler. The domain language in the example is essentially XML in shorthand - with the full closing tags replaced with single closing brackets, attribute names replaced with a more positional-based syntax, etc. The complexity of definitions written in the domain language is in the same order of magnitude as that of in XML.
    --Jing Xue

  10. #30
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    Quote Originally Posted by manifoldronin
    Quote Originally Posted by Alarmnummer
    If I remove the XML syntax and introduce a domain language, I can guarantee that the config files will be a lot shorter.
    I doubt it. Even in the example you posted, while the domain language version is shorter in the sense of number of lines, it's not materially simpler.
    That is correct and it was never meant to make it simpeler, just less verbose.

    Would you like to program java in a XML based syntax? You write the same:
    Code:
    <ifstatement>
        <condition>
              <varable>a</variable>
              <operator>==</operator>  
              <constant>10</constant>
        </condition>
        <then>
           ....
        </then>
    </ifstatement>
    Or do you like the easier-on-the-eyes-syntax:

    Code:
    if&#40;a==10&#41;&#123;
    ...
    &#125;
    Semantically they are both the same.. just a different syntax.

    The domain language in the example is essentially XML in shorthand - with the full closing tags replaced with single closing brackets, attribute names replaced with a more positional-based syntax, etc. The complexity of definitions written in the domain language is in the same order of magnitude as that of in XML.
    Yes.. but it a hell of a lot easier on the eyes.

    I can see in a single blink what is going on.. I need more blinks to see what is going on in the xml based version.... just because there is more (verbose) text to read.. not because the semantics are simpeler. Does this have to be so difficult to understand? I`m not a computer.. I can only process a few words a second.

Similar Threads

  1. Replies: 2
    Last Post: Oct 8th, 2007, 02:31 PM
  2. Replies: 0
    Last Post: Aug 4th, 2005, 05:26 PM
  3. Obfuscators experience with Spring
    By emarceta in forum Architecture
    Replies: 1
    Last Post: Mar 16th, 2005, 06:02 AM
  4. Real world application/project experience with Spring
    By morayani in forum Architecture
    Replies: 3
    Last Post: Feb 11th, 2005, 02:42 AM
  5. Replies: 0
    Last Post: Sep 16th, 2004, 01:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •