001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * LGPL Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.channel.ho.server.generic;
032:
033: import de.ug2t.kernel.*;
034: import de.ug2t.unifiedGui.interfaces.*;
035: import de.ug2t.xmlScript.*;
036:
037: public final class HoSrvGenericImage extends AHoSrvGenericComponent
038: implements IUnImage {
039: public HoSrvGenericImage(String xName, String xValue,
040: IUnApplication xAppl, String xClass) throws Exception {
041: super (xName);
042: this .pcmf_setAppl(xAppl);
043: this .pcmf_setLocalValue(xValue);
044:
045: if (xClass == null)
046: pdm_clientClass = "de.ug2t.channel.ho.client.swing.HoSwingImage";
047: else
048: pdm_clientClass = xClass;
049:
050: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
051: "");
052:
053: if (this .pdm_session.pcmf_isInTransaction()) {
054: ScXmlScript.pcmf_createPBody(l_remCall);
055: } else {
056: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
057: ScXmlScript.pcmf_addProc(l_remCall, null);
058: }
059: ;
060: ScXmlScript.pcmf_addDecl(l_remCall, this .pcmf_getRemName(),
061: this .pdm_clientClass, "global");
062: ScXmlScript.pcmf_addDeclPar(l_remCall, xName, "false",
063: "java.lang.String");
064: ScXmlScript.pcmf_addDeclPar(l_remCall, pcmf_buildUrl(xValue),
065: "false", "java.lang.String");
066: ScXmlScript.pcmf_addDeclPar(l_remCall,
067: ((HoSrvGenericApplication) xAppl).pcmf_getRemName(),
068: "true", "de.ug2t.unifiedGui.interfaces.IUnApplication");
069:
070: ScXmlScript.pcmf_endAll(l_remCall);
071:
072: this .pdm_session.pcmf_call(l_remCall.toString(), this );
073:
074: return;
075: };
076:
077: public IUnImage pcmf_clone() {
078: return (this .pcmf_getAppl().pcmf_getComponentFactory()
079: .pcmf_createImage(this .pcmf_getAppl()
080: .pcmf_getApplType(), this .pcmf_getName(),
081: (String) this .pcmf_getValue(), this
082: .pcmf_getAppl()));
083: }
084:
085: private String pcmf_buildUrl(String xValue) {
086: KeStringTemplate l_string = new KeStringTemplate(xValue);
087: HoSrvGenericApplication l_appl = (HoSrvGenericApplication) this
088: .pcmf_getAppl();
089:
090: if (xValue.trim().indexOf("http:") == 0
091: || xValue.trim().indexOf("https:") == 0) {
092: l_string = KeTools.pcmf_stringSubst(l_string, "$URL",
093: l_appl.pcmf_getHostName() + ":"
094: + Integer.toString(l_appl.pcmf_getPort())
095: + "/" + l_appl.pcmf_getRootUrl());
096: return (l_string.toString());
097: } else if (xValue.trim().indexOf("file:") == 0) {
098: return (xValue);
099: } else {
100: if (l_appl.pcmf_isMixedMode())
101: return (l_appl.pcmf_getProtocol() + "://"
102: + l_appl.pcmf_getHostName() + ":"
103: + Integer.toString(l_appl.pcmf_getPort()) + "/"
104: + l_appl.pcmf_getRootUrl() + "/" + KeEnvironment
105: .pcmf_encodeURL(xValue));
106: else
107: return ("file:" + KeEnvironment.pcmf_buildPath(xValue));
108: }
109: }
110:
111: public AHoSrvGenericComponent pcmf_buildRefObj() throws Exception {
112: AHoSrvGenericComponent l_obj = new HoSrvGenericImage(this
113: .pcmf_getName(), this .pcmf_getValue().toString(), this
114: .pcmf_getAppl(), this .pdm_clientClass);
115: l_obj.pcmf_setGlobal(true);
116: l_obj.pcmf_setRefFrom(this );
117: this .pcmf_setGlobal(true);
118: l_obj.pcmf_setAutoEcho(this .pcmf_doAutoEcho());
119: this .pcmf_addRef(l_obj);
120:
121: return l_obj;
122: };
123:
124: public void pcmf_setValue(Object xValue) {
125: super .pcmf_setValue(this .pcmf_buildUrl(xValue.toString()));
126: };
127:
128: private int pem_refcount = 0;
129:
130: public final void pcmf_attach() {
131: synchronized (this ) {
132: if (this .pdm_deleted)
133: KeLog
134: .pcmf_log(
135: "ug2t",
136: "attach a deleted ressource, error in synchronisation",
137: this , KeLog.FATAL);
138:
139: this .pem_refcount++;
140: }
141: }
142:
143: public final void pcmf_detach() {
144: synchronized (this ) {
145: if (this .pem_refcount > 0)
146: this .pem_refcount--;
147: }
148: }
149:
150: public void pcmf_forceDetach() {
151: synchronized (this ) {
152: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
153: "");
154:
155: if (this .pdm_session.pcmf_isInTransaction()) {
156: ScXmlScript.pcmf_createPBody(l_remCall);
157: } else {
158: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
159: ScXmlScript.pcmf_addProc(l_remCall, null);
160: }
161: ;
162: ScXmlScript.pcmf_addCall(l_remCall, null, this
163: .pcmf_getRemName(), "pcmf_forceDetach");
164: ScXmlScript.pcmf_endAll(l_remCall);
165:
166: this .pdm_session.pcmf_call(l_remCall.toString(), this );
167:
168: this .pem_refcount = 0;
169: }
170: }
171:
172: public void pcmf_delete() throws Exception {
173: synchronized (this ) {
174: if (this .pdm_deleted == true || this .pem_refcount > 0)
175: return;
176:
177: super .pcmf_delete();
178: }
179: };
180:
181: public void pcmf_attachImage() {
182: synchronized (this ) {
183: if (this .pdm_deleted)
184: KeLog
185: .pcmf_log(
186: "ug2t",
187: "attach a deleted ressource, error in synchronisation",
188: this , KeLog.FATAL);
189: else {
190: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
191: "");
192:
193: if (this .pdm_session.pcmf_isInTransaction()) {
194: ScXmlScript.pcmf_createPBody(l_remCall);
195: } else {
196: ScXmlScript.pcmf_createxScriptString(l_remCall,
197: null);
198: ScXmlScript.pcmf_addProc(l_remCall, null);
199: }
200: ;
201: ScXmlScript.pcmf_addCall(l_remCall, null, this
202: .pcmf_getRemName(), "pcmf_attachImage");
203: ScXmlScript.pcmf_endAll(l_remCall);
204:
205: this .pdm_session.pcmf_call(l_remCall.toString(), this );
206: }
207:
208: this .pem_refcount++;
209: }
210: }
211:
212: public void pcmf_detachImage() {
213: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
214: "");
215:
216: if (this .pdm_session.pcmf_isInTransaction()) {
217: ScXmlScript.pcmf_createPBody(l_remCall);
218: } else {
219: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
220: ScXmlScript.pcmf_addProc(l_remCall, null);
221: }
222: ;
223: ScXmlScript.pcmf_addCall(l_remCall, null, this
224: .pcmf_getRemName(), "pcmf_detachImage");
225: ScXmlScript.pcmf_endAll(l_remCall);
226:
227: this .pdm_session.pcmf_call(l_remCall.toString(), this );
228:
229: synchronized (this ) {
230: if (this .pem_refcount > 0)
231: this .pem_refcount--;
232: }
233: }
234:
235: /**
236: * <p>
237: * Releases an image for beeing deleted when not in use - delegate to fit
238: * interface
239: * </p>
240: * <p>
241: *
242: * </p>
243: * <p>
244: * </p>
245: */
246: public void pcmf_attachExtern() {
247: this .pcmf_attachImage();
248: }
249:
250: /**
251: * <p>
252: * Releases an image for beeing deleted when not in use - delegate to fit
253: * interface
254: * </p>
255: * <p>
256: *
257: * </p>
258: * <p>
259: * </p>
260: */
261: public void pcmf_detachExtern() {
262: this.pcmf_detachImage();
263: }
264: }
|