KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > service > impl > JdkBeanInterfaceFactory


1 // Copyright 2006 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.service.impl;
16
17 import java.lang.reflect.InvocationHandler JavaDoc;
18 import java.lang.reflect.Method JavaDoc;
19 import java.lang.reflect.Proxy JavaDoc;
20
21 import org.apache.hivemind.Location;
22 import org.apache.hivemind.definition.ImplementationConstructionContext;
23 import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
24
25 /**
26  *
27  * @author James Carman
28  *
29  */

30 public class JdkBeanInterfaceFactory extends AbstractServiceImplementationConstructor
31 {
32
33     public JdkBeanInterfaceFactory(Location location, String JavaDoc contributingModuleId)
34     {
35         super(location);
36     }
37
38     public Object JavaDoc constructCoreServiceImplementation(ImplementationConstructionContext context)
39     {
40         return createJdkBean();
41     }
42
43     /**
44      * @return
45      */

46     public static BeanInterface createJdkBean() {
47         return ( BeanInterface )Proxy.newProxyInstance( BeanInterface.class.getClassLoader(), new Class JavaDoc[] { BeanInterface.class }, new InvocationHandler JavaDoc()
48                 {
49                     public Object JavaDoc invoke(Object JavaDoc proxy, Method JavaDoc method, Object JavaDoc[] args) throws Throwable JavaDoc {
50                         return "Hello, World!";
51                     }
52                 } );
53     }
54     
55
56 }
57
Popular Tags