01: /*
02: * hgcommons 7
03: * Hammurapi Group Common Library
04: * Copyright (C) 2003 Hammurapi Group
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21: * e-Mail: support@hammurapi.biz
22: */
23: package biz.hammurapi.metrics;
24:
25: import java.net.MalformedURLException;
26: import java.rmi.Naming;
27: import java.rmi.NotBoundException;
28: import java.rmi.RemoteException;
29:
30: import javax.xml.transform.TransformerConfigurationException;
31: import javax.xml.transform.TransformerException;
32:
33: import biz.hammurapi.config.Component;
34: import biz.hammurapi.config.ConfigurationException;
35: import biz.hammurapi.config.DomConfigurable;
36: import biz.hammurapi.xml.dom.AbstractDomObject;
37:
38: /**
39: * @author Pavel Vlasov
40: */
41: public class RemoteSlicingMeasurementCategoryFactory extends
42: SlicingMeasurementCategoryFactory implements DomConfigurable,
43: Component {
44: private RemoteSliceConsumer remoteSliceConsumer;
45:
46: /**
47: * @param remoteConsumer
48: */
49: public RemoteSlicingMeasurementCategoryFactory(
50: RemoteSliceConsumer remoteConsumer) {
51: super ();
52: this .remoteSliceConsumer = remoteConsumer;
53: }
54:
55: public RemoteSlicingMeasurementCategoryFactory() {
56:
57: }
58:
59: protected SliceConsumer createSliceConsumer()
60: throws ConfigurationException {
61: try {
62: if (remoteSliceConsumer == null) {
63: remoteSliceConsumer = (RemoteSliceConsumer) Naming
64: .lookup(AbstractDomObject.getElementText(
65: configElement, "remote-slice-consumer",
66: null));
67: }
68:
69: return new SliceConsumer() {
70:
71: String rootCategory = AbstractDomObject.getElementText(
72: configElement, "root-category", null);
73:
74: public boolean consumeSlice(String category, Slice slice) {
75: try {
76: return remoteSliceConsumer.consumeSlice(
77: rootCategory + "." + category, slice);
78: } catch (RemoteException e) {
79: e.printStackTrace();
80: return false;
81: }
82: }
83:
84: };
85: } catch (TransformerConfigurationException e) {
86: throw new ConfigurationException(e);
87: } catch (MalformedURLException e) {
88: throw new ConfigurationException(e);
89: } catch (RemoteException e) {
90: throw new ConfigurationException(e);
91: } catch (NotBoundException e) {
92: throw new ConfigurationException(e);
93: } catch (TransformerException e) {
94: throw new ConfigurationException(e);
95: }
96: }
97: }
|