%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.components.portletregistry.PortletDefinitionCompositeProxy |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" |
|
13 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.components.portletregistry; |
|
18 | ||
19 | import java.lang.reflect.InvocationHandler; |
|
20 | import java.lang.reflect.InvocationTargetException; |
|
21 | import java.lang.reflect.Method; |
|
22 | import java.lang.reflect.Proxy; |
|
23 | ||
24 | import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; |
|
25 | ||
26 | public class PortletDefinitionCompositeProxy implements InvocationHandler |
|
27 | { |
|
28 | 0 | private PortletDefinitionComposite def = null; |
29 | private static PortletRegistry registry; |
|
30 | private String name; |
|
31 | ||
32 | public PortletDefinitionCompositeProxy(PortletDefinitionComposite def) |
|
33 | 0 | { |
34 | 0 | this.def = def; |
35 | 0 | this.name = def.getUniqueName(); |
36 | 0 | } |
37 | ||
38 | public static void setRegistry(PortletRegistry r) |
|
39 | { |
|
40 | 0 | registry = r; |
41 | 0 | } |
42 | ||
43 | public static PortletDefinitionComposite createProxy( |
|
44 | PortletDefinitionComposite def) |
|
45 | { |
|
46 | 0 | Class[] proxyInterfaces = new Class[] |
47 | 0 | { PortletDefinitionComposite.class}; |
48 | 0 | PortletDefinitionComposite proxy = (PortletDefinitionComposite) Proxy |
49 | .newProxyInstance(PortletDefinitionComposite.class |
|
50 | .getClassLoader(), proxyInterfaces, |
|
51 | new PortletDefinitionCompositeProxy(def)); |
|
52 | 0 | return proxy; |
53 | } |
|
54 | ||
55 | protected void invalidate() |
|
56 | { |
|
57 | 0 | this.def = null; |
58 | 0 | } |
59 | ||
60 | protected void setRealDefinition(PortletDefinitionComposite d) |
|
61 | { |
|
62 | 0 | this.def = d; |
63 | 0 | } |
64 | ||
65 | protected PortletDefinitionComposite getRealApplication() |
|
66 | { |
|
67 | 0 | return def; |
68 | } |
|
69 | ||
70 | public Object invoke(Object proxy, Method m, Object[] args) |
|
71 | throws Throwable |
|
72 | { |
|
73 | try |
|
74 | { |
|
75 | 0 | if (def == null) |
76 | { |
|
77 | 0 | def = registry.getPortletDefinitionByUniqueName(name); |
78 | } |
|
79 | 0 | return m.invoke(def, args); |
80 | } |
|
81 | 0 | catch (InvocationTargetException e) |
82 | { |
|
83 | 0 | throw e.getTargetException(); |
84 | } |
|
85 | } |
|
86 | ||
87 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |