What is the Perl equivalent of this Java snippet? (Java explanation in terms of Perl)

Can someone help me "translate" this java fragment into perl / Moose? ". Trying to understand java object syntax / logic, and I only know perl.

EDIT based on comments: the fragment comes from the xwiki package - http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents ... Is it too big to parse, so what about the remaining code? Possibly (just to explain, ignore @lines? What is the general meaning of "@something"?

@Component("hello")
public class HelloWorldScriptService implements ScriptService
{
    @Requirement
    private HelloWorld helloWorld;

    public String greet()
    {
        return this.helloWorld.sayHello();
    }
}

Looking for something like the following perl snippet, but have no idea about "@Component, @Requirement - etc .: (

package HelloWorldScriptService;
use Moose;
sub greet {
    return $self->
}

There are several documents where java is explained by perl-ish conditions? (at least some basics)

+3
2

@Component, :

package HelloWorld;
use Moose;

sub say_hello {
   print "Hello";
}

1;

package HelloWorldScriptService;
use Moose;

has 'hello_world' => ( is => 'rw', isa => 'HelloWorld' );

# TODO - will need to instantiate the hello_world object somewhere...

sub greet {
   my ($self) = @_;
   return $self->hello_world->say_hello();
}

1;

helloWorld , "hello_world" ( init_args = > undef) - , Java, , , ( new())

+5

Dependency Injection (, XWiki , ).

, . DI, @Requirement , helloWorld , @Component , .

+3

All Articles