~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to java/src/Ice/PluginManagerI.java

  • Committer: Bazaar Package Importer
  • Author(s): Cleto Martin Angelina
  • Date: 2011-04-25 18:44:24 UTC
  • mfrom: (6.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110425184424-sep9i9euu434vq4c
Tags: 3.4.1-7
* Bug fix: "libdb5.1-java.jar was renamed to db.jar", thanks to Ondřej
  Surý (Closes: #623555).
* Bug fix: "causes noise in php5", thanks to Jayen Ashar (Closes:
  #623533).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
29
29
        java.util.List<Plugin> initializedPlugins = new java.util.ArrayList<Plugin>();
30
30
        try
31
31
        {
32
 
            java.util.Iterator<Plugin> i = _initOrder.iterator();
33
 
            while(i.hasNext())
 
32
            for(Plugin p : _initOrder)
34
33
            {
35
 
                Plugin p = i.next();
36
34
                p.initialize();
37
35
                initializedPlugins.add(p);
38
36
            }
62
60
        _initialized = true;
63
61
    }
64
62
 
 
63
    public synchronized String[]
 
64
    getPlugins()
 
65
    {
 
66
        java.util.ArrayList<String> names = new java.util.ArrayList<String>();
 
67
        for(java.util.Map.Entry<String, Plugin> p : _plugins.entrySet())
 
68
        {
 
69
            names.add(p.getKey());
 
70
        }
 
71
        return names.toArray(new String[0]);
 
72
    }
 
73
 
65
74
    public synchronized Plugin
66
75
    getPlugin(String name)
67
76
    {
106
115
        {
107
116
            if(_initialized)
108
117
            {
109
 
                java.util.Iterator<java.util.Map.Entry<String, Plugin> > i = _plugins.entrySet().iterator();
110
 
                java.util.Map.Entry<String, Plugin> entry;
111
 
                while(i.hasNext())
 
118
                for(java.util.Map.Entry<String, Plugin> p : _plugins.entrySet())
112
119
                {
113
 
                    entry = i.next();
114
120
                    try
115
121
                    {
116
 
                        Plugin p = entry.getValue();
117
 
                        p.destroy();
 
122
                        p.getValue().destroy();
118
123
                    }
119
124
                    catch(RuntimeException ex)
120
125
                    {
121
 
                        Ice.Util.getProcessLogger().warning("unexpected exception raised by plug-in `" + 
122
 
                                                            entry.getKey() + "' destruction:\n" + ex.toString());
 
126
                        Ice.Util.getProcessLogger().warning("unexpected exception raised by plug-in `" + p.getKey() +
 
127
                                                            "' destruction:\n" + ex.toString());
123
128
                    }
124
129
                }
125
130
            }
156
161
        java.util.Map<String, String> plugins = properties.getPropertiesForPrefix(prefix);
157
162
 
158
163
        final String[] loadOrder = properties.getPropertyAsList("Ice.PluginLoadOrder");
159
 
        for(int i = 0; i < loadOrder.length; ++i)
 
164
        for(String name : loadOrder)
160
165
        {
161
 
            if(_plugins.containsKey(loadOrder[i]))
 
166
            if(_plugins.containsKey(name))
162
167
            {
163
168
                PluginInitializationException ex = new PluginInitializationException();
164
 
                ex.reason = "plug-in `" + loadOrder[i] + "' already loaded";
 
169
                ex.reason = "plug-in `" + name + "' already loaded";
165
170
                throw ex;
166
171
            }
167
172
 
168
 
            String key = "Ice.Plugin." + loadOrder[i] + ".java";
 
173
            String key = "Ice.Plugin." + name + ".java";
169
174
            boolean hasKey = plugins.containsKey(key);
170
175
            if(hasKey)
171
176
            {
172
 
                plugins.remove("Ice.Plugin." + loadOrder[i]);
 
177
                plugins.remove("Ice.Plugin." + name);
173
178
            }
174
179
            else
175
180
            {
176
 
                key = "Ice.Plugin." + loadOrder[i];
 
181
                key = "Ice.Plugin." + name;
177
182
                hasKey = plugins.containsKey(key);
178
183
            }
179
184
            
180
185
            if(hasKey)
181
186
            {
182
 
                final String value = (String)plugins.get(key);
183
 
                loadPlugin(loadOrder[i], value, cmdArgs);
 
187
                final String value = plugins.get(key);
 
188
                loadPlugin(name, value, cmdArgs);
184
189
                plugins.remove(key);
185
190
            }
186
191
            else
187
192
            {
188
193
                PluginInitializationException ex = new PluginInitializationException();
189
 
                ex.reason = "plug-in `" + loadOrder[i] + "' not defined";
 
194
                ex.reason = "plug-in `" + name + "' not defined";
190
195
                throw ex;
191
196
            }
192
197
        }
249
254
                loadPlugin(name, value, cmdArgs);
250
255
            }
251
256
        }
252
 
 
253
 
        //
254
 
        // An application can set Ice.InitPlugins=0 if it wants to postpone
255
 
        // initialization until after it has interacted directly with the
256
 
        // plug-ins.
257
 
        //
258
 
        if(properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0)
259
 
        {
260
 
            initializePlugins();
261
 
        }
262
257
    }
263
258
 
264
259
    private void
306
301
        PluginFactory pluginFactory = null;
307
302
        try
308
303
        {
309
 
            Class<?> c = Class.forName(className);
 
304
            Class<?> c = IceInternal.Util.getInstance(_communicator).findClass(className);
 
305
            if(c == null)
 
306
            {
 
307
                PluginInitializationException e = new PluginInitializationException();
 
308
                e.reason = "class " + className + " not found";
 
309
                throw e;
 
310
            }
310
311
            java.lang.Object obj = c.newInstance();
311
312
            try
312
313
            {
320
321
                throw e;
321
322
            }
322
323
        }
323
 
        catch(ClassNotFoundException ex)
324
 
        {
325
 
            PluginInitializationException e = new PluginInitializationException();
326
 
            e.reason = "class " + className + " not found";
327
 
            e.initCause(ex);
328
 
            throw e;
329
 
        }
330
324
        catch(IllegalAccessException ex)
331
325
        {
332
326
            PluginInitializationException e = new PluginInitializationException();