Skip to content

Commit e011551

Browse files
committed
Created a sample doc catalog
Sample docs moved to main resources
1 parent 9cbf933 commit e011551

File tree

13 files changed

+926
-753
lines changed

13 files changed

+926
-753
lines changed

fj-doc-base/src/main/docs/doc_xsd_config_ref.html

Lines changed: 752 additions & 752 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.fugerit.java.doc.sample.facade;
2+
3+
import org.fugerit.java.core.cfg.xml.BasicIdConfigType;
4+
5+
public class DocCatalogEntry extends BasicIdConfigType {
6+
7+
private static final long serialVersionUID = -3140948907871403724L;
8+
9+
public String path;
10+
11+
public String description;
12+
13+
public String getPath() {
14+
return path;
15+
}
16+
17+
public void setPath(String path) {
18+
this.path = path;
19+
}
20+
21+
public String getDescription() {
22+
return description;
23+
}
24+
25+
public void setDescription(String description) {
26+
this.description = description;
27+
}
28+
29+
@Override
30+
public String toString() {
31+
return super.toString()+"[path=" + path + ", description=" + description + "]";
32+
}
33+
34+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.fugerit.java.doc.sample.facade;
2+
3+
import java.io.InputStream;
4+
import java.io.InputStreamReader;
5+
import java.io.Reader;
6+
7+
import org.fugerit.java.core.cfg.ConfigException;
8+
import org.fugerit.java.core.cfg.ConfigRuntimeException;
9+
import org.fugerit.java.core.cfg.xml.ListMapCatalogConfig;
10+
import org.fugerit.java.core.lang.helpers.ClassHelper;
11+
12+
public class DocCatalogSample extends ListMapCatalogConfig<DocCatalogEntry> {
13+
14+
public static final String ATT_BASE_PATH = "path-base";
15+
16+
private static final long serialVersionUID = -7903871203856880584L;
17+
18+
public DocCatalogSample() {
19+
super( "catalog", "doc" );
20+
this.getGeneralProps().setProperty( ATT_TYPE,DocCatalogEntry.class.getCanonicalName() );
21+
}
22+
23+
public static DocCatalogSample loadConfig( InputStream is ) throws Exception {
24+
return (DocCatalogSample)load( is, new DocCatalogSample() );
25+
}
26+
27+
private static DocCatalogSample loadDefaultInstance() {
28+
DocCatalogSample catalog = null;
29+
try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "sample_docs/doc_catalog.xml" ) ) {
30+
catalog = loadConfig( is );
31+
} catch (Exception e) {
32+
throw new ConfigRuntimeException( "Error loading default instance : "+e, e );
33+
}
34+
return catalog;
35+
}
36+
37+
private static final DocCatalogSample INSTANCE = loadDefaultInstance();
38+
39+
public static DocCatalogSample getInstance() {
40+
return INSTANCE;
41+
}
42+
43+
public Reader entryReader( DocCatalogEntry entry ) throws ConfigException {
44+
return new InputStreamReader( this.entryStream( entry ) );
45+
}
46+
47+
public InputStream entryStream( DocCatalogEntry entry ) throws ConfigException {
48+
String path = entry.getPath();
49+
String fullPath = this.getGeneralProps().getProperty( ATT_BASE_PATH, "" )+path;
50+
logger.info( "load entry full path : {}, entry : {}", fullPath , entry );
51+
try {
52+
return ClassHelper.loadFromDefaultClassLoader( fullPath );
53+
} catch (Exception e) {
54+
throw new ConfigException( "Failed to read entry : "+entry+"["+e+"]", e );
55+
}
56+
}
57+
58+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<doc-catalog
2+
path-mode="classloader"
3+
path-base="sample_docs/">
4+
5+
<catalog id="playground-core">
6+
<doc id="default" path="playground/default_doc.xml" description="Default sample doc"/>
7+
</catalog>
8+
9+
</doc-catalog>

0 commit comments

Comments
 (0)