Thanks for the help!
I actually got it working by changing my binding file. Here is my use case:
public interface Engine{
void setName(String name);
String getName();
}
public class EngineImpl implements Engine{
// Implement methods above
}
public class StyleImpl implements Style{
// Didn't show Style interface for brevity
private Engine engine;
}
I was getting an error using this mapping on the Style binding:
<structure name="engine" field="engine" usage="optional" />
However I changed it to use the 'map-as' attribute and it worked
correctly and stopped trying to instrument the Engine interface.
<structure field="engine" usage="optional"
map-as="com.edmunds.vehicle.jpa.EngineImpl"/>
I wasn't ever trying to reference the actual Engine interface in my
binding file however since the interface was being used in the
StyleImpl class and the binding wasn't specifying a class to use it
was trying to instrument the Engine class.
Thanks again!
On Fri, May 2, 2008 at 2:08 PM, Joshua Davies
<[EMAIL PROTECTED]> wrote:
> Most likely, you're trying to map directly to it, which doesn't really
> make sense from a jibx perspective - you're telling jibx to instantiate
> and populate this interface which, of course, it can't, since interfaces
> can't be instantiated. I'm just guessing, though - I'd have to see your
> code to be sure. Here's an example of a class structure that uses
> interfaces that compiles and runs using jibx 1.1.5, for reference:
>
> public interface Person
> {
> public String getName();
> }
>
> public class Employee implements Person
> {
> private String firstName;
> private String lastName;
>
> public String getName()
> {
> return firstName + " " + lastName;
> }
> }
>
> public class Manager implements Person
> {
> private String firstName;
> private String lastName;
> private String level;
>
> public String getName( )
> {
> return firstName + " " + lastName + " " + level;
> }
> }
>
> import java.util.ArrayList;
>
> public class TopLevel
> {
> private ArrayList< Person > people;
>
> public String toString( )
> {
> String s = "";
> for ( Person person : people )
> {
> s += person.getName() + "\n";
> }
> return s;
> }
> }
>
> <binding direction="input">
> <mapping name="collection" class="TopLevel">
> <collection field="people" />
> </mapping>
>
> <mapping name="employee" class="Employee">
> <value style="element" name="firstname" field="firstName" />
> <value style="element" name="lastname" field="lastName" />
> </mapping>
>
> <mapping name="manager" class="Manager">
> <value style="element" name="firstname" field="firstName" />
> <value style="element" name="lastname" field="lastName" />
> <value style="element" name="level" field="level" />
> </mapping>
> </binding>
>
> <collection>
> <employee>
> <firstname>Ed</firstname>
> <lastname>Employee</lastname>
> </employee>
> <manager>
> <firstname>Mike</firstname>
> <lastname>Manager</lastname>
> <level>senior</level>
> </manager>
> </collection>
>
> This compiles OK because I don't try to refer to the interface "Person"
> anywhere in the binding file. This code works fine even if I jar up
> "Person" and reference it by classpath - the jibx compiler never tries
> to access it to modify it.
>
> If your actual use case is more complex (go figure), don't hesitate to
> post a sample that replicates the actual problem here (although the
> smaller the better, of course) and I'll see if I can work out what's
> gone wrong.
>
>
> On Fri, 2008-05-02 at 13:34 -0700, reemo wrote:
> > I have a class that is implementing an interface and when I try to run the
> > JIBX compiler on the class it complains that it cant modify the actual
> > Interface? Do interfaces have to be available on the classpath as actual
> > .class files? Why would JIBX need to do this? I know that JIBX has to be
> > able to modify the actual class files on the file system (not in a jar)
> > unless they are marked "abstract" in the mapping file.
> >
> > Error:
> > --------
> > Cannot modify class com.edmunds.vehicle.Engine
> >
> > Any help is greatly apprecaited!
> >
> > Thanks.
> >
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
>
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> jibx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users