annotate Lib/IMPL/ORM.pm @ 134:44977efed303

Significant performance optimizations Fixed recursion problems due converting objects to JSON Added cache support for the templates Added discovery feature for the web methods
author wizard
date Mon, 21 Jun 2010 02:39:53 +0400
parents 2d1c3f713280
children 4267a2ac3d46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
1 package IMPL::ORM;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
5 use base qw(IMPL::Object);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
7 use Scalar::Util qw(weaken refaddr);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
9 use IMPL::Exception;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
11 our $Depth = 1; # загружать объект + 1 уровень детей
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
12 our $UseProxy = 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
14 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
15 private property _ObjectCache => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
16 private property _MapInstances => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
17 private property _WorkUnit => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
18 public property Schema => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
19 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
21 sub ObjectInfoById {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
22 my ($this,$oid) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
24 return $this->_ObjectCache->{$oid};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
25 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
26
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
27 sub ObjectInfo {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
28 my ($this,$inst) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
30 die new IMPL::InvalidOperationException("This method can be used only for a reference") unless ref $inst;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
31
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
32 return $this->_MapInstances->{refaddr $inst};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
33 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
34
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
35
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
36 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
37 __END__
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
38
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
39 =pod
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
40
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
41 =head1 NAME
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
42
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
43 C<IMPL::ORM> - Object Relational Mapping
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
44
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
45 =head1 SYNOPSIS
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
46
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
47 =begin code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
48
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
49 my $ds = IMPL::ORM::Storage::DBIC->new('My::Data',$dsn,$user,$pass,{Autocommit => 1});
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
50
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
51
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
52 my $foo = $ds->Insert(
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
53 My::Data::Foo->new(
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
54 'foo class'
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
55 )
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
56 );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
57
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
58 my $bar = $ds->Insert(
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
59 My::Data::Bar->new(
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
60 'bar class'
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
61 )
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
62 )
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
63
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
64 $bar->fooObject($foo);
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
65
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
66 $ds->Save($bar);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
67
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
68 my $fooOther = $ds->Retrieve(
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
69 'My::Data::Bar',
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
70 {
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
71 name => 'bar class',
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
72 fooObject => {
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
73 name => 'some foo'
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
74 }
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
75 }
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
76 )
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
77
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
78 =end code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
79
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
80 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
81
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
82 =cut