1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * Copyright 2000, 2010 Oracle and/or its affiliates.
5 *
6 * OpenOffice.org - a multi-platform office productivity suite
7 *
8 * This file is part of OpenOffice.org.
9 *
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
13 *
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org.  If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
25 
26 package com.sun.star.comp.test.deployment.active_java;
27 
28 import com.sun.star.frame.DispatchDescriptor;
29 import com.sun.star.frame.XDispatch;
30 import com.sun.star.frame.XDispatchProvider;
31 import com.sun.star.lang.XServiceInfo;
32 import com.sun.star.lib.uno.helper.WeakBase;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XComponentContext;
35 import com.sun.star.util.URL;
36 
37 public final class Provider extends WeakBase
38     implements XServiceInfo, XDispatchProvider
39 {
40     public Provider(XComponentContext context) {
41         this.context = context;
42     }
43 
44     public String getImplementationName() { return implementationName; }
45 
46     public boolean supportsService(String ServiceName) {
47         return ServiceName.equals(getSupportedServiceNames()[0]); //TODO
48     }
49 
50     public String[] getSupportedServiceNames() {
51         return serviceNames;
52     }
53 
54     public XDispatch queryDispatch(
55         URL URL, String TargetFrameName, int SearchFlags)
56     {
57         return UnoRuntime.queryInterface(
58             XDispatch.class,
59             context.getValueByName(
60                 "/singletons/" +
61                 "com.sun.star.test.deployment.active_java_singleton"));
62     }
63 
64     public XDispatch[] queryDispatches(DispatchDescriptor[] Requests) {
65         XDispatch[] s = new XDispatch[Requests.length];
66         for (int i = 0; i < s.length; ++i) {
67             s[i] = queryDispatch(
68                 Requests[i].FeatureURL, Requests[i].FrameName,
69                 Requests[i].SearchFlags);
70         }
71         return s;
72     }
73 
74     private final XComponentContext context;
75 
76     static final String implementationName =
77         "com.sun.star.comp.test.deployment.active_java";
78 
79     static final String[] serviceNames = new String[] {
80         "com.sun.star.test.deployment.active_java" };
81 }
82