001 // SECTION-START[License Header] 002 // <editor-fold defaultstate="collapsed" desc=" Generated License "> 003 /* 004 * Java Object Management and Configuration 005 * Copyright (C) Christian Schulte, 2005-206 006 * All rights reserved. 007 * 008 * Redistribution and use in source and binary forms, with or without 009 * modification, are permitted provided that the following conditions 010 * are met: 011 * 012 * o Redistributions of source code must retain the above copyright 013 * notice, this list of conditions and the following disclaimer. 014 * 015 * o Redistributions in binary form must reproduce the above copyright 016 * notice, this list of conditions and the following disclaimer in 017 * the documentation and/or other materials provided with the 018 * distribution. 019 * 020 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 021 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 022 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 023 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, 024 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 025 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 026 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 027 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 029 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 030 * 031 * $JOMC: TestInvoker.java 4459 2012-03-27 23:55:31Z schulte2005 $ 032 * 033 */ 034 // </editor-fold> 035 // SECTION-END 036 package org.jomc.ri.test.support; 037 038 import java.util.Arrays; 039 import java.util.Iterator; 040 import org.jomc.model.Instance; 041 import org.jomc.ri.DefaultInvocation; 042 import org.jomc.ri.DefaultInvoker; 043 import org.jomc.spi.Invocation; 044 045 // SECTION-START[Documentation] 046 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 047 /** 048 * Test {@code Invoker} implementation. 049 * 050 * <dl> 051 * <dt><b>Identifier:</b></dt><dd>JOMC :: RI :: Tests :: Test Invoker</dd> 052 * <dt><b>Name:</b></dt><dd>JOMC :: RI :: Tests :: Test Invoker</dd> 053 * <dt><b>Specifications:</b></dt> 054 * <dd>org.jomc.spi.Invoker</dd> 055 * <dt><b>Abstract:</b></dt><dd>No</dd> 056 * <dt><b>Final:</b></dt><dd>No</dd> 057 * <dt><b>Stateless:</b></dt><dd>No</dd> 058 * </dl> 059 * 060 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0 061 * @version 1.2.2 062 */ 063 // </editor-fold> 064 // SECTION-END 065 // SECTION-START[Annotations] 066 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 067 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" ) 068 // </editor-fold> 069 // SECTION-END 070 public class TestInvoker extends DefaultInvoker 071 { 072 // SECTION-START[Invoker] 073 // SECTION-END 074 // SECTION-START[TestInvoker] 075 076 @Override 077 public Invocation postInvoke( final Invocation invocation ) 078 { 079 final StringBuilder b = new StringBuilder(); 080 b.append( invocation.getObject().toString() ); 081 082 if ( invocation.getContext().get( DefaultInvocation.INSTANCE_KEY ) != null ) 083 { 084 b.append( "[" ).append( ( (Instance) invocation.getContext().get( DefaultInvocation.INSTANCE_KEY ) ). 085 getIdentifier() ).append( "]: " ); 086 087 } 088 089 b.append( invocation.getMethod().getName() ).append( "( " ); 090 091 if ( invocation.getArguments() != null ) 092 { 093 for ( Iterator it = Arrays.asList( invocation.getArguments() ).iterator(); it.hasNext(); ) 094 { 095 b.append( it.next() ); 096 if ( it.hasNext() ) 097 { 098 b.append( ", " ); 099 } 100 } 101 } 102 103 b.append( " ): " ).append( invocation.getResult() ); 104 System.out.println( b.toString() ); 105 return invocation; 106 } 107 108 // SECTION-END 109 // SECTION-START[Constructors] 110 // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> 111 /** Creates a new {@code TestInvoker} instance. */ 112 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" ) 113 public TestInvoker() 114 { 115 // SECTION-START[Default Constructor] 116 super(); 117 // SECTION-END 118 } 119 // </editor-fold> 120 // SECTION-END 121 // SECTION-START[Dependencies] 122 // SECTION-END 123 // SECTION-START[Properties] 124 // SECTION-END 125 // SECTION-START[Messages] 126 // SECTION-END 127 }